Remove monotonicallyIncreasingTime
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Mar 2018 17:13:32 +0000 (17:13 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Mar 2018 17:13:32 +0000 (17:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182911

Reviewed by Michael Catanzaro.

Source/JavaScriptCore:

* debugger/Debugger.cpp:
(JSC::Debugger::willEvaluateScript):
(JSC::Debugger::didEvaluateScript):
* debugger/Debugger.h:
* debugger/ScriptProfilingScope.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::breakpointActionProbe):
* inspector/agents/InspectorHeapAgent.cpp:
(Inspector::InspectorHeapAgent::snapshot):
(Inspector::InspectorHeapAgent::didGarbageCollect):
(Inspector::InspectorHeapAgent::dispatchGarbageCollectedEvent):
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
(Inspector::InspectorScriptProfilerAgent::startTracking):
(Inspector::InspectorScriptProfilerAgent::willEvaluateScript):
(Inspector::InspectorScriptProfilerAgent::didEvaluateScript):
(Inspector::InspectorScriptProfilerAgent::addEvent):
(Inspector::buildSamples):
* inspector/agents/InspectorScriptProfilerAgent.h:
* runtime/SamplingProfiler.cpp:
(JSC::SamplingProfiler::takeSample):
* runtime/SamplingProfiler.h:

Source/WebCore:

While generic code uses MonotonicTime, CAAnimation uses media time (CFTimeInterval).
At this boundary, we convert MonotonicTime to media time, this is the same logic to
the code before this patch.

* Modules/gamepad/Gamepad.h:
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::SourceBuffer):
(WebCore::SourceBuffer::monitorBufferingRate):
* Modules/mediasource/SourceBuffer.h:
* Modules/speech/SpeechSynthesis.cpp:
(WebCore::SpeechSynthesis::startSpeakingImmediately):
(WebCore::SpeechSynthesis::fireEvent):
* Modules/speech/SpeechSynthesisUtterance.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::parseRuleList):
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad const):
* dom/Element.cpp:
(WebCore::Element::setActive):
* history/CachedPage.cpp:
(WebCore::CachedPage::CachedPage):
(WebCore::CachedPage::hasExpired const):
* history/CachedPage.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::startProgressEventTimer):
(WebCore::HTMLMediaElement::progressEventTimerFired):
(WebCore::HTMLMediaElement::refreshCachedTime const):
(WebCore::HTMLMediaElement::invalidateCachedTime const):
(WebCore::HTMLMediaElement::currentMediaTime const):
(WebCore::HTMLMediaElement::startPlaybackProgressTimer):
* html/HTMLMediaElement.h:
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::removeBehaviorRestriction):
(WebCore::MediaElementSession::mostRecentUserInteractionTime const):
(WebCore::MediaElementSession::resetPlaybackSessionState):
* html/MediaElementSession.h:
* html/parser/HTMLParserScheduler.cpp:
(WebCore::PumpSession::PumpSession):
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
* html/parser/HTMLParserScheduler.h:
(WebCore::HTMLParserScheduler::checkForYield):
* inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::recordAction):
(WebCore::InspectorCanvas::finalizeFrame):
* inspector/InspectorCanvas.h:
* inspector/agents/InspectorMemoryAgent.cpp:
(WebCore::InspectorMemoryAgent::startTracking):
(WebCore::InspectorMemoryAgent::didHandleMemoryPressure):
(WebCore::InspectorMemoryAgent::collectSample):
* inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::buildObjectForTiming):
(WebCore::InspectorNetworkAgent::timestamp):
(WebCore::InspectorNetworkAgent::didFinishLoading):
* inspector/agents/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::timestamp):
* inspector/agents/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::timestamp):
* inspector/agents/WebHeapAgent.cpp:
(WebCore::WebHeapAgent::dispatchGarbageCollectedEvent):
* inspector/agents/WebHeapAgent.h:
* loader/cache/CachedCSSStyleSheet.cpp:
(WebCore::CachedCSSStyleSheet::restoreParsedStyleSheet):
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::didDraw):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::didAccessDecodedData):
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::pruneLiveResourcesToSize):
* page/EventHandler.cpp:
(WebCore::MaximumDurationTracker::MaximumDurationTracker):
(WebCore::MaximumDurationTracker::~MaximumDurationTracker):
* page/FocusController.cpp:
(WebCore::FocusController::setFocusedElement):
(WebCore::FocusController::timeSinceFocusWasSet const):
* page/FocusController.h:
* page/FrameView.cpp:
(WebCore::FrameView::reset):
(WebCore::FrameView::willPaintContents):
(WebCore::FrameView::didPaintContents):
* page/FrameView.h:
* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::freezeAtTime):
(WebCore::AnimationBase::beginAnimationUpdateTime const):
* page/animation/AnimationBase.h:
(WebCore::AnimationBase::onAnimationStartResponse):
* page/animation/CSSAnimationController.cpp:
(WebCore::CSSAnimationControllerPrivate::beginAnimationUpdateTime):
(WebCore::CSSAnimationControllerPrivate::receivedStartTimeResponse):
(WebCore::CSSAnimationControllerPrivate::startTimeResponse):
(WebCore::CSSAnimationController::notifyAnimationStarted):
* page/animation/CSSAnimationController.h:
* page/animation/CSSAnimationControllerPrivate.h:
* page/mac/WheelEventDeltaFilterMac.h:
* page/mac/WheelEventDeltaFilterMac.mm:
(WebCore::WheelEventDeltaFilterMac::beginFilteringDeltas):
(WebCore::WheelEventDeltaFilterMac::updateFromDelta):
(WebCore::WheelEventDeltaFilterMac::endFilteringDeltas):
* platform/ControlStates.h:
(WebCore::ControlStates::timeSinceControlWasFocused const):
(WebCore::ControlStates::setTimeSinceControlWasFocused):
* platform/PlatformSpeechSynthesisUtterance.h:
(WebCore::PlatformSpeechSynthesisUtterance::startTime const):
(WebCore::PlatformSpeechSynthesisUtterance::setStartTime):
* platform/gamepad/PlatformGamepad.h:
(WebCore::PlatformGamepad::lastUpdateTime const):
(WebCore::PlatformGamepad::connectTime const):
(WebCore::PlatformGamepad::PlatformGamepad):
* platform/gamepad/cocoa/GameControllerGamepad.mm:
(WebCore::GameControllerGamepad::setupAsExtendedGamepad):
(WebCore::GameControllerGamepad::setupAsGamepad):
* platform/gamepad/mac/HIDGamepad.cpp:
(WebCore::HIDGamepad::HIDGamepad):
(WebCore::HIDGamepad::valueChanged):
* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::suspendAnimations):
* platform/graphics/GraphicsLayer.h:
* platform/graphics/GraphicsLayerClient.h:
(WebCore::GraphicsLayerClient::notifyAnimationStarted):
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
(WebCore::LayerClient::platformCALayerAnimationStarted):
(WebCore::AVFWrapper::createImageForTimeInRect):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect):
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::addAnimation):
(WebCore::GraphicsLayerCA::pauseAnimation):
(WebCore::GraphicsLayerCA::platformCALayerAnimationStarted):
(WebCore::GraphicsLayerCA::setAnimationOnLayer):
(WebCore::GraphicsLayerCA::pauseCAAnimationOnLayer):
(WebCore::GraphicsLayerCA::createAnimationFromKeyframes):
(WebCore::GraphicsLayerCA::appendToUncommittedAnimations):
(WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
* platform/graphics/ca/GraphicsLayerCA.h:
(WebCore::GraphicsLayerCA::LayerPropertyAnimation::LayerPropertyAnimation):
(WebCore::GraphicsLayerCA::AnimationProcessingAction::AnimationProcessingAction):
* platform/graphics/ca/LayerPool.cpp:
(WebCore::LayerPool::LayerPool):
(WebCore::LayerPool::addLayer):
(WebCore::LayerPool::decayedCapacity const):
(WebCore::LayerPool::pruneTimerFired):
* platform/graphics/ca/LayerPool.h:
* platform/graphics/ca/PlatformCAAnimation.h:
* platform/graphics/ca/PlatformCALayer.h:
* platform/graphics/ca/PlatformCALayerClient.h:
(WebCore::PlatformCALayerClient::platformCALayerAnimationStarted):
* platform/graphics/ca/TileGrid.cpp:
(WebCore::TileGrid::revalidateTiles):
(WebCore::TileGrid::startedNewCohort):
(WebCore::TileGrid::TileCohortInfo::timeUntilExpiration):
(WebCore::TileGrid::cohortRemovalTimerFired):
* platform/graphics/ca/TileGrid.h:
(WebCore::TileGrid::TileCohortInfo::TileCohortInfo):
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(mediaTimeToCurrentTime):
(-[WebAnimationDelegate animationDidStart:]):
(PlatformCALayerCocoa::animationStarted):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::notifyAnimationsStarted):
* platform/graphics/ca/win/PlatformCALayerWin.cpp:
(PlatformCALayerWin::animationStarted):
(PlatformCALayerWin::layerTreeAsString const):
* platform/graphics/ca/win/PlatformCALayerWin.h:
* platform/graphics/cocoa/WebCoreDecompressionSession.mm:
(WebCore::WebCoreDecompressionSession::decodeSample):
* platform/graphics/texmap/BitmapTexturePool.cpp:
(WebCore::BitmapTexturePool::releaseUnusedTexturesTimerFired):
* platform/graphics/texmap/BitmapTexturePool.h:
(WebCore::BitmapTexturePool::Entry::markIsInUse):
(WebCore::BitmapTexturePool::Entry::canBeReleased const):
(): Deleted.
* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::GraphicsLayerTextureMapper):
(WebCore::GraphicsLayerTextureMapper::addAnimation):
(WebCore::GraphicsLayerTextureMapper::pauseAnimation):
* platform/graphics/texmap/GraphicsLayerTextureMapper.h:
* platform/graphics/texmap/TextureMapperAnimation.cpp:
(WebCore::TextureMapperAnimation::TextureMapperAnimation):
(WebCore::TextureMapperAnimation::apply):
(WebCore::TextureMapperAnimation::pause):
(WebCore::TextureMapperAnimation::resume):
(WebCore::TextureMapperAnimation::computeTotalRunningTime):
(WebCore::TextureMapperAnimations::pause):
(WebCore::TextureMapperAnimations::suspend):
* platform/graphics/texmap/TextureMapperAnimation.h:
(WebCore::TextureMapperAnimation::startTime const):
(WebCore::TextureMapperAnimation::pauseTime const):
* platform/graphics/texmap/TextureMapperFPSCounter.cpp:
(WebCore::TextureMapperFPSCounter::TextureMapperFPSCounter):
(WebCore::TextureMapperFPSCounter::updateFPSAndDisplay):
* platform/graphics/texmap/TextureMapperFPSCounter.h:
* platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h:
(WebCore::TextureMapperPlatformLayerBuffer::markUsed):
(WebCore::TextureMapperPlatformLayerBuffer::lastUsedTime const):
(): Deleted.
* platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
(WebCore::TextureMapperPlatformLayerProxy::releaseUnusedBuffersTimerFired):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::addAnimation):
(WebCore::CoordinatedGraphicsLayer::pauseAnimation):
(WebCore::CoordinatedGraphicsLayer::suspendAnimations):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
* platform/mediastream/RealtimeMediaSource.h:
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::sendFrame):
* platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp:
(WebCore::LibWebRTCAudioModule::StartPlayoutOnAudioThread):
* platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:
(WebCore::DisplayCaptureSourceCocoa::startProducingData):
(WebCore::DisplayCaptureSourceCocoa::stopProducingData):
(WebCore::DisplayCaptureSourceCocoa::elapsedTime):
* platform/mediastream/mac/DisplayCaptureSourceCocoa.h:
* platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
* platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
(WebCore::MockRealtimeAudioSourceMac::render):
* platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
(WebCore::MockRealtimeVideoSourceMac::CMSampleBufferFromPixelBuffer):
* platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h:
* platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
(WebCore::ScreenDisplayCaptureSourceMac::sampleBufferFromPixelBuffer):
(WebCore::ScreenDisplayCaptureSourceMac::frameAvailable):
* platform/mock/MockRealtimeAudioSource.cpp:
(WebCore::MockRealtimeAudioSource::startProducingData):
(WebCore::MockRealtimeAudioSource::stopProducingData):
(WebCore::MockRealtimeAudioSource::elapsedTime):
(WebCore::MockRealtimeAudioSource::tick):
(WebCore::MockRealtimeAudioSource::delaySamples):
* platform/mock/MockRealtimeAudioSource.h:
(WebCore::MockRealtimeAudioSource::render):
* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::startProducingData):
(WebCore::MockRealtimeVideoSource::stopProducingData):
(WebCore::MockRealtimeVideoSource::elapsedTime):
(WebCore::MockRealtimeVideoSource::drawText):
(WebCore::MockRealtimeVideoSource::delaySamples):
(WebCore::MockRealtimeVideoSource::generateFrame):
* platform/mock/MockRealtimeVideoSource.h:
* platform/network/DNSResolveQueue.cpp:
(WebCore::DNSResolveQueue::DNSResolveQueue):
(WebCore::DNSResolveQueue::isUsingProxy):
* platform/network/DNSResolveQueue.h:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::suspendAnimations):
* rendering/RenderBoxModelObject.h:
* rendering/RenderElement.cpp:
(WebCore::RenderElement::paintFocusRing):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::paintAreaElementFocusRing):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::notifyAnimationStarted):
(WebCore::RenderLayerBacking::suspendAnimations):
* rendering/RenderLayerBacking.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::didPaintBacking):
* rendering/RenderProgress.cpp:
(WebCore::RenderProgress::RenderProgress):
(WebCore::RenderProgress::animationProgress const):
(WebCore::RenderProgress::updateAnimationState):
* rendering/RenderProgress.h:
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::animationDurationForProgressBar const):
* rendering/RenderTheme.h:
* rendering/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::animationDurationForProgressBar const):
* rendering/RenderThemeGtk.h:
* rendering/RenderThemeIOS.h:
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::animationDurationForProgressBar const):
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::animationDurationForProgressBar const):
* svg/animation/SMILTimeContainer.cpp:
(WebCore::SMILTimeContainer::SMILTimeContainer):
(WebCore::SMILTimeContainer::elapsed const):
(WebCore::SMILTimeContainer::isActive const):
(WebCore::SMILTimeContainer::isPaused const):
(WebCore::SMILTimeContainer::isStarted const):
(WebCore::SMILTimeContainer::begin):
(WebCore::SMILTimeContainer::pause):
(WebCore::SMILTimeContainer::resume):
(WebCore::SMILTimeContainer::setElapsed):
(WebCore::SMILTimeContainer::timerFired):
* svg/animation/SMILTimeContainer.h:
* testing/Internals.cpp:
(WebCore::Internals::delayMediaStreamTrackSamples):
* testing/MockGamepad.cpp:
(WebCore::MockGamepad::MockGamepad):
(WebCore::MockGamepad::updateDetails):
(WebCore::MockGamepad::setAxisValue):
(WebCore::MockGamepad::setButtonValue):

Source/WebCore/PAL:

* pal/system/ClockGeneric.cpp:
(PAL::ClockGeneric::currentTime const):
(PAL::ClockGeneric::now const):
* pal/system/ClockGeneric.h:

Source/WebKit:

* NetworkProcess/cache/CacheStorageEngineCache.cpp:
(WebKit::CacheStorage::Cache::toRecordInformation):
* Platform/IPC/ArgumentCoders.cpp:
(IPC::ArgumentCoder<Seconds>::encode):
(IPC::ArgumentCoder<Seconds>::decode):
(IPC::ArgumentCoder<MonotonicTime>::encode):
(IPC::ArgumentCoder<MonotonicTime>::decode):
* Platform/IPC/ArgumentCoders.h:
* Shared/Gamepad/GamepadData.cpp:
(WebKit::GamepadData::GamepadData):
* Shared/Gamepad/GamepadData.h:
(WebKit::GamepadData::lastUpdateTime const):
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<MonotonicTime>::encode): Deleted.
(IPC::ArgumentCoder<MonotonicTime>::decode): Deleted.
(IPC::ArgumentCoder<Seconds>::encode): Deleted.
(IPC::ArgumentCoder<Seconds>::decode): Deleted.
ArgumentCoders for MonotonicTime and Seconds are now used internally.
Move them to Platform/IPC/ArgumentCoders.h.

* Shared/WebCoreArgumentCoders.h:
* UIProcess/API/glib/IconDatabase.cpp:
(WebKit::IconDatabase::iconDatabaseSyncThread):
* UIProcess/DrawingAreaProxyImpl.cpp:
(WebKit::DrawingAreaProxyImpl::DrawingMonitor::start):
(WebKit::DrawingAreaProxyImpl::DrawingMonitor::stop):
(WebKit::DrawingAreaProxyImpl::DrawingMonitor::didDraw):
* UIProcess/DrawingAreaProxyImpl.h:
* UIProcess/Gamepad/UIGamepad.h:
* UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart):
* UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h:
* UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::animationDidStart):
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::acceleratedAnimationDidStart):
* WebProcess/WebPage/DrawingArea.messages.in:
* WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h:
* WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm:
(mediaTimeToCurrentTime):
(-[WKAnimationDelegate animationDidStart:]):
* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::animationStarted):
This argument `beginTime` is not CFTimeInverval actually. We add currentTimeToMediaTime
conversion here to fix this issue.

* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h:
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h:
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:
(WebKit::RemoteLayerTreeContext::animationDidStart):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::destroyRenderingResources):

Source/WebKitLegacy/win:

* FullscreenVideoController.cpp:
(FullscreenVideoController::LayerClient::platformCALayerAnimationStarted):
* Plugins/PluginMessageThrottlerWin.cpp:
(WebCore::PluginMessageThrottlerWin::PluginMessageThrottlerWin):
(WebCore::PluginMessageThrottlerWin::appendMessage):
* Plugins/PluginMessageThrottlerWin.h:
* WebView.cpp:
(WebView::notifyAnimationStarted):
* WebView.h:

Source/WTF:

This patch drops monotonicallyIncreasingTime and monotonicallyIncreasingTimeMS.
We have MonotonicTime API instead. This offers strongly typed MonotonicTime,
Seconds etc. This reduces the chance of bugs mixing doubles which represent milliseconds
and seconds.

Large part of this patch is mechanical one: replacing monotonicallyIncreasingTime with
MonotonicTime, using MonotonicTime and Seconds instead of raw doubles.

But this patch actually finds some bugs (but it is a bit difficult to show it as a test).
One is mixing media time (CACurrentMediaTime()) and MonotonicTime. Basically they are
super close because both uses mach_absolute_time(). But they would be slightly different.
So we should not mix them.

The second bug is GraphicsLayer::suspendAnimations(double). While CA ports (Apple, AppleWin,
iOS etc.) use this double as MonotonicTime, GTK and WPE use this double as Seconds (timeOffset).
This patch fixes it and now the signature becomes GraphicsLayer::suspendAnimations(MonotonicTime).

In this patch, we still uses bunch of double for Seconds. But fixing them at this patch increases
the size of this larger and larger. So some of them remains double. This should be fixed in
subsequent patches.

* benchmarks/ConditionSpeedTest.cpp:
* benchmarks/LockSpeedTest.cpp:
* wtf/CurrentTime.cpp:
(WTF::MonotonicTime::now):
(WTF::monotonicallyIncreasingTime): Deleted.
* wtf/CurrentTime.h:
(WTF::monotonicallyIncreasingTimeMS): Deleted.
* wtf/MemoryPressureHandler.h:
* wtf/MonotonicTime.cpp:
(WTF::MonotonicTime::now): Deleted.
* wtf/MonotonicTime.h:
* wtf/ParkingLot.cpp:
* wtf/Seconds.h:
(WTF::Seconds::nan):
* wtf/Stopwatch.h:
(WTF::Stopwatch::reset):
(WTF::Stopwatch::start):
(WTF::Stopwatch::stop):
(WTF::Stopwatch::elapsedTime):
(WTF::Stopwatch::elapsedTimeSince):
* wtf/cocoa/MemoryPressureHandlerCocoa.mm:
(WTF::MemoryPressureHandler::holdOff):
(WTF::MemoryPressureHandler::respondToMemoryPressure):
* wtf/linux/MemoryPressureHandlerLinux.cpp:
(WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
(WTF::MemoryPressureHandler::holdOff):
(WTF::MemoryPressureHandler::respondToMemoryPressure):
* wtf/win/MemoryPressureHandlerWin.cpp:
(WTF::MemoryPressureHandler::holdOff):

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

177 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/debugger/Debugger.cpp
Source/JavaScriptCore/debugger/Debugger.h
Source/JavaScriptCore/debugger/ScriptProfilingScope.h
Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.h
Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.h
Source/JavaScriptCore/runtime/SamplingProfiler.cpp
Source/JavaScriptCore/runtime/SamplingProfiler.h
Source/WTF/ChangeLog
Source/WTF/benchmarks/ConditionSpeedTest.cpp
Source/WTF/benchmarks/LockSpeedTest.cpp
Source/WTF/wtf/CurrentTime.cpp
Source/WTF/wtf/CurrentTime.h
Source/WTF/wtf/MemoryPressureHandler.h
Source/WTF/wtf/MonotonicTime.cpp
Source/WTF/wtf/MonotonicTime.h
Source/WTF/wtf/ParkingLot.cpp
Source/WTF/wtf/Seconds.h
Source/WTF/wtf/Stopwatch.h
Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm
Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp
Source/WTF/wtf/win/MemoryPressureHandlerWin.cpp
Source/WebCore/ChangeLog
Source/WebCore/Modules/gamepad/Gamepad.h
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.h
Source/WebCore/Modules/speech/SpeechSynthesis.cpp
Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/system/ClockGeneric.cpp
Source/WebCore/PAL/pal/system/ClockGeneric.h
Source/WebCore/contentextensions/ContentExtensionCompiler.cpp
Source/WebCore/contentextensions/ContentExtensionParser.cpp
Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/history/CachedPage.cpp
Source/WebCore/history/CachedPage.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/MediaElementSession.cpp
Source/WebCore/html/MediaElementSession.h
Source/WebCore/html/parser/HTMLParserScheduler.cpp
Source/WebCore/html/parser/HTMLParserScheduler.h
Source/WebCore/inspector/InspectorCanvas.cpp
Source/WebCore/inspector/InspectorCanvas.h
Source/WebCore/inspector/agents/InspectorMemoryAgent.cpp
Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp
Source/WebCore/inspector/agents/InspectorPageAgent.cpp
Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp
Source/WebCore/inspector/agents/WebHeapAgent.cpp
Source/WebCore/inspector/agents/WebHeapAgent.h
Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/MemoryCache.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/FocusController.cpp
Source/WebCore/page/FocusController.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/page/animation/AnimationBase.cpp
Source/WebCore/page/animation/AnimationBase.h
Source/WebCore/page/animation/CSSAnimationController.cpp
Source/WebCore/page/animation/CSSAnimationController.h
Source/WebCore/page/animation/CSSAnimationControllerPrivate.h
Source/WebCore/page/mac/WheelEventDeltaFilterMac.h
Source/WebCore/page/mac/WheelEventDeltaFilterMac.mm
Source/WebCore/platform/ControlStates.h
Source/WebCore/platform/PlatformSpeechSynthesisUtterance.h
Source/WebCore/platform/gamepad/PlatformGamepad.h
Source/WebCore/platform/gamepad/cocoa/GameControllerGamepad.mm
Source/WebCore/platform/gamepad/mac/HIDGamepad.cpp
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/GraphicsLayerClient.h
Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/platform/graphics/ca/LayerPool.cpp
Source/WebCore/platform/graphics/ca/LayerPool.h
Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h
Source/WebCore/platform/graphics/ca/PlatformCALayer.h
Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h
Source/WebCore/platform/graphics/ca/TileGrid.cpp
Source/WebCore/platform/graphics/ca/TileGrid.h
Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h
Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm
Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h
Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm
Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp
Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h
Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.h
Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h
Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
Source/WebCore/platform/mediastream/RealtimeMediaSource.h
Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.cpp
Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp
Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp
Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h
Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h
Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm
Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm
Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h
Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm
Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp
Source/WebCore/platform/mock/MockRealtimeAudioSource.h
Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp
Source/WebCore/platform/mock/MockRealtimeVideoSource.h
Source/WebCore/platform/network/DNSResolveQueue.cpp
Source/WebCore/platform/network/DNSResolveQueue.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderBoxModelObject.h
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderProgress.cpp
Source/WebCore/rendering/RenderProgress.h
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeGtk.cpp
Source/WebCore/rendering/RenderThemeGtk.h
Source/WebCore/rendering/RenderThemeIOS.h
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/svg/animation/SMILTimeContainer.cpp
Source/WebCore/svg/animation/SMILTimeContainer.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/MockGamepad.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp
Source/WebKit/Platform/IPC/ArgumentCoders.h
Source/WebKit/Shared/Gamepad/GamepadData.cpp
Source/WebKit/Shared/Gamepad/GamepadData.h
Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Source/WebKit/Shared/WebCoreArgumentCoders.h
Source/WebKit/UIProcess/API/glib/IconDatabase.cpp
Source/WebKit/UIProcess/DrawingAreaProxyImpl.cpp
Source/WebKit/UIProcess/DrawingAreaProxyImpl.h
Source/WebKit/UIProcess/Gamepad/UIGamepad.h
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm
Source/WebKit/WebProcess/WebPage/DrawingArea.h
Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm
Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/FullscreenVideoController.cpp
Source/WebKitLegacy/win/Plugins/PluginMessageThrottlerWin.cpp
Source/WebKitLegacy/win/Plugins/PluginMessageThrottlerWin.h
Source/WebKitLegacy/win/WebView.cpp
Source/WebKitLegacy/win/WebView.h

index cd42c9b..017821c 100644 (file)
@@ -1,5 +1,35 @@
 2018-03-01  Yusuke Suzuki  <utatane.tea@gmail.com>
 
+        Remove monotonicallyIncreasingTime
+        https://bugs.webkit.org/show_bug.cgi?id=182911
+
+        Reviewed by Michael Catanzaro.
+
+        * debugger/Debugger.cpp:
+        (JSC::Debugger::willEvaluateScript):
+        (JSC::Debugger::didEvaluateScript):
+        * debugger/Debugger.h:
+        * debugger/ScriptProfilingScope.h:
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::breakpointActionProbe):
+        * inspector/agents/InspectorHeapAgent.cpp:
+        (Inspector::InspectorHeapAgent::snapshot):
+        (Inspector::InspectorHeapAgent::didGarbageCollect):
+        (Inspector::InspectorHeapAgent::dispatchGarbageCollectedEvent):
+        * inspector/agents/InspectorHeapAgent.h:
+        * inspector/agents/InspectorScriptProfilerAgent.cpp:
+        (Inspector::InspectorScriptProfilerAgent::startTracking):
+        (Inspector::InspectorScriptProfilerAgent::willEvaluateScript):
+        (Inspector::InspectorScriptProfilerAgent::didEvaluateScript):
+        (Inspector::InspectorScriptProfilerAgent::addEvent):
+        (Inspector::buildSamples):
+        * inspector/agents/InspectorScriptProfilerAgent.h:
+        * runtime/SamplingProfiler.cpp:
+        (JSC::SamplingProfiler::takeSample):
+        * runtime/SamplingProfiler.h:
+
+2018-03-01  Yusuke Suzuki  <utatane.tea@gmail.com>
+
         ASSERTION FAILED: matchContextualKeyword(m_vm->propertyNames->async)
         https://bugs.webkit.org/show_bug.cgi?id=183173
 
index c325080..bcbabab 100644 (file)
@@ -247,12 +247,12 @@ void Debugger::setProfilingClient(ProfilingClient* client)
     m_profilingClient = client;
 }
 
-double Debugger::willEvaluateScript()
+Seconds Debugger::willEvaluateScript()
 {
     return m_profilingClient->willEvaluateScript();
 }
 
-void Debugger::didEvaluateScript(double startTime, ProfilingReason reason)
+void Debugger::didEvaluateScript(Seconds startTime, ProfilingReason reason)
 {
     m_profilingClient->didEvaluateScript(startTime, reason);
 }
index 3f51bb4..bcd72ea 100644 (file)
@@ -140,15 +140,15 @@ public:
     public:
         virtual ~ProfilingClient();
         virtual bool isAlreadyProfiling() const = 0;
-        virtual double willEvaluateScript() = 0;
-        virtual void didEvaluateScript(double startTime, ProfilingReason) = 0;
+        virtual Seconds willEvaluateScript() = 0;
+        virtual void didEvaluateScript(Seconds startTime, ProfilingReason) = 0;
     };
 
     void setProfilingClient(ProfilingClient*);
     bool hasProfilingClient() const { return m_profilingClient != nullptr; }
     bool isAlreadyProfiling() const { return m_profilingClient && m_profilingClient->isAlreadyProfiling(); }
-    double willEvaluateScript();
-    void didEvaluateScript(double startTime, ProfilingReason);
+    Seconds willEvaluateScript();
+    void didEvaluateScript(Seconds startTime, ProfilingReason);
 
 protected:
     virtual void handleBreakpointHit(JSGlobalObject*, const Breakpoint&) { }
index e40337f..c4bee4d 100644 (file)
@@ -83,7 +83,7 @@ private:
     }
 
     JSGlobalObject* m_globalObject { nullptr };
-    std::optional<double> m_startTime;
+    std::optional<Seconds> m_startTime;
     ProfilingReason m_reason;
 };
 
index 240816c..20e4ecb 100644 (file)
@@ -1041,7 +1041,7 @@ void InspectorDebuggerAgent::breakpointActionProbe(JSC::ExecState& scriptState,
         .setProbeId(action.identifier)
         .setBatchId(batchId)
         .setSampleId(sampleId)
-        .setTimestamp(m_injectedScriptManager.inspectorEnvironment().executionStopwatch()->elapsedTime())
+        .setTimestamp(m_injectedScriptManager.inspectorEnvironment().executionStopwatch()->elapsedTime().seconds())
         .setPayload(WTFMove(payload))
         .release();
     m_frontendDispatcher->didSampleProbe(WTFMove(result));
index f9fbbd6..a2b6d04 100644 (file)
@@ -103,7 +103,7 @@ void InspectorHeapAgent::snapshot(ErrorString&, double* timestamp, String* snaps
     HeapSnapshotBuilder snapshotBuilder(vm.ensureHeapProfiler());
     snapshotBuilder.buildSnapshot();
 
-    *timestamp = m_environment.executionStopwatch()->elapsedTime();
+    *timestamp = m_environment.executionStopwatch()->elapsedTime().seconds();
     *snapshotData = snapshotBuilder.json([&] (const HeapSnapshotNode& node) {
         if (Structure* structure = node.cell->structure(vm)) {
             if (JSGlobalObject* globalObject = structure->globalObject()) {
@@ -273,7 +273,7 @@ void InspectorHeapAgent::willGarbageCollect()
 void InspectorHeapAgent::didGarbageCollect(CollectionScope scope)
 {
     if (!m_enabled) {
-        m_gcStartTime = NAN;
+        m_gcStartTime = Seconds::nan();
         return;
     }
 
@@ -284,10 +284,10 @@ void InspectorHeapAgent::didGarbageCollect(CollectionScope scope)
 
     // FIXME: Include number of bytes freed by collection.
 
-    double endTime = m_environment.executionStopwatch()->elapsedTime();
+    Seconds endTime = m_environment.executionStopwatch()->elapsedTime();
     dispatchGarbageCollectedEvent(protocolTypeForHeapOperation(scope), m_gcStartTime, endTime);
 
-    m_gcStartTime = NAN;
+    m_gcStartTime = Seconds::nan();
 }
 
 void InspectorHeapAgent::clearHeapSnapshots()
@@ -301,12 +301,12 @@ void InspectorHeapAgent::clearHeapSnapshots()
     }
 }
 
-void InspectorHeapAgent::dispatchGarbageCollectedEvent(Protocol::Heap::GarbageCollection::Type type, double startTime, double endTime)
+void InspectorHeapAgent::dispatchGarbageCollectedEvent(Protocol::Heap::GarbageCollection::Type type, Seconds startTime, Seconds endTime)
 {
     auto protocolObject = Protocol::Heap::GarbageCollection::create()
         .setType(type)
-        .setStartTime(startTime)
-        .setEndTime(endTime)
+        .setStartTime(startTime.seconds())
+        .setEndTime(endTime.seconds())
         .release();
 
     m_frontendDispatcher->garbageCollected(WTFMove(protocolObject));
index aeebf39..de6dda9 100644 (file)
@@ -31,6 +31,7 @@
 #include "InspectorFrontendDispatchers.h"
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/Seconds.h>
 
 namespace JSC {
 struct HeapSnapshotNode;
@@ -68,7 +69,7 @@ public:
 protected:
     void clearHeapSnapshots();
 
-    virtual void dispatchGarbageCollectedEvent(Protocol::Heap::GarbageCollection::Type, double startTime, double endTime);
+    virtual void dispatchGarbageCollectedEvent(Protocol::Heap::GarbageCollection::Type, Seconds startTime, Seconds endTime);
 
 private:
     std::optional<JSC::HeapSnapshotNode> nodeForHeapObjectIdentifier(ErrorString&, unsigned heapObjectIdentifier);
@@ -80,7 +81,7 @@ private:
 
     bool m_enabled { false };
     bool m_tracking { false };
-    double m_gcStartTime { NAN };
+    Seconds m_gcStartTime { Seconds::nan() };
 };
 
 } // namespace Inspector
index 597e08e..a2bc3da 100644 (file)
@@ -90,7 +90,7 @@ void InspectorScriptProfilerAgent::startTracking(ErrorString&, const bool* inclu
 
     m_environment.scriptDebugServer().setProfilingClient(this);
 
-    m_frontendDispatcher->trackingStart(m_environment.executionStopwatch()->elapsedTime());
+    m_frontendDispatcher->trackingStart(m_environment.executionStopwatch()->elapsedTime().seconds());
 }
 
 void InspectorScriptProfilerAgent::stopTracking(ErrorString&)
@@ -111,7 +111,7 @@ bool InspectorScriptProfilerAgent::isAlreadyProfiling() const
     return m_activeEvaluateScript;
 }
 
-double InspectorScriptProfilerAgent::willEvaluateScript()
+Seconds InspectorScriptProfilerAgent::willEvaluateScript()
 {
     m_activeEvaluateScript = true;
 
@@ -126,11 +126,11 @@ double InspectorScriptProfilerAgent::willEvaluateScript()
     return m_environment.executionStopwatch()->elapsedTime();
 }
 
-void InspectorScriptProfilerAgent::didEvaluateScript(double startTime, ProfilingReason reason)
+void InspectorScriptProfilerAgent::didEvaluateScript(Seconds startTime, ProfilingReason reason)
 {
     m_activeEvaluateScript = false;
 
-    double endTime = m_environment.executionStopwatch()->elapsedTime();
+    Seconds endTime = m_environment.executionStopwatch()->elapsedTime();
 
     addEvent(startTime, endTime, reason);
 }
@@ -150,13 +150,13 @@ static Protocol::ScriptProfiler::EventType toProtocol(ProfilingReason reason)
     return Protocol::ScriptProfiler::EventType::Other;
 }
 
-void InspectorScriptProfilerAgent::addEvent(double startTime, double endTime, ProfilingReason reason)
+void InspectorScriptProfilerAgent::addEvent(Seconds startTime, Seconds endTime, ProfilingReason reason)
 {
     ASSERT(endTime >= startTime);
 
     auto event = Protocol::ScriptProfiler::Event::create()
-        .setStartTime(startTime)
-        .setEndTime(endTime)
+        .setStartTime(startTime.seconds())
+        .setEndTime(endTime.seconds())
         .setType(toProtocol(reason))
         .release();
 
@@ -189,7 +189,7 @@ static Ref<Protocol::ScriptProfiler::Samples> buildSamples(VM& vm, Vector<Sampli
             frames->addItem(WTFMove(frameObject));
         }
         Ref<Protocol::ScriptProfiler::StackTrace> inspectorStackTrace = Protocol::ScriptProfiler::StackTrace::create()
-            .setTimestamp(stackTrace.timestamp)
+            .setTimestamp(stackTrace.timestamp.seconds())
             .setStackFrames(WTFMove(frames))
             .release();
         stackTraces->addItem(WTFMove(inspectorStackTrace));
index 2c2fa60..dab774f 100644 (file)
@@ -58,11 +58,11 @@ public:
 
     // Debugger::ProfilingClient
     bool isAlreadyProfiling() const override;
-    double willEvaluateScript() override;
-    void didEvaluateScript(double, JSC::ProfilingReason) override;
+    Seconds willEvaluateScript() override;
+    void didEvaluateScript(Seconds, JSC::ProfilingReason) override;
 
 private:
-    void addEvent(double startTime, double endTime, JSC::ProfilingReason);
+    void addEvent(Seconds startTime, Seconds endTime, JSC::ProfilingReason);
     void trackingComplete();
     void stopSamplingWhenDisconnecting();
 
index 9727c18..b3f61f6 100644 (file)
@@ -336,7 +336,7 @@ void SamplingProfiler::takeSample(const AbstractLocker&, Seconds& stackTraceProc
 {
     ASSERT(m_lock.isLocked());
     if (m_vm.entryScope) {
-        double nowTime = m_stopwatch->elapsedTime();
+        Seconds nowTime = m_stopwatch->elapsedTime();
 
         auto machineThreadsLocker = holdLock(m_vm.heap.machineThreads().getLock());
         LockHolder codeBlockSetLocker(m_vm.heap.codeBlockSet().getLock());
index 7d91ad4..65bea9f 100644 (file)
@@ -137,7 +137,7 @@ public:
     };
 
     struct UnprocessedStackTrace {
-        double timestamp;
+        Seconds timestamp;
         void* topPC;
         bool topFrameIsLLInt;
         void* llintPC;
@@ -145,7 +145,7 @@ public:
     };
 
     struct StackTrace {
-        double timestamp;
+        Seconds timestamp;
         Vector<StackFrame> frames;
         StackTrace()
         { }
@@ -193,7 +193,7 @@ private:
     Vector<StackTrace> m_stackTraces;
     Vector<UnprocessedStackTrace> m_unprocessedStackTraces;
     Seconds m_timingInterval;
-    double m_lastTime;
+    Seconds m_lastTime;
     Lock m_lock;
     RefPtr<Thread> m_thread;
     RefPtr<Thread> m_jscExecutionThread;
index d188e46..ce5201f 100644 (file)
@@ -1,3 +1,61 @@
+2018-03-01  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Remove monotonicallyIncreasingTime
+        https://bugs.webkit.org/show_bug.cgi?id=182911
+
+        Reviewed by Michael Catanzaro.
+
+        This patch drops monotonicallyIncreasingTime and monotonicallyIncreasingTimeMS.
+        We have MonotonicTime API instead. This offers strongly typed MonotonicTime,
+        Seconds etc. This reduces the chance of bugs mixing doubles which represent milliseconds
+        and seconds.
+
+        Large part of this patch is mechanical one: replacing monotonicallyIncreasingTime with
+        MonotonicTime, using MonotonicTime and Seconds instead of raw doubles.
+
+        But this patch actually finds some bugs (but it is a bit difficult to show it as a test).
+        One is mixing media time (CACurrentMediaTime()) and MonotonicTime. Basically they are
+        super close because both uses mach_absolute_time(). But they would be slightly different.
+        So we should not mix them.
+
+        The second bug is GraphicsLayer::suspendAnimations(double). While CA ports (Apple, AppleWin,
+        iOS etc.) use this double as MonotonicTime, GTK and WPE use this double as Seconds (timeOffset).
+        This patch fixes it and now the signature becomes GraphicsLayer::suspendAnimations(MonotonicTime).
+
+        In this patch, we still uses bunch of double for Seconds. But fixing them at this patch increases
+        the size of this larger and larger. So some of them remains double. This should be fixed in
+        subsequent patches.
+
+        * benchmarks/ConditionSpeedTest.cpp:
+        * benchmarks/LockSpeedTest.cpp:
+        * wtf/CurrentTime.cpp:
+        (WTF::MonotonicTime::now):
+        (WTF::monotonicallyIncreasingTime): Deleted.
+        * wtf/CurrentTime.h:
+        (WTF::monotonicallyIncreasingTimeMS): Deleted.
+        * wtf/MemoryPressureHandler.h:
+        * wtf/MonotonicTime.cpp:
+        (WTF::MonotonicTime::now): Deleted.
+        * wtf/MonotonicTime.h:
+        * wtf/ParkingLot.cpp:
+        * wtf/Seconds.h:
+        (WTF::Seconds::nan):
+        * wtf/Stopwatch.h:
+        (WTF::Stopwatch::reset):
+        (WTF::Stopwatch::start):
+        (WTF::Stopwatch::stop):
+        (WTF::Stopwatch::elapsedTime):
+        (WTF::Stopwatch::elapsedTimeSince):
+        * wtf/cocoa/MemoryPressureHandlerCocoa.mm:
+        (WTF::MemoryPressureHandler::holdOff):
+        (WTF::MemoryPressureHandler::respondToMemoryPressure):
+        * wtf/linux/MemoryPressureHandlerLinux.cpp:
+        (WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
+        (WTF::MemoryPressureHandler::holdOff):
+        (WTF::MemoryPressureHandler::respondToMemoryPressure):
+        * wtf/win/MemoryPressureHandlerWin.cpp:
+        (WTF::MemoryPressureHandler::holdOff):
+
 2018-03-02  Dan Bernstein  <mitz@apple.com>
 
         Safari uses WebContent.Development when loading injected bundle embedded in its app bundle
index 2389854..847c8b7 100644 (file)
@@ -175,7 +175,7 @@ void runBenchmark(
     const NotifyFunctor& notify,
     const NotifyAllFunctor& notifyAll)
 {
-    double before = monotonicallyIncreasingTimeMS();
+    MonotonicTime before = MonotonicTime::now();
     
     runTest<LockType, ConditionType>(
         numProducers,
@@ -185,9 +185,9 @@ void runBenchmark(
         notify,
         notifyAll);
 
-    double after = monotonicallyIncreasingTimeMS();
+    MonotonicTime after = MonotonicTime::now();
 
-    printf("%s: %.3lf ms.\n", name, after - before);
+    printf("%s: %.3lf ms.\n", name, (after - before).milliseconds());
 }
 
 } // anonymous namespace
index cd13f69..dc839ab 100644 (file)
@@ -81,7 +81,7 @@ struct Benchmark {
 
         volatile bool keepGoing = true;
 
-        double before = monotonicallyIncreasingTime();
+        MonotonicTime before = MonotonicTime::now();
     
         Lock numIterationsLock;
         uint64_t numIterations = 0;
@@ -121,9 +121,9 @@ struct Benchmark {
         for (unsigned threadIndex = numThreadGroups * numThreadsPerGroup; threadIndex--;)
             threads[threadIndex]->waitForCompletion();
 
-        double after = monotonicallyIncreasingTime();
+        MonotonicTime after = MonotonicTime::now();
     
-        reportResult(name, numIterations / (after - before) / 1000);
+        reportResult(name, numIterations / (after - before).seconds() / 1000);
     }
 };
 
index 8abc2ff..1eb63ca 100644 (file)
@@ -250,17 +250,11 @@ WallTime WallTime::now()
     return fromRawSeconds(currentTime());
 }
 
-#if USE(GLIB)
-
-double monotonicallyIncreasingTime()
+MonotonicTime MonotonicTime::now()
 {
-    return static_cast<double>(g_get_monotonic_time() / 1000000.0);
-}
-
+#if USE(GLIB)
+    return fromRawSeconds(static_cast<double>(g_get_monotonic_time() / 1000000.0));
 #elif OS(DARWIN)
-
-double monotonicallyIncreasingTime()
-{
     // Based on listing #2 from Apple QA 1398, but modified to be thread-safe.
     static mach_timebase_info_data_t timebaseInfo;
     static std::once_flag initializeTimerOnceFlag;
@@ -270,31 +264,20 @@ double monotonicallyIncreasingTime()
         ASSERT(timebaseInfo.denom);
     });
 
-    return (mach_absolute_time() * timebaseInfo.numer) / (1.0e9 * timebaseInfo.denom);
-}
-
+    return fromRawSeconds((mach_absolute_time() * timebaseInfo.numer) / (1.0e9 * timebaseInfo.denom));
 #elif OS(LINUX) || OS(FREEBSD) || OS(OPENBSD) || OS(NETBSD)
-
-double monotonicallyIncreasingTime()
-{
     struct timespec ts { };
     clock_gettime(CLOCK_MONOTONIC, &ts);
-    return static_cast<double>(ts.tv_sec) + ts.tv_nsec / 1.0e9;
-}
-
+    return fromRawSeconds(static_cast<double>(ts.tv_sec) + ts.tv_nsec / 1.0e9);
 #else
-
-double monotonicallyIncreasingTime()
-{
     static double lastTime = 0;
     double currentTimeNow = currentTime();
     if (currentTimeNow < lastTime)
         return lastTime;
     lastTime = currentTimeNow;
-    return currentTimeNow;
-}
-
+    return fromRawSeconds(currentTimeNow);
 #endif
+}
 
 Seconds currentCPUTime()
 {
index b3e6c14..b2f6fd5 100644 (file)
 
 namespace WTF {
 
-// Provides a monotonically increasing time in seconds since an arbitrary point in the past.
-// On unsupported platforms, this function only guarantees the result will be non-decreasing.
-// Result of this function increases monotonically even when clock time goes back due to
-// NTP or manual adjustments, so it is better suited for elapsed time measurement.
-WTF_EXPORT_PRIVATE double monotonicallyIncreasingTime();
-
-inline double monotonicallyIncreasingTimeMS()
-{
-    return monotonicallyIncreasingTime() * 1000.0;
-}
-
 // Returns the current CPU time of the current thread.
 // Precision varies depending on platform but is usually as good or better
 // than a millisecond.
@@ -58,8 +47,6 @@ WTF_EXPORT_PRIVATE void sleep(Seconds);
 } // namespace WTF
 
 using WTF::currentCPUTime;
-using WTF::monotonicallyIncreasingTime;
-using WTF::monotonicallyIncreasingTimeMS;
 using WTF::sleep;
 
 #endif // CurrentTime_h
index 57894ca..5d26356 100644 (file)
@@ -154,7 +154,7 @@ private:
 
     void uninstall();
 
-    void holdOff(unsigned);
+    void holdOff(Seconds);
 
     MemoryPressureHandler();
     ~MemoryPressureHandler() = delete;
index 25d3f0e..e0d7d91 100644 (file)
 
 namespace WTF {
 
-MonotonicTime MonotonicTime::now()
-{
-    return fromRawSeconds(monotonicallyIncreasingTime());
-}
-
 WallTime MonotonicTime::approximateWallTime() const
 {
     return *this - now() + WallTime::now();
index 91b1c88..0bbee82 100644 (file)
@@ -38,9 +38,6 @@ class PrintStream;
 // possibly don't count downtime. This uses floating point internally so that you can reason about
 // infinity and other things that arise in math. It's acceptable to use this to wrap NaN times,
 // negative times, and infinite times, so long as they are all relative to the same clock.
-// Specifically, MonotonicTime should be used in agreement with the principle that
-// MonotonicTime::now().secondsSinceEpoch().value() is the same as
-// WTF::monotonicallyIncreasingTime().
 class MonotonicTime {
 public:
     static const ClockType clockType = ClockType::Monotonic;
@@ -48,9 +45,8 @@ public:
     // This is the epoch. So, x.secondsSinceEpoch() should be the same as x - MonotonicTime().
     constexpr MonotonicTime() { }
     
-    // Call this if you know for sure that the double represents time according to
-    // WTF::monotonicallyIncreasingTime(). It must be in seconds and it must be from the same time
-    // source.
+    // Call this if you know for sure that the double represents monotonic time according to the
+    // same time source as MonotonicTime. It must be in seconds.
     static constexpr MonotonicTime fromRawSeconds(double value)
     {
         return MonotonicTime(value);
@@ -141,6 +137,34 @@ public:
     {
         return *this;
     }
+
+    template<class Encoder>
+    void encode(Encoder& encoder) const
+    {
+        encoder << m_value;
+    }
+
+    template<class Decoder>
+    static std::optional<MonotonicTime> decode(Decoder& decoder)
+    {
+        std::optional<double> time;
+        decoder >> time;
+        if (!time)
+            return std::nullopt;
+        return MonotonicTime::fromRawSeconds(*time);
+    }
+
+    template<class Decoder>
+    static bool decode(Decoder& decoder, MonotonicTime& time)
+    {
+        double value;
+        if (!decoder.decode(value))
+            return false;
+
+        time = MonotonicTime::fromRawSeconds(value);
+        return true;
+    }
+
 private:
     constexpr MonotonicTime(double rawValue)
         : m_value(rawValue)
index 8a5ec8d..5179dc8 100644 (file)
@@ -133,7 +133,7 @@ public:
         ThreadData** currentPtr = &queueHead;
         ThreadData* previous = nullptr;
 
-        double time = monotonicallyIncreasingTimeMS();
+        MonotonicTime time = MonotonicTime::now();
         bool timeToBeFair = false;
         if (time > nextFairTime)
             timeToBeFair = true;
@@ -170,7 +170,7 @@ public:
         }
         
         if (timeToBeFair && didDequeue)
-            nextFairTime = time + random.get();
+            nextFairTime = time + Seconds::fromMilliseconds(random.get());
 
         ASSERT(!!queueHead == !!queueTail);
     }
@@ -193,7 +193,7 @@ public:
     // this lock.
     WordLock lock;
     
-    double nextFairTime { 0 };
+    MonotonicTime nextFairTime;
     
     WeakRandom random;
 
index 079fba7..e43ec4c 100644 (file)
@@ -27,6 +27,7 @@
 #define WTF_Seconds_h
 
 #include <wtf/MathExtras.h>
+#include <wtf/Optional.h>
 
 namespace WTF {
 
@@ -88,6 +89,11 @@ public:
     {
         return Seconds(std::numeric_limits<double>::infinity());
     }
+
+    static constexpr Seconds nan()
+    {
+        return Seconds(std::numeric_limits<double>::quiet_NaN());
+    }
     
     explicit constexpr operator bool() const { return !!m_value; }
     
@@ -214,6 +220,33 @@ public:
         return *this;
     }
 
+    template<class Encoder>
+    void encode(Encoder& encoder) const
+    {
+        encoder << m_value;
+    }
+
+    template<class Decoder>
+    static std::optional<Seconds> decode(Decoder& decoder)
+    {
+        std::optional<double> seconds;
+        decoder >> seconds;
+        if (!seconds)
+            return std::nullopt;
+        return Seconds(*seconds);
+    }
+
+    template<class Decoder>
+    static bool decode(Decoder& decoder, Seconds& seconds)
+    {
+        double value;
+        if (!decoder.decode(value))
+            return false;
+
+        seconds = Seconds(value);
+        return true;
+    }
+
 private:
     double m_value { 0 };
 };
index 9f4c018..48522d4 100644 (file)
@@ -42,52 +42,52 @@ public:
     void start();
     void stop();
 
-    double elapsedTime();
-    double elapsedTimeSince(MonotonicTime);
+    Seconds elapsedTime();
+    Seconds elapsedTimeSince(MonotonicTime);
 
     bool isActive() const { return !std::isnan(m_lastStartTime); }
 private:
     Stopwatch() { reset(); }
 
-    double m_elapsedTime;
-    double m_lastStartTime;
+    Seconds m_elapsedTime;
+    MonotonicTime m_lastStartTime;
 };
 
 inline void Stopwatch::reset()
 {
-    m_elapsedTime = 0.0;
-    m_lastStartTime = NAN;
+    m_elapsedTime = 0_s;
+    m_lastStartTime = MonotonicTime::nan();
 }
 
 inline void Stopwatch::start()
 {
     ASSERT_WITH_MESSAGE(std::isnan(m_lastStartTime), "Tried to start the stopwatch, but it is already running.");
 
-    m_lastStartTime = monotonicallyIncreasingTime();
+    m_lastStartTime = MonotonicTime::now();
 }
 
 inline void Stopwatch::stop()
 {
     ASSERT_WITH_MESSAGE(!std::isnan(m_lastStartTime), "Tried to stop the stopwatch, but it is not running.");
 
-    m_elapsedTime += monotonicallyIncreasingTime() - m_lastStartTime;
-    m_lastStartTime = NAN;
+    m_elapsedTime += MonotonicTime::now() - m_lastStartTime;
+    m_lastStartTime = MonotonicTime::nan();
 }
 
-inline double Stopwatch::elapsedTime()
+inline Seconds Stopwatch::elapsedTime()
 {
     if (!isActive())
         return m_elapsedTime;
 
-    return m_elapsedTime + (monotonicallyIncreasingTime() - m_lastStartTime);
+    return m_elapsedTime + (MonotonicTime::now() - m_lastStartTime);
 }
 
-inline double Stopwatch::elapsedTimeSince(MonotonicTime timeStamp)
+inline Seconds Stopwatch::elapsedTimeSince(MonotonicTime timeStamp)
 {
     if (!isActive())
         return m_elapsedTime;
 
-    return m_elapsedTime + (timeStamp.secondsSinceEpoch().seconds() - m_lastStartTime);
+    return m_elapsedTime + (timeStamp - m_lastStartTime);
 }
 
 } // namespace WTF
index daba2d6..5003d0e 100644 (file)
@@ -57,7 +57,7 @@ static int _notifyTokens[3];
 // this is 1 / s_holdOffMultiplier percent of the time.
 // These value seems reasonable and testing verifies that it throttles frequent
 // low memory events, greatly reducing CPU usage.
-static const unsigned s_minimumHoldOffTime = 5;
+static const Seconds s_minimumHoldOffTime { 5_s };
 #if !PLATFORM(IOS)
 static const unsigned s_holdOffMultiplier = 20;
 #endif
@@ -152,13 +152,15 @@ void MemoryPressureHandler::uninstall()
         notify_cancel(token);
 }
 
-void MemoryPressureHandler::holdOff(unsigned seconds)
+void MemoryPressureHandler::holdOff(Seconds seconds)
 {
     dispatch_async(dispatch_get_main_queue(), ^{
         _timer_event_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
         if (_timer_event_source) {
             dispatch_set_context(_timer_event_source, this);
-            dispatch_source_set_timer(_timer_event_source, dispatch_time(DISPATCH_TIME_NOW, seconds * NSEC_PER_SEC), DISPATCH_TIME_FOREVER, 1 * s_minimumHoldOffTime);
+            // FIXME: The final argument `s_minimumHoldOffTime.seconds()` seems wrong.
+            // https://bugs.webkit.org/show_bug.cgi?id=183277
+            dispatch_source_set_timer(_timer_event_source, dispatch_time(DISPATCH_TIME_NOW, seconds.seconds() * NSEC_PER_SEC), DISPATCH_TIME_FOREVER, s_minimumHoldOffTime.seconds());
             dispatch_source_set_event_handler(_timer_event_source, ^{
                 if (_timer_event_source) {
                     dispatch_source_cancel(_timer_event_source);
@@ -176,13 +178,13 @@ void MemoryPressureHandler::respondToMemoryPressure(Critical critical, Synchrono
 {
 #if !PLATFORM(IOS)
     uninstall();
-    double startTime = monotonicallyIncreasingTime();
+    MonotonicTime startTime = MonotonicTime::now();
 #endif
 
     releaseMemory(critical, synchronous);
 
 #if !PLATFORM(IOS)
-    unsigned holdOffTime = (monotonicallyIncreasingTime() - startTime) * s_holdOffMultiplier;
+    Seconds holdOffTime = (MonotonicTime::now() - startTime) * s_holdOffMultiplier;
     holdOff(std::max(holdOffTime, s_minimumHoldOffTime));
 #endif
 }
index 15a5b12..e881441 100644 (file)
@@ -59,8 +59,8 @@ namespace WTF {
 // we wait longer to try again (s_maximumHoldOffTime).
 // These value seems reasonable and testing verifies that it throttles frequent
 // low memory events, greatly reducing CPU usage.
-static const unsigned s_minimumHoldOffTime = 5;
-static const unsigned s_maximumHoldOffTime = 30;
+static const Seconds s_minimumHoldOffTime { 5_s };
+static const Seconds s_maximumHoldOffTime { 30_s };
 static const size_t s_minimumBytesFreedToUseMinimumHoldOffTime = 1 * MB;
 static const unsigned s_holdOffMultiplier = 20;
 
@@ -277,7 +277,7 @@ void MemoryPressureHandler::holdOffTimerFired()
     install();
 }
 
-void MemoryPressureHandler::holdOff(unsigned seconds)
+void MemoryPressureHandler::holdOff(Seconds seconds)
 {
     m_holdOffTimer.startOneShot(seconds);
 }
@@ -293,13 +293,13 @@ void MemoryPressureHandler::respondToMemoryPressure(Critical critical, Synchrono
 {
     uninstall();
 
-    double startTime = monotonicallyIncreasingTime();
+    MonotonicTime startTime = MonotonicTime::now();
     int64_t processMemory = processMemoryUsage();
     releaseMemory(critical, synchronous);
     int64_t bytesFreed = processMemory - processMemoryUsage();
-    unsigned holdOffTime = s_maximumHoldOffTime;
+    Seconds holdOffTime = s_maximumHoldOffTime;
     if (bytesFreed > 0 && static_cast<size_t>(bytesFreed) >= s_minimumBytesFreedToUseMinimumHoldOffTime)
-        holdOffTime = (monotonicallyIncreasingTime() - startTime) * s_holdOffMultiplier;
+        holdOffTime = (MonotonicTime::now() - startTime) * s_holdOffMultiplier;
     holdOff(std::max(holdOffTime, s_minimumHoldOffTime));
 }
 
index 312cf02..69ab63e 100644 (file)
@@ -85,7 +85,7 @@ void MemoryPressureHandler::uninstall()
     m_installed = false;
 }
 
-void MemoryPressureHandler::holdOff(unsigned seconds)
+void MemoryPressureHandler::holdOff(Seconds seconds)
 {
 }
 
index ab7feb0..f26a203 100644 (file)
@@ -1,3 +1,305 @@
+2018-03-01  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Remove monotonicallyIncreasingTime
+        https://bugs.webkit.org/show_bug.cgi?id=182911
+
+        Reviewed by Michael Catanzaro.
+
+        While generic code uses MonotonicTime, CAAnimation uses media time (CFTimeInterval).
+        At this boundary, we convert MonotonicTime to media time, this is the same logic to
+        the code before this patch.
+
+        * Modules/gamepad/Gamepad.h:
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::SourceBuffer):
+        (WebCore::SourceBuffer::monitorBufferingRate):
+        * Modules/mediasource/SourceBuffer.h:
+        * Modules/speech/SpeechSynthesis.cpp:
+        (WebCore::SpeechSynthesis::startSpeakingImmediately):
+        (WebCore::SpeechSynthesis::fireEvent):
+        * Modules/speech/SpeechSynthesisUtterance.h:
+        * contentextensions/ContentExtensionCompiler.cpp:
+        (WebCore::ContentExtensions::compileRuleList):
+        * contentextensions/ContentExtensionParser.cpp:
+        (WebCore::ContentExtensions::parseRuleList):
+        * contentextensions/ContentExtensionsBackend.cpp:
+        (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad const):
+        * dom/Element.cpp:
+        (WebCore::Element::setActive):
+        * history/CachedPage.cpp:
+        (WebCore::CachedPage::CachedPage):
+        (WebCore::CachedPage::hasExpired const):
+        * history/CachedPage.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::startProgressEventTimer):
+        (WebCore::HTMLMediaElement::progressEventTimerFired):
+        (WebCore::HTMLMediaElement::refreshCachedTime const):
+        (WebCore::HTMLMediaElement::invalidateCachedTime const):
+        (WebCore::HTMLMediaElement::currentMediaTime const):
+        (WebCore::HTMLMediaElement::startPlaybackProgressTimer):
+        * html/HTMLMediaElement.h:
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::removeBehaviorRestriction):
+        (WebCore::MediaElementSession::mostRecentUserInteractionTime const):
+        (WebCore::MediaElementSession::resetPlaybackSessionState):
+        * html/MediaElementSession.h:
+        * html/parser/HTMLParserScheduler.cpp:
+        (WebCore::PumpSession::PumpSession):
+        (WebCore::HTMLParserScheduler::HTMLParserScheduler):
+        * html/parser/HTMLParserScheduler.h:
+        (WebCore::HTMLParserScheduler::checkForYield):
+        * inspector/InspectorCanvas.cpp:
+        (WebCore::InspectorCanvas::recordAction):
+        (WebCore::InspectorCanvas::finalizeFrame):
+        * inspector/InspectorCanvas.h:
+        * inspector/agents/InspectorMemoryAgent.cpp:
+        (WebCore::InspectorMemoryAgent::startTracking):
+        (WebCore::InspectorMemoryAgent::didHandleMemoryPressure):
+        (WebCore::InspectorMemoryAgent::collectSample):
+        * inspector/agents/InspectorNetworkAgent.cpp:
+        (WebCore::InspectorNetworkAgent::buildObjectForTiming):
+        (WebCore::InspectorNetworkAgent::timestamp):
+        (WebCore::InspectorNetworkAgent::didFinishLoading):
+        * inspector/agents/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::timestamp):
+        * inspector/agents/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::timestamp):
+        * inspector/agents/WebHeapAgent.cpp:
+        (WebCore::WebHeapAgent::dispatchGarbageCollectedEvent):
+        * inspector/agents/WebHeapAgent.h:
+        * loader/cache/CachedCSSStyleSheet.cpp:
+        (WebCore::CachedCSSStyleSheet::restoreParsedStyleSheet):
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::didDraw):
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::didAccessDecodedData):
+        * loader/cache/CachedResource.h:
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::pruneLiveResourcesToSize):
+        * page/EventHandler.cpp:
+        (WebCore::MaximumDurationTracker::MaximumDurationTracker):
+        (WebCore::MaximumDurationTracker::~MaximumDurationTracker):
+        * page/FocusController.cpp:
+        (WebCore::FocusController::setFocusedElement):
+        (WebCore::FocusController::timeSinceFocusWasSet const):
+        * page/FocusController.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::reset):
+        (WebCore::FrameView::willPaintContents):
+        (WebCore::FrameView::didPaintContents):
+        * page/FrameView.h:
+        * page/animation/AnimationBase.cpp:
+        (WebCore::AnimationBase::freezeAtTime):
+        (WebCore::AnimationBase::beginAnimationUpdateTime const):
+        * page/animation/AnimationBase.h:
+        (WebCore::AnimationBase::onAnimationStartResponse):
+        * page/animation/CSSAnimationController.cpp:
+        (WebCore::CSSAnimationControllerPrivate::beginAnimationUpdateTime):
+        (WebCore::CSSAnimationControllerPrivate::receivedStartTimeResponse):
+        (WebCore::CSSAnimationControllerPrivate::startTimeResponse):
+        (WebCore::CSSAnimationController::notifyAnimationStarted):
+        * page/animation/CSSAnimationController.h:
+        * page/animation/CSSAnimationControllerPrivate.h:
+        * page/mac/WheelEventDeltaFilterMac.h:
+        * page/mac/WheelEventDeltaFilterMac.mm:
+        (WebCore::WheelEventDeltaFilterMac::beginFilteringDeltas):
+        (WebCore::WheelEventDeltaFilterMac::updateFromDelta):
+        (WebCore::WheelEventDeltaFilterMac::endFilteringDeltas):
+        * platform/ControlStates.h:
+        (WebCore::ControlStates::timeSinceControlWasFocused const):
+        (WebCore::ControlStates::setTimeSinceControlWasFocused):
+        * platform/PlatformSpeechSynthesisUtterance.h:
+        (WebCore::PlatformSpeechSynthesisUtterance::startTime const):
+        (WebCore::PlatformSpeechSynthesisUtterance::setStartTime):
+        * platform/gamepad/PlatformGamepad.h:
+        (WebCore::PlatformGamepad::lastUpdateTime const):
+        (WebCore::PlatformGamepad::connectTime const):
+        (WebCore::PlatformGamepad::PlatformGamepad):
+        * platform/gamepad/cocoa/GameControllerGamepad.mm:
+        (WebCore::GameControllerGamepad::setupAsExtendedGamepad):
+        (WebCore::GameControllerGamepad::setupAsGamepad):
+        * platform/gamepad/mac/HIDGamepad.cpp:
+        (WebCore::HIDGamepad::HIDGamepad):
+        (WebCore::HIDGamepad::valueChanged):
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::suspendAnimations):
+        * platform/graphics/GraphicsLayer.h:
+        * platform/graphics/GraphicsLayerClient.h:
+        (WebCore::GraphicsLayerClient::notifyAnimationStarted):
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+        (WebCore::LayerClient::platformCALayerAnimationStarted):
+        (WebCore::AVFWrapper::createImageForTimeInRect):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::addAnimation):
+        (WebCore::GraphicsLayerCA::pauseAnimation):
+        (WebCore::GraphicsLayerCA::platformCALayerAnimationStarted):
+        (WebCore::GraphicsLayerCA::setAnimationOnLayer):
+        (WebCore::GraphicsLayerCA::pauseCAAnimationOnLayer):
+        (WebCore::GraphicsLayerCA::createAnimationFromKeyframes):
+        (WebCore::GraphicsLayerCA::appendToUncommittedAnimations):
+        (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        (WebCore::GraphicsLayerCA::LayerPropertyAnimation::LayerPropertyAnimation):
+        (WebCore::GraphicsLayerCA::AnimationProcessingAction::AnimationProcessingAction):
+        * platform/graphics/ca/LayerPool.cpp:
+        (WebCore::LayerPool::LayerPool):
+        (WebCore::LayerPool::addLayer):
+        (WebCore::LayerPool::decayedCapacity const):
+        (WebCore::LayerPool::pruneTimerFired):
+        * platform/graphics/ca/LayerPool.h:
+        * platform/graphics/ca/PlatformCAAnimation.h:
+        * platform/graphics/ca/PlatformCALayer.h:
+        * platform/graphics/ca/PlatformCALayerClient.h:
+        (WebCore::PlatformCALayerClient::platformCALayerAnimationStarted):
+        * platform/graphics/ca/TileGrid.cpp:
+        (WebCore::TileGrid::revalidateTiles):
+        (WebCore::TileGrid::startedNewCohort):
+        (WebCore::TileGrid::TileCohortInfo::timeUntilExpiration):
+        (WebCore::TileGrid::cohortRemovalTimerFired):
+        * platform/graphics/ca/TileGrid.h:
+        (WebCore::TileGrid::TileCohortInfo::TileCohortInfo):
+        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
+        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
+        (mediaTimeToCurrentTime):
+        (-[WebAnimationDelegate animationDidStart:]):
+        (PlatformCALayerCocoa::animationStarted):
+        * platform/graphics/ca/win/CACFLayerTreeHost.cpp:
+        (WebCore::CACFLayerTreeHost::notifyAnimationsStarted):
+        * platform/graphics/ca/win/PlatformCALayerWin.cpp:
+        (PlatformCALayerWin::animationStarted):
+        (PlatformCALayerWin::layerTreeAsString const):
+        * platform/graphics/ca/win/PlatformCALayerWin.h:
+        * platform/graphics/cocoa/WebCoreDecompressionSession.mm:
+        (WebCore::WebCoreDecompressionSession::decodeSample):
+        * platform/graphics/texmap/BitmapTexturePool.cpp:
+        (WebCore::BitmapTexturePool::releaseUnusedTexturesTimerFired):
+        * platform/graphics/texmap/BitmapTexturePool.h:
+        (WebCore::BitmapTexturePool::Entry::markIsInUse):
+        (WebCore::BitmapTexturePool::Entry::canBeReleased const):
+        (): Deleted.
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
+        (WebCore::GraphicsLayerTextureMapper::GraphicsLayerTextureMapper):
+        (WebCore::GraphicsLayerTextureMapper::addAnimation):
+        (WebCore::GraphicsLayerTextureMapper::pauseAnimation):
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
+        * platform/graphics/texmap/TextureMapperAnimation.cpp:
+        (WebCore::TextureMapperAnimation::TextureMapperAnimation):
+        (WebCore::TextureMapperAnimation::apply):
+        (WebCore::TextureMapperAnimation::pause):
+        (WebCore::TextureMapperAnimation::resume):
+        (WebCore::TextureMapperAnimation::computeTotalRunningTime):
+        (WebCore::TextureMapperAnimations::pause):
+        (WebCore::TextureMapperAnimations::suspend):
+        * platform/graphics/texmap/TextureMapperAnimation.h:
+        (WebCore::TextureMapperAnimation::startTime const):
+        (WebCore::TextureMapperAnimation::pauseTime const):
+        * platform/graphics/texmap/TextureMapperFPSCounter.cpp:
+        (WebCore::TextureMapperFPSCounter::TextureMapperFPSCounter):
+        (WebCore::TextureMapperFPSCounter::updateFPSAndDisplay):
+        * platform/graphics/texmap/TextureMapperFPSCounter.h:
+        * platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h:
+        (WebCore::TextureMapperPlatformLayerBuffer::markUsed):
+        (WebCore::TextureMapperPlatformLayerBuffer::lastUsedTime const):
+        (): Deleted.
+        * platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
+        (WebCore::TextureMapperPlatformLayerProxy::releaseUnusedBuffersTimerFired):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::addAnimation):
+        (WebCore::CoordinatedGraphicsLayer::pauseAnimation):
+        (WebCore::CoordinatedGraphicsLayer::suspendAnimations):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+        * platform/mediastream/RealtimeMediaSource.h:
+        * platform/mediastream/RealtimeOutgoingVideoSource.cpp:
+        (WebCore::RealtimeOutgoingVideoSource::sendFrame):
+        * platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp:
+        (WebCore::LibWebRTCAudioModule::StartPlayoutOnAudioThread):
+        * platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:
+        (WebCore::DisplayCaptureSourceCocoa::startProducingData):
+        (WebCore::DisplayCaptureSourceCocoa::stopProducingData):
+        (WebCore::DisplayCaptureSourceCocoa::elapsedTime):
+        * platform/mediastream/mac/DisplayCaptureSourceCocoa.h:
+        * platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
+        * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
+        (WebCore::MockRealtimeAudioSourceMac::render):
+        * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
+        (WebCore::MockRealtimeVideoSourceMac::CMSampleBufferFromPixelBuffer):
+        * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h:
+        * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
+        (WebCore::ScreenDisplayCaptureSourceMac::sampleBufferFromPixelBuffer):
+        (WebCore::ScreenDisplayCaptureSourceMac::frameAvailable):
+        * platform/mock/MockRealtimeAudioSource.cpp:
+        (WebCore::MockRealtimeAudioSource::startProducingData):
+        (WebCore::MockRealtimeAudioSource::stopProducingData):
+        (WebCore::MockRealtimeAudioSource::elapsedTime):
+        (WebCore::MockRealtimeAudioSource::tick):
+        (WebCore::MockRealtimeAudioSource::delaySamples):
+        * platform/mock/MockRealtimeAudioSource.h:
+        (WebCore::MockRealtimeAudioSource::render):
+        * platform/mock/MockRealtimeVideoSource.cpp:
+        (WebCore::MockRealtimeVideoSource::startProducingData):
+        (WebCore::MockRealtimeVideoSource::stopProducingData):
+        (WebCore::MockRealtimeVideoSource::elapsedTime):
+        (WebCore::MockRealtimeVideoSource::drawText):
+        (WebCore::MockRealtimeVideoSource::delaySamples):
+        (WebCore::MockRealtimeVideoSource::generateFrame):
+        * platform/mock/MockRealtimeVideoSource.h:
+        * platform/network/DNSResolveQueue.cpp:
+        (WebCore::DNSResolveQueue::DNSResolveQueue):
+        (WebCore::DNSResolveQueue::isUsingProxy):
+        * platform/network/DNSResolveQueue.h:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::suspendAnimations):
+        * rendering/RenderBoxModelObject.h:
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::paintFocusRing):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::paintAreaElementFocusRing):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::notifyAnimationStarted):
+        (WebCore::RenderLayerBacking::suspendAnimations):
+        * rendering/RenderLayerBacking.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::didPaintBacking):
+        * rendering/RenderProgress.cpp:
+        (WebCore::RenderProgress::RenderProgress):
+        (WebCore::RenderProgress::animationProgress const):
+        (WebCore::RenderProgress::updateAnimationState):
+        * rendering/RenderProgress.h:
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::animationDurationForProgressBar const):
+        * rendering/RenderTheme.h:
+        * rendering/RenderThemeGtk.cpp:
+        (WebCore::RenderThemeGtk::animationDurationForProgressBar const):
+        * rendering/RenderThemeGtk.h:
+        * rendering/RenderThemeIOS.h:
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::animationDurationForProgressBar const):
+        * rendering/RenderThemeMac.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::animationDurationForProgressBar const):
+        * svg/animation/SMILTimeContainer.cpp:
+        (WebCore::SMILTimeContainer::SMILTimeContainer):
+        (WebCore::SMILTimeContainer::elapsed const):
+        (WebCore::SMILTimeContainer::isActive const):
+        (WebCore::SMILTimeContainer::isPaused const):
+        (WebCore::SMILTimeContainer::isStarted const):
+        (WebCore::SMILTimeContainer::begin):
+        (WebCore::SMILTimeContainer::pause):
+        (WebCore::SMILTimeContainer::resume):
+        (WebCore::SMILTimeContainer::setElapsed):
+        (WebCore::SMILTimeContainer::timerFired):
+        * svg/animation/SMILTimeContainer.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::delayMediaStreamTrackSamples):
+        * testing/MockGamepad.cpp:
+        (WebCore::MockGamepad::MockGamepad):
+        (WebCore::MockGamepad::updateDetails):
+        (WebCore::MockGamepad::setAxisValue):
+        (WebCore::MockGamepad::setButtonValue):
+
 2018-03-02  Alejandro G. Castro  <alex@igalia.com>
 
         Make LibWebRTCProvider port agnostic again after r215424
index f32992f..8f19334 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(GAMEPAD)
 
+#include <wtf/MonotonicTime.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
@@ -49,7 +50,7 @@ public:
     const String& mapping() const { return m_mapping; }
 
     bool connected() const { return m_connected; }
-    double timestamp() const { return m_timestamp; }
+    double timestamp() const { return m_timestamp.secondsSinceEpoch().seconds(); }
     const Vector<double>& axes() const;
     const Vector<Ref<GamepadButton>>& buttons() const;
 
@@ -60,7 +61,7 @@ private:
     String m_id;
     unsigned m_index;
     bool m_connected;
-    double m_timestamp;
+    MonotonicTime m_timestamp;
     String m_mapping;
 
     Vector<double> m_axes;
index f3f085d..800a282 100644 (file)
@@ -107,7 +107,7 @@ SourceBuffer::SourceBuffer(Ref<SourceBufferPrivate>&& sourceBufferPrivate, Media
     , m_groupEndTimestamp(MediaTime::zeroTime())
     , m_buffered(TimeRanges::create())
     , m_appendState(WaitingForSegment)
-    , m_timeOfBufferingMonitor(monotonicallyIncreasingTime())
+    , m_timeOfBufferingMonitor(MonotonicTime::now())
     , m_pendingRemoveStart(MediaTime::invalidTime())
     , m_pendingRemoveEnd(MediaTime::invalidTime())
     , m_removeTimer(*this, &SourceBuffer::removeTimerFired)
@@ -1915,14 +1915,14 @@ void SourceBuffer::didDropSample()
 
 void SourceBuffer::monitorBufferingRate()
 {
-    double now = monotonicallyIncreasingTime();
-    double interval = now - m_timeOfBufferingMonitor;
-    double rateSinceLastMonitor = m_bufferedSinceLastMonitor / interval;
+    MonotonicTime now = MonotonicTime::now();
+    Seconds interval = now - m_timeOfBufferingMonitor;
+    double rateSinceLastMonitor = m_bufferedSinceLastMonitor / interval.seconds();
 
     m_timeOfBufferingMonitor = now;
     m_bufferedSinceLastMonitor = 0;
 
-    m_averageBufferRate += (interval * ExponentialMovingAverageCoefficient) * (rateSinceLastMonitor - m_averageBufferRate);
+    m_averageBufferRate += (interval.seconds() * ExponentialMovingAverageCoefficient) * (rateSinceLastMonitor - m_averageBufferRate);
 
     LOG(MediaSource, "SourceBuffer::monitorBufferingRate(%p) - m_avegareBufferRate: %lf", this, m_averageBufferRate);
 }
index 6cca87a..0d7a144 100644 (file)
@@ -214,7 +214,7 @@ private:
     enum AppendStateType { WaitingForSegment, ParsingInitSegment, ParsingMediaSegment };
     AppendStateType m_appendState;
 
-    double m_timeOfBufferingMonitor;
+    MonotonicTime m_timeOfBufferingMonitor;
     double m_bufferedSinceLastMonitor { 0 };
     double m_averageBufferRate { 0 };
 
index fbaad9b..0ae4f27 100644 (file)
@@ -104,7 +104,7 @@ bool SpeechSynthesis::paused() const
 void SpeechSynthesis::startSpeakingImmediately(SpeechSynthesisUtterance& utterance)
 {
     ASSERT(!m_currentSpeechUtterance);
-    utterance.setStartTime(monotonicallyIncreasingTime());
+    utterance.setStartTime(MonotonicTime::now());
     m_currentSpeechUtterance = &utterance;
     m_isPaused = false;
 
@@ -164,7 +164,7 @@ void SpeechSynthesis::resume()
 
 void SpeechSynthesis::fireEvent(const AtomicString& type, SpeechSynthesisUtterance& utterance, unsigned long charIndex, const String& name)
 {
-    utterance.dispatchEvent(SpeechSynthesisEvent::create(type, charIndex, (monotonicallyIncreasingTime() - utterance.startTime()), name));
+    utterance.dispatchEvent(SpeechSynthesisEvent::create(type, charIndex, (MonotonicTime::now() - utterance.startTime()).seconds(), name));
 }
 
 void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance& utterance, bool errorOccurred)
index b5cb520..8c24f77 100644 (file)
@@ -59,8 +59,8 @@ public:
     float pitch() const { return m_platformUtterance->pitch(); }
     void setPitch(float pitch) { m_platformUtterance->setPitch(pitch); }
 
-    double startTime() const { return m_platformUtterance->startTime(); }
-    void setStartTime(double startTime) { m_platformUtterance->setStartTime(startTime); }
+    MonotonicTime startTime() const { return m_platformUtterance->startTime(); }
+    void setStartTime(MonotonicTime startTime) { m_platformUtterance->setStartTime(startTime); }
 
     using RefCounted::ref;
     using RefCounted::deref;
index b47128e..84f3df8 100644 (file)
@@ -1,3 +1,15 @@
+2018-03-01  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Remove monotonicallyIncreasingTime
+        https://bugs.webkit.org/show_bug.cgi?id=182911
+
+        Reviewed by Michael Catanzaro.
+
+        * pal/system/ClockGeneric.cpp:
+        (PAL::ClockGeneric::currentTime const):
+        (PAL::ClockGeneric::now const):
+        * pal/system/ClockGeneric.h:
+
 2018-02-27  Tim Horton  <timothy_horton@apple.com>
 
         Stop using deprecated CADisplay SPI
index a6c71b4..1c8ccf9 100644 (file)
@@ -54,7 +54,7 @@ double ClockGeneric::currentTime() const
 {
     if (m_running)
         m_lastTime = now();
-    return ((m_lastTime - m_startTime) * m_rate) + m_offset;
+    return ((m_lastTime - m_startTime).seconds() * m_rate) + m_offset;
 }
 
 void ClockGeneric::setPlayRate(double rate)
@@ -83,9 +83,9 @@ void ClockGeneric::stop()
     m_running = false;
 }
 
-double ClockGeneric::now() const
+MonotonicTime ClockGeneric::now() const
 {
-    return monotonicallyIncreasingTime();
+    return MonotonicTime::now();
 }
 
 }
index 5fdf6f9..6d77ec5 100644 (file)
@@ -27,6 +27,7 @@
 #pragma once
 
 #include "Clock.h"
+#include <wtf/MonotonicTime.h>
 
 namespace PAL {
 
@@ -45,13 +46,13 @@ private:
     void stop() override;
     bool isRunning() const override { return m_running; }
 
-    double now() const;
+    MonotonicTime now() const;
 
     bool m_running;
     double m_rate;
     double m_offset;
-    double m_startTime;
-    mutable double m_lastTime;
+    MonotonicTime m_startTime;
+    mutable MonotonicTime m_lastTime;
 };
 
 }
index ef63409..42db31d 100644 (file)
@@ -311,7 +311,7 @@ std::error_code compileRuleList(ContentExtensionCompilationClient& client, Strin
         return ContentExtensionError::JSONTopURLAndDomainConditions;
 
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
-    double patternPartitioningStart = monotonicallyIncreasingTime();
+    MonotonicTime patternPartitioningStart = MonotonicTime::now();
 #endif
     
     client.writeSource(ruleJSON);
@@ -402,8 +402,8 @@ std::error_code compileRuleList(ContentExtensionCompilationClient& client, Strin
     actionLocations.clear();
 
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
-    double patternPartitioningEnd = monotonicallyIncreasingTime();
-    dataLogF("    Time spent partitioning the rules into groups: %f\n", (patternPartitioningEnd - patternPartitioningStart));
+    MonotonicTime patternPartitioningEnd = MonotonicTime::now();
+    dataLogF("    Time spent partitioning the rules into groups: %f\n", (patternPartitioningEnd - patternPartitioningStart).seconds());
 #endif
 
     LOG_LARGE_STRUCTURES(filtersWithoutConditions, filtersWithoutConditions.memoryUsed());
@@ -411,7 +411,7 @@ std::error_code compileRuleList(ContentExtensionCompilationClient& client, Strin
     LOG_LARGE_STRUCTURES(topURLFilters, topURLFilters.memoryUsed());
 
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
-    double totalNFAToByteCodeBuildTimeStart = monotonicallyIncreasingTime();
+    MonotonicTime totalNFAToByteCodeBuildTimeStart = MonotonicTime::now();
 #endif
 
     compileToBytecode(WTFMove(filtersWithoutConditions), WTFMove(universalActionsWithoutConditions), [&](Vector<DFABytecode>&& bytecode) {
@@ -425,8 +425,8 @@ std::error_code compileRuleList(ContentExtensionCompilationClient& client, Strin
     });
     
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
-    double totalNFAToByteCodeBuildTimeEnd = monotonicallyIncreasingTime();
-    dataLogF("    Time spent building and compiling the DFAs: %f\n", (totalNFAToByteCodeBuildTimeEnd - totalNFAToByteCodeBuildTimeStart));
+    MonotonicTime totalNFAToByteCodeBuildTimeEnd = MonotonicTime::now();
+    dataLogF("    Time spent building and compiling the DFAs: %f\n", (totalNFAToByteCodeBuildTimeEnd - totalNFAToByteCodeBuildTimeStart).seconds());
 
     dataLogF("    Number of machines without condition filters: %d (total bytecode size = %d)\n", machinesWithoutConditionsCount, totalBytecodeSizeForMachinesWithoutConditions);
     dataLogF("    Number of machines with condition filters: %d (total bytecode size = %d)\n", machinesWithConditionsCount, totalBytecodeSizeForMachinesWithConditions);
index ccdb262..5f8f9f0 100644 (file)
@@ -352,7 +352,7 @@ static Expected<Vector<ContentExtensionRule>, std::error_code> loadEncodedRules(
 Expected<Vector<ContentExtensionRule>, std::error_code> parseRuleList(String&& ruleJSON)
 {
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
-    double loadExtensionStartTime = monotonicallyIncreasingTime();
+    MonotonicTime loadExtensionStartTime = MonotonicTime::now();
 #endif
     RefPtr<VM> vm = VM::create();
 
@@ -371,8 +371,8 @@ Expected<Vector<ContentExtensionRule>, std::error_code> parseRuleList(String&& r
         return makeUnexpected(ContentExtensionError::JSONContainsNoRules);
 
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
-    double loadExtensionEndTime = monotonicallyIncreasingTime();
-    dataLogF("Time spent loading extension %f\n", (loadExtensionEndTime - loadExtensionStartTime));
+    MonotonicTime loadExtensionEndTime = MonotonicTime::now();
+    dataLogF("Time spent loading extension %f\n", (loadExtensionEndTime - loadExtensionStartTime).seconds());
 #endif
 
     return WTFMove(*ruleList);
index f811e9e..654a50c 100644 (file)
@@ -74,7 +74,7 @@ void ContentExtensionsBackend::removeAllContentExtensions()
 std::pair<Vector<Action>, Vector<String>> ContentExtensionsBackend::actionsForResourceLoad(const ResourceLoadInfo& resourceLoadInfo) const
 {
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
-    double addedTimeStart = monotonicallyIncreasingTime();
+    MonotonicTime addedTimeStart = MonotonicTime::now();
 #endif
     if (m_contentExtensions.isEmpty()
         || !resourceLoadInfo.resourceURL.isValid()
@@ -132,8 +132,8 @@ std::pair<Vector<Action>, Vector<String>> ContentExtensionsBackend::actionsForRe
             stylesheetIdentifiers.append(contentExtension->identifier());
     }
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
-    double addedTimeEnd = monotonicallyIncreasingTime();
-    dataLogF("Time added: %f microseconds %s \n", (addedTimeEnd - addedTimeStart) * 1.0e6, resourceLoadInfo.resourceURL.string().utf8().data());
+    MonotonicTime addedTimeEnd = MonotonicTime::now();
+    dataLogF("Time added: %f microseconds %s \n", (addedTimeEnd - addedTimeStart).microseconds(), resourceLoadInfo.resourceURL.string().utf8().data());
 #endif
     return { WTFMove(finalActions), WTFMove(stylesheetIdentifiers) };
 }
index c2b2039..70c18c4 100644 (file)
@@ -585,7 +585,7 @@ void Element::setActive(bool flag, bool pause)
         // "up" state. Once you assume this, you can just delay for 100ms - that time (assuming that after you
         // leave this method, it will be about that long before the flush of the up state happens again).
 #ifdef HAVE_FUNC_USLEEP
-        double startTime = monotonicallyIncreasingTime();
+        MonotonicTime startTime = MonotonicTime::now();
 #endif
 
         document().updateStyleIfNeeded();
@@ -597,9 +597,9 @@ void Element::setActive(bool flag, bool pause)
         // FIXME: Come up with a less ridiculous way of doing this.
 #ifdef HAVE_FUNC_USLEEP
         // Now pause for a small amount of time (1/10th of a second from before we repainted in the pressed state)
-        double remainingTime = 0.1 - (monotonicallyIncreasingTime() - startTime);
-        if (remainingTime > 0)
-            usleep(static_cast<useconds_t>(remainingTime * 1000000.0));
+        Seconds remainingTime = 100_ms - (MonotonicTime::now() - startTime);
+        if (remainingTime > 0_s)
+            usleep(static_cast<useconds_t>(remainingTime.microseconds()));
 #endif
     }
 }
index 348edc0..d96f5dd 100644 (file)
@@ -56,7 +56,7 @@ DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, cachedPageCounter, ("Cached
 
 CachedPage::CachedPage(Page& page)
     : m_page(page)
-    , m_expirationTime(monotonicallyIncreasingTime() + page.settings().backForwardCacheExpirationInterval())
+    , m_expirationTime(MonotonicTime::now() + Seconds(page.settings().backForwardCacheExpirationInterval()))
     , m_cachedMainFrame(std::make_unique<CachedFrame>(page.mainFrame()))
 {
 #ifndef NDEBUG
@@ -183,7 +183,7 @@ void CachedPage::clear()
 
 bool CachedPage::hasExpired() const
 {
-    return monotonicallyIncreasingTime() > m_expirationTime;
+    return MonotonicTime::now() > m_expirationTime;
 }
 
 } // namespace WebCore
index 73bdd5a..1142987 100644 (file)
@@ -60,7 +60,7 @@ public:
 
 private:
     Page& m_page;
-    double m_expirationTime;
+    MonotonicTime m_expirationTime;
     std::unique_ptr<CachedFrame> m_cachedMainFrame;
 #if ENABLE(VIDEO_TRACK)
     bool m_needsCaptionPreferencesChanged { false };
index a0eecf4..40922a9 100644 (file)
@@ -380,7 +380,7 @@ struct MediaElementSessionInfo {
     const MediaElementSession* session;
     MediaElementSession::PlaybackControlsPurpose purpose;
 
-    double timeOfLastUserInteraction;
+    MonotonicTime timeOfLastUserInteraction;
     bool canShowControlsManager : 1;
     bool isVisibleInViewportOrFullscreen : 1;
     bool isLargeEnoughForMainContent : 1;
@@ -2124,7 +2124,7 @@ void HTMLMediaElement::startProgressEventTimer()
     if (m_progressEventTimer.isActive())
         return;
 
-    m_previousProgressTime = monotonicallyIncreasingTime();
+    m_previousProgressTime = MonotonicTime::now();
     // 350ms is not magic, it is in the spec!
     m_progressEventTimer.startRepeating(350_ms);
 }
@@ -2815,8 +2815,8 @@ void HTMLMediaElement::progressEventTimerFired()
     if (m_networkState != NETWORK_LOADING)
         return;
 
-    double time = monotonicallyIncreasingTime();
-    double timedelta = time - m_previousProgressTime;
+    MonotonicTime time = MonotonicTime::now();
+    Seconds timedelta = time - m_previousProgressTime;
 
     if (m_player->didLoadingProgress()) {
         scheduleEvent(eventNames().progressEvent);
@@ -2825,7 +2825,7 @@ void HTMLMediaElement::progressEventTimerFired()
         updateRenderer();
         if (hasMediaControls())
             mediaControls()->bufferingProgressed();
-    } else if (timedelta > 3.0 && !m_sentStalledEvent) {
+    } else if (timedelta > 3_s && !m_sentStalledEvent) {
         scheduleEvent(eventNames().stalledEvent);
         m_sentStalledEvent = true;
         setShouldDelayLoadEvent(false);
@@ -3106,7 +3106,7 @@ void HTMLMediaElement::refreshCachedTime() const
         return;
     }
 
-    m_clockTimeAtLastCachedTimeUpdate = monotonicallyIncreasingTime();
+    m_clockTimeAtLastCachedTimeUpdate = MonotonicTime::now();
 }
 
 void HTMLMediaElement::invalidateCachedTime() const
@@ -3118,9 +3118,9 @@ void HTMLMediaElement::invalidateCachedTime() const
     // Don't try to cache movie time when playback first starts as the time reported by the engine
     // sometimes fluctuates for a short amount of time, so the cached time will be off if we take it
     // too early.
-    static const double minimumTimePlayingBeforeCacheSnapshot = 0.5;
+    static const Seconds minimumTimePlayingBeforeCacheSnapshot = 500_ms;
 
-    m_minimumClockTimeToUpdateCachedTime = monotonicallyIncreasingTime() + minimumTimePlayingBeforeCacheSnapshot;
+    m_minimumClockTimeToUpdateCachedTime = MonotonicTime::now() + minimumTimePlayingBeforeCacheSnapshot;
 }
 
 // playback state
@@ -3153,15 +3153,15 @@ MediaTime HTMLMediaElement::currentMediaTime() const
     }
 
     // Is it too soon use a cached time?
-    double now = monotonicallyIncreasingTime();
+    MonotonicTime now = MonotonicTime::now();
     double maximumDurationToCacheMediaTime = m_player->maximumDurationToCacheMediaTime();
 
     if (maximumDurationToCacheMediaTime && m_cachedTime.isValid() && !m_paused && now > m_minimumClockTimeToUpdateCachedTime) {
-        double clockDelta = now - m_clockTimeAtLastCachedTimeUpdate;
+        Seconds clockDelta = now - m_clockTimeAtLastCachedTimeUpdate;
 
         // Not too soon, use the cached time only if it hasn't expired.
-        if (clockDelta < maximumDurationToCacheMediaTime) {
-            MediaTime adjustedCacheTime = m_cachedTime + MediaTime::createWithDouble(effectivePlaybackRate() * clockDelta);
+        if (clockDelta.seconds() < maximumDurationToCacheMediaTime) {
+            MediaTime adjustedCacheTime = m_cachedTime + MediaTime::createWithDouble(effectivePlaybackRate() * clockDelta.seconds());
 
 #if LOG_CACHED_TIME_WARNINGS
             MediaTime delta = adjustedCacheTime - m_player->currentTime();
@@ -3174,8 +3174,8 @@ MediaTime HTMLMediaElement::currentMediaTime() const
 
 #if LOG_CACHED_TIME_WARNINGS
     if (maximumDurationToCacheMediaTime && now > m_minimumClockTimeToUpdateCachedTime && m_cachedTime != MediaPlayer::invalidTime()) {
-        double clockDelta = now - m_clockTimeAtLastCachedTimeUpdate;
-        MediaTime delta = m_cachedTime + MediaTime::createWithDouble(effectivePlaybackRate() * clockDelta) - m_player->currentTime();
+        Seconds clockDelta = now - m_clockTimeAtLastCachedTimeUpdate;
+        MediaTime delta = m_cachedTime + MediaTime::createWithDouble(effectivePlaybackRate() * clockDelta.seconds()) - m_player->currentTime();
         WARNING_LOG(LOGIDENTIFIER, "cached time was ", delta, " seconds off of media time when it expired");
     }
 #endif
@@ -3816,7 +3816,7 @@ void HTMLMediaElement::startPlaybackProgressTimer()
     if (m_playbackProgressTimer.isActive())
         return;
 
-    m_previousProgressTime = monotonicallyIncreasingTime();
+    m_previousProgressTime = MonotonicTime::now();
     m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency);
 }
 
index e2ba392..a5d1ced 100644 (file)
@@ -963,7 +963,7 @@ private:
     bool m_volumeInitialized { false };
     MediaTime m_lastSeekTime;
     
-    double m_previousProgressTime { std::numeric_limits<double>::max() };
+    MonotonicTime m_previousProgressTime { MonotonicTime::infinity() };
     double m_playbackStartedTime { 0 };
 
     // The last time a timeupdate event was sent (based on monotonic clock).
@@ -1014,8 +1014,8 @@ private:
 #endif
 
     mutable MediaTime m_cachedTime;
-    mutable double m_clockTimeAtLastCachedTimeUpdate { 0 };
-    mutable double m_minimumClockTimeToUpdateCachedTime { 0 };
+    mutable MonotonicTime m_clockTimeAtLastCachedTimeUpdate;
+    mutable MonotonicTime m_minimumClockTimeToUpdateCachedTime;
 
     MediaTime m_fragmentStartTime;
     MediaTime m_fragmentEndTime;
index 73054c8..8e4e9ee 100644 (file)
@@ -140,7 +140,7 @@ void MediaElementSession::addBehaviorRestriction(BehaviorRestrictions restrictio
 void MediaElementSession::removeBehaviorRestriction(BehaviorRestrictions restriction)
 {
     if (restriction & RequireUserGestureToControlControlsManager) {
-        m_mostRecentUserInteractionTime = monotonicallyIncreasingTime();
+        m_mostRecentUserInteractionTime = MonotonicTime::now();
         if (auto page = m_element.document().page())
             page->setAllowsPlaybackControlsForAutoplayingAudio(true);
     }
@@ -395,7 +395,7 @@ bool MediaElementSession::isLargeEnoughForMainContent(MediaSessionMainContentPur
     return isElementLargeEnoughForMainContent(m_element, purpose);
 }
 
-double MediaElementSession::mostRecentUserInteractionTime() const
+MonotonicTime MediaElementSession::mostRecentUserInteractionTime() const
 {
     return m_mostRecentUserInteractionTime;
 }
@@ -652,7 +652,7 @@ void MediaElementSession::mediaEngineUpdated(const HTMLMediaElement& element)
 
 void MediaElementSession::resetPlaybackSessionState()
 {
-    m_mostRecentUserInteractionTime = 0;
+    m_mostRecentUserInteractionTime = MonotonicTime();
     addBehaviorRestriction(RequireUserGestureToControlControlsManager | RequirePlaybackToControlControlsManager);
 }
 
index 6a1cb0b..7add5be 100644 (file)
@@ -136,7 +136,7 @@ public:
     enum class PlaybackControlsPurpose { ControlsManager, NowPlaying };
     bool canShowControlsManager(PlaybackControlsPurpose) const;
     bool isLargeEnoughForMainContent(MediaSessionMainContentPurpose) const;
-    double mostRecentUserInteractionTime() const;
+    MonotonicTime mostRecentUserInteractionTime() const;
 
     bool allowsPlaybackControlsForAutoplayingAudio() const;
     bool allowsNowPlayingControlsVisibility() const override;
@@ -185,7 +185,7 @@ private:
     bool m_hasPlaybackTargetAvailabilityListeners { false };
 #endif
 
-    double m_mostRecentUserInteractionTime { 0 };
+    MonotonicTime m_mostRecentUserInteractionTime;
 
     mutable bool m_isMainContent { false };
     Timer m_mainContentCheckTimer;
index 1a2cff4..35b6a59 100644 (file)
@@ -69,7 +69,6 @@ PumpSession::PumpSession(unsigned& nestingLevel, Document* document)
     // after any token during any parse where yielding is allowed.
     // At that time we'll initialize startTime.
     , processedTokens(INT_MAX)
-    , startTime(0)
     , didSeeScript(false)
 {
 }
@@ -78,7 +77,7 @@ PumpSession::~PumpSession() = default;
 
 HTMLParserScheduler::HTMLParserScheduler(HTMLDocumentParser& parser)
     : m_parser(parser)
-    , m_parserTimeLimit(parserTimeLimit(m_parser.document()->page()))
+    , m_parserTimeLimit(Seconds(parserTimeLimit(m_parser.document()->page())))
     , m_continueNextChunkTimer(*this, &HTMLParserScheduler::continueNextChunkTimerFired)
     , m_isSuspendedWithActiveTimer(false)
 #if !ASSERT_DISABLED
index a79e064..8f446a5 100644 (file)
@@ -54,7 +54,7 @@ public:
     ~PumpSession();
 
     unsigned processedTokens;
-    double startTime;
+    MonotonicTime startTime;
     bool didSeeScript;
 };
 
@@ -94,20 +94,20 @@ private:
         session.processedTokens = 1;
         session.didSeeScript = false;
 
-        // monotonicallyIncreasingTime() can be expensive. By delaying, we avoided calling
-        // monotonicallyIncreasingTime() when constructing non-yielding PumpSessions.
+        // MonotonicTime::now() can be expensive. By delaying, we avoided calling
+        // MonotonicTime::now() when constructing non-yielding PumpSessions.
         if (!session.startTime) {
-            session.startTime = monotonicallyIncreasingTime();
+            session.startTime = MonotonicTime::now();
             return false;
         }
 
-        double elapsedTime = monotonicallyIncreasingTime() - session.startTime;
+        Seconds elapsedTime = MonotonicTime::now() - session.startTime;
         return elapsedTime > m_parserTimeLimit;
     }
 
     HTMLDocumentParser& m_parser;
 
-    double m_parserTimeLimit;
+    Seconds m_parserTimeLimit;
     Timer m_continueNextChunkTimer;
     bool m_isSuspendedWithActiveTimer;
 #if !ASSERT_DISABLED
index a950199..4ba64da 100644 (file)
@@ -148,7 +148,7 @@ void InspectorCanvas::recordAction(const String& name, Vector<RecordCanvasAction
 
         m_frames->addItem(WTFMove(frame));
 
-        m_currentFrameStartTime = monotonicallyIncreasingTimeMS();
+        m_currentFrameStartTime = MonotonicTime::now();
     }
 
     appendActionSnapshotIfNeeded();
@@ -185,9 +185,9 @@ void InspectorCanvas::finalizeFrame()
 {
     if (m_frames && m_frames->length() && !std::isnan(m_currentFrameStartTime)) {
         auto currentFrame = static_cast<Inspector::Protocol::Recording::Frame*>(m_frames->get(m_frames->length() - 1).get());
-        currentFrame->setDuration(monotonicallyIncreasingTimeMS() - m_currentFrameStartTime);
+        currentFrame->setDuration((MonotonicTime::now() - m_currentFrameStartTime).milliseconds());
 
-        m_currentFrameStartTime = NAN;
+        m_currentFrameStartTime = MonotonicTime::nan();
     }
 
     m_currentActions = nullptr;
index 1d42634..e102d5a 100644 (file)
@@ -114,7 +114,7 @@ private:
     Vector<DuplicateDataVariant> m_indexedDuplicateData;
 
     String m_recordingName;
-    double m_currentFrameStartTime { NAN };
+    MonotonicTime m_currentFrameStartTime { MonotonicTime::nan() };
     size_t m_bufferLimit { 100 * 1024 * 1024 };
     size_t m_bufferUsed { 0 };
     bool m_singleFrame { true };
index 65f30ff..d43d266 100644 (file)
@@ -80,7 +80,7 @@ void InspectorMemoryAgent::startTracking(ErrorString&)
 
     m_tracking = true;
 
-    m_frontendDispatcher->trackingStart(m_environment.executionStopwatch()->elapsedTime());
+    m_frontendDispatcher->trackingStart(m_environment.executionStopwatch()->elapsedTime().seconds());
 }
 
 void InspectorMemoryAgent::stopTracking(ErrorString&)
@@ -101,7 +101,7 @@ void InspectorMemoryAgent::didHandleMemoryPressure(Critical critical)
         return;
 
     MemoryFrontendDispatcher::Severity severity = critical == Critical::Yes ? MemoryFrontendDispatcher::Severity::Critical : MemoryFrontendDispatcher::Severity::NonCritical;
-    m_frontendDispatcher->memoryPressure(m_environment.executionStopwatch()->elapsedTime(), severity);
+    m_frontendDispatcher->memoryPressure(m_environment.executionStopwatch()->elapsedTime().seconds(), severity);
 }
 
 void InspectorMemoryAgent::collectSample(const ResourceUsageData& data)
@@ -145,7 +145,7 @@ void InspectorMemoryAgent::collectSample(const ResourceUsageData& data)
     categories->addItem(WTFMove(otherCategory));
 
     auto event = Protocol::Memory::Event::create()
-        .setTimestamp(m_environment.executionStopwatch()->elapsedTime())
+        .setTimestamp(m_environment.executionStopwatch()->elapsedTime().seconds())
         .setCategories(WTFMove(categories))
         .release();
 
index bbf3511..4d0958a 100644 (file)
@@ -194,10 +194,10 @@ static Ref<JSON::Object> buildObjectForHeaders(const HTTPHeaderMap& headers)
 Ref<Inspector::Protocol::Network::ResourceTiming> InspectorNetworkAgent::buildObjectForTiming(const NetworkLoadMetrics& timing, ResourceLoader& resourceLoader)
 {
     MonotonicTime startTime = resourceLoader.loadTiming().startTime();
-    double startTimeInInspector = m_environment.executionStopwatch()->elapsedTimeSince(startTime);
+    Seconds startTimeInInspector = m_environment.executionStopwatch()->elapsedTimeSince(startTime);
 
     return Inspector::Protocol::Network::ResourceTiming::create()
-        .setStartTime(startTimeInInspector)
+        .setStartTime(startTimeInInspector.seconds())
         .setDomainLookupStart(timing.domainLookupStart.milliseconds())
         .setDomainLookupEnd(timing.domainLookupEnd.milliseconds())
         .setConnectStart(timing.connectStart.milliseconds())
@@ -340,7 +340,7 @@ InspectorNetworkAgent::~InspectorNetworkAgent()
 
 double InspectorNetworkAgent::timestamp()
 {
-    return m_environment.executionStopwatch()->elapsedTime();
+    return m_environment.executionStopwatch()->elapsedTime().seconds();
 }
 
 void InspectorNetworkAgent::willSendRequest(unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse, InspectorPageAgent::ResourceType type)
@@ -486,8 +486,8 @@ void InspectorNetworkAgent::didFinishLoading(unsigned long identifier, DocumentL
     double elapsedFinishTime;
     if (resourceLoader && networkLoadMetrics.isComplete()) {
         MonotonicTime startTime = resourceLoader->loadTiming().startTime();
-        double startTimeInInspector = m_environment.executionStopwatch()->elapsedTimeSince(startTime);
-        elapsedFinishTime = startTimeInInspector + networkLoadMetrics.responseEnd.seconds();
+        Seconds startTimeInInspector = m_environment.executionStopwatch()->elapsedTimeSince(startTime);
+        elapsedFinishTime = (startTimeInInspector + networkLoadMetrics.responseEnd).seconds();
     } else
         elapsedFinishTime = timestamp();
 
index ff01260..eb34575 100644 (file)
@@ -292,7 +292,7 @@ void InspectorPageAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReas
 
 double InspectorPageAgent::timestamp()
 {
-    return m_environment.executionStopwatch()->elapsedTime();
+    return m_environment.executionStopwatch()->elapsedTime().seconds();
 }
 
 void InspectorPageAgent::enable(ErrorString&)
index 3b304f3..59c4600 100644 (file)
@@ -239,7 +239,7 @@ void InspectorTimelineAgent::internalStop()
 
 double InspectorTimelineAgent::timestamp()
 {
-    return m_environment.executionStopwatch()->elapsedTime();
+    return m_environment.executionStopwatch()->elapsedTime().seconds();
 }
 
 void InspectorTimelineAgent::startFromConsole(JSC::ExecState* exec, const String& title)
index d207611..bf507fa 100644 (file)
@@ -35,8 +35,8 @@ using namespace Inspector;
 
 struct GarbageCollectionData {
     Inspector::Protocol::Heap::GarbageCollection::Type type;
-    double startTime;
-    double endTime;
+    Seconds startTime;
+    Seconds endTime;
 };
 
 class SendGarbageCollectionEventsTask {
@@ -110,7 +110,7 @@ void WebHeapAgent::disable(ErrorString& errorString)
     InspectorHeapAgent::disable(errorString);
 }
 
-void WebHeapAgent::dispatchGarbageCollectedEvent(Inspector::Protocol::Heap::GarbageCollection::Type type, double startTime, double endTime)
+void WebHeapAgent::dispatchGarbageCollectedEvent(Inspector::Protocol::Heap::GarbageCollection::Type type, Seconds startTime, Seconds endTime)
 {
     // Dispatch the event asynchronously because this method may be
     // called between collection and sweeping and we don't want to
index f9df600..e13f876 100644 (file)
@@ -45,7 +45,7 @@ public:
 protected:
     void disable(ErrorString&) override;
 
-    void dispatchGarbageCollectedEvent(Inspector::Protocol::Heap::GarbageCollection::Type, double startTime, double endTime) override;
+    void dispatchGarbageCollectedEvent(Inspector::Protocol::Heap::GarbageCollection::Type, Seconds startTime, Seconds endTime) override;
 
     void dispatchGarbageCollectionEventsAfterDelay(Vector<GarbageCollectionData>&& collections);
 
index 9ed2b31..046e534 100644 (file)
@@ -186,7 +186,7 @@ RefPtr<StyleSheetContents> CachedCSSStyleSheet::restoreParsedStyleSheet(const CS
     if (m_parsedStyleSheetCache->parserContext() != context)
         return nullptr;
 
-    didAccessDecodedData(monotonicallyIncreasingTime());
+    didAccessDecodedData(MonotonicTime::now());
 
     return m_parsedStyleSheetCache;
 }
index 0093056..c266a45 100644 (file)
@@ -592,9 +592,9 @@ void CachedImage::didDraw(const Image& image)
     if (&image != m_image)
         return;
     
-    double timeStamp = FrameView::currentPaintTimeStamp();
+    MonotonicTime timeStamp = FrameView::currentPaintTimeStamp();
     if (!timeStamp) // If didDraw is called outside of a Frame paint.
-        timeStamp = monotonicallyIncreasingTime();
+        timeStamp = MonotonicTime::now();
     
     CachedResource::didAccessDecodedData(timeStamp);
 }
index c23c3be..71aef83 100644 (file)
@@ -672,7 +672,7 @@ void CachedResource::setEncodedSize(unsigned size)
     }
 }
 
-void CachedResource::didAccessDecodedData(double timeStamp)
+void CachedResource::didAccessDecodedData(MonotonicTime timeStamp)
 {
     m_lastDecodedAccessTime = timeStamp;
     
index a863b77..bcdb624 100644 (file)
@@ -291,7 +291,7 @@ protected:
 
     void setEncodedSize(unsigned);
     void setDecodedSize(unsigned);
-    void didAccessDecodedData(double timeStamp);
+    void didAccessDecodedData(MonotonicTime timeStamp);
 
     virtual void didReplaceSharedBufferContents() { }
 
@@ -334,7 +334,7 @@ private:
     RefPtr<SecurityOrigin> m_origin;
     AtomicString m_initiatorName;
 
-    double m_lastDecodedAccessTime { 0 }; // Used as a "thrash guard" in the cache
+    MonotonicTime m_lastDecodedAccessTime; // Used as a "thrash guard" in the cache
 
     unsigned m_encodedSize { 0 };
     unsigned m_decodedSize { 0 };
index 4f65f40..f675aca 100644 (file)
@@ -49,7 +49,7 @@
 namespace WebCore {
 
 static const int cDefaultCacheCapacity = 8192 * 1024;
-static const double cMinDelayBeforeLiveDecodedPrune = 1; // Seconds.
+static const Seconds cMinDelayBeforeLiveDecodedPrune { 1_s };
 static const float cTargetPrunePercentage = .95f; // Percentage of capacity toward which we prune, to avoid immediately pruning again.
 
 MemoryCache& MemoryCache::singleton()
@@ -297,9 +297,9 @@ void MemoryCache::pruneLiveResourcesToSize(unsigned targetSize, bool shouldDestr
         return;
     SetForScope<bool> reentrancyProtector(m_inPruneResources, true);
 
-    double currentTime = FrameView::currentPaintTimeStamp();
+    MonotonicTime currentTime = FrameView::currentPaintTimeStamp();
     if (!currentTime) // In case prune is called directly, outside of a Frame paint.
-        currentTime = monotonicallyIncreasingTime();
+        currentTime = MonotonicTime::now();
     
     // Destroy any decoded data in live objects that we can.
     // Start from the head, since this is the least recently accessed of the objects.
@@ -324,7 +324,7 @@ void MemoryCache::pruneLiveResourcesToSize(unsigned targetSize, bool shouldDestr
         ASSERT(current->hasClients());
         if (current->isLoaded() && current->decodedSize()) {
             // Check to see if the remaining resources are too new to prune.
-            double elapsedTime = currentTime - current->m_lastDecodedAccessTime;
+            Seconds elapsedTime = currentTime - current->m_lastDecodedAccessTime;
             if (!shouldDestroyDecodedDataForAllLiveResources && elapsedTime < cMinDelayBeforeLiveDecodedPrune)
                 return;
 
index adcbe66..133579c 100644 (file)
@@ -184,18 +184,18 @@ class MaximumDurationTracker {
 public:
     explicit MaximumDurationTracker(double *maxDuration)
         : m_maxDuration(maxDuration)
-        , m_start(monotonicallyIncreasingTime())
+        , m_start(MonotonicTime::now())
     {
     }
 
     ~MaximumDurationTracker()
     {
-        *m_maxDuration = std::max(*m_maxDuration, monotonicallyIncreasingTime() - m_start);
+        *m_maxDuration = std::max(*m_maxDuration, (MonotonicTime::now() - m_start).seconds());
     }
 
 private:
     double* m_maxDuration;
-    double m_start;
+    MonotonicTime m_start;
 };
 
 #if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS)
index 8e2bb54..effc736 100644 (file)
@@ -836,7 +836,7 @@ bool FocusController::setFocusedElement(Element* element, Frame& newFocusedFrame
     if (newDocument->focusedElement() == element)
         m_page.editorClient().setInputMethodState(element->shouldUseInputMethod());
 
-    m_focusSetTime = monotonicallyIncreasingTime();
+    m_focusSetTime = MonotonicTime::now();
     m_focusRepaintTimer.stop();
 
     return true;
@@ -1123,9 +1123,9 @@ void FocusController::focusRepaintTimerFired()
         focusedElement->renderer()->repaint();
 }
 
-double FocusController::timeSinceFocusWasSet() const
+Seconds FocusController::timeSinceFocusWasSet() const
 {
-    return monotonicallyIncreasingTime() - m_focusSetTime;
+    return MonotonicTime::now() - m_focusSetTime;
 }
 
 } // namespace WebCore
index 5297155..e87cb80 100644 (file)
@@ -77,7 +77,7 @@ public:
     WEBCORE_EXPORT Element* previousFocusableElement(Node&);
 
     void setFocusedElementNeedsRepaint();
-    double timeSinceFocusWasSet() const;
+    Seconds timeSinceFocusWasSet() const;
 
 private:
     void setActiveInternal(bool);
@@ -122,7 +122,7 @@ private:
     ActivityState::Flags m_activityState;
 
     Timer m_focusRepaintTimer;
-    double m_focusSetTime;
+    MonotonicTime m_focusSetTime;
 };
 
 } // namespace WebCore
index cbeb3df..e3439b5 100644 (file)
@@ -124,7 +124,7 @@ using namespace HTMLNames;
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(FrameView);
 
-double FrameView::sCurrentPaintTimeStamp = 0.0;
+MonotonicTime FrameView::sCurrentPaintTimeStamp { };
 
 // The maximum number of updateEmbeddedObjects iterations that should be done before returning.
 static const unsigned maxUpdateEmbeddedObjectsIterations = 2;
@@ -272,7 +272,7 @@ void FrameView::reset()
     m_lastZoomFactor = 1.0f;
     m_isTrackingRepaints = false;
     m_trackedRepaintRects.clear();
-    m_lastPaintTime = 0;
+    m_lastPaintTime = MonotonicTime();
     m_paintBehavior = PaintBehaviorNormal;
     m_isPainting = false;
     m_visuallyNonEmptyCharacterCount = 0;
@@ -4015,7 +4015,7 @@ void FrameView::willPaintContents(GraphicsContext& context, const IntRect&, Pain
     paintingState.isTopLevelPainter = !sCurrentPaintTimeStamp;
 
     if (paintingState.isTopLevelPainter)
-        sCurrentPaintTimeStamp = monotonicallyIncreasingTime();
+        sCurrentPaintTimeStamp = MonotonicTime::now();
 
     paintingState.paintBehavior = m_paintBehavior;
     
@@ -4049,7 +4049,7 @@ void FrameView::didPaintContents(GraphicsContext& context, const IntRect& dirtyR
         notifyWidgetsInAllFrames(DidPaintFlattened);
 
     m_paintBehavior = paintingState.paintBehavior;
-    m_lastPaintTime = monotonicallyIncreasingTime();
+    m_lastPaintTime = MonotonicTime::now();
 
     // Regions may have changed as a result of the visibility/z-index of element changing.
 #if ENABLE(DASHBOARD_SUPPORT)
@@ -4058,7 +4058,7 @@ void FrameView::didPaintContents(GraphicsContext& context, const IntRect& dirtyR
 #endif
 
     if (paintingState.isTopLevelPainter)
-        sCurrentPaintTimeStamp = 0;
+        sCurrentPaintTimeStamp = MonotonicTime();
 
     if (!context.paintingDisabled()) {
         InspectorInstrumentation::didPaint(*renderView(), dirtyRect);
index f6ffc99..276db68 100644 (file)
@@ -366,8 +366,8 @@ public:
     WEBCORE_EXPORT void setPaintBehavior(PaintBehavior);
     WEBCORE_EXPORT PaintBehavior paintBehavior() const;
     bool isPainting() const;
-    bool hasEverPainted() const { return m_lastPaintTime; }
-    void setLastPaintTime(double lastPaintTime) { m_lastPaintTime = lastPaintTime; }
+    bool hasEverPainted() const { return !!m_lastPaintTime; }
+    void setLastPaintTime(MonotonicTime lastPaintTime) { m_lastPaintTime = lastPaintTime; }
     WEBCORE_EXPORT void setNodeToDraw(Node*);
 
     enum SelectionInSnapshot { IncludeSelection, ExcludeSelection };
@@ -385,7 +385,7 @@ public:
     void startDisallowingLayout() { layoutContext().startDisallowingLayout(); }
     void endDisallowingLayout() { layoutContext().endDisallowingLayout(); }
 
-    static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
+    static MonotonicTime currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
     
     WEBCORE_EXPORT void updateLayoutAndStyleIfNeededRecursive();
 
@@ -786,7 +786,7 @@ private:
 
     HashSet<Widget*> m_widgetsInRenderTree;
 
-    static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
+    static MonotonicTime sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
 
     LayoutSize m_size;
     LayoutSize m_margins;
@@ -830,7 +830,7 @@ private:
     SelectionRevealMode m_selectionRevealModeForFocusedElement;
     Timer m_delayedScrollToFocusedElementTimer;
 
-    double m_lastPaintTime;
+    MonotonicTime m_lastPaintTime;
 
     bool m_isTrackingRepaints; // Used for testing.
     Vector<FloatRect> m_trackedRepaintRects;
index 15be731..ffe862f 100644 (file)
@@ -698,7 +698,7 @@ void AnimationBase::freezeAtTime(double t)
         // If we haven't started yet, make it as if we started.
         LOG(Animations, "%p AnimationState %s -> StartWaitResponse", this, nameForState(m_animationState));
         m_animationState = AnimationState::StartWaitResponse;
-        onAnimationStartResponse(monotonicallyIncreasingTime());
+        onAnimationStartResponse(MonotonicTime::now());
     }
 
     ASSERT(m_startTime); // If m_startTime is zero, we haven't started yet, so we'll get a bad pause time.
@@ -708,7 +708,7 @@ void AnimationBase::freezeAtTime(double t)
         m_pauseTime = m_startTime.value_or(0) + t - m_animation->delay();
 
     if (auto* renderer = compositedRenderer())
-        renderer->suspendAnimations(m_pauseTime.value());
+        renderer->suspendAnimations(MonotonicTime::fromRawSeconds(m_pauseTime.value()));
 }
 
 double AnimationBase::beginAnimationUpdateTime() const
@@ -716,7 +716,7 @@ double AnimationBase::beginAnimationUpdateTime() const
     if (!m_compositeAnimation)
         return 0;
 
-    return m_compositeAnimation->animationController().beginAnimationUpdateTime();
+    return m_compositeAnimation->animationController().beginAnimationUpdateTime().secondsSinceEpoch().seconds();
 }
 
 double AnimationBase::getElapsedTime() const
index 94cf0c4..4c733f1 100644 (file)
@@ -102,9 +102,9 @@ public:
     void updateStateMachine(AnimationStateInput, double param);
 
     // Animation has actually started, at passed time
-    void onAnimationStartResponse(double startTime)
+    void onAnimationStartResponse(MonotonicTime startTime)
     {
-        updateStateMachine(AnimationStateInput::StartTimeSet, startTime);
+        updateStateMachine(AnimationStateInput::StartTimeSet, startTime.secondsSinceEpoch().seconds());
     }
 
     // Called to change to or from paused state
index b75b566..9424762 100644 (file)
@@ -433,11 +433,11 @@ bool CSSAnimationControllerPrivate::pauseTransitionAtTime(Element& element, cons
     return false;
 }
 
-double CSSAnimationControllerPrivate::beginAnimationUpdateTime()
+MonotonicTime CSSAnimationControllerPrivate::beginAnimationUpdateTime()
 {
     ASSERT(m_beginAnimationUpdateCount);
     if (!m_beginAnimationUpdateTime)
-        m_beginAnimationUpdateTime = monotonicallyIncreasingTime();
+        m_beginAnimationUpdateTime = MonotonicTime::now();
 
     return m_beginAnimationUpdateTime.value();
 }
@@ -460,9 +460,9 @@ void CSSAnimationControllerPrivate::endAnimationUpdate()
     --m_beginAnimationUpdateCount;
 }
 
-void CSSAnimationControllerPrivate::receivedStartTimeResponse(double time)
+void CSSAnimationControllerPrivate::receivedStartTimeResponse(MonotonicTime time)
 {
-    LOG(Animations, "CSSAnimationControllerPrivate %p receivedStartTimeResponse %f", this, time);
+    LOG(Animations, "CSSAnimationControllerPrivate %p receivedStartTimeResponse %f", this, time.secondsSinceEpoch().seconds());
 
     m_waitingForAsyncStartNotification = false;
     startTimeResponse(time);
@@ -563,7 +563,7 @@ void CSSAnimationControllerPrivate::removeFromAnimationsWaitingForStartTimeRespo
         m_waitingForAsyncStartNotification = false;
 }
 
-void CSSAnimationControllerPrivate::startTimeResponse(double time)
+void CSSAnimationControllerPrivate::startTimeResponse(MonotonicTime time)
 {
     // Go through list of waiters and send them on their way
 
@@ -697,9 +697,9 @@ bool CSSAnimationController::computeExtentOfAnimation(RenderElement& renderer, L
     return m_data->computeExtentOfAnimation(*renderer.element(), bounds);
 }
 
-void CSSAnimationController::notifyAnimationStarted(RenderElement& renderer, double startTime)
+void CSSAnimationController::notifyAnimationStarted(RenderElement& renderer, MonotonicTime startTime)
 {
-    LOG(Animations, "CSSAnimationController %p notifyAnimationStarted on renderer %p, time=%f", this, &renderer, startTime);
+    LOG(Animations, "CSSAnimationController %p notifyAnimationStarted on renderer %p, time=%f", this, &renderer, startTime.secondsSinceEpoch().seconds());
     UNUSED_PARAM(renderer);
 
     AnimationUpdateBlock animationUpdateBlock(this);
index 25c86d3..ee0ee1b 100644 (file)
@@ -70,7 +70,7 @@ public:
     bool computeExtentOfAnimation(RenderElement&, LayoutRect&) const;
 
     // This is called when an accelerated animation or transition has actually started to animate.
-    void notifyAnimationStarted(RenderElement&, double startTime);
+    void notifyAnimationStarted(RenderElement&, MonotonicTime startTime);
 
     WEBCORE_EXPORT bool pauseAnimationAtTime(Element&, const AtomicString& name, double t); // To be used only for testing
     WEBCORE_EXPORT bool pauseTransitionAtTime(Element&, const String& property, double t); // To be used only for testing
index aba415b..728a175 100644 (file)
@@ -87,11 +87,11 @@ public:
 
     bool computeExtentOfAnimation(Element&, LayoutRect&) const;
 
-    double beginAnimationUpdateTime();
+    MonotonicTime beginAnimationUpdateTime();
     
     void beginAnimationUpdate();
     void endAnimationUpdate();
-    void receivedStartTimeResponse(double);
+    void receivedStartTimeResponse(MonotonicTime);
     
     void addToAnimationsWaitingForStyle(AnimationBase*);
     void removeFromAnimationsWaitingForStyle(AnimationBase*);
@@ -122,7 +122,7 @@ private:
 
     void styleAvailable();
     void fireEventsAndUpdateStyle();
-    void startTimeResponse(double t);
+    void startTimeResponse(MonotonicTime);
 
     HashMap<RefPtr<Element>, RefPtr<CompositeAnimation>> m_compositeAnimations;
     Timer m_animationTimer;
@@ -139,7 +139,7 @@ private:
     Vector<Ref<Element>> m_elementChangesToDispatch;
     HashSet<Document*> m_suspendedDocuments;
 
-    std::optional<double> m_beginAnimationUpdateTime;
+    std::optional<MonotonicTime> m_beginAnimationUpdateTime;
 
     using AnimationsSet = HashSet<RefPtr<AnimationBase>>;
     AnimationsSet m_animationsWaitingForStyle;
index 0193569..b00b23a 100644 (file)
@@ -44,7 +44,7 @@ public:
 
 private:
     RetainPtr<_NSScrollingPredominantAxisFilter> m_predominantAxisFilter;
-    double m_beginFilteringDeltasTime { 0 };
+    MonotonicTime m_beginFilteringDeltasTime;
 };
 
 } // namespace WebCore
index 74255e4..664c8a9 100644 (file)
@@ -42,7 +42,7 @@ WheelEventDeltaFilterMac::WheelEventDeltaFilterMac()
 
 void WheelEventDeltaFilterMac::beginFilteringDeltas()
 {
-    m_beginFilteringDeltasTime = monotonicallyIncreasingTime();
+    m_beginFilteringDeltasTime = MonotonicTime::now();
     m_isFilteringDeltas = true;
 }
 
@@ -53,7 +53,7 @@ void WheelEventDeltaFilterMac::updateFromDelta(const FloatSize& delta)
 
     NSPoint filteredDeltaResult;
     NSPoint filteredVelocityResult;
-    [m_predominantAxisFilter filterInputDelta:NSPoint(FloatPoint(delta.width(), delta.height())) timestamp:monotonicallyIncreasingTime() - m_beginFilteringDeltasTime outputDelta:&filteredDeltaResult velocity:&filteredVelocityResult];
+    [m_predominantAxisFilter filterInputDelta:NSPoint(FloatPoint(delta.width(), delta.height())) timestamp:(MonotonicTime::now() - m_beginFilteringDeltasTime).seconds() outputDelta:&filteredDeltaResult velocity:&filteredVelocityResult];
     m_currentFilteredVelocity = FloatSize(filteredVelocityResult.x, filteredVelocityResult.y);
     m_currentFilteredDelta = FloatSize(filteredDeltaResult.x, filteredDeltaResult.y);
 }
@@ -61,7 +61,7 @@ void WheelEventDeltaFilterMac::updateFromDelta(const FloatSize& delta)
 void WheelEventDeltaFilterMac::endFilteringDeltas()
 {
     m_currentFilteredDelta = FloatSize(0, 0);
-    m_beginFilteringDeltasTime = 0;
+    m_beginFilteringDeltasTime = MonotonicTime();
     [m_predominantAxisFilter reset];
     m_isFilteringDeltas = false;
 }
index 0dce9f9..fb709d0 100644 (file)
@@ -27,6 +27,7 @@
 #define ControlStates_h
 
 #include <wtf/RetainPtr.h>
+#include <wtf/Seconds.h>
 
 namespace WebCore {
 
@@ -80,8 +81,8 @@ public:
     bool isDirty() const { return m_isDirty; }
     void setDirty(bool d) { m_isDirty = d; }
 
-    double timeSinceControlWasFocused() const { return m_timeSinceControlWasFocused; }
-    void setTimeSinceControlWasFocused(double time) { m_timeSinceControlWasFocused = time; }
+    Seconds timeSinceControlWasFocused() const { return m_timeSinceControlWasFocused; }
+    void setTimeSinceControlWasFocused(Seconds time) { m_timeSinceControlWasFocused = time; }
 
 #if PLATFORM(COCOA)
     PlatformControlInstance platformControl() const { return m_controlInstance.get(); }
@@ -93,7 +94,7 @@ private:
     bool m_initialized { false };
     bool m_needsRepaint { false };
     bool m_isDirty { false };
-    double m_timeSinceControlWasFocused { 0 };
+    Seconds m_timeSinceControlWasFocused { 0_s };
 #if PLATFORM(COCOA)
     RetainPtr<PlatformControlInstance> m_controlInstance;
 #endif
index e08775b..d0817a6 100644 (file)
@@ -28,6 +28,7 @@
 #if ENABLE(SPEECH_SYNTHESIS)
 
 #include "PlatformSpeechSynthesisVoice.h"
+#include <wtf/MonotonicTime.h>
 
 namespace WebCore {
     
@@ -59,8 +60,8 @@ public:
     float pitch() const { return m_pitch; }
     void setPitch(float pitch) { m_pitch = std::max(std::min(2.0f, pitch), 0.0f); }
 
-    double startTime() const { return m_startTime; }
-    void setStartTime(double startTime) { m_startTime = startTime; }
+    MonotonicTime startTime() const { return m_startTime; }
+    void setStartTime(MonotonicTime startTime) { m_startTime = startTime; }
     
     PlatformSpeechSynthesisUtteranceClient* client() const { return m_client; }
     void setClient(PlatformSpeechSynthesisUtteranceClient* client) { m_client = client; }
@@ -75,7 +76,7 @@ private:
     float m_volume { 1 };
     float m_rate { 1 };
     float m_pitch { 1 };
-    double m_startTime { 0 };
+    MonotonicTime m_startTime;
 };
     
 } // namespace WebCore
index d4bd2e5..65f91cc 100644 (file)
@@ -28,6 +28,7 @@
 #if ENABLE(GAMEPAD)
 
 #include <wtf/Forward.h>
+#include <wtf/MonotonicTime.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -38,23 +39,21 @@ public:
 
     const String& id() const { return m_id; }
     unsigned index() const { return m_index; }
-    double lastUpdateTime() const { return m_lastUpdateTime; }
-    double connectTime() const { return m_connectTime; }
+    MonotonicTime lastUpdateTime() const { return m_lastUpdateTime; }
+    MonotonicTime connectTime() const { return m_connectTime; }
     virtual const Vector<double>& axisValues() const = 0;
     virtual const Vector<double>& buttonValues() const = 0;
 
 protected:
     explicit PlatformGamepad(unsigned index)
         : m_index(index)
-        , m_lastUpdateTime(0.0)
-        , m_connectTime(0.0)
     {
     }
 
     String m_id;
     unsigned m_index;
-    double m_lastUpdateTime;
-    double m_connectTime;
+    MonotonicTime m_lastUpdateTime;
+    MonotonicTime m_connectTime;
 };
 
 } // namespace WebCore
index 29950ba..df0e8f3 100644 (file)
@@ -58,7 +58,7 @@ void GameControllerGamepad::setupAsExtendedGamepad()
     m_id = makeString(String(m_gcController.get().vendorName), ASCIILiteral(" Extended Gamepad"));
 
     m_extendedGamepad.get().valueChangedHandler = ^(GCExtendedGamepad *, GCControllerElement *) {
-        m_lastUpdateTime = monotonicallyIncreasingTime();
+        m_lastUpdateTime = MonotonicTime::now();
         GameControllerGamepadProvider::singleton().gamepadHadInput(*this, m_hadButtonPresses);
         m_hadButtonPresses = false;
     };
@@ -149,7 +149,7 @@ void GameControllerGamepad::setupAsGamepad()
     m_id = makeString(String(m_gcController.get().vendorName), ASCIILiteral(" Gamepad"));
 
     m_gamepad.get().valueChangedHandler = ^(GCGamepad *, GCControllerElement *) {
-        m_lastUpdateTime = monotonicallyIncreasingTime();
+        m_lastUpdateTime = MonotonicTime::now();
         GameControllerGamepadProvider::singleton().gamepadHadInput(*this, m_hadButtonPresses);
         m_hadButtonPresses = false;
     };
index f86cf16..d8f47c9 100644 (file)
@@ -44,7 +44,7 @@ HIDGamepad::HIDGamepad(IOHIDDeviceRef hidDevice, unsigned index)
     : PlatformGamepad(index)
     , m_hidDevice(hidDevice)
 {
-    m_connectTime = m_lastUpdateTime = monotonicallyIncreasingTime();
+    m_connectTime = m_lastUpdateTime = MonotonicTime::now();
 
     CFNumberRef cfVendorID = (CFNumberRef)IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDVendorIDKey));
     CFNumberRef cfProductID = (CFNumberRef)IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductIDKey));
@@ -267,7 +267,7 @@ HIDInputType HIDGamepad::valueChanged(IOHIDValueRef value)
     } else
         ASSERT_NOT_REACHED();
 
-    m_lastUpdateTime = monotonicallyIncreasingTime();
+    m_lastUpdateTime = MonotonicTime::now();
 
     return element->isButton() ? HIDInputType::ButtonPress : HIDInputType::NotAButtonPress;
 }
index e8b8694..698180e 100644 (file)
@@ -444,7 +444,7 @@ String GraphicsLayer::animationNameForTransition(AnimatedPropertyID property)
     return id.toString();
 }
 
-void GraphicsLayer::suspendAnimations(double)
+void GraphicsLayer::suspendAnimations(MonotonicTime)
 {
 }
 
index aafc79a..750023f 100644 (file)
@@ -454,7 +454,7 @@ public:
     virtual void pauseAnimation(const String& /*animationName*/, double /*timeOffset*/) { }
     virtual void removeAnimation(const String& /*animationName*/) { }
 
-    WEBCORE_EXPORT virtual void suspendAnimations(double time);
+    WEBCORE_EXPORT virtual void suspendAnimations(MonotonicTime);
     WEBCORE_EXPORT virtual void resumeAnimations();
 
     // Layer contents
index 3ca4678..b2fc8f6 100644 (file)
@@ -89,7 +89,7 @@ public:
     virtual void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) { }
     
     // Callback for when hardware-accelerated animation started.
-    virtual void notifyAnimationStarted(const GraphicsLayer*, const String& /*animationKey*/, double /*time*/) { }
+    virtual void notifyAnimationStarted(const GraphicsLayer*, const String& /*animationKey*/, MonotonicTime /*time*/) { }
     virtual void notifyAnimationEnded(const GraphicsLayer*, const String& /*animationKey*/) { }
 
     // Notification that a layer property changed that requires a subsequent call to flushCompositingState()
index 499613f..9cc7920 100644 (file)
@@ -219,7 +219,7 @@ private:
     virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*);
     virtual bool platformCALayerRespondsToLayoutChanges() const { return true; }
 
-    virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) { }
+    virtual void platformCALayerAnimationStarted(MonotonicTime beginTime) { }
     virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesBottomUp; }
     virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&, GraphicsLayerPaintBehavior) { }
     virtual bool platformCALayerShowDebugBorders() const { return false; }
@@ -2048,7 +2048,7 @@ RetainPtr<CGImageRef> AVFWrapper::createImageForTimeInRect(const MediaTime& time
         return 0;
 
 #if !LOG_DISABLED
-    double start = monotonicallyIncreasingTime();
+    MonotonicTime start = MonotonicTime::now();
 #endif
 
     AVCFAssetImageGeneratorSetMaximumSize(m_imageGenerator.get(), CGSize(rect.size()));
@@ -2056,8 +2056,8 @@ RetainPtr<CGImageRef> AVFWrapper::createImageForTimeInRect(const MediaTime& time
     RetainPtr<CGImageRef> image = adoptCF(CGImageCreateCopyWithColorSpace(rawimage.get(), adoptCF(CGColorSpaceCreateDeviceRGB()).get()));
 
 #if !LOG_DISABLED
-    double duration = monotonicallyIncreasingTime() - start;
-    LOG(Media, "AVFWrapper::createImageForTimeInRect(%p) - creating image took %.4f", this, narrowPrecisionToFloat(duration));
+    Seconds duration = MonotonicTime::now() - start;
+    LOG(Media, "AVFWrapper::createImageForTimeInRect(%p) - creating image took %.4f", this, narrowPrecisionToFloat(duration.seconds()));
 #endif
 
     return image;
index af3995b..4f69869 100644 (file)
@@ -1650,7 +1650,7 @@ RetainPtr<CGImageRef> MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRe
     ASSERT(m_imageGenerator);
 
 #if !RELEASE_LOG_DISABLED
-    double start = monotonicallyIncreasingTime();
+    MonotonicTime start = MonotonicTime::now();
 #endif
 
     [m_imageGenerator.get() setMaximumSize:CGSize(rect.size())];
@@ -1658,7 +1658,7 @@ RetainPtr<CGImageRef> MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRe
     RetainPtr<CGImageRef> image = adoptCF(CGImageCreateCopyWithColorSpace(rawImage.get(), sRGBColorSpaceRef()));
 
 #if !RELEASE_LOG_DISABLED
-    DEBUG_LOG(LOGIDENTIFIER, "creating image took ", monotonicallyIncreasingTime() - start);
+    DEBUG_LOG(LOGIDENTIFIER, "creating image took ", (MonotonicTime::now() - start).seconds());
 #endif
 
     return image;
@@ -2350,13 +2350,13 @@ void MediaPlayerPrivateAVFoundationObjC::updateLastImage()
     }
 
 #if !RELEASE_LOG_DISABLED
-    double start = monotonicallyIncreasingTime();
+    MonotonicTime start = MonotonicTime::now();
 #endif
 
     m_lastImage = m_pixelBufferConformer->createImageFromPixelBuffer(m_lastPixelBuffer.get());
 
 #if !RELEASE_LOG_DISABLED
-    DEBUG_LOG(LOGIDENTIFIER, "creating buffer took ", monotonicallyIncreasingTime() - start);
+    DEBUG_LOG(LOGIDENTIFIER, "creating buffer took ", (MonotonicTime::now() - start).seconds());
 #endif
 }
 
index 26d4674..94b47e0 100644 (file)
@@ -1018,19 +1018,19 @@ bool GraphicsLayerCA::addAnimation(const KeyframeValueList& valueList, const Flo
 
     bool createdAnimations = false;
     if (valueList.property() == AnimatedPropertyTransform)
-        createdAnimations = createTransformAnimationsFromKeyframes(valueList, anim, animationName, timeOffset, boxSize);
+        createdAnimations = createTransformAnimationsFromKeyframes(valueList, anim, animationName, Seconds { timeOffset }, boxSize);
     else if (valueList.property() == AnimatedPropertyFilter) {
         if (supportsAcceleratedFilterAnimations())
-            createdAnimations = createFilterAnimationsFromKeyframes(valueList, anim, animationName, timeOffset);
+            createdAnimations = createFilterAnimationsFromKeyframes(valueList, anim, animationName, Seconds { timeOffset });
     }
 #if ENABLE(FILTERS_LEVEL_2)
     else if (valueList.property() == AnimatedPropertyWebkitBackdropFilter) {
         if (supportsAcceleratedFilterAnimations())
-            createdAnimations = createFilterAnimationsFromKeyframes(valueList, anim, animationName, timeOffset);
+            createdAnimations = createFilterAnimationsFromKeyframes(valueList, anim, animationName, Seconds { timeOffset });
     }
 #endif
     else
-        createdAnimations = createAnimationFromKeyframes(valueList, anim, animationName, timeOffset);
+        createdAnimations = createAnimationFromKeyframes(valueList, anim, animationName, Seconds { timeOffset });
 
     if (createdAnimations)
         noteLayerPropertyChanged(AnimationChanged);
@@ -1046,7 +1046,7 @@ void GraphicsLayerCA::pauseAnimation(const String& animationName, double timeOff
         return;
 
     // Call add since if there is already a Remove in there, we don't want to overwrite it with a Pause.
-    m_animationsToProcess.add(animationName, AnimationProcessingAction { Pause, timeOffset });
+    m_animationsToProcess.add(animationName, AnimationProcessingAction { Pause, Seconds { timeOffset } });
 
     noteLayerPropertyChanged(AnimationChanged);
 }
@@ -1062,9 +1062,9 @@ void GraphicsLayerCA::removeAnimation(const String& animationName)
     noteLayerPropertyChanged(AnimationChanged);
 }
 
-void GraphicsLayerCA::platformCALayerAnimationStarted(const String& animationKey, CFTimeInterval startTime)
+void GraphicsLayerCA::platformCALayerAnimationStarted(const String& animationKey, MonotonicTime startTime)
 {
-    LOG(Animations, "GraphicsLayerCA %p platformCALayerAnimationStarted %s at %f", this, animationKey.utf8().data(), startTime);
+    LOG(Animations, "GraphicsLayerCA %p platformCALayerAnimationStarted %s at %f", this, animationKey.utf8().data(), startTime.secondsSinceEpoch().seconds());
     client().notifyAnimationStarted(this, animationKey, startTime);
 }
 
@@ -2826,12 +2826,12 @@ bool GraphicsLayerCA::isRunningTransformAnimation() const
     return false;
 }
 
-void GraphicsLayerCA::setAnimationOnLayer(PlatformCAAnimation& caAnim, AnimatedPropertyID property, const String& animationName, int index, int subIndex, double timeOffset)
+void GraphicsLayerCA::setAnimationOnLayer(PlatformCAAnimation& caAnim, AnimatedPropertyID property, const String& animationName, int index, int subIndex, Seconds timeOffset)
 {
     PlatformCALayer* layer = animatedLayer(property);
 
     if (timeOffset)
-        caAnim.setBeginTime(CACurrentMediaTime() - timeOffset);
+        caAnim.setBeginTime(CACurrentMediaTime() - timeOffset.seconds());
 
     String animationID = animationIdentifier(animationName, property, index, subIndex);
 
@@ -2888,7 +2888,7 @@ bool GraphicsLayerCA::removeCAAnimationFromLayer(AnimatedPropertyID property, co
     return true;
 }
 
-void GraphicsLayerCA::pauseCAAnimationOnLayer(AnimatedPropertyID property, const String& animationName, int index, int subIndex, double timeOffset)
+void GraphicsLayerCA::pauseCAAnimationOnLayer(AnimatedPropertyID property, const String& animationName, int index, int subIndex, Seconds timeOffset)
 {
     PlatformCALayer* layer = animatedLayer(property);
 
@@ -2902,7 +2902,7 @@ void GraphicsLayerCA::pauseCAAnimationOnLayer(AnimatedPropertyID property, const
     RefPtr<PlatformCAAnimation> newAnim = curAnim->copy();
 
     newAnim->setSpeed(0);
-    newAnim->setTimeOffset(timeOffset);
+    newAnim->setTimeOffset(timeOffset.seconds());
     
     layer->addAnimationForKey(animationID, *newAnim); // This will replace the running animation.
 
@@ -2938,7 +2938,7 @@ void GraphicsLayerCA::updateContentsNeedsDisplay()
         m_contentsLayer->setNeedsDisplay();
 }
 
-bool GraphicsLayerCA::createAnimationFromKeyframes(const KeyframeValueList& valueList, const Animation* animation, const String& animationName, double timeOffset)
+bool GraphicsLayerCA::createAnimationFromKeyframes(const KeyframeValueList& valueList, const Animation* animation, const String& animationName, Seconds timeOffset)
 {
     ASSERT(valueList.property() != AnimatedPropertyTransform && (!supportsAcceleratedFilterAnimations() || valueList.property() != AnimatedPropertyFilter));
 
@@ -2969,7 +2969,7 @@ bool GraphicsLayerCA::createAnimationFromKeyframes(const KeyframeValueList& valu
     return true;
 }
 
-bool GraphicsLayerCA::appendToUncommittedAnimations(const KeyframeValueList& valueList, const TransformOperations* operations, const Animation* animation, const String& animationName, const FloatSize& boxSize, int animationIndex, double timeOffset, bool isMatrixAnimation)
+bool GraphicsLayerCA::appendToUncommittedAnimations(const KeyframeValueList& valueList, const TransformOperations* operations, const Animation* animation, const String& animationName, const FloatSize& boxSize, int animationIndex, Seconds timeOffset, bool isMatrixAnimation)
 {
     TransformOperation::OperationType transformOp = isMatrixAnimation ? TransformOperation::MATRIX_3D : operations->operations().at(animationIndex)->type();
     bool additive = animationIndex > 0;
@@ -2995,7 +2995,7 @@ bool GraphicsLayerCA::appendToUncommittedAnimations(const KeyframeValueList& val
     return true;
 }
 
-bool GraphicsLayerCA::createTransformAnimationsFromKeyframes(const KeyframeValueList& valueList, const Animation* animation, const String& animationName, double timeOffset, const FloatSize& boxSize)
+bool GraphicsLayerCA::createTransformAnimationsFromKeyframes(const KeyframeValueList& valueList, const Animation* animation, const String& animationName, Seconds timeOffset, const FloatSize& boxSize)
 {
     ASSERT(valueList.property() == AnimatedPropertyTransform);
 
@@ -3024,7 +3024,7 @@ bool GraphicsLayerCA::createTransformAnimationsFromKeyframes(const KeyframeValue
     return validMatrices;
 }
 
-bool GraphicsLayerCA::appendToUncommittedAnimations(const KeyframeValueList& valueList, const FilterOperation* operation, const Animation* animation, const String& animationName, int animationIndex, double timeOffset)
+bool GraphicsLayerCA::appendToUncommittedAnimations(const KeyframeValueList& valueList, const FilterOperation* operation, const Animation* animation, const String& animationName, int animationIndex, Seconds timeOffset)
 {
     bool isKeyframe = valueList.size() > 2;
     
@@ -3059,7 +3059,7 @@ bool GraphicsLayerCA::appendToUncommittedAnimations(const KeyframeValueList& val
     return true;
 }
 
-bool GraphicsLayerCA::createFilterAnimationsFromKeyframes(const KeyframeValueList& valueList, const Animation* animation, const String& animationName, double timeOffset)
+bool GraphicsLayerCA::createFilterAnimationsFromKeyframes(const KeyframeValueList& valueList, const Animation* animation, const String& animationName, Seconds timeOffset)
 {
 #if ENABLE(FILTERS_LEVEL_2)
     ASSERT(valueList.property() == AnimatedPropertyFilter || valueList.property() == AnimatedPropertyWebkitBackdropFilter);
@@ -3419,9 +3419,9 @@ bool GraphicsLayerCA::setFilterAnimationKeyframes(const KeyframeValueList& value
     return true;
 }
 
-void GraphicsLayerCA::suspendAnimations(double time)
+void GraphicsLayerCA::suspendAnimations(MonotonicTime time)
 {
-    double t = PlatformCALayer::currentTimeToMediaTime(time ? time : monotonicallyIncreasingTime());
+    double t = PlatformCALayer::currentTimeToMediaTime(time ? time : MonotonicTime::now());
     primaryLayer()->setSpeed(0);
     primaryLayer()->setTimeOffset(t);
 
index 56d7b91..c22e7c6 100644 (file)
@@ -125,7 +125,7 @@ public:
     WEBCORE_EXPORT void setShapeLayerPath(const Path&) override;
     WEBCORE_EXPORT void setShapeLayerWindRule(WindRule) override;
 
-    WEBCORE_EXPORT void suspendAnimations(double time) override;
+    WEBCORE_EXPORT void suspendAnimations(MonotonicTime) override;
     WEBCORE_EXPORT void resumeAnimations() override;
 
     WEBCORE_EXPORT bool addAnimation(const KeyframeValueList&, const FloatSize& boxSize, const Animation*, const String& animationName, double timeOffset) override;
@@ -186,7 +186,7 @@ private:
     bool platformCALayerRespondsToLayoutChanges() const override { return false; }
     WEBCORE_EXPORT void platformCALayerCustomSublayersChanged(PlatformCALayer*) override;
 
-    WEBCORE_EXPORT void platformCALayerAnimationStarted(const String& animationKey, CFTimeInterval beginTime) override;
+    WEBCORE_EXPORT void platformCALayerAnimationStarted(const String& animationKey, MonotonicTime beginTime) override;
     WEBCORE_EXPORT void platformCALayerAnimationEnded(const String& animationKey) override;
     CompositingCoordinatesOrientation platformCALayerContentsOrientation() const override { return contentsOrientation(); }
     WEBCORE_EXPORT void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& clip, GraphicsLayerPaintBehavior) override;
@@ -239,9 +239,9 @@ private:
     LayerMap* primaryLayerClones() const { return m_structuralLayer.get() ? m_structuralLayerClones.get() : m_layerClones.get(); }
     LayerMap* animatedLayerClones(AnimatedPropertyID) const;
 
-    bool createAnimationFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, double timeOffset);
-    bool createTransformAnimationsFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, double timeOffset, const FloatSize& boxSize);
-    bool createFilterAnimationsFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, double timeOffset);
+    bool createAnimationFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, Seconds timeOffset);
+    bool createTransformAnimationsFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, Seconds timeOffset, const FloatSize& boxSize);
+    bool createFilterAnimationsFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, Seconds timeOffset);
 
     // Return autoreleased animation (use RetainPtr?)
     Ref<PlatformCAAnimation> createBasicAnimation(const Animation*, const String& keyPath, bool additive);
@@ -440,9 +440,9 @@ private:
     void ensureStructuralLayer(StructuralLayerPurpose);
     StructuralLayerPurpose structuralLayerPurpose() const;
 
-    void setAnimationOnLayer(PlatformCAAnimation&, AnimatedPropertyID, const String& animationName, int index, int subIndex, double timeOffset);
+    void setAnimationOnLayer(PlatformCAAnimation&, AnimatedPropertyID, const String& animationName, int index, int subIndex, Seconds timeOffset);
     bool removeCAAnimationFromLayer(AnimatedPropertyID, const String& animationName, int index, int subINdex);
-    void pauseCAAnimationOnLayer(AnimatedPropertyID, const String& animationName, int index, int subIndex, double timeOffset);
+    void pauseCAAnimationOnLayer(AnimatedPropertyID, const String& animationName, int index, int subIndex, Seconds timeOffset);
 
     enum MoveOrCopy { Move, Copy };
     static void moveOrCopyLayerAnimation(MoveOrCopy, const String& animationIdentifier, PlatformCALayer *fromLayer, PlatformCALayer *toLayer);
@@ -457,8 +457,8 @@ private:
         moveOrCopyAnimations(Copy, fromLayer, toLayer);
     }
 
-    bool appendToUncommittedAnimations(const KeyframeValueList&, const TransformOperations*, const Animation*, const String& animationName, const FloatSize& boxSize, int animationIndex, double timeOffset, bool isMatrixAnimation);
-    bool appendToUncommittedAnimations(const KeyframeValueList&, const FilterOperation*, const Animation*, const String& animationName, int animationIndex, double timeOffset);
+    bool appendToUncommittedAnimations(const KeyframeValueList&, const TransformOperations*, const Animation*, const String& animationName, const FloatSize& boxSize, int animationIndex, Seconds timeOffset, bool isMatrixAnimation);
+    bool appendToUncommittedAnimations(const KeyframeValueList&, const FilterOperation*, const Animation*, const String& animationName, int animationIndex, Seconds timeOffset);
 
     enum LayerChange : uint64_t {
         NoChange                                = 0,
@@ -561,7 +561,7 @@ private:
     // This represents the animation of a single property. There may be multiple transform animations for
     // a single transition or keyframe animation, so index is used to distinguish these.
     struct LayerPropertyAnimation {
-        LayerPropertyAnimation(Ref<PlatformCAAnimation>&& caAnimation, const String& animationName, AnimatedPropertyID property, int index, int subIndex, double timeOffset)
+        LayerPropertyAnimation(Ref<PlatformCAAnimation>&& caAnimation, const String& animationName, AnimatedPropertyID property, int index, int subIndex, Seconds timeOffset)
             : m_animation(WTFMove(caAnimation))
             , m_name(animationName)
             , m_property(property)
@@ -575,7 +575,7 @@ private:
         AnimatedPropertyID m_property;
         int m_index;
         int m_subIndex;
-        double m_timeOffset;
+        Seconds m_timeOffset;
     };
     
     // Uncommitted transitions and animations.
@@ -583,13 +583,13 @@ private:
     
     enum Action { Remove, Pause };
     struct AnimationProcessingAction {
-        AnimationProcessingAction(Action action = Remove, double timeOffset = 0)
+        AnimationProcessingAction(Action action = Remove, Seconds timeOffset = 0_s)
             : action(action)
             , timeOffset(timeOffset)
         {
         }
         Action action;
-        double timeOffset; // only used for pause
+        Seconds timeOffset; // only used for pause
     };
     typedef HashMap<String, AnimationProcessingAction> AnimationsToProcessMap;
     AnimationsToProcessMap m_animationsToProcess;
index 0cc4fac..33e3bea 100644 (file)
 
 namespace WebCore {
 
-static const double capacityDecayTime = 5;
+static const Seconds capacityDecayTime { 5_s };
 
 LayerPool::LayerPool()
     : m_totalBytes(0)
     , m_maxBytesForPool(48 * 1024 * 1024)
     , m_pruneTimer(*this, &LayerPool::pruneTimerFired)
-    , m_lastAddTime(0)
 {
     allLayerPools().add(this);
 }
@@ -81,7 +80,7 @@ void LayerPool::addLayer(const RefPtr<PlatformCALayer>& layer)
     listOfLayersWithSize(layerSize).prepend(layer);
     m_totalBytes += backingStoreBytesForSize(layerSize);
     
-    m_lastAddTime = monotonicallyIncreasingTime();
+    m_lastAddTime = MonotonicTime::now();
     schedulePrune();
 }
 
@@ -99,7 +98,7 @@ RefPtr<PlatformCALayer> LayerPool::takeLayerWithSize(const IntSize& size)
 unsigned LayerPool::decayedCapacity() const
 {
     // Decay to one quarter over capacityDecayTime
-    double timeSinceLastAdd = monotonicallyIncreasingTime() - m_lastAddTime;
+    Seconds timeSinceLastAdd = MonotonicTime::now() - m_lastAddTime;
     if (timeSinceLastAdd > capacityDecayTime)
         return m_maxBytesForPool / 4;
     float decayProgess = float(timeSinceLastAdd / capacityDecayTime);
@@ -131,7 +130,7 @@ void LayerPool::pruneTimerFired()
         // still have a backing store.
         oldestReuseList.remove(--oldestReuseList.end());
     }
-    if (monotonicallyIncreasingTime() - m_lastAddTime <= capacityDecayTime)
+    if (MonotonicTime::now() - m_lastAddTime <= capacityDecayTime)
         schedulePrune();
 }
 
index 5351dc6..b8cf59b 100644 (file)
@@ -75,7 +75,7 @@ private:
 
     Timer m_pruneTimer;
 
-    double m_lastAddTime;
+    MonotonicTime m_lastAddTime;
 };
 
 }
index 43b1b78..88ae040 100644 (file)
@@ -31,6 +31,7 @@
 #include "FloatPoint3D.h"
 #include "TransformationMatrix.h"
 #include <wtf/Forward.h>
+#include <wtf/MonotonicTime.h>
 #include <wtf/RefCounted.h>
 #include <wtf/TypeCasts.h>
 
index 48bd2b1..3a99f8d 100644 (file)
@@ -56,7 +56,7 @@ class WEBCORE_EXPORT PlatformCALayer : public RefCounted<PlatformCALayer> {
     friend class PlatformCALayerWin;
 #endif
 public:
-    static CFTimeInterval currentTimeToMediaTime(double t) { return CACurrentMediaTime() + t - monotonicallyIncreasingTime(); }
+    static CFTimeInterval currentTimeToMediaTime(MonotonicTime t) { return CACurrentMediaTime() + (t - MonotonicTime::now()).seconds(); }
 
     // LayerTypeRootLayer is used on some platforms. It has no backing store, so setNeedsDisplay
     // should not call CACFLayerSetNeedsDisplay, but rather just notify the renderer that it
@@ -102,7 +102,7 @@ public:
     PlatformCALayerClient* owner() const { return m_owner; }
     virtual void setOwner(PlatformCALayerClient* owner) { m_owner = owner; }
 
-    virtual void animationStarted(const String& key, CFTimeInterval beginTime) = 0;
+    virtual void animationStarted(const String& key, MonotonicTime beginTime) = 0;
     virtual void animationEnded(const String& key) = 0;
 
     virtual void setNeedsDisplay() = 0;
index 226f703..1f9b7c0 100644 (file)
@@ -40,7 +40,7 @@ public:
 
     virtual void platformCALayerCustomSublayersChanged(PlatformCALayer*) { }
 
-    virtual void platformCALayerAnimationStarted(const String& /*animationKey*/, CFTimeInterval) { }
+    virtual void platformCALayerAnimationStarted(const String& /*animationKey*/, MonotonicTime) { }
     virtual void platformCALayerAnimationEnded(const String& /*animationKey*/) { }
     virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesTopDown; }
     virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& inClip, GraphicsLayerPaintBehavior) = 0;
index 51a5497..5919f97 100644 (file)
@@ -402,9 +402,9 @@ void TileGrid::revalidateTiles(TileValidationPolicy validationPolicy)
                 for (auto& cohort : m_cohortList) {
                     if (cohort.cohort != tileInfo.cohort)
                         continue;
-                    double timeUntilCohortExpires = cohort.timeUntilExpiration();
-                    if (timeUntilCohortExpires > 0) {
-                        minimumRevalidationTimerDuration = std::min(minimumRevalidationTimerDuration, Seconds { timeUntilCohortExpires });
+                    Seconds timeUntilCohortExpires = cohort.timeUntilExpiration();
+                    if (timeUntilCohortExpires > 0_s) {
+                        minimumRevalidationTimerDuration = std::min(minimumRevalidationTimerDuration, timeUntilCohortExpires);
                         needsTileRevalidation = true;
                     } else
                         tileLayer->removeFromSuperlayer();
@@ -504,7 +504,7 @@ TileGrid::TileCohort TileGrid::nextTileCohort() const
 
 void TileGrid::startedNewCohort(TileCohort cohort)
 {
-    m_cohortList.append(TileCohortInfo(cohort, monotonicallyIncreasingTime()));
+    m_cohortList.append(TileCohortInfo(cohort, MonotonicTime::now()));
 #if PLATFORM(IOS)
     if (!m_controller.isInWindow())
         tileControllerMemoryHandler().tileControllerGainedUnparentedTiles(&m_controller);
@@ -530,10 +530,10 @@ void TileGrid::scheduleCohortRemoval()
         m_cohortRemovalTimer.startRepeating(cohortRemovalTimerSeconds);
 }
 
-double TileGrid::TileCohortInfo::timeUntilExpiration()
+Seconds TileGrid::TileCohortInfo::timeUntilExpiration()
 {
-    double cohortLifeTimeSeconds = 2;
-    double timeThreshold = monotonicallyIncreasingTime() - cohortLifeTimeSeconds;
+    Seconds cohortLifeTimeSeconds = 2_s;
+    MonotonicTime timeThreshold = MonotonicTime::now() - cohortLifeTimeSeconds;
     return creationTime - timeThreshold;
 }
 
@@ -544,7 +544,7 @@ void TileGrid::cohortRemovalTimerFired()
         return;
     }
 
-    while (!m_cohortList.isEmpty() && m_cohortList.first().timeUntilExpiration() < 0) {
+    while (!m_cohortList.isEmpty() && m_cohortList.first().timeUntilExpiration() < 0_s) {
         TileCohortInfo firstCohort = m_cohortList.takeFirst();
         removeTilesInCohort(firstCohort.cohort);
     }
index 9835d2f..705ca73 100644 (file)
@@ -120,13 +120,13 @@ private:
 
     struct TileCohortInfo {
         TileCohort cohort;
-        double creationTime; // in monotonicallyIncreasingTime().
-        TileCohortInfo(TileCohort inCohort, double inTime)
+        MonotonicTime creationTime;
+        TileCohortInfo(TileCohort inCohort, MonotonicTime inTime)
             : cohort(inCohort)
             , creationTime(inTime)
         { }
 
-        double timeUntilExpiration();
+        Seconds timeUntilExpiration();
     };
 
     void removeAllTiles();
index ec77b52..e59cb0d 100644 (file)
@@ -63,7 +63,7 @@ public:
     void addAnimationForKey(const String& key, PlatformCAAnimation&) override;
     void removeAnimationForKey(const String& key) override;
     RefPtr<PlatformCAAnimation> animationForKey(const String& key) override;
-    void animationStarted(const String& key, CFTimeInterval beginTime) override;
+    void animationStarted(const String& key, MonotonicTime beginTime) override;
     void animationEnded(const String& key) override;
 
     void setMask(PlatformCALayer*) override;
index 8eea276..6c398f4 100644 (file)
@@ -93,9 +93,9 @@ PlatformCALayer* PlatformCALayer::platformCALayer(void* platformLayer)
     return platformCALayer;
 }
 
-static double mediaTimeToCurrentTime(CFTimeInterval t)
+static MonotonicTime mediaTimeToCurrentTime(CFTimeInterval t)
 {
-    return monotonicallyIncreasingTime() + t - CACurrentMediaTime();
+    return MonotonicTime::now() + Seconds(t - CACurrentMediaTime());
 }
 
 // Delegate for animationDidStart callback
@@ -118,7 +118,7 @@ static double mediaTimeToCurrentTime(CFTimeInterval t)
     if (!m_owner)
         return;
 
-    CFTimeInterval startTime;
+    MonotonicTime startTime;
     if (hasExplicitBeginTime(animation)) {
         // We don't know what time CA used to commit the animation, so just use the current time
         // (even though this will be slightly off).
@@ -378,7 +378,7 @@ PlatformCALayerCocoa::~PlatformCALayerCocoa()
         [static_cast<WebTiledBackingLayer *>(m_layer.get()) invalidate];
 }
 
-void PlatformCALayerCocoa::animationStarted(const String& animationKey, CFTimeInterval beginTime)
+void PlatformCALayerCocoa::animationStarted(const String& animationKey, MonotonicTime beginTime)
 {
     if (m_owner)
         m_owner->platformCALayerAnimationStarted(animationKey, beginTime);
index 729f843..f2160e9 100644 (file)
@@ -324,7 +324,7 @@ void CACFLayerTreeHost::notifyAnimationsStarted()
     // Send currentTime to the pending animations. This function is called by CACF in a callback
     // which occurs after the drawInContext calls. So currentTime is very close to the time
     // the animations actually start
-    double currentTime = monotonicallyIncreasingTime();
+    MonotonicTime currentTime = MonotonicTime::now();
 
     HashSet<RefPtr<PlatformCALayer> >::iterator end = m_pendingAnimatedLayers.end();
     for (HashSet<RefPtr<PlatformCALayer> >::iterator it = m_pendingAnimatedLayers.begin(); it != end; ++it)
index ca1da9f..d680ec9 100644 (file)
@@ -208,7 +208,7 @@ PlatformCALayer* PlatformCALayerWin::rootLayer() const
     return host ? host->rootLayer() : nullptr;
 }
 
-void PlatformCALayerWin::animationStarted(const String& animationKey, CFTimeInterval beginTime)
+void PlatformCALayerWin::animationStarted(const String& animationKey, MonotonicTime beginTime)
 {
     // Update start time for any animation not yet started
     CFTimeInterval cacfBeginTime = currentTimeToMediaTime(beginTime);
@@ -921,7 +921,7 @@ String PlatformCALayerWin::layerTreeAsString() const
 
     StringBuilder builder;
     builder.append("\n\n** Render tree at time ");
-    builder.appendNumber(monotonicallyIncreasingTime());
+    builder.appendNumber(MonotonicTime::now().secondsSinceEpoch().seconds());
     builder.append(" (bounds ");
     builder.appendNumber(rootBounds.origin.x);
     builder.append(", ");
index b3fb254..781ad8e 100644 (file)
@@ -55,7 +55,7 @@ public:
     void addAnimationForKey(const String& key, PlatformCAAnimation&) override;
     void removeAnimationForKey(const String& key) override;
     RefPtr<PlatformCAAnimation> animationForKey(const String& key) override;
-    void animationStarted(const String& key, CFTimeInterval beginTime) override;
+    void animationStarted(const String& key, MonotonicTime beginTime) override;
     void animationEnded(const String& key) override;
 
     void setMask(PlatformCALayer*) override;
index a84338e..53595e2 100644 (file)
@@ -260,9 +260,9 @@ void WebCoreDecompressionSession::decodeSample(CMSampleBufferRef sample, bool di
         return;
     }
 
-    double startTime = monotonicallyIncreasingTime();
+    MonotonicTime startTime = MonotonicTime::now();
     VTDecompressionSessionDecodeFrameWithOutputHandler(m_decompressionSession.get(), sample, flags, nullptr, [this, displaying, startTime](OSStatus status, VTDecodeInfoFlags infoFlags, CVImageBufferRef imageBuffer, CMTime presentationTimeStamp, CMTime presentationDuration) {
-        double deltaRatio = (monotonicallyIncreasingTime() - startTime) / CMTimeGetSeconds(presentationDuration);
+        double deltaRatio = (MonotonicTime::now() - startTime).seconds() / CMTimeGetSeconds(presentationDuration);
 
         updateQosWithDecodeTimeStatistics(deltaRatio);
         handleDecompressionOutput(displaying, status, infoFlags, imageBuffer, presentationTimeStamp, presentationDuration);
index 12c9d06..75d4ae6 100644 (file)
@@ -33,7 +33,7 @@
 
 namespace WebCore {
 
-static const double releaseUnusedSecondsTolerance = 3;
+static const Seconds releaseUnusedSecondsTolerance { 3_s };
 static const Seconds releaseUnusedTexturesTimerInterval { 500_ms };
 
 #if USE(TEXTURE_MAPPER_GL)
@@ -72,7 +72,7 @@ void BitmapTexturePool::scheduleReleaseUnusedTextures()
 void BitmapTexturePool::releaseUnusedTexturesTimerFired()
 {
     // Delete entries, which have been unused in releaseUnusedSecondsTolerance.
-    double minUsedTime = monotonicallyIncreasingTime() - releaseUnusedSecondsTolerance;
+    MonotonicTime minUsedTime = MonotonicTime::now() - releaseUnusedSecondsTolerance;
 
     if (!m_textures.isEmpty()) {
         m_textures.removeAllMatching([&minUsedTime](const Entry& entry) {
index 31caff7..515ea2d 100644 (file)
@@ -52,11 +52,11 @@ private:
             : m_texture(WTFMove(texture))
         { }
 
-        void markIsInUse() { m_lastUsedTime = monotonicallyIncreasingTime(); }
-        bool canBeReleased (double minUsedTime) const { return m_lastUsedTime < minUsedTime && m_texture->refCount() == 1; }
+        void markIsInUse() { m_lastUsedTime = MonotonicTime::now(); }
+        bool canBeReleased (MonotonicTime minUsedTime) const { return m_lastUsedTime < minUsedTime && m_texture->refCount() == 1; }
 
         RefPtr<BitmapTexture> m_texture;
-        double m_lastUsedTime { 0.0 };
+        MonotonicTime m_lastUsedTime;
     };
 
     void scheduleReleaseUnusedTextures();
index a026f4c..3a6d169 100644 (file)
@@ -46,7 +46,6 @@ GraphicsLayerTextureMapper::GraphicsLayerTextureMapper(Type layerType, GraphicsL
     , m_fixedToViewport(false)
     , m_debugBorderWidth(0)
     , m_contentsLayer(0)
-    , m_animationStartTime(0)
     , m_isScrollable(false)
 {
 }
@@ -596,13 +595,13 @@ bool GraphicsLayerTextureMapper::addAnimation(const KeyframeValueList& valueList
     if (valueList.property() == AnimatedPropertyTransform)
         listsMatch = validateTransformOperations(valueList, hasBigRotation) >= 0;
 
-    const double currentTime = monotonicallyIncreasingTime();
-    m_animations.add(TextureMapperAnimation(keyframesName, valueList, boxSize, *anim, listsMatch, currentTime - timeOffset, 0, TextureMapperAnimation::AnimationState::Playing));
+    const MonotonicTime currentTime = MonotonicTime::now();
+    m_animations.add(TextureMapperAnimation(keyframesName, valueList, boxSize, *anim, listsMatch, currentTime - Seconds(timeOffset), 0_s, TextureMapperAnimation::AnimationState::Playing));
     // m_animationStartTime is the time of the first real frame of animation, now or delayed by a negative offset.
-    if (timeOffset > 0)
+    if (Seconds(timeOffset) > 0_s)
         m_animationStartTime = currentTime;
     else
-        m_animationStartTime = currentTime - timeOffset;
+        m_animationStartTime = currentTime - Seconds(timeOffset);
     notifyChange(AnimationChange);
     notifyChange(AnimationStarted);
     return true;
@@ -617,7 +616,7 @@ void GraphicsLayerTextureMapper::setAnimations(const TextureMapperAnimations& an
 
 void GraphicsLayerTextureMapper::pauseAnimation(const String& animationName, double timeOffset)
 {
-    m_animations.pause(animationName, timeOffset);
+    m_animations.pause(animationName, Seconds(timeOffset));
 }
 
 void GraphicsLayerTextureMapper::removeAnimation(const String& animationName)
index a1faa93..feb5c38 100644 (file)
@@ -179,7 +179,7 @@ private:
     TextureMapperPlatformLayer* m_contentsLayer;
     FloatRect m_needsDisplayRect;
     TextureMapperAnimations m_animations;
-    double m_animationStartTime;
+    MonotonicTime m_animationStartTime;
 
     IntSize m_committedScrollOffset;
     bool m_isScrollable;
index b287f24..38d8dd6 100644 (file)
@@ -165,7 +165,7 @@ static const TimingFunction& timingFunctionForAnimationValue(const AnimationValu
     return CubicBezierTimingFunction::defaultTimingFunction();
 }
 
-TextureMapperAnimation::TextureMapperAnimation(const String& name, const KeyframeValueList& keyframes, const FloatSize& boxSize, const Animation& animation, bool listsMatch, double startTime, double pauseTime, AnimationState state)
+TextureMapperAnimation::TextureMapperAnimation(const String& name, const KeyframeValueList& keyframes, const FloatSize& boxSize, const Animation& animation, bool listsMatch, MonotonicTime startTime, Seconds pauseTime, AnimationState state)
     : m_name(name.isSafeToSendToAnotherThread() ? name : name.isolatedCopy())
     , m_keyframes(keyframes)
     , m_boxSize(boxSize)
@@ -173,7 +173,7 @@ TextureMapperAnimation::TextureMapperAnimation(const String& name, const Keyfram
     , m_listsMatch(listsMatch)
     , m_startTime(startTime)
     , m_pauseTime(pauseTime)
-    , m_totalRunningTime(0)
+    , m_totalRunningTime(0_s)
     , m_lastRefreshedTime(m_startTime)
     , m_state(state)
 {
@@ -198,12 +198,12 @@ void TextureMapperAnimation::apply(Client& client)
     if (!isActive())
         return;
 
-    double totalRunningTime = computeTotalRunningTime();
-    double normalizedValue = normalizedAnimationValue(totalRunningTime, m_animation->duration(), m_animation->direction(), m_animation->iterationCount());
+    Seconds totalRunningTime = computeTotalRunningTime();
+    double normalizedValue = normalizedAnimationValue(totalRunningTime.seconds(), m_animation->duration(), m_animation->direction(), m_animation->iterationCount());
 
-    if (m_animation->iterationCount() != Animation::IterationCountInfinite && totalRunningTime >= m_animation->duration() * m_animation->iterationCount()) {
+    if (m_animation->iterationCount() != Animation::IterationCountInfinite && totalRunningTime.seconds() >= m_animation->duration() * m_animation->iterationCount()) {
         m_state = AnimationState::Stopped;
-        m_pauseTime = 0;
+        m_pauseTime = 0_s;
         if (m_animation->fillsForwards())
             normalizedValue = normalizedAnimationValueForFillsForwards(m_animation->iterationCount(), m_animation->direction());
     }
@@ -238,7 +238,7 @@ void TextureMapperAnimation::apply(Client& client)
     }
 }
 
-void TextureMapperAnimation::pause(double time)
+void TextureMapperAnimation::pause(Seconds time)
 {
     m_state = AnimationState::Paused;
     m_pauseTime = time;
@@ -247,18 +247,20 @@ void TextureMapperAnimation::pause(double time)
 void TextureMapperAnimation::resume()
 {
     m_state = AnimationState::Playing;
-    m_pauseTime = 0;
+    // FIXME: This seems wrong. m_totalRunningTime is cleared.
+    // https://bugs.webkit.org/show_bug.cgi?id=183113
+    m_pauseTime = 0_s;
     m_totalRunningTime = m_pauseTime;
-    m_lastRefreshedTime = monotonicallyIncreasingTime();
+    m_lastRefreshedTime = MonotonicTime::now();
 }
 
-double TextureMapperAnimation::computeTotalRunningTime()
+Seconds TextureMapperAnimation::computeTotalRunningTime()
 {
     if (m_state == AnimationState::Paused)
         return m_pauseTime;
 
-    double oldLastRefreshedTime = m_lastRefreshedTime;
-    m_lastRefreshedTime = monotonicallyIncreasingTime();
+    MonotonicTime oldLastRefreshedTime = m_lastRefreshedTime;
+    m_lastRefreshedTime = MonotonicTime::now();
     m_totalRunningTime += m_lastRefreshedTime - oldLastRefreshedTime;
     return m_totalRunningTime;
 }
@@ -307,7 +309,7 @@ void TextureMapperAnimations::remove(const String& name, AnimatedPropertyID prop
     });
 }
 
-void TextureMapperAnimations::pause(const String& name, double offset)
+void TextureMapperAnimations::pause(const String& name, Seconds offset)
 {
     for (auto& animation : m_animations) {
         if (animation.name() == name)
@@ -315,10 +317,12 @@ void TextureMapperAnimations::pause(const String& name, double offset)
     }
 }
 
-void TextureMapperAnimations::suspend(double offset)
+void TextureMapperAnimations::suspend(MonotonicTime time)
 {
+    // FIXME: This seems wrong. `pause` takes time offset (Seconds), not MonotonicTime.
+    // https://bugs.webkit.org/show_bug.cgi?id=183112
     for (auto& animation : m_animations)
-        animation.pause(offset);
+        animation.pause(time.secondsSinceEpoch());
 }
 
 void TextureMapperAnimations::resume()
index 24137e0..f880ef9 100644 (file)
@@ -40,11 +40,11 @@ public:
     TextureMapperAnimation()
         : m_keyframes(AnimatedPropertyInvalid)
     { }
-    TextureMapperAnimation(const String&, const KeyframeValueList&, const FloatSize&, const Animation&, bool, double, double, AnimationState);
+    TextureMapperAnimation(const String&, const KeyframeValueList&, const FloatSize&, const Animation&, bool, MonotonicTime, Seconds, AnimationState);
     WEBCORE_EXPORT TextureMapperAnimation(const TextureMapperAnimation&);
 
     void apply(Client&);
-    void pause(double);
+    void pause(Seconds);
     void resume();
     bool isActive() const;
 
@@ -53,23 +53,23 @@ public:
     const FloatSize& boxSize() const { return m_boxSize; }
     const RefPtr<Animation> animation() const { return m_animation; }
     bool listsMatch() const { return m_listsMatch; }
-    double startTime() const { return m_startTime; }
-    double pauseTime() const { return m_pauseTime; }
+    MonotonicTime startTime() const { return m_startTime; }
+    Seconds pauseTime() const { return m_pauseTime; }
     AnimationState state() const { return m_state; }
 
 private:
     void applyInternal(Client&, const AnimationValue& from, const AnimationValue& to, float progress);
-    double computeTotalRunningTime();
+    Seconds computeTotalRunningTime();
 
     String m_name;
     KeyframeValueList m_keyframes;
     FloatSize m_boxSize;
     RefPtr<Animation> m_animation;
     bool m_listsMatch;
-    double m_startTime;
-    double m_pauseTime;
-    double m_totalRunningTime;
-    double m_lastRefreshedTime;
+    MonotonicTime m_startTime;
+    Seconds m_pauseTime;
+    Seconds m_totalRunningTime;
+    MonotonicTime m_lastRefreshedTime;
     AnimationState m_state;
 };
 
@@ -80,8 +80,8 @@ public:
     void add(const TextureMapperAnimation&);
     void remove(const String& name);
     void remove(const String& name, AnimatedPropertyID);
-    void pause(const String&, double);
-    void suspend(double);
+    void pause(const String&, Seconds);
+    void suspend(MonotonicTime);
     void resume();
 
     void apply(TextureMapperAnimation::Client&);
index 7785147..a88d59d 100644 (file)
@@ -31,17 +31,16 @@ namespace WebCore {
 
 TextureMapperFPSCounter::TextureMapperFPSCounter()
     : m_isShowingFPS(false)
-    , m_fpsInterval(0)
-    , m_fpsTimestamp(0)
+    , m_fpsInterval(0_s)
     , m_lastFPS(0)
     , m_frameCount(0)
 {
     String showFPSEnvironment = getenv("WEBKIT_SHOW_FPS");
     bool ok = false;
-    m_fpsInterval = showFPSEnvironment.toDouble(&ok);
+    m_fpsInterval = Seconds(showFPSEnvironment.toDouble(&ok));
     if (ok && m_fpsInterval) {
         m_isShowingFPS = true;
-        m_fpsTimestamp = monotonicallyIncreasingTime();
+        m_fpsTimestamp = MonotonicTime::now();
     }
 }
 
@@ -51,9 +50,9 @@ void TextureMapperFPSCounter::updateFPSAndDisplay(TextureMapper& textureMapper,
         return;
 
     m_frameCount++;
-    double delta = monotonicallyIncreasingTime() - m_fpsTimestamp;
+    Seconds delta = MonotonicTime::now() - m_fpsTimestamp;
     if (delta >= m_fpsInterval) {
-        m_lastFPS = int(m_frameCount / delta);
+        m_lastFPS = int(m_frameCount / delta.seconds());
         m_frameCount = 0;
         m_fpsTimestamp += delta;
     }
index b30fcf9..ce148db 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "FloatPoint.h"
 #include "TransformationMatrix.h"
+#include <wtf/MonotonicTime.h>
 #include <wtf/Noncopyable.h>
 
 namespace WebCore {
@@ -38,8 +39,8 @@ public:
 
 private:
     bool m_isShowingFPS;
-    double m_fpsInterval;
-    double m_fpsTimestamp;
+    Seconds m_fpsInterval;
+    MonotonicTime m_fpsTimestamp;
     int m_lastFPS;
     int m_frameCount;
 };
index 6066df5..036433b 100644 (file)
@@ -28,7 +28,7 @@
 #include "BitmapTextureGL.h"
 #include "TextureMapperGLHeaders.h"
 #include "TextureMapperPlatformLayer.h"
-#include <wtf/CurrentTime.h>
+#include <wtf/MonotonicTime.h>
 
 #if USE(COORDINATED_GRAPHICS_THREADED)
 
@@ -48,8 +48,8 @@ public:
     bool canReuseWithoutReset(const IntSize&, GLint internalFormat);
     BitmapTextureGL& textureGL() { return static_cast<BitmapTextureGL&>(*m_texture); }
 
-    inline void markUsed() { m_timeLastUsed = monotonicallyIncreasingTime(); }
-    double lastUsedTime() const { return m_timeLastUsed; }
+    inline void markUsed() { m_timeLastUsed = MonotonicTime::now(); }
+    MonotonicTime lastUsedTime() const { return m_timeLastUsed; }
 
     class UnmanagedBufferDataHolder {
         WTF_MAKE_NONCOPYABLE(UnmanagedBufferDataHolder);
@@ -68,7 +68,7 @@ public:
 private:
 
     RefPtr<BitmapTexture> m_texture;
-    double m_timeLastUsed { 0 };
+    MonotonicTime m_timeLastUsed;
 
     GLuint m_textureID;
     IntSize m_size;
index b23dac2..474b120 100644 (file)
@@ -37,7 +37,7 @@
 #include <wtf/glib/RunLoopSourcePriority.h>
 #endif
 
-static const double releaseUnusedSecondsTolerance = 1;
+static const Seconds releaseUnusedSecondsTolerance { 1_s };
 static const Seconds releaseUnusedBuffersTimerInterval = { 500_ms };
 
 namespace WebCore {
@@ -163,7 +163,7 @@ void TextureMapperPlatformLayerProxy::releaseUnusedBuffersTimerFired()
         return;
 
     auto buffers = WTFMove(m_usedBuffers);
-    double minUsedTime = monotonicallyIncreasingTime() - releaseUnusedSecondsTolerance;
+    MonotonicTime minUsedTime = MonotonicTime::now() - releaseUnusedSecondsTolerance;
 
     for (auto& buffer : buffers) {
         if (buffer && buffer->lastUsedTime() >= minUsedTime)
index 0a4b08e..c69d761 100644 (file)
@@ -1156,8 +1156,8 @@ bool CoordinatedGraphicsLayer::addAnimation(const KeyframeValueList& valueList,
     if (valueList.property() == AnimatedPropertyTransform)
         listsMatch = validateTransformOperations(valueList, ignoredHasBigRotation) >= 0;
 
-    m_lastAnimationStartTime = monotonicallyIncreasingTime() - delayAsNegativeTimeOffset;
-    m_animations.add(TextureMapperAnimation(keyframesName, valueList, boxSize, *anim, listsMatch, m_lastAnimationStartTime, 0, TextureMapperAnimation::AnimationState::Playing));
+    m_lastAnimationStartTime = MonotonicTime::now() - Seconds(delayAsNegativeTimeOffset);
+    m_animations.add(TextureMapperAnimation(keyframesName, valueList, boxSize, *anim, listsMatch, m_lastAnimationStartTime, 0_s, TextureMapperAnimation::AnimationState::Playing));
     m_animationStartedTimer.startOneShot(0_s);
     didChangeAnimations();
     return true;
@@ -1165,7 +1165,7 @@ bool CoordinatedGraphicsLayer::addAnimation(const KeyframeValueList& valueList,
 
 void CoordinatedGraphicsLayer::pauseAnimation(const String& animationName, double time)
 {
-    m_animations.pause(animationName, time);
+    m_animations.pause(animationName, Seconds(time));
     didChangeAnimations();
 }
 
@@ -1175,7 +1175,7 @@ void CoordinatedGraphicsLayer::removeAnimation(const String& animationName)
     didChangeAnimations();
 }
 
-void CoordinatedGraphicsLayer::suspendAnimations(double time)
+void CoordinatedGraphicsLayer::suspendAnimations(MonotonicTime time)
 {
     m_animations.suspend(time);
     didChangeAnimations();
index 33dbdd1..fd961fa 100644 (file)
@@ -108,7 +108,7 @@ public:
     bool addAnimation(const KeyframeValueList&, const FloatSize&, const Animation*, const String&, double) override;
     void pauseAnimation(const String&, double) override;
     void removeAnimation(const String&) override;
-    void suspendAnimations(double time) override;
+    void suspendAnimations(MonotonicTime) override;
     void resumeAnimations() override;
     bool usesContentsLayer() const override { return m_platformLayer || m_compositedImage; }
 
@@ -228,7 +228,7 @@ private:
     PlatformLayer* m_platformLayer;
     Timer m_animationStartedTimer;
     TextureMapperAnimations m_animations;
-    double m_lastAnimationStartTime { 0.0 };
+    MonotonicTime m_lastAnimationStartTime;
 
     ScrollableArea* m_scrollableArea;
 };
index 91e0ac4..24b88e4 100644 (file)
@@ -219,7 +219,7 @@ public:
     void captureFailed();
 
     // Testing only
-    virtual void delaySamples(float) { };
+    virtual void delaySamples(Seconds) { };
 
 protected:
     RealtimeMediaSource(const String& id, Type, const String& name);
index 359dc11..70447f9 100644 (file)
@@ -177,8 +177,8 @@ void RealtimeOutgoingVideoSource::sendOneBlackFrame()
 
 void RealtimeOutgoingVideoSource::sendFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer)
 {
-    int64_t timestampMicroSeconds = monotonicallyIncreasingTimeMS() * 1000;
-    webrtc::VideoFrame frame(buffer, m_shouldApplyRotation ? webrtc::kVideoRotation_0 : m_currentRotation, timestampMicroSeconds);
+    MonotonicTime timestamp = MonotonicTime::now();
+    webrtc::VideoFrame frame(buffer, m_shouldApplyRotation ? webrtc::kVideoRotation_0 : m_currentRotation, static_cast<int64_t>(timestamp.secondsSinceEpoch().microseconds()));
     for (auto* sink : m_sinks)
         sink->OnFrame(frame);
 }
index 4f6ad4e..d88c389 100644 (file)
@@ -28,7 +28,7 @@
 
 #if USE(LIBWEBRTC)
 
-#include <wtf/CurrentTime.h>
+#include <wtf/MonotonicTime.h>
 
 namespace WebCore {
 
@@ -78,12 +78,12 @@ const unsigned bytesPerSample = 2;
 
 void LibWebRTCAudioModule::StartPlayoutOnAudioThread()
 {
-    double startTime = WTF::monotonicallyIncreasingTimeMS();
+    MonotonicTime startTime = MonotonicTime::now();
     while (true) {
         PollFromSource();
 
-        double now = WTF::monotonicallyIncreasingTimeMS();
-        double sleepFor = pollInterval - remainder(now - startTime, pollInterval);
+        MonotonicTime now = MonotonicTime::now();
+        double sleepFor = pollInterval - remainder((now - startTime).milliseconds(), pollInterval);
         m_audioTaskRunner->SleepMs(sleepFor);
         if (!m_isPlaying)
             return;
index cb4368a..2763189 100644 (file)
@@ -109,23 +109,23 @@ void DisplayCaptureSourceCocoa::startProducingData()
     RealtimeMediaSourceCenter::singleton().videoFactory().setActiveSource(*this);
 #endif
 
-    m_startTime = monotonicallyIncreasingTime();
+    m_startTime = MonotonicTime::now();
     m_timer.startRepeating(1_ms * lround(1000 / frameRate()));
 }
 
 void DisplayCaptureSourceCocoa::stopProducingData()
 {
     m_timer.stop();
-    m_elapsedTime += monotonicallyIncreasingTime() - m_startTime;
-    m_startTime = NAN;
+    m_elapsedTime += MonotonicTime::now() - m_startTime;
+    m_startTime = MonotonicTime::nan();
 }
 
-double DisplayCaptureSourceCocoa::elapsedTime()
+Seconds DisplayCaptureSourceCocoa::elapsedTime()
 {
     if (std::isnan(m_startTime))
         return m_elapsedTime;
 
-    return m_elapsedTime + (monotonicallyIncreasingTime() - m_startTime);
+    return m_elapsedTime + (MonotonicTime::now() - m_startTime);
 }
 
 bool DisplayCaptureSourceCocoa::applyFrameRate(double rate)
index 2cec9dc..8b2bcef 100644 (file)
@@ -53,7 +53,7 @@ protected:
     void startProducingData() override;
     void stopProducingData() override;
 
-    double elapsedTime();
+    Seconds elapsedTime();
     bool applyFrameRate(double) override;
 
 private:
@@ -70,8 +70,8 @@ private:
     mutable std::optional<RealtimeMediaSourceSettings> m_currentSettings;
     RealtimeMediaSourceSupportedConstraints m_supportedConstraints;
 
-    double m_startTime { NAN };
-    double m_elapsedTime { 0 };
+    MonotonicTime m_startTime { MonotonicTime::nan() };
+    Seconds m_elapsedTime { 0_s };
 
     RunLoop::Timer<DisplayCaptureSourceCocoa> m_timer;
 };
index bad53f7..6d14b03 100644 (file)
@@ -54,7 +54,7 @@ private:
     bool applySampleSize(int) final { return false; }
 
     void emitSampleBuffers(uint32_t);
-    void render(double) final;
+    void render(Seconds) final;
     void reconfigure();
 
     std::unique_ptr<WebAudioBufferList> m_audioBufferList;
index bb5471d..0b4229d 100644 (file)
@@ -130,12 +130,12 @@ void MockRealtimeAudioSourceMac::reconfigure()
     m_formatDescription = adoptCF(formatDescription);
 }
 
-void MockRealtimeAudioSourceMac::render(double delta)
+void MockRealtimeAudioSourceMac::render(Seconds delta)
 {
     if (!m_audioBufferList)
         reconfigure();
 
-    uint32_t totalFrameCount = alignTo16Bytes(delta * sampleRate());
+    uint32_t totalFrameCount = alignTo16Bytes(delta.seconds() * sampleRate());
     uint32_t frameCount = std::min(totalFrameCount, m_maximiumFrameCount);
 
     while (frameCount) {
index e1fced1..8a63fd3 100644 (file)
@@ -71,7 +71,7 @@ RetainPtr<CMSampleBufferRef> MockRealtimeVideoSourceMac::CMSampleBufferFromPixel
         if (!pixelBuffer)
         return nullptr;
 
-    CMTime sampleTime = CMTimeMake((elapsedTime() + .1) * videoSampleRate, videoSampleRate);
+    CMTime sampleTime = CMTimeMake(((elapsedTime() + 100_ms) * videoSampleRate).seconds(), videoSampleRate);
     CMSampleTimingInfo timingInfo = { kCMTimeInvalid, sampleTime, sampleTime };
 
     CMVideoFormatDescriptionRef formatDescription = nullptr;
index 96cfcba..07bc3f8 100644 (file)
@@ -106,7 +106,7 @@ private:
 
     OSObjectPtr<dispatch_queue_t> m_captureQueue;
 
-    double m_lastFrameTime { NAN };
+    MonotonicTime m_lastFrameTime { MonotonicTime::nan() };
     uint32_t m_displayID { 0 };
     bool m_isRunning { false };
     bool m_observingDisplayChanges { false };
index fed6ee5..f433cc5 100644 (file)
@@ -220,7 +220,7 @@ RetainPtr<CMSampleBufferRef> ScreenDisplayCaptureSourceMac::sampleBufferFromPixe
     if (!pixelBuffer)
         return nullptr;
 
-    CMTime sampleTime = CMTimeMake((elapsedTime() + .1) * 100, 100);
+    CMTime sampleTime = CMTimeMake(((elapsedTime() + 100_ms) * 100).seconds(), 100);
     CMSampleTimingInfo timingInfo = { kCMTimeInvalid, sampleTime, sampleTime };
 
     CMVideoFormatDescriptionRef formatDescription = nullptr;
@@ -388,7 +388,7 @@ void ScreenDisplayCaptureSourceMac::frameAvailable(CGDisplayStreamFrameStatus st
         return;
 
     LockHolder lock(m_currentFrameMutex);
-    m_lastFrameTime = monotonicallyIncreasingTime();
+    m_lastFrameTime = MonotonicTime::now();
     m_currentFrame = frameSurface;
 }
 
index 266f685..c50abcb 100644 (file)
@@ -120,46 +120,46 @@ void MockRealtimeAudioSource::startProducingData()
     if (!sampleRate())
         setSampleRate(device() == MockRealtimeMediaSource::MockDevice::Microphone1 ? 44100 : 48000);
 
-    m_startTime = monotonicallyIncreasingTime();
+    m_startTime = MonotonicTime::now();
     m_timer.startRepeating(renderInterval());
 }
 
 void MockRealtimeAudioSource::stopProducingData()
 {
     m_timer.stop();
-    m_elapsedTime += monotonicallyIncreasingTime() - m_startTime;
-    m_startTime = NAN;
+    m_elapsedTime += MonotonicTime::now() - m_startTime;
+    m_startTime = MonotonicTime::nan();
 }
 
-double MockRealtimeAudioSource::elapsedTime()
+Seconds MockRealtimeAudioSource::elapsedTime()
 {
     if (std::isnan(m_startTime))
         return m_elapsedTime;
 
-    return m_elapsedTime + (monotonicallyIncreasingTime() - m_startTime);
+    return m_elapsedTime + (MonotonicTime::now() - m_startTime);
 }
 
 void MockRealtimeAudioSource::tick()
 {
     if (std::isnan(m_lastRenderTime))
-        m_lastRenderTime = monotonicallyIncreasingTime();
+        m_lastRenderTime = MonotonicTime::now();
 
-    double now = monotonicallyIncreasingTime();
+    MonotonicTime now = MonotonicTime::now();
 
     if (m_delayUntil) {
         if (m_delayUntil < now)
             return;
-        m_delayUntil = 0;
+        m_delayUntil = MonotonicTime();
     }
 
-    double delta = now - m_lastRenderTime;
+    Seconds delta = now - m_lastRenderTime;
     m_lastRenderTime = now;
     render(delta);
 }
 
-void MockRealtimeAudioSource::delaySamples(float delta)
+void MockRealtimeAudioSource::delaySamples(Seconds delta)
 {
-    m_delayUntil = monotonicallyIncreasingTime() + delta;
+    m_delayUntil = MonotonicTime::now() + delta;
 }
 
 } // namespace WebCore
index cb4ff79..381a444 100644 (file)
@@ -53,9 +53,9 @@ protected:
     void startProducingData() final;
     void stopProducingData() final;
 
-    virtual void render(double) { }
+    virtual void render(Seconds) { }
 
-    double elapsedTime();
+    Seconds elapsedTime();
     static Seconds renderInterval() { return 60_ms; }
 
 private:
@@ -73,13 +73,13 @@ private:
 
     bool isCaptureSource() const final { return true; }
 
-    void delaySamples(float) final;
+    void delaySamples(Seconds) final;
 
     RunLoop::Timer<MockRealtimeAudioSource> m_timer;
-    double m_startTime { NAN };
-    double m_lastRenderTime { NAN };
-    double m_elapsedTime { 0 };
-    double m_delayUntil { 0 };
+    MonotonicTime m_startTime { MonotonicTime::nan() };
+    MonotonicTime m_lastRenderTime { MonotonicTime::nan() };
+    Seconds m_elapsedTime { 0_s };
+    MonotonicTime m_delayUntil;
 };
 
 } // namespace WebCore
index 5fdc3f5..c405c9e 100644 (file)
@@ -154,23 +154,23 @@ void MockRealtimeVideoSource::startProducingData()
         setHeight(480);
     }
 
-    m_startTime = monotonicallyIncreasingTime();
+    m_startTime = MonotonicTime::now();
     m_timer.startRepeating(1_ms * lround(1000 / frameRate()));
 }
 
 void MockRealtimeVideoSource::stopProducingData()
 {
     m_timer.stop();
-    m_elapsedTime += monotonicallyIncreasingTime() - m_startTime;
-    m_startTime = NAN;
+    m_elapsedTime += MonotonicTime::now() - m_startTime;
+    m_startTime = MonotonicTime::nan();
 }
 
-double MockRealtimeVideoSource::elapsedTime()
+Seconds MockRealtimeVideoSource::elapsedTime()
 {
     if (std::isnan(m_startTime))
         return m_elapsedTime;
 
-    return m_elapsedTime + (monotonicallyIncreasingTime() - m_startTime);
+    return m_elapsedTime + (MonotonicTime::now() - m_startTime);
 }
 
 void MockRealtimeVideoSource::updateSettings(RealtimeMediaSourceSettings& settings)
@@ -326,7 +326,7 @@ void MockRealtimeVideoSource::drawBoxes(GraphicsContext& context)
 
 void MockRealtimeVideoSource::drawText(GraphicsContext& context)
 {
-    unsigned milliseconds = lround(elapsedTime() * 1000);
+    unsigned milliseconds = lround(elapsedTime().milliseconds());
     unsigned seconds = milliseconds / 1000 % 60;
     unsigned minutes = seconds / 60 % 60;
     unsigned hours = minutes / 60 % 60;
@@ -409,17 +409,17 @@ void MockRealtimeVideoSource::drawText(GraphicsContext& context)
     }
 }
 
-void MockRealtimeVideoSource::delaySamples(float delta)
+void MockRealtimeVideoSource::delaySamples(Seconds delta)
 {
-    m_delayUntil = monotonicallyIncreasingTime() + delta;
+    m_delayUntil = MonotonicTime::now() + delta;
 }
 
 void MockRealtimeVideoSource::generateFrame()
 {
     if (m_delayUntil) {
-        if (m_delayUntil < monotonicallyIncreasingTime())
+        if (m_delayUntil < MonotonicTime::now())
             return;
-        m_delayUntil = 0;
+        m_delayUntil = MonotonicTime();
     }
 
     ImageBuffer* buffer = imageBuffer();
index 94c8be9..bd52682 100644 (file)
@@ -58,7 +58,7 @@ protected:
 
     ImageBuffer* imageBuffer() const;
 
-    double elapsedTime();
+    Seconds elapsedTime();
     bool applySize(const IntSize&) override;
 
 private:
@@ -81,7 +81,7 @@ private:
 
     void generateFrame();
 
-    void delaySamples(float) override;
+    void delaySamples(Seconds) override;
 
     bool mockCamera() const { return device() == MockDevice::Camera1 || device() == MockDevice::Camera2; }
     bool mockScreen() const { return device() == MockDevice::Screen1 || device() == MockDevice::Screen2; }
@@ -95,9 +95,9 @@ private:
     Path m_path;
     DashArray m_dashWidths;
 
-    double m_startTime { NAN };
-    double m_elapsedTime { 0 };
-    double m_delayUntil { 0 };
+    MonotonicTime m_startTime { MonotonicTime::nan() };
+    Seconds m_elapsedTime { 0_s };
+    MonotonicTime m_delayUntil;
 
     unsigned m_frameNumber { 0 };
 
index a8c2df4..6a01b73 100644 (file)
@@ -61,7 +61,6 @@ DNSResolveQueue::DNSResolveQueue()
     : m_timer(*this, &DNSResolveQueue::timerFired)
     , m_requestsInFlight(0)
     , m_isUsingProxy(true)
-    , m_lastProxyEnabledStatusCheckTime(0)
 {
     // isUsingProxy will return the initial value of m_isUsingProxy at first on
     // platforms that have an asynchronous implementation of updateIsUsingProxy,
@@ -74,8 +73,8 @@ DNSResolveQueue::DNSResolveQueue()
 // fake internal address, local caches may keep it even after re-connecting to another network.
 bool DNSResolveQueue::isUsingProxy()
 {
-    double time = monotonicallyIncreasingTime();
-    static const double minimumProxyCheckDelay = 5;
+    MonotonicTime time = MonotonicTime::now();
+    static const Seconds minimumProxyCheckDelay = 5_s;
     if (time - m_lastProxyEnabledStatusCheckTime > minimumProxyCheckDelay) {
         m_lastProxyEnabledStatusCheckTime = time;
         updateIsUsingProxy();
index d2a7a77..07b8fdc 100644 (file)
@@ -62,7 +62,7 @@ private:
     HashSet<String> m_names;
     std::atomic<int> m_requestsInFlight;
     bool m_isUsingProxy;
-    double m_lastProxyEnabledStatusCheckTime;
+    MonotonicTime m_lastProxyEnabledStatusCheckTime;
 };
 
 }
index 03608a2..fbaae92 100644 (file)
@@ -201,7 +201,7 @@ void RenderBoxModelObject::animationFinished(const String& name)
     layer()->backing()->animationFinished(name);
 }
 
-void RenderBoxModelObject::suspendAnimations(double time)
+void RenderBoxModelObject::suspendAnimations(MonotonicTime time)
 {
     ASSERT(hasLayer());
     ASSERT(isComposited());
index d91c74e..5333823 100644 (file)
@@ -231,7 +231,7 @@ public:
     void animationPaused(double timeOffset, const String& name);
     void animationFinished(const String& name);
 
-    void suspendAnimations(double time = 0);
+    void suspendAnimations(MonotonicTime = MonotonicTime());
 
     RenderBoxModelObject* continuation() const;
     WEBCORE_EXPORT RenderInline* inlineContinuation() const;
index bc79252..180cd09 100644 (file)
@@ -1857,9 +1857,9 @@ void RenderElement::paintFocusRing(PaintInfo& paintInfo, const RenderStyle& styl
             for (auto rect : pixelSnappedFocusRingRects)
                 path.addRect(rect);
         }
-        paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet(), needsRepaint);
+        paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint);
     } else
-        paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, page().focusController().timeSinceFocusWasSet(), needsRepaint);
+        paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint);
     if (needsRepaint)
         page().focusController().setFocusedElementNeedsRepaint();
 #else
index f34ed10..02094a3 100644 (file)
@@ -543,7 +543,7 @@ void RenderImage::paintAreaElementFocusRing(PaintInfo& paintInfo, const LayoutPo
 
 #if PLATFORM(MAC)
     bool needsRepaint;
-    paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet(), needsRepaint);
+    paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint);
     if (needsRepaint)
         page().focusController().setFocusedElementNeedsRepaint();
 #else
index 3d1a600..d7dc176 100644 (file)
@@ -2864,7 +2864,7 @@ void RenderLayerBacking::transitionFinished(CSSPropertyID property)
         m_graphicsLayer->removeAnimation(GraphicsLayer::animationNameForTransition(animatedProperty));
 }
 
-void RenderLayerBacking::notifyAnimationStarted(const GraphicsLayer*, const String&, double time)
+void RenderLayerBacking::notifyAnimationStarted(const GraphicsLayer*, const String&, MonotonicTime time)
 {
     renderer().animation().notifyAnimationStarted(renderer(), time);
 }
@@ -2882,7 +2882,7 @@ void RenderLayerBacking::notifyFlushBeforeDisplayRefresh(const GraphicsLayer* la
 }
 
 // This is used for the 'freeze' API, for testing only.
-void RenderLayerBacking::suspendAnimations(double time)
+void RenderLayerBacking::suspendAnimations(MonotonicTime time)
 {
     m_graphicsLayer->suspendAnimations(time);
 }
index 3447ca6..5e57a3e 100644 (file)
@@ -169,7 +169,7 @@ public:
     void animationPaused(double timeOffset, const String& name);
     void animationFinished(const String& name);
 
-    void suspendAnimations(double time = 0);
+    void suspendAnimations(MonotonicTime = MonotonicTime());
     void resumeAnimations();
 
     LayoutRect compositedBounds() const;
@@ -191,7 +191,7 @@ public:
 
     // GraphicsLayerClient interface
     void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) override;
-    void notifyAnimationStarted(const GraphicsLayer*, const String& animationKey, double startTime) override;
+    void notifyAnimationStarted(const GraphicsLayer*, const String& animationKey, MonotonicTime startTime) override;
     void notifyFlushRequired(const GraphicsLayer*) override;
     void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) override;
 
index c10dc85..d906785 100644 (file)
@@ -560,7 +560,7 @@ void RenderLayerCompositor::didFlushChangesForLayer(RenderLayer& layer, const Gr
 void RenderLayerCompositor::didPaintBacking(RenderLayerBacking*)
 {
     auto& frameView = m_renderView.frameView();
-    frameView.setLastPaintTime(monotonicallyIncreasingTime());
+    frameView.setLastPaintTime(MonotonicTime::now());
     if (frameView.milestonesPendingPaint())
         frameView.firePaintRelatedMilestonesIfNeeded();
 }
index c078cd2..a5b34f6 100644 (file)
@@ -34,9 +34,6 @@ WTF_MAKE_ISO_ALLOCATED_IMPL(RenderProgress);
 RenderProgress::RenderProgress(HTMLElement& element, RenderStyle&& style)
     : RenderBlockFlow(element, WTFMove(style))
     , m_position(HTMLProgressElement::InvalidPosition)
-    , m_animationStartTime(0)
-    , m_animationDuration(0)
-    , m_animating(false)
     , m_animationTimer(*this, &RenderProgress::animationTimerFired)
 {
 }
@@ -70,7 +67,7 @@ RenderBox::LogicalExtentComputedValues RenderProgress::computeLogicalHeight(Layo
 
 double RenderProgress::animationProgress() const
 {
-    return m_animating ? (fmod((monotonicallyIncreasingTime() - m_animationStartTime), m_animationDuration) / m_animationDuration) : 0;
+    return m_animating ? (fmod((MonotonicTime::now() - m_animationStartTime).seconds(), m_animationDuration.seconds()) / m_animationDuration.seconds()) : 0;
 }
 
 bool RenderProgress::isDeterminate() const
@@ -91,13 +88,13 @@ void RenderProgress::updateAnimationState()
     m_animationDuration = theme().animationDurationForProgressBar(*this);
     m_animationRepeatInterval = theme().animationRepeatIntervalForProgressBar(*this);
 
-    bool animating = style().hasAppearance() && m_animationDuration > 0;
+    bool animating = style().hasAppearance() && m_animationDuration > 0_s;
     if (animating == m_animating)
         return;
 
     m_animating = animating;
     if (m_animating) {
-        m_animationStartTime = monotonicallyIncreasingTime();
+        m_animationStartTime = MonotonicTime::now();
         m_animationTimer.startOneShot(m_animationRepeatInterval);
     } else
         m_animationTimer.stop();
index d57a19c..3e12ac7 100644 (file)
@@ -34,7 +34,7 @@ public:
 
     double position() const { return m_position; }
     double animationProgress() const;
-    double animationStartTime() const { return m_animationStartTime; }
+    MonotonicTime animationStartTime() const { return m_animationStartTime; }
 
     bool isDeterminate() const;
     void updateFromElement() override;
@@ -50,10 +50,10 @@ private:
     void updateAnimationState();
 
     double m_position;
-    double m_animationStartTime;
-    Seconds m_animationRepeatInterval;
-    double m_animationDuration;
-    bool m_animating;
+    MonotonicTime m_animationStartTime;
+    Seconds m_animationRepeatInterval { 0_s };
+    Seconds m_animationDuration { 0_s };
+    bool m_animating { false };
     Timer m_animationTimer;
 };
 
index 978e95c..ca3b3a4 100644 (file)
@@ -1079,9 +1079,9 @@ Seconds RenderTheme::animationRepeatIntervalForProgressBar(RenderProgress&) cons
     return 0_s;
 }
 
-double RenderTheme::animationDurationForProgressBar(RenderProgress&) const
+Seconds RenderTheme::animationDurationForProgressBar(RenderProgress&) const
 {
-    return 0;
+    return 0_s;
 }
 
 void RenderTheme::adjustProgressBarStyle(StyleResolver&, RenderStyle&, const Element*) const
index e2472e0..de46672 100644 (file)
@@ -179,7 +179,7 @@ public:
     // Returns the repeat interval of the animation for the progress bar.
     virtual Seconds animationRepeatIntervalForProgressBar(RenderProgress&) const;
     // Returns the duration of the animation for the progress bar.
-    virtual double animationDurationForProgressBar(RenderProgress&) const;
+    virtual Seconds animationDurationForProgressBar(RenderProgress&) const;
     virtual IntRect progressBarRectForBounds(const RenderObject&, const IntRect&) const;
 
 #if ENABLE(VIDEO)
index d81edb2..9f7adeb 100644 (file)
@@ -1965,9 +1965,9 @@ Seconds RenderThemeGtk::animationRepeatIntervalForProgressBar(RenderProgress&) c
     return progressAnimationInterval;
 }
 
-double RenderThemeGtk::animationDurationForProgressBar(RenderProgress&) const
+Seconds RenderThemeGtk::animationDurationForProgressBar(RenderProgress&) const
 {
-    return progressAnimationInterval.value() * progressAnimationFrames * 2; // "2" for back and forth;
+    return progressAnimationInterval * progressAnimationFrames * 2; // "2" for back and forth;
 }
 
 IntRect RenderThemeGtk::calculateProgressRect(const RenderObject& renderObject, const IntRect& fullBarRect)
index 012fdde..63a2bb0 100644 (file)
@@ -169,7 +169,7 @@ private:
 #endif
 
     Seconds animationRepeatIntervalForProgressBar(RenderProgress&) const override;
-    double animationDurationForProgressBar(RenderProgress&) const override;
+    Seconds animationDurationForProgressBar(RenderProgress&) const override;
     void adjustProgressBarStyle(StyleResolver&, RenderStyle&, const Element*) const override;
     IntRect progressBarRectForBounds(const RenderObject&, const IntRect&) const override;
     bool paintProgressBar(const RenderObject&, const PaintInfo&, const IntRect&) override;
index 641e434..961d60d 100644 (file)
@@ -84,7 +84,7 @@ protected:
     // Returns the repeat interval of the animation for the progress bar.
     Seconds animationRepeatIntervalForProgressBar(RenderProgress&) const override;
     // Returns the duration of the animation for the progress bar.
-    double animationDurationForProgressBar(RenderProgress&) const override;
+    Seconds animationDurationForProgressBar(RenderProgress&) const override;
 
     bool paintProgressBar(const RenderObject&, const PaintInfo&, const IntRect&) override;
 
index 9f2338c..c7a5226 100644 (file)
@@ -870,9 +870,9 @@ Seconds RenderThemeIOS::animationRepeatIntervalForProgressBar(RenderProgress&) c
     return 0_s;
 }
 
-double RenderThemeIOS::animationDurationForProgressBar(RenderProgress&) const
+Seconds RenderThemeIOS::animationDurationForProgressBar(RenderProgress&) const
 {
-    return 0;
+    return 0_s;
 }
 
 bool RenderThemeIOS::paintProgressBar(const RenderObject& renderer, const PaintInfo& paintInfo, const IntRect& rect)
index a4874a0..5dde57b 100644 (file)
@@ -88,7 +88,7 @@ public:
     // Returns the repeat interval of the animation for the progress bar.
     Seconds animationRepeatIntervalForProgressBar(RenderProgress&) const final;
     // Returns the duration of the animation for the progress bar.
-    double animationDurationForProgressBar(RenderProgress&) const final;
+    Seconds animationDurationForProgressBar(RenderProgress&) const final;
     IntRect progressBarRectForBounds(const RenderObject&, const IntRect&) const final;
 
     // Controls color values returned from platformFocusRingColor(). systemColor() will be used when false.
index d8cab2c..df0c565 100644 (file)
@@ -1078,9 +1078,9 @@ Seconds RenderThemeMac::animationRepeatIntervalForProgressBar(RenderProgress&) c
     return progressAnimationFrameRate;
 }
 
-double RenderThemeMac::animationDurationForProgressBar(RenderProgress&) const
+Seconds RenderThemeMac::animationDurationForProgressBar(RenderProgress&) const
 {
-    return progressAnimationNumFrames * progressAnimationFrameRate.value();
+    return progressAnimationFrameRate * progressAnimationNumFrames;
 }
 
 void RenderThemeMac::adjustProgressBarStyle(StyleResolver&, RenderStyle&, const Element*) const
index b73b56d..4156f18 100644 (file)
@@ -39,17 +39,8 @@ static const Seconds SMILAnimationFrameDelay { 1_s / 60. };
 static const Seconds SMILAnimationFrameThrottledDelay { 1_s / 30. };
 
 SMILTimeContainer::SMILTimeContainer(SVGSVGElement& owner)
-    : m_beginTime(0)
-    , m_pauseTime(0)
-    , m_accumulatedActiveTime(0)
-    , m_resumeTime(0)
-    , m_presetStartTime(0)
-    , m_documentOrderIndexesDirty(false)
-    , m_timer(*this, &SMILTimeContainer::timerFired)
+    : m_timer(*this, &SMILTimeContainer::timerFired)
     , m_ownerSVGElement(owner)
-#ifndef NDEBUG
-    , m_preventScheduledAnimationsChanges(false)
-#endif
 {
 }
 
@@ -115,37 +106,37 @@ Seconds SMILTimeContainer::animationFrameDelay() const
 SMILTime SMILTimeContainer::elapsed() const
 {
     if (!m_beginTime)
-        return 0;
+        return 0_s;
     if (isPaused())
         return m_accumulatedActiveTime;
-    return monotonicallyIncreasingTime() + m_accumulatedActiveTime - m_resumeTime;
+    return MonotonicTime::now() + m_accumulatedActiveTime - m_resumeTime;
 }
 
 bool SMILTimeContainer::isActive() const
 {
-    return m_beginTime && !isPaused();
+    return !!m_beginTime && !isPaused();
 }
 
 bool SMILTimeContainer::isPaused() const
 {
-    return m_pauseTime;
+    return !!m_pauseTime;
 }
 
 bool SMILTimeContainer::isStarted() const
 {
-    return m_beginTime;
+    return !!m_beginTime;
 }
 
 void SMILTimeContainer::begin()
 {
     ASSERT(!m_beginTime);
-    double now = monotonicallyIncreasingTime();
+    MonotonicTime now = MonotonicTime::now();
 
     // If 'm_presetStartTime' is set, the timeline was modified via setElapsed() before the document began.
     // In this case pass on 'seekToTime=true' to updateAnimations().
     m_beginTime = m_resumeTime = now - m_presetStartTime;
     updateAnimations(SMILTime(m_presetStartTime), m_presetStartTime ? true : false);
-    m_presetStartTime = 0;
+    m_presetStartTime = 0_s;
 
     if (m_pauseTime) {
         m_pauseTime = now;
@@ -157,7 +148,7 @@ void SMILTimeContainer::pause()
 {
     ASSERT(!isPaused());
 
-    m_pauseTime = monotonicallyIncreasingTime();
+    m_pauseTime = MonotonicTime::now();
     if (m_beginTime) {
         m_accumulatedActiveTime += m_pauseTime - m_resumeTime;
         m_timer.stop();
@@ -168,8 +159,8 @@ void SMILTimeContainer::resume()
 {
     ASSERT(isPaused());
 
-    m_resumeTime = monotonicallyIncreasingTime();
-    m_pauseTime = 0;
+    m_resumeTime = MonotonicTime::now();
+    m_pauseTime = MonotonicTime();
     startTimer(elapsed(), 0);
 }
 
@@ -177,19 +168,19 @@ void SMILTimeContainer::setElapsed(SMILTime time)
 {
     // If the documment didn't begin yet, record a new start time, we'll seek to once its possible.
     if (!m_beginTime) {
-        m_presetStartTime = time.value();
+        m_presetStartTime = Seconds(time.value());
         return;
     }
 
     if (m_beginTime)
         m_timer.stop();
 
-    double now = monotonicallyIncreasingTime();
-    m_beginTime = now - time.value();
+    MonotonicTime now = MonotonicTime::now();
+    m_beginTime = now - Seconds { time.value() };
 
     if (m_pauseTime) {
         m_resumeTime = m_pauseTime = now;
-        m_accumulatedActiveTime = time.value();
+        m_accumulatedActiveTime = Seconds(time.value());
     } else
         m_resumeTime = m_beginTime;
 
@@ -221,7 +212,7 @@ void SMILTimeContainer::startTimer(SMILTime elapsed, SMILTime fireTime, SMILTime
 
 void SMILTimeContainer::timerFired()
 {
-    ASSERT(m_beginTime);
+    ASSERT(!!m_beginTime);
     ASSERT(!m_pauseTime);
     updateAnimations(elapsed());
 }
index 8d6367c..d8fc4f8 100644 (file)
@@ -73,13 +73,13 @@ private:
     void updateDocumentOrderIndexes();
     void sortByPriority(Vector<SVGSMILElement*>& smilElements, SMILTime elapsed);
 
-    double m_beginTime;
-    double m_pauseTime;
-    double m_accumulatedActiveTime;
-    double m_resumeTime;
-    double m_presetStartTime;
+    MonotonicTime m_beginTime;
+    MonotonicTime m_pauseTime;
+    Seconds m_accumulatedActiveTime { 0_s };
+    MonotonicTime m_resumeTime;
+    Seconds m_presetStartTime { 0_s };
 
-    bool m_documentOrderIndexesDirty;
+    bool m_documentOrderIndexesDirty { false };
     
     Timer m_timer;
 
@@ -91,7 +91,7 @@ private:
     SVGSVGElement& m_ownerSVGElement;
 
 #ifndef NDEBUG
-    bool m_preventScheduledAnimationsChanges;
+    bool m_preventScheduledAnimationsChanges { false };
 #endif
 };
 
index 6e92475..d84be49 100644 (file)
@@ -4256,7 +4256,7 @@ ExceptionOr<void> Internals::setMediaDeviceState(const String& id, const String&
 
 void Internals::delayMediaStreamTrackSamples(MediaStreamTrack& track, float delay)
 {
-    track.source().delaySamples(delay);
+    track.source().delaySamples(Seconds { delay });
 }
 
 void Internals::setMediaStreamTrackMuted(MediaStreamTrack& track, bool muted)
index a49af87..9fb3346 100644 (file)
@@ -35,7 +35,7 @@ namespace WebCore {
 MockGamepad::MockGamepad(unsigned index, const String& gamepadID, unsigned axisCount, unsigned buttonCount)
     : PlatformGamepad(index)
 {
-    m_connectTime = m_lastUpdateTime = monotonicallyIncreasingTime();
+    m_connectTime = m_lastUpdateTime = MonotonicTime::now();
     updateDetails(gamepadID, axisCount, buttonCount);
 }
 
@@ -44,7 +44,7 @@ void MockGamepad::updateDetails(const String& gamepadID, unsigned axisCount, uns
     m_id = gamepadID;
     m_axisValues = Vector<double>(axisCount, 0.0);
     m_buttonValues = Vector<double>(buttonCount, 0.0);
-    m_lastUpdateTime = monotonicallyIncreasingTime();
+    m_lastUpdateTime = MonotonicTime::now();
 }
 
 bool MockGamepad::setAxisValue(unsigned index, double value)
@@ -55,7 +55,7 @@ bool MockGamepad::setAxisValue(unsigned index, double value)
     }
 
     m_axisValues[index] = value;
-    m_lastUpdateTime = monotonicallyIncreasingTime();
+    m_lastUpdateTime = MonotonicTime::now();
     return true;
 }
 
@@ -67,7 +67,7 @@ bool MockGamepad::setButtonValue(unsigned index, double value)
     }
 
     m_buttonValues[index] = value;
-    m_lastUpdateTime = monotonicallyIncreasingTime();
+    m_lastUpdateTime = MonotonicTime::now();
     return true;
 }
 
index 4127063..31cc1ca 100644 (file)
@@ -1,3 +1,67 @@
+2018-03-01  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Remove monotonicallyIncreasingTime
+        https://bugs.webkit.org/show_bug.cgi?id=182911
+
+        Reviewed by Michael Catanzaro.
+
+        * NetworkProcess/cache/CacheStorageEngineCache.cpp:
+        (WebKit::CacheStorage::Cache::toRecordInformation):
+        * Platform/IPC/ArgumentCoders.cpp:
+        (IPC::ArgumentCoder<Seconds>::encode):
+        (IPC::ArgumentCoder<Seconds>::decode):
+        (IPC::ArgumentCoder<MonotonicTime>::encode):
+        (IPC::ArgumentCoder<MonotonicTime>::decode):
+        * Platform/IPC/ArgumentCoders.h:
+        * Shared/Gamepad/GamepadData.cpp:
+        (WebKit::GamepadData::GamepadData):
+        * Shared/Gamepad/GamepadData.h:
+        (WebKit::GamepadData::lastUpdateTime const):
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<MonotonicTime>::encode): Deleted.
+        (IPC::ArgumentCoder<MonotonicTime>::decode): Deleted.
+        (IPC::ArgumentCoder<Seconds>::encode): Deleted.
+        (IPC::ArgumentCoder<Seconds>::decode): Deleted.
+        ArgumentCoders for MonotonicTime and Seconds are now used internally.
+        Move them to Platform/IPC/ArgumentCoders.h.
+
+        * Shared/WebCoreArgumentCoders.h:
+        * UIProcess/API/glib/IconDatabase.cpp:
+        (WebKit::IconDatabase::iconDatabaseSyncThread):
+        * UIProcess/DrawingAreaProxyImpl.cpp:
+        (WebKit::DrawingAreaProxyImpl::DrawingMonitor::start):
+        (WebKit::DrawingAreaProxyImpl::DrawingMonitor::stop):
+        (WebKit::DrawingAreaProxyImpl::DrawingMonitor::didDraw):
+        * UIProcess/DrawingAreaProxyImpl.h:
+        * UIProcess/Gamepad/UIGamepad.h:
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h:
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart):
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h:
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::animationDidStart):
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::acceleratedAnimationDidStart):
+        * WebProcess/WebPage/DrawingArea.messages.in:
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h:
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm:
+        (mediaTimeToCurrentTime):
+        (-[WKAnimationDelegate animationDidStart:]):
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::animationStarted):
+        This argument `beginTime` is not CFTimeInverval actually. We add currentTimeToMediaTime
+        conversion here to fix this issue.
+
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h:
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h:
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:
+        (WebKit::RemoteLayerTreeContext::animationDidStart):
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::destroyRenderingResources):
+
 2018-03-02  Brent Fulgham  <bfulgham@apple.com>
 
         [iOS] whitelist missing AppleJPEG logging feature
index 7aaf577..6e1f642 100644 (file)
@@ -99,7 +99,7 @@ static inline void updateVaryInformation(RecordInformation& recordInformation, c
 RecordInformation Cache::toRecordInformation(const Record& record)
 {
     Key key { ASCIILiteral("record"), m_uniqueName, { }, createCanonicalUUIDString(), m_caches.salt() };
-    RecordInformation recordInformation { WTFMove(key), monotonicallyIncreasingTimeMS(), record.identifier, 0 , record.responseBodySize, record.request.url(), false, { } };
+    RecordInformation recordInformation { WTFMove(key), MonotonicTime::now().secondsSinceEpoch().milliseconds(), record.identifier, 0 , record.responseBodySize, record.request.url(), false, { } };
 
     updateVaryInformation(recordInformation, record.request, record.response);
 
index d9e9fa4..f772102 100644 (file)
@@ -29,6 +29,7 @@
 #include "Encoder.h"
 #include <utility>
 #include <wtf/Forward.h>
+#include <wtf/MonotonicTime.h>
 #include <wtf/SHA1.h>
 #include <wtf/WallTime.h>
 
index 4e9cf87..905d827 100644 (file)
@@ -33,7 +33,7 @@
 
 namespace WebKit {
 
-GamepadData::GamepadData(unsigned index, const Vector<double>& axisValues, const Vector<double>& buttonValues, double lastUpdateTime)
+GamepadData::GamepadData(unsigned index, const Vector<double>& axisValues, const Vector<double>& buttonValues, MonotonicTime lastUpdateTime)
     : m_index(index)
     , m_axisValues(axisValues)
     , m_buttonValues(buttonValues)
@@ -41,7 +41,7 @@ GamepadData::GamepadData(unsigned index, const Vector<double>& axisValues, const
 {
 }
 
-GamepadData::GamepadData(unsigned index, const String& id, const Vector<double>& axisValues, const Vector<double>& buttonValues, double lastUpdateTime)
+GamepadData::GamepadData(unsigned index, const String& id, const Vector<double>& axisValues, const Vector<double>& buttonValues, MonotonicTime lastUpdateTime)
     : m_index(index)
     , m_id(id)
     , m_axisValues(axisValues)
index 059f2de..e80e04b 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(GAMEPAD)
 
+#include <wtf/MonotonicTime.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
@@ -44,15 +45,15 @@ public:
     {
     }
 
-    GamepadData(unsigned index, const Vector<double>& axisValues, const Vector<double>& buttonValues, double lastUpdateTime);
-    GamepadData(unsigned index, const String& id, const Vector<double>& axisValues, const Vector<double>& buttonValues, double lastUpdateTime);
+    GamepadData(unsigned index, const Vector<double>& axisValues, const Vector<double>& buttonValues, MonotonicTime lastUpdateTime);
+    GamepadData(unsigned index, const String& id, const Vector<double>& axisValues, const Vector<double>& buttonValues, MonotonicTime lastUpdateTime);
 
     void encode(IPC::Encoder&) const;
     static std::optional<GamepadData> decode(IPC::Decoder&);
 
     bool isNull() const { return m_isNull; }
 
-    double lastUpdateTime() const { return m_lastUpdateTime; }
+    MonotonicTime lastUpdateTime() const { return m_lastUpdateTime; }
     unsigned index() const { return m_index; }
     const String& id() const { return m_id; }
     const Vector<double>& axisValues() const { return m_axisValues; }
@@ -63,7 +64,7 @@ private:
     String m_id;
     Vector<double> m_axisValues;
     Vector<double> m_buttonValues;
-    double m_lastUpdateTime { 0.0 };
+    MonotonicTime m_lastUpdateTime;
 
     bool m_isNull { false };
 
index 08282a8..3a1bccf 100644 (file)
@@ -79,8 +79,6 @@
 #include <WebCore/ViewportArguments.h>
 #include <WebCore/WindowFeatures.h>
 #include <pal/SessionID.h>
-#include <wtf/MonotonicTime.h>
-#include <wtf/Seconds.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringHash.h>
 
@@ -174,36 +172,6 @@ static bool decodeTypesAndData(Decoder& decoder, Vector<String>& types, Vector<R
     return true;
 }
 
-void ArgumentCoder<MonotonicTime>::encode(Encoder& encoder, const MonotonicTime& time)
-{
-    encoder << time.secondsSinceEpoch().value();
-}
-
-bool ArgumentCoder<MonotonicTime>::decode(Decoder& decoder, MonotonicTime& time)
-{
-    double value;
-    if (!decoder.decode(value))
-        return false;
-
-    time = MonotonicTime::fromRawSeconds(value);
-    return true;
-}
-
-void ArgumentCoder<Seconds>::encode(Encoder& encoder, const Seconds& seconds)
-{
-    encoder << seconds.value();
-}
-
-bool ArgumentCoder<Seconds>::decode(Decoder& decoder, Seconds& seconds)
-{
-    double value;
-    if (!decoder.decode(value))
-        return false;
-
-    seconds = Seconds(value);
-    return true;
-}
-
 void ArgumentCoder<AffineTransform>::encode(Encoder& encoder, const AffineTransform& affineTransform)
 {
     SimpleArgumentCoder<AffineTransform>::encode(encoder, affineTransform);
index 6914c7d..3df7535 100644 (file)
 #include <WebCore/PaymentHeaders.h>
 #endif
 
-namespace WTF {
-class MonotonicTime;
-class Seconds;
-}
-
 namespace WebCore {
 class AffineTransform;
 class AuthenticationChallenge;
@@ -165,16 +160,6 @@ using IDBKeyPath = Variant<String, Vector<String>>;
 
 namespace IPC {
 
-template<> struct ArgumentCoder<WTF::MonotonicTime> {
-    static void encode(Encoder&, const WTF::MonotonicTime&);
-    static bool decode(Decoder&, WTF::MonotonicTime&);
-};
-
-template<> struct ArgumentCoder<WTF::Seconds> {
-    static void encode(Encoder&, const WTF::Seconds&);
-    static bool decode(Decoder&, WTF::Seconds&);
-};
-
 template<> struct ArgumentCoder<WebCore::AffineTransform> {
     static void encode(Encoder&, const WebCore::AffineTransform&);
     static bool decode(Decoder&, WebCore::AffineTransform&);
index 229f712..86c2cf6 100644 (file)
@@ -909,7 +909,7 @@ void IconDatabase::iconDatabaseSyncThread()
 #endif
 
     // Uncomment the following line to simulate a long lasting URL import (*HUGE* icon databases, or network home directories)
-    // while (monotonicallyIncreasingTime() - timeStamp < 10);
+    // while (MonotonicTime::now() - timeStamp < 10_s);
 
     // Read in URL mappings from the database
     LOG(IconDatabase, "(THREAD) Starting iconURL import");
index e542239..e002411 100644 (file)
@@ -224,7 +224,7 @@ int DrawingAreaProxyImpl::DrawingMonitor::webViewDrawCallback(DrawingAreaProxyIm
 
 void DrawingAreaProxyImpl::DrawingMonitor::start(WTF::Function<void (CallbackBase::Error)>&& callback)
 {
-    m_startTime = monotonicallyIncreasingTimeMS();
+    m_startTime = MonotonicTime::now();
     m_callback = WTFMove(callback);
 #if PLATFORM(GTK)
     g_signal_connect_swapped(m_webPage.viewWidget(), "draw", reinterpret_cast<GCallback>(webViewDrawCallback), this);
@@ -240,7 +240,7 @@ void DrawingAreaProxyImpl::DrawingMonitor::stop()
 #if PLATFORM(GTK)
     g_signal_handlers_disconnect_by_func(m_webPage.viewWidget(), reinterpret_cast<gpointer>(webViewDrawCallback), this);
 #endif
-    m_startTime = 0;
+    m_startTime = MonotonicTime();
     if (m_callback) {
         m_callback(CallbackBase::Error::None);
         m_callback = nullptr;
@@ -252,7 +252,7 @@ void DrawingAreaProxyImpl::DrawingMonitor::didDraw()
     // We wait up to 1 second for draw events. If there are several draw events queued quickly,
     // we want to wait until all of them have been processed, so after receiving a draw, we wait
     // up to 100ms for the next one or stop.
-    if (monotonicallyIncreasingTimeMS() - m_startTime > 1000)
+    if (MonotonicTime::now() - m_startTime > 1_s)
         stop();
     else
         m_timer.startOneShot(100_ms);
index 73533f4..9665225 100644 (file)
@@ -77,7 +77,7 @@ private:
         void didDraw();
 
         WebPageProxy& m_webPage;
-        double m_startTime { 0 };
+        MonotonicTime m_startTime;
         WTF::Function<void (CallbackBase::Error)> m_callback;
         RunLoop::Timer<DrawingMonitor> m_timer;
     };
index 0c47e85..9df6e21 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(GAMEPAD)
 
+#include <wtf/MonotonicTime.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
@@ -54,7 +55,7 @@ private:
     String m_id;
     Vector<double> m_axisValues;
     Vector<double> m_buttonValues;
-    double m_lastUpdateTime;
+    MonotonicTime m_lastUpdateTime;
 };
 
 }
index 204fef2..2ffc5ef 100644 (file)
@@ -45,7 +45,7 @@ public:
 
     const RemoteLayerTreeHost& remoteLayerTreeHost() const { return m_remoteLayerTreeHost; }
 
-    void acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime);
+    void acceleratedAnimationDidStart(uint64_t layerID, const String& key, MonotonicTime startTime);
     void acceleratedAnimationDidEnd(uint64_t layerID, const String& key);
 
     uint64_t nextLayerTreeTransactionID() const { return m_pendingLayerTreeTransactionID + 1; }
index 8093677..88e3ad4 100644 (file)
@@ -254,7 +254,7 @@ void RemoteLayerTreeDrawingAreaProxy::commitLayerTree(const RemoteLayerTreeTrans
     }
 }
 
-void RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime)
+void RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart(uint64_t layerID, const String& key, MonotonicTime startTime)
 {
     m_webPageProxy.process().send(Messages::DrawingArea::AcceleratedAnimationDidStart(layerID, key, startTime), m_webPageProxy.pageID());
 }
index 4a711f8..5a533d7 100644 (file)
@@ -58,7 +58,7 @@ public:
     typedef HashMap<WebCore::GraphicsLayer::PlatformLayerID, RetainPtr<WKAnimationDelegate>> LayerAnimationDelegateMap;
     LayerAnimationDelegateMap& animationDelegates() { return m_animationDelegates; }
 
-    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, CAAnimation *, double startTime);
+    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, CAAnimation *, MonotonicTime startTime);
     void animationDidEnd(WebCore::GraphicsLayer::PlatformLayerID, CAAnimation *);
 
     void clearLayers();
index 9df1dcf..bdc12f3 100644 (file)
@@ -158,7 +158,7 @@ void RemoteLayerTreeHost::layerWillBeRemoved(WebCore::GraphicsLayer::PlatformLay
     m_layers.remove(layerID);
 }
 
-void RemoteLayerTreeHost::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, CAAnimation *animation, double startTime)
+void RemoteLayerTreeHost::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, CAAnimation *animation, MonotonicTime startTime)
 {
     CALayer *layer = asLayer(getLayer(layerID));
     if (!layer)
index 4284dec..f7cdaf9 100644 (file)
@@ -91,7 +91,7 @@ public:
     virtual void setViewExposedRect(std::optional<WebCore::FloatRect>) = 0;
     virtual std::optional<WebCore::FloatRect> viewExposedRect() const = 0;
 
-    virtual void acceleratedAnimationDidStart(uint64_t /*layerID*/, const String& /*key*/, double /*startTime*/) { }
+    virtual void acceleratedAnimationDidStart(uint64_t /*layerID*/, const String& /*key*/, MonotonicTime /*startTime*/) { }
     virtual void acceleratedAnimationDidEnd(uint64_t /*layerID*/, const String& /*key*/) { }
     virtual void addFence(const WebCore::MachSendRight&) { }
 #endif
index 993b1c4..bc675e5 100644 (file)
@@ -34,7 +34,7 @@ messages -> DrawingArea {
     AdjustTransientZoom(double scale, WebCore::FloatPoint origin)
     CommitTransientZoom(double scale, WebCore::FloatPoint origin)
     
-    AcceleratedAnimationDidStart(uint64_t layerID, String key, double startTime)
+    AcceleratedAnimationDidStart(uint64_t layerID, String key, MonotonicTime startTime)
     AcceleratedAnimationDidEnd(uint64_t layerID, String key)
     
     AddTransactionCallbackID(WebKit::CallbackID callbackID)
index 8a4aead..a3ba308 100644 (file)
@@ -267,7 +267,7 @@ public:
         String keyPath;
         PlatformCAAnimation::AnimationType animationType;
 
-        double beginTime;
+        CFTimeInterval beginTime;
         double duration;
         double timeOffset;
         float repeatCount;
index 85f49e2..9bdf3bb 100644 (file)
@@ -43,9 +43,9 @@
 using namespace WTF;
 using namespace WebCore;
 
-static double mediaTimeToCurrentTime(CFTimeInterval t)
+static MonotonicTime mediaTimeToCurrentTime(CFTimeInterval t)
 {
-    return monotonicallyIncreasingTime() + t - CACurrentMediaTime();
+    return MonotonicTime::now() + Seconds(t - CACurrentMediaTime());
 }
 
 static NSString * const WKExplicitBeginTimeFlag = @"WKPlatformCAAnimationExplicitBeginTimeFlag";
@@ -81,7 +81,7 @@ static NSString * const WKExplicitBeginTimeFlag = @"WKPlatformCAAnimationExplici
         return;
 
     bool hasExplicitBeginTime = [[animation valueForKey:WKExplicitBeginTimeFlag] boolValue];
-    CFTimeInterval startTime;
+    MonotonicTime startTime;
 
     if (hasExplicitBeginTime) {
         // We don't know what time CA used to commit the animation, so just use the current time
index 27b149d..d78014c 100644 (file)
@@ -368,11 +368,11 @@ static inline bool isEquivalentLayer(const PlatformCALayer* layer, GraphicsLayer
     return layerID == newLayerID;
 }
 
-void PlatformCALayerRemote::animationStarted(const String& key, CFTimeInterval beginTime)
+void PlatformCALayerRemote::animationStarted(const String& key, MonotonicTime beginTime)
 {
     auto it = m_animations.find(key);
     if (it != m_animations.end())
-        downcast<PlatformCAAnimationRemote>(*it->value).didStart(beginTime);
+        downcast<PlatformCAAnimationRemote>(*it->value).didStart(currentTimeToMediaTime(beginTime));
     
     if (m_owner)
         m_owner->platformCALayerAnimationStarted(key, beginTime);
index 50e859f..8f84ca3 100644 (file)
@@ -67,7 +67,7 @@ public:
     void addAnimationForKey(const String& key, WebCore::PlatformCAAnimation&) override;
     void removeAnimationForKey(const String& key) override;
     RefPtr<WebCore::PlatformCAAnimation> animationForKey(const String& key) override;
-    void animationStarted(const String& key, CFTimeInterval beginTime) override;
+    void animationStarted(const String& key, MonotonicTime beginTime) override;
     void animationEnded(const String& key) override;
 
     void setMask(WebCore::PlatformCALayer*) override;
index 9a7bff1..e3d3f5a 100644 (file)
@@ -62,7 +62,7 @@ public:
     void layerPropertyChangedWhileBuildingTransaction(PlatformCALayerRemote&);
 
     // From the UI process
-    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, const String& key, double startTime);
+    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, const String& key, MonotonicTime startTime);
     void animationDidEnd(WebCore::GraphicsLayer::PlatformLayerID, const String& key);
 
     void willStartAnimationOnLayer(PlatformCALayerRemote&);
index 4fb5bc8..aa996cb 100644 (file)
@@ -143,7 +143,7 @@ void RemoteLayerTreeContext::willStartAnimationOnLayer(PlatformCALayerRemote& la
     m_layersWithAnimations.add(layer.layerID(), &layer);
 }
 
-void RemoteLayerTreeContext::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, const String& key, double startTime)
+void RemoteLayerTreeContext::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, const String& key, MonotonicTime startTime)
 {
     auto it = m_layersWithAnimations.find(layerID);
     if (it != m_layersWithAnimations.end())
index 555c584..7c53cc0 100644 (file)
@@ -88,7 +88,7 @@ private:
     void setViewExposedRect(std::optional<WebCore::FloatRect>) override;
     std::optional<WebCore::FloatRect> viewExposedRect() const override { return m_scrolledViewExposedRect; }
 
-    void acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime) override;
+    void acceleratedAnimationDidStart(uint64_t layerID, const String& key, MonotonicTime startTime) override;
     void acceleratedAnimationDidEnd(uint64_t layerID, const String& key) override;
 
 #if PLATFORM(IOS)
index 243c7fa..d800555 100644 (file)
@@ -208,7 +208,7 @@ void RemoteLayerTreeDrawingArea::forceRepaint()
     flushLayers();
 }
 
-void RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime)
+void RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart(uint64_t layerID, const String& key, MonotonicTime startTime)
 {
     m_remoteLayerTreeContext->animationDidStart(layerID, key, startTime);
 }
index 456c7c9..4e9cd04 100644 (file)
@@ -539,13 +539,13 @@ RefPtr<ObjCObjectGraph> WebProcess::transformObjectsToHandles(ObjCObjectGraph& o
 void WebProcess::destroyRenderingResources()
 {
 #if !RELEASE_LOG_DISABLED
-    double startTime = monotonicallyIncreasingTime();
+    MonotonicTime startTime = MonotonicTime::now();
 #endif
     CABackingStoreCollectBlocking();
 #if !RELEASE_LOG_DISABLED
-    double endTime = monotonicallyIncreasingTime();
+    MonotonicTime endTime = MonotonicTime::now();
 #endif
-    RELEASE_LOG(ProcessSuspension, "%p - WebProcess::destroyRenderingResources() took %.2fms", this, (endTime - startTime) * 1000.0);
+    RELEASE_LOG(ProcessSuspension, "%p - WebProcess::destroyRenderingResources() took %.2fms", this, (endTime - startTime).milliseconds());
 }
 
 // FIXME: This should live somewhere else, and it should have the implementation in line instead of calling out to WKSI.
index 0f1f6d2..58080e9 100644 (file)
@@ -1,3 +1,20 @@
+2018-03-01  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Remove monotonicallyIncreasingTime
+        https://bugs.webkit.org/show_bug.cgi?id=182911
+
+        Reviewed by Michael Catanzaro.
+
+        * FullscreenVideoController.cpp:
+        (FullscreenVideoController::LayerClient::platformCALayerAnimationStarted):
+        * Plugins/PluginMessageThrottlerWin.cpp:
+        (WebCore::PluginMessageThrottlerWin::PluginMessageThrottlerWin):
+        (WebCore::PluginMessageThrottlerWin::appendMessage):
+        * Plugins/PluginMessageThrottlerWin.h:
+        * WebView.cpp:
+        (WebView::notifyAnimationStarted):
+        * WebView.h:
+
 2018-03-01  Ross Kirsling  <ross.kirsling@sony.com>
 
         [Win][DRT] Implement setSpatialNavigationEnabled.