<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[286877] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/286877">286877</a></dd>
<dt>Author</dt> <dd>graouts@webkit.org</dd>
<dt>Date</dt> <dd>2021-12-10 14:17:27 -0800 (Fri, 10 Dec 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Expose the maximum device frame rate to the Web Animations model
https://bugs.webkit.org/show_bug.cgi?id=234161
rdar://85983792

Reviewed by Simon Fraser.

Source/WebCore:

Expose a new property on DocumentTimeline, governed by an off-by-default runtime flag,
that exposes the maximum frame rate supported by the device. This will allow authors
to use this information to make informed decision on appropriate frame rates to set
on animations.

* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::maximumFrameRate const):
* animation/DocumentTimeline.h:
* animation/DocumentTimeline.idl:

Source/WebCore/PAL:

Add a newly-used CADisplayLink SPI.

* pal/spi/cocoa/QuartzCoreSPI.h:

Source/WebKit:

The display's nominal frame rate was only provided to the Page on macOS. We also
expose it on iOS such that the new DocumentTimeline property also works on iOS.

* UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
(-[WKOneShotDisplayLinkHandler initWithDrawingAreaProxy:]):
* UIProcess/WebPageProxy.h:

Source/WTF:

Add a new experimental feature controlling the availability of per-animation frame rate.

* Scripts/Preferences/WebPreferencesExperimental.yaml:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFScriptsPreferencesWebPreferencesExperimentalyaml">trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePALChangeLog">trunk/Source/WebCore/PAL/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePALpalspicocoaQuartzCoreSPIh">trunk/Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h</a></li>
<li><a href="#trunkSourceWebCoreanimationDocumentTimelinecpp">trunk/Source/WebCore/animation/DocumentTimeline.cpp</a></li>
<li><a href="#trunkSourceWebCoreanimationDocumentTimelineh">trunk/Source/WebCore/animation/DocumentTimeline.h</a></li>
<li><a href="#trunkSourceWebCoreanimationDocumentTimelineidl">trunk/Source/WebCore/animation/DocumentTimeline.idl</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessRemoteLayerTreeRemoteLayerTreeDrawingAreaProxymm">trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxyh">trunk/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (286876 => 286877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WTF/ChangeLog  2021-12-10 22:17:27 UTC (rev 286877)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2021-12-10  Antoine Quint  <graouts@webkit.org>
+
+        Expose the maximum device frame rate to the Web Animations model
+        https://bugs.webkit.org/show_bug.cgi?id=234161
+        rdar://85983792
+
+        Reviewed by Simon Fraser.
+
+        Add a new experimental feature controlling the availability of per-animation frame rate.
+
+        * Scripts/Preferences/WebPreferencesExperimental.yaml:
+
</ins><span class="cx"> 2021-12-10  Sam Sneddon  <gsnedders@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Enable the 'resolution' media query by default
</span></span></pre></div>
<a id="trunkSourceWTFScriptsPreferencesWebPreferencesExperimentalyaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (286876 => 286877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml     2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml        2021-12-10 22:17:27 UTC (rev 286877)
</span><span class="lines">@@ -1496,6 +1496,19 @@
</span><span class="cx">     WebCore:
</span><span class="cx">       default: false
</span><span class="cx"> 
</span><ins>+WebAnimationsCustomFrameRateEnabled:
+  type: bool
+  humanReadableName: "Web Animations custom frame rate"
+  humanReadableDescription: "Support for specifying a custom frame rate for Web Animations"
+  defaultValue:
+    WebKitLegacy:
+      default: false
+    WebKit:
+      "ENABLE(EXPERIMENTAL_FEATURES)" : true
+      default: false
+    WebCore:
+      default: false
+
</ins><span class="cx"> # FIXME: This is enabled when ENABLE(EXPERIMENTAL_FEATURES) is true in WebKit2. Perhaps we should consider using that for WebKitLegacy as well.
</span><span class="cx"> WebAnimationsMutableTimelinesEnabled:
</span><span class="cx">   type: bool
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (286876 => 286877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebCore/ChangeLog      2021-12-10 22:17:27 UTC (rev 286877)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2021-12-10  Antoine Quint  <graouts@webkit.org>
+
+        Expose the maximum device frame rate to the Web Animations model
+        https://bugs.webkit.org/show_bug.cgi?id=234161
+        rdar://85983792
+
+        Reviewed by Simon Fraser.
+
+        Expose a new property on DocumentTimeline, governed by an off-by-default runtime flag,
+        that exposes the maximum frame rate supported by the device. This will allow authors
+        to use this information to make informed decision on appropriate frame rates to set
+        on animations.
+
+        * animation/DocumentTimeline.cpp:
+        (WebCore::DocumentTimeline::maximumFrameRate const):
+        * animation/DocumentTimeline.h:
+        * animation/DocumentTimeline.idl:
+
</ins><span class="cx"> 2021-12-10  Alexey Shvayka  <ashvayka@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Extend the scope where the Window's current event is set
</span></span></pre></div>
<a id="trunkSourceWebCorePALChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PAL/ChangeLog (286876 => 286877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PAL/ChangeLog       2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebCore/PAL/ChangeLog  2021-12-10 22:17:27 UTC (rev 286877)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2021-12-10  Antoine Quint  <graouts@webkit.org>
+
+        Expose the maximum device frame rate to the Web Animations model
+        https://bugs.webkit.org/show_bug.cgi?id=234161
+        rdar://85983792
+
+        Reviewed by Simon Fraser.
+
+        Add a newly-used CADisplayLink SPI.
+
+        * pal/spi/cocoa/QuartzCoreSPI.h:
+
</ins><span class="cx"> 2021-12-09  Robert Jenner  <Jenner@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, reverting r286754.
</span></span></pre></div>
<a id="trunkSourceWebCorePALpalspicocoaQuartzCoreSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h (286876 => 286877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h   2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h      2021-12-10 22:17:27 UTC (rev 286877)
</span><span class="lines">@@ -48,6 +48,10 @@
</span><span class="cx"> #import <QuartzCore/CARenderCG.h>
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS_FAMILY)
+#import <QuartzCore/CADisplayLinkPrivate.h>
+#endif
+
</ins><span class="cx"> #endif // __OBJC__
</span><span class="cx"> 
</span><span class="cx"> #else
</span><span class="lines">@@ -55,6 +59,12 @@
</span><span class="cx"> #ifdef __OBJC__
</span><span class="cx"> typedef struct _CARenderContext CARenderContext;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS_FAMILY)
+@interface CADisplayLink ()
+@property (readonly, nonatomic) CFTimeInterval maximumRefreshRate;
+@end
+#endif
+
</ins><span class="cx"> #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
</span><span class="cx"> @class CAFenceHandle;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreanimationDocumentTimelinecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (286876 => 286877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/animation/DocumentTimeline.cpp      2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp 2021-12-10 22:17:27 UTC (rev 286877)
</span><span class="lines">@@ -530,4 +530,11 @@
</span><span class="cx">     return animation;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+std::optional<FramesPerSecond> DocumentTimeline::maximumFrameRate() const
+{
+    if (!m_document || !m_document->page())
+        return std::nullopt;
+    return m_document->page()->displayNominalFramesPerSecond();
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreanimationDocumentTimelineh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/animation/DocumentTimeline.h (286876 => 286877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/animation/DocumentTimeline.h        2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebCore/animation/DocumentTimeline.h   2021-12-10 22:17:27 UTC (rev 286877)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><ins>+#include "AnimationFrameRate.h"
</ins><span class="cx"> #include "AnimationTimeline.h"
</span><span class="cx"> #include "DocumentTimelineOptions.h"
</span><span class="cx"> #include "Timer.h"
</span><span class="lines">@@ -85,6 +86,8 @@
</span><span class="cx">     WEBCORE_EXPORT Vector<std::pair<String, double>> acceleratedAnimationsForElement(Element&) const;    
</span><span class="cx">     WEBCORE_EXPORT unsigned numberOfAnimationTimelineInvalidationsForTesting() const;
</span><span class="cx"> 
</span><ins>+    std::optional<FramesPerSecond> maximumFrameRate() const;
+
</ins><span class="cx"> private:
</span><span class="cx">     DocumentTimeline(Document&, Seconds);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreanimationDocumentTimelineidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/animation/DocumentTimeline.idl (286876 => 286877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/animation/DocumentTimeline.idl      2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebCore/animation/DocumentTimeline.idl 2021-12-10 22:17:27 UTC (rev 286877)
</span><span class="lines">@@ -23,9 +23,12 @@
</span><span class="cx">  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><ins>+typedef unsigned long FramesPerSecond;
+
</ins><span class="cx"> [
</span><span class="cx">     Exposed=Window
</span><span class="cx"> ] interface DocumentTimeline : AnimationTimeline {
</span><span class="cx">     [CallWith=Document] constructor(optional DocumentTimelineOptions options);
</span><span class="cx">     [EnabledBySetting=WebAnimationsCustomEffectsEnabled] WebAnimation animate(CustomEffectCallback callback, optional (unrestricted double or CustomAnimationOptions) options);
</span><ins>+    [EnabledBySetting=WebAnimationsCustomFrameRateEnabled] readonly attribute FramesPerSecond? maximumFrameRate;
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (286876 => 286877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebKit/ChangeLog       2021-12-10 22:17:27 UTC (rev 286877)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2021-12-10  Antoine Quint  <graouts@webkit.org>
+
+        Expose the maximum device frame rate to the Web Animations model
+        https://bugs.webkit.org/show_bug.cgi?id=234161
+        rdar://85983792
+
+        Reviewed by Simon Fraser.
+
+        The display's nominal frame rate was only provided to the Page on macOS. We also
+        expose it on iOS such that the new DocumentTimeline property also works on iOS.
+
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
+        (-[WKOneShotDisplayLinkHandler initWithDrawingAreaProxy:]):
+        * UIProcess/WebPageProxy.h:
+
</ins><span class="cx"> 2021-12-10  Devin Rousso  <drousso@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Allow `Pasteboard::readBuffer` to read from the pasteboard as a whole instead of a specific item
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessRemoteLayerTreeRemoteLayerTreeDrawingAreaProxymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm (286876 => 286877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm 2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm    2021-12-10 22:17:27 UTC (rev 286877)
</span><span class="lines">@@ -34,9 +34,11 @@
</span><span class="cx"> #import "WebPageProxy.h"
</span><span class="cx"> #import "WebProcessProxy.h"
</span><span class="cx"> #import <QuartzCore/QuartzCore.h>
</span><ins>+#import <WebCore/AnimationFrameRate.h>
</ins><span class="cx"> #import <WebCore/GraphicsContextCG.h>
</span><span class="cx"> #import <WebCore/IOSurfacePool.h>
</span><span class="cx"> #import <WebCore/WebActionDisablingCALayerDelegate.h>
</span><ins>+#import <pal/spi/cocoa/QuartzCoreSPI.h>
</ins><span class="cx"> #import <wtf/MachSendRight.h>
</span><span class="cx"> #import <wtf/SystemTracing.h>
</span><span class="cx"> 
</span><span class="lines">@@ -67,6 +69,17 @@
</span><span class="cx">         [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
</span><span class="cx">         _displayLink.paused = YES;
</span><span class="cx">         _displayLink.preferredFramesPerSecond = 60;
</span><ins>+
+        if (drawingAreaProxy) {
+            auto minimumRefreshInterval = _displayLink.maximumRefreshRate;
+            if (minimumRefreshInterval > 0) {
+                auto& page = drawingAreaProxy->page();
+                if (auto displayId = page.displayId()) {
+                    WebCore::FramesPerSecond frameRate = std::round(1.0 / minimumRefreshInterval);
+                    page.windowScreenDidChange(*displayId, frameRate);
+                }
+            }
+        }
</ins><span class="cx">     }
</span><span class="cx">     return self;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (286876 => 286877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2021-12-10 22:17:27 UTC (rev 286877)
</span><span class="lines">@@ -1105,6 +1105,7 @@
</span><span class="cx">     void setIntrinsicDeviceScaleFactor(float);
</span><span class="cx">     void setCustomDeviceScaleFactor(float);
</span><span class="cx">     void windowScreenDidChange(WebCore::PlatformDisplayID, std::optional<unsigned> nominalFramesPerSecond);
</span><ins>+    std::optional<WebCore::PlatformDisplayID> displayId() const { return m_displayID; }
</ins><span class="cx">     void accessibilitySettingsDidChange();
</span><span class="cx"> 
</span><span class="cx">     void setUseFixedLayout(bool);
</span></span></pre>
</div>
</div>

</body>
</html>