Rendering update steps should use Seconds for the timestamps
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Apr 2020 01:02:58 +0000 (01:02 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Apr 2020 01:02:58 +0000 (01:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=210990

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2020-04-26
Reviewed by Daniel Bates.

Source/WebCore:

Make DOMWindow::nowTimestamp() return ReducedResolutionSeconds and change
the callers accordingly. ReducedResolutionSeconds is a new type but it's
just an alias of the type Seconds. It indicates that the returned value
is a web-safe seconds.

* Headers.cmake:
* WebCore.xcodeproj/project.pbxproj:
* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::suspendAnimations):
(WebCore::DocumentTimeline::liveCurrentTime const):
(WebCore::DocumentTimeline::cacheCurrentTime):
(WebCore::DocumentTimeline::documentWillUpdateAnimationsAndSendEvents):
* animation/DocumentTimeline.h:
* animation/DocumentTimelinesController.cpp:
(WebCore::DocumentTimelinesController::updateAnimationsAndSendEvents):
* animation/DocumentTimelinesController.h:
* dom/Document.cpp:
(WebCore::Document::serviceRequestAnimationFrameCallbacks):
(WebCore::Document::updateIntersectionObservations):
* dom/Document.h:
* dom/ScriptedAnimationController.cpp:
(WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks):
(WebCore::ScriptedAnimationController::scheduleAnimation):
* dom/ScriptedAnimationController.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::getVideoPlaybackQuality):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::nowTimestamp const):
* page/DOMWindow.h:
* page/IntersectionObserver.cpp:
(WebCore::IntersectionObserver::nowTimestamp const):
(WebCore::IntersectionObserver::createTimestamp const): Deleted.
* page/IntersectionObserver.h:
* page/Page.cpp:
(WebCore::Page::updateRendering):
* page/Performance.cpp:
(WebCore::Performance::now const):
(WebCore::Performance::nowInReducedResolutionSeconds const):
* page/Performance.h:
* page/ReducedResolutionSeconds.h: Added.

Source/WebKit:

* WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
(WebKit::CompositingCoordinator::timestamp const):

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

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Headers.cmake
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/animation/DocumentTimeline.cpp
Source/WebCore/animation/DocumentTimeline.h
Source/WebCore/animation/DocumentTimelinesController.cpp
Source/WebCore/animation/DocumentTimelinesController.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/ScriptedAnimationController.cpp
Source/WebCore/dom/ScriptedAnimationController.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h
Source/WebCore/page/IntersectionObserver.cpp
Source/WebCore/page/IntersectionObserver.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Performance.cpp
Source/WebCore/page/Performance.h
Source/WebCore/page/ReducedResolutionSeconds.h [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp

index b4c6234..0195240 100644 (file)
@@ -1,3 +1,51 @@
+2020-04-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Rendering update steps should use Seconds for the timestamps
+        https://bugs.webkit.org/show_bug.cgi?id=210990
+
+        Reviewed by Daniel Bates.
+
+        Make DOMWindow::nowTimestamp() return ReducedResolutionSeconds and change
+        the callers accordingly. ReducedResolutionSeconds is a new type but it's
+        just an alias of the type Seconds. It indicates that the returned value
+        is a web-safe seconds.
+
+        * Headers.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+        * animation/DocumentTimeline.cpp:
+        (WebCore::DocumentTimeline::suspendAnimations):
+        (WebCore::DocumentTimeline::liveCurrentTime const):
+        (WebCore::DocumentTimeline::cacheCurrentTime):
+        (WebCore::DocumentTimeline::documentWillUpdateAnimationsAndSendEvents):
+        * animation/DocumentTimeline.h:
+        * animation/DocumentTimelinesController.cpp:
+        (WebCore::DocumentTimelinesController::updateAnimationsAndSendEvents):
+        * animation/DocumentTimelinesController.h:
+        * dom/Document.cpp:
+        (WebCore::Document::serviceRequestAnimationFrameCallbacks):
+        (WebCore::Document::updateIntersectionObservations):
+        * dom/Document.h:
+        * dom/ScriptedAnimationController.cpp:
+        (WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks):
+        (WebCore::ScriptedAnimationController::scheduleAnimation):
+        * dom/ScriptedAnimationController.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::getVideoPlaybackQuality):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::nowTimestamp const):
+        * page/DOMWindow.h:
+        * page/IntersectionObserver.cpp:
+        (WebCore::IntersectionObserver::nowTimestamp const):
+        (WebCore::IntersectionObserver::createTimestamp const): Deleted.
+        * page/IntersectionObserver.h:
+        * page/Page.cpp:
+        (WebCore::Page::updateRendering):
+        * page/Performance.cpp:
+        (WebCore::Performance::now const):
+        (WebCore::Performance::nowInReducedResolutionSeconds const):
+        * page/Performance.h:
+        * page/ReducedResolutionSeconds.h: Added.
+
 2020-04-26  Alexey Shvayka  <shvaikalesh@gmail.com>
 
         InternalFunction::createSubclassStructure should use newTarget's globalObject
index 54ab276..65c7caf 100644 (file)
@@ -840,6 +840,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
     page/PrintContext.h
     page/ProcessWarming.h
     page/Quirks.h
+    page/ReducedResolutionSeconds.h
     page/RemoteDOMWindow.h
     page/RemoteFrame.h
     page/RenderingUpdateScheduler.h
index d59d45e..0f14061 100644 (file)
                555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; };
                556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5576A5651D88A70800CCC04C /* ImageFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 5576A5631D88A70800CCC04C /* ImageFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               5584765A2453F334009F550C /* ReducedResolutionSeconds.h in Headers */ = {isa = PBXBuildFile; fileRef = 558476582453ABC2009F550C /* ReducedResolutionSeconds.h */; settings = {ATTRIBUTES = (Private, ); }; };
                55A336F91D821E3C0022C4C7 /* ImageBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
                55AD093E2408963500DE4D2F /* DisplayListImageBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 72EA09F723FCCB3D008504A5 /* DisplayListImageBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
                55AD09402408964000DE4D2F /* DisplayListDrawingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 72EA09F923FCCC6A008504A5 /* DisplayListDrawingContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
                556C7C4922123943009B06CA /* RenderingUpdateScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderingUpdateScheduler.cpp; sourceTree = "<group>"; };
                5576A5621D88A70800CCC04C /* ImageFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageFrame.cpp; sourceTree = "<group>"; };
                5576A5631D88A70800CCC04C /* ImageFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrame.h; sourceTree = "<group>"; };
+               558476582453ABC2009F550C /* ReducedResolutionSeconds.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReducedResolutionSeconds.h; sourceTree = "<group>"; };
                5597FCCB2076C06800D35BB0 /* GlyphDisplayListCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlyphDisplayListCache.h; sourceTree = "<group>"; };
                55A336F61D8209F40022C4C7 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; };
                55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBackingStore.h; sourceTree = "<group>"; };
                                E42050142141901A0066EF3B /* ProcessWarming.h */,
                                CD9A87F9215D6CF3006F17B5 /* Quirks.cpp */,
                                CD9A87FB215D6CF3006F17B5 /* Quirks.h */,
+                               558476582453ABC2009F550C /* ReducedResolutionSeconds.h */,
                                46B9518D207D632A00A7D2DD /* RemoteDOMWindow.cpp */,
                                46B9518E207D632A00A7D2DD /* RemoteDOMWindow.h */,
                                46BCBBC3208500A700710638 /* RemoteDOMWindow.idl */,
                                BC4368E80C226E32005EFB5F /* Rect.h in Headers */,
                                FD45A958175D414C00C21EC8 /* RectangleShape.h in Headers */,
                                5CEEE4361F5F8F210014A5F5 /* RectEdges.h in Headers */,
+                               5584765A2453F334009F550C /* ReducedResolutionSeconds.h in Headers */,
                                9831AE4A154225C900FE2644 /* ReferrerPolicy.h in Headers */,
                                BCAB418213E356E800D8AAF3 /* Region.h in Headers */,
                                26B9998F1803AE7200D01121 /* RegisterAllocator.h in Headers */,
index 54c89cd..461a5f7 100644 (file)
@@ -232,7 +232,7 @@ void DocumentTimeline::suspendAnimations()
         return;
 
     if (!m_cachedCurrentTime)
-        m_cachedCurrentTime = Seconds(liveCurrentTime());
+        m_cachedCurrentTime = liveCurrentTime();
 
     for (const auto& animation : m_animations)
         animation->setSuspended(true);
@@ -274,7 +274,7 @@ unsigned DocumentTimeline::numberOfActiveAnimationsForTesting() const
     return count;
 }
 
-DOMHighResTimeStamp DocumentTimeline::liveCurrentTime() const
+ReducedResolutionSeconds DocumentTimeline::liveCurrentTime() const
 {
     return m_document->domWindow()->nowTimestamp();
 }
@@ -297,11 +297,11 @@ Optional<Seconds> DocumentTimeline::currentTime()
     return m_cachedCurrentTime.value() - m_originTime;
 }
 
-void DocumentTimeline::cacheCurrentTime(DOMHighResTimeStamp newCurrentTime)
+void DocumentTimeline::cacheCurrentTime(ReducedResolutionSeconds newCurrentTime)
 {
     ASSERT(m_document);
 
-    m_cachedCurrentTime = Seconds(newCurrentTime);
+    m_cachedCurrentTime = newCurrentTime;
     // We want to be sure to keep this time cached until we've both finished running JS and finished updating
     // animations, so we schedule the invalidation task and register a whenIdle callback on the VM, which will
     // fire syncronously if no JS is running.
@@ -361,7 +361,7 @@ bool DocumentTimeline::shouldRunUpdateAnimationsAndSendEventsIgnoringSuspensionS
     return !m_animations.isEmpty() || !m_pendingAnimationEvents.isEmpty() || !m_acceleratedAnimationsPendingRunningStateChange.isEmpty();
 }
 
-DocumentTimeline::ShouldUpdateAnimationsAndSendEvents DocumentTimeline::documentWillUpdateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp)
+DocumentTimeline::ShouldUpdateAnimationsAndSendEvents DocumentTimeline::documentWillUpdateAnimationsAndSendEvents(ReducedResolutionSeconds timestamp)
 {
     // We need to freeze the current time even if no animation is running.
     // document.timeline.currentTime may be called from a rAF callback and
index 6c57acc..02a0d42 100644 (file)
@@ -28,6 +28,7 @@
 #include "AnimationTimeline.h"
 #include "DocumentTimelineOptions.h"
 #include "GenericTaskQueue.h"
+#include "ReducedResolutionSeconds.h"
 #include "Timer.h"
 #include <wtf/Markable.h>
 #include <wtf/Ref.h>
@@ -74,7 +75,7 @@ public:
     void enqueueAnimationEvent(AnimationEventBase&);
     
     enum class ShouldUpdateAnimationsAndSendEvents : uint8_t { Yes, No };
-    ShouldUpdateAnimationsAndSendEvents documentWillUpdateAnimationsAndSendEvents(DOMHighResTimeStamp);
+    ShouldUpdateAnimationsAndSendEvents documentWillUpdateAnimationsAndSendEvents(ReducedResolutionSeconds);
     void removeReplacedAnimations();
     AnimationEvents prepareForPendingAnimationEventsDispatch();
     void documentDidUpdateAnimationsAndSendEvents();
@@ -92,9 +93,9 @@ private:
     DocumentTimeline(Document&, Seconds);
 
     DocumentTimelinesController* controller() const;
-    DOMHighResTimeStamp liveCurrentTime() const;
+    ReducedResolutionSeconds liveCurrentTime() const;
     void applyPendingAcceleratedAnimations();
-    void cacheCurrentTime(DOMHighResTimeStamp);
+    void cacheCurrentTime(ReducedResolutionSeconds);
     void maybeClearCachedCurrentTime();
     void scheduleInvalidationTaskIfNeeded();
     void scheduleAnimationResolution();
index 5e9d3f2..3abd37e 100644 (file)
@@ -61,7 +61,7 @@ void DocumentTimelinesController::detachFromDocument()
         m_timelines.begin()->detachFromDocument();
 }
 
-void DocumentTimelinesController::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp)
+void DocumentTimelinesController::updateAnimationsAndSendEvents(ReducedResolutionSeconds timestamp)
 {
     ASSERT(!m_timelines.hasNullReferences());
 
index c587460..906c17d 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "DOMHighResTimeStamp.h"
+#include "ReducedResolutionSeconds.h"
 #include <wtf/WeakHashSet.h>
 
 namespace WebCore {
@@ -44,7 +44,7 @@ public:
     void addTimeline(DocumentTimeline&);
     void removeTimeline(DocumentTimeline&);
     void detachFromDocument();
-    void updateAnimationsAndSendEvents(DOMHighResTimeStamp);
+    void updateAnimationsAndSendEvents(ReducedResolutionSeconds);
 
 private:
     struct AnimationsToProcess {
index 6f4af47..c4e69ef 100644 (file)
@@ -6371,7 +6371,7 @@ void Document::resumeScriptedAnimationControllerCallbacks()
         m_scriptedAnimationController->resume();
 }
 
-void Document::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp)
+void Document::serviceRequestAnimationFrameCallbacks(ReducedResolutionSeconds timestamp)
 {
     if (m_scriptedAnimationController)
         m_scriptedAnimationController->serviceRequestAnimationFrameCallbacks(timestamp);
@@ -7622,8 +7622,8 @@ void Document::updateIntersectionObservations()
 
     for (const auto& observer : m_intersectionObservers) {
         bool needNotify = false;
-        DOMHighResTimeStamp timestamp;
-        if (!observer->createTimestamp(timestamp))
+        auto timestamp = observer->nowTimestamp();
+        if (!timestamp)
             continue;
         for (Element* target : observer->observationTargets()) {
             auto& targetRegistrations = target->intersectionObserverDataIfExists()->registrations;
@@ -7676,7 +7676,7 @@ void Document::updateIntersectionObservations()
                 }
 
                 observer->appendQueuedEntry(IntersectionObserverEntry::create({
-                    timestamp,
+                    timestamp->milliseconds(),
                     reportedRootBounds,
                     { targetBoundingClientRect.x(), targetBoundingClientRect.y(), targetBoundingClientRect.width(), targetBoundingClientRect.height() },
                     { clientIntersectionRect.x(), clientIntersectionRect.y(), clientIntersectionRect.width(), clientIntersectionRect.height() },
index f76af2e..2814b63 100644 (file)
@@ -1080,7 +1080,7 @@ public:
     void suspendScriptedAnimationControllerCallbacks();
     void resumeScriptedAnimationControllerCallbacks();
 
-    void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp);
+    void serviceRequestAnimationFrameCallbacks(ReducedResolutionSeconds);
 
     void windowScreenDidChange(PlatformDisplayID);
 
index 6e4007b..9087520 100644 (file)
@@ -193,14 +193,14 @@ void ScriptedAnimationController::cancelCallback(CallbackId id)
     }
 }
 
-void ScriptedAnimationController::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp)
+void ScriptedAnimationController::serviceRequestAnimationFrameCallbacks(ReducedResolutionSeconds timestamp)
 {
     if (!m_callbacks.size() || m_suspendCount || !requestAnimationFrameEnabled())
         return;
 
     TraceScope tracingScope(RAFCallbackStart, RAFCallbackEnd);
 
-    auto highResNowMs = std::round(1000 * timestamp);
+    auto highResNowMs = timestamp.milliseconds();
     if (m_document && m_document->quirks().needsMillisecondResolutionForHighResTimeStamp())
         highResNowMs += 0.1;
 
@@ -273,7 +273,7 @@ void ScriptedAnimationController::scheduleAnimation()
         return;
 
     Seconds animationInterval = interval();
-    Seconds scheduleDelay = std::max(animationInterval - Seconds(m_document->domWindow()->nowTimestamp() - m_lastAnimationFrameTimestamp), 0_s);
+    Seconds scheduleDelay = std::max(animationInterval - (m_document->domWindow()->nowTimestamp() - m_lastAnimationFrameTimestamp), 0_s);
 
     if (isThrottled()) {
         // FIXME: not ideal to snapshot time both in now() and nowTimestamp(), the latter of which also has reduced resolution.
index 0d21208..75862cf 100644 (file)
@@ -53,7 +53,7 @@ public:
 
     CallbackId registerCallback(Ref<RequestAnimationFrameCallback>&&);
     void cancelCallback(CallbackId);
-    void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp);
+    void serviceRequestAnimationFrameCallbacks(ReducedResolutionSeconds);
 
     void suspend();
     void resume();
@@ -86,7 +86,7 @@ private:
     int m_suspendCount { 0 };
 
     Timer m_animationTimer;
-    double m_lastAnimationFrameTimestamp { 0 };
+    ReducedResolutionSeconds m_lastAnimationFrameTimestamp { 0 };
 
 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
     OptionSet<ThrottlingReason> m_throttlingReasons;
index e1ede8d..b7e2f3a 100644 (file)
@@ -7110,7 +7110,7 @@ void HTMLMediaElement::updateRateChangeRestrictions()
 RefPtr<VideoPlaybackQuality> HTMLMediaElement::getVideoPlaybackQuality()
 {
     RefPtr<DOMWindow> domWindow = document().domWindow();
-    double timestamp = domWindow ? 1000 * domWindow->nowTimestamp() : 0;
+    double timestamp = domWindow ? domWindow->nowTimestamp().milliseconds() : 0;
 
     auto metrics = m_player ? m_player->videoPlaybackQualityMetrics() : WTF::nullopt;
     if (!metrics)
index 78fe40d..27dc45f 100644 (file)
@@ -734,9 +734,9 @@ Performance& DOMWindow::performance() const
     return *m_performance;
 }
 
-double DOMWindow::nowTimestamp() const
+ReducedResolutionSeconds DOMWindow::nowTimestamp() const
 {
-    return performance().now() / 1000.;
+    return performance().nowInReducedResolutionSeconds();
 }
 
 Location& DOMWindow::location()
index 40d9c23..b8728e4 100644 (file)
@@ -34,6 +34,7 @@
 #include "FrameDestructionObserver.h"
 #include "ImageBitmap.h"
 #include "PostMessageOptions.h"
+#include "ReducedResolutionSeconds.h"
 #include "ScrollToOptions.h"
 #include "ScrollTypes.h"
 #include "Supplementable.h"
@@ -349,7 +350,7 @@ public:
 #endif
 
     Performance& performance() const;
-    WEBCORE_EXPORT double nowTimestamp() const;
+    WEBCORE_EXPORT ReducedResolutionSeconds nowTimestamp() const;
 
 #if PLATFORM(IOS_FAMILY)
     void incrementScrollEventListenersCount();
index 0c97565..6b36dd7 100644 (file)
@@ -244,21 +244,21 @@ void IntersectionObserver::rootDestroyed()
     m_root = nullptr;
 }
 
-bool IntersectionObserver::createTimestamp(DOMHighResTimeStamp& timestamp) const
+Optional<ReducedResolutionSeconds> IntersectionObserver::nowTimestamp() const
 {
     if (!m_callback)
-        return false;
+        return WTF::nullopt;
 
     auto* context = m_callback->scriptExecutionContext();
     if (!context)
-        return false;
+        return WTF::nullopt;
+
     ASSERT(context->isDocument());
     auto& document = downcast<Document>(*context);
-    if (auto* window = document.domWindow()) {
-        timestamp =  window->performance().now();
-        return true;
-    }
-    return false;
+    if (auto* window = document.domWindow())
+        return window->nowTimestamp();
+    
+    return WTF::nullopt;
 }
 
 void IntersectionObserver::appendQueuedEntry(Ref<IntersectionObserverEntry>&& entry)
index 1c08a4e..d89b19e 100644 (file)
@@ -94,7 +94,7 @@ public:
     bool hasObservationTargets() const { return m_observationTargets.size(); }
     void rootDestroyed();
 
-    bool createTimestamp(DOMHighResTimeStamp&) const;
+    Optional<ReducedResolutionSeconds> nowTimestamp() const;
 
     void appendQueuedEntry(Ref<IntersectionObserverEntry>&&);
     void notify();
index 64fe45e..ee19671 100644 (file)
@@ -1358,7 +1358,7 @@ void Page::updateRendering()
     forEachDocument([] (Document& document) {
         if (!document.domWindow())
             return;
-        DOMHighResTimeStamp timestamp = document.domWindow()->nowTimestamp();
+        auto timestamp = document.domWindow()->nowTimestamp();
         if (auto* timelinesController = document.timelinesController())
             timelinesController->updateAnimationsAndSendEvents(timestamp);
         // FIXME: Run the fullscreen steps.
index cbbac21..7eb7d3d 100644 (file)
@@ -74,8 +74,13 @@ void Performance::contextDestroyed()
 
 DOMHighResTimeStamp Performance::now() const
 {
+    return nowInReducedResolutionSeconds().milliseconds();
+}
+
+ReducedResolutionSeconds Performance::nowInReducedResolutionSeconds() const
+{
     Seconds now = MonotonicTime::now() - m_timeOrigin;
-    return reduceTimeResolution(now).milliseconds();
+    return reduceTimeResolution(now);
 }
 
 Seconds Performance::reduceTimeResolution(Seconds seconds)
index d5b11c2..53d6f12 100644 (file)
@@ -37,6 +37,7 @@
 #include "EventTarget.h"
 #include "ExceptionOr.h"
 #include "GenericTaskQueue.h"
+#include "ReducedResolutionSeconds.h"
 #include <wtf/ListHashSet.h>
 
 namespace WebCore {
@@ -58,6 +59,7 @@ public:
     ~Performance();
 
     DOMHighResTimeStamp now() const;
+    ReducedResolutionSeconds nowInReducedResolutionSeconds() const;
 
     PerformanceNavigation* navigation();
     PerformanceTiming* timing();
diff --git a/Source/WebCore/page/ReducedResolutionSeconds.h b/Source/WebCore/page/ReducedResolutionSeconds.h
new file mode 100644 (file)
index 0000000..8739962
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Seconds.h>
+
+namespace WebCore {
+
+using ReducedResolutionSeconds = Seconds;
+
+}
+
index e2a3fa1..53b023c 100644 (file)
@@ -1,3 +1,13 @@
+2020-04-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Rendering update steps should use Seconds for the timestamps
+        https://bugs.webkit.org/show_bug.cgi?id=210990
+
+        Reviewed by Daniel Bates.
+
+        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
+        (WebKit::CompositingCoordinator::timestamp const):
+
 2020-04-26  Peng Liu  <peng.liu6@apple.com>
 
         Remove unused class PlaybackSessionInterface
index a6571d8..283f0e7 100644 (file)
@@ -180,7 +180,7 @@ double CompositingCoordinator::timestamp() const
     auto* document = m_page.corePage()->mainFrame().document();
     if (!document)
         return 0;
-    return document->domWindow() ? document->domWindow()->nowTimestamp() : document->monotonicTimestamp();
+    return document->domWindow() ? document->domWindow()->nowTimestamp().seconds() : document->monotonicTimestamp();
 }
 
 void CompositingCoordinator::syncDisplayState()