Title: [206606] trunk
- Revision
- 206606
- Author
- commit-qu...@webkit.org
- Date
- 2016-09-29 13:02:25 -0700 (Thu, 29 Sep 2016)
Log Message
[Modern Media Controls] scheduler for layout nodes
https://bugs.webkit.org/show_bug.cgi?id=162726
<rdar://problem/28543043>
Patch by Antoine Quint <grao...@apple.com> on 2016-09-29
Reviewed by Dean Jackson.
Source/WebCore:
For the work on the modern media controls we will be using a tree of LayoutNode objects that will
commit to the DOM in coordinated `requestAnimationFrame()` calls to ensure all layouts are done
in an efficient and coordinated manner. As a preamble, we introduce a `scheduler` singleton which
provides a single public method `scheduleLayout(callback)` to queue callbacks to be fired in the
next `requestAnimationFrame()` callback.
Tests: media/modern-media-controls/scheduler/not-reentrant.html
media/modern-media-controls/scheduler/single-callback-when-registered-multiple-times.html
* Modules/modern-media-controls/controls/scheduler.js: Added.
(const.scheduler.new.prototype.scheduleLayout):
(const.scheduler.new.prototype._requestFrameIfNeeded):
(const.scheduler.new.prototype._frameDidFire):
(const.scheduler.new.prototype._layout):
LayoutTests:
Testing the basic functionality for the LayoutNode scheduler.
* media/modern-media-controls/scheduler/not-reentrant-expected.txt: Added.
* media/modern-media-controls/scheduler/not-reentrant.html: Added.
* media/modern-media-controls/scheduler/single-callback-when-registered-multiple-times-expected.txt: Added.
* media/modern-media-controls/scheduler/single-callback-when-registered-multiple-times.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (206605 => 206606)
--- trunk/LayoutTests/ChangeLog 2016-09-29 19:49:54 UTC (rev 206605)
+++ trunk/LayoutTests/ChangeLog 2016-09-29 20:02:25 UTC (rev 206606)
@@ -1,3 +1,18 @@
+2016-09-29 Antoine Quint <grao...@apple.com>
+
+ [Modern Media Controls] scheduler for layout nodes
+ https://bugs.webkit.org/show_bug.cgi?id=162726
+ <rdar://problem/28543043>
+
+ Reviewed by Dean Jackson.
+
+ Testing the basic functionality for the LayoutNode scheduler.
+
+ * media/modern-media-controls/scheduler/not-reentrant-expected.txt: Added.
+ * media/modern-media-controls/scheduler/not-reentrant.html: Added.
+ * media/modern-media-controls/scheduler/single-callback-when-registered-multiple-times-expected.txt: Added.
+ * media/modern-media-controls/scheduler/single-callback-when-registered-multiple-times.html: Added.
+
2016-09-28 Ryosuke Niwa <rn...@webkit.org>
Text nodes assigned to a linked slot are not clickable
Added: trunk/LayoutTests/media/modern-media-controls/scheduler/not-reentrant-expected.txt (0 => 206606)
--- trunk/LayoutTests/media/modern-media-controls/scheduler/not-reentrant-expected.txt (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/scheduler/not-reentrant-expected.txt 2016-09-29 20:02:25 UTC (rev 206606)
@@ -0,0 +1,17 @@
+This test checks that calling `scheduleLayout()` during a layout callback delays that callback until the next frame.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+scheduler.scheduleLayout(layout)
+Frame #0 will fire
+layout() was called
+scheduler.scheduleLayout(layout)
+Frame #0 fired
+Frame #1 will fire
+layout() was called
+Frame #1 fired
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/media/modern-media-controls/scheduler/not-reentrant.html (0 => 206606)
--- trunk/LayoutTests/media/modern-media-controls/scheduler/not-reentrant.html (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/scheduler/not-reentrant.html 2016-09-29 20:02:25 UTC (rev 206606)
@@ -0,0 +1,45 @@
+<script src=""
+<script src="" type="text/_javascript_"></script>
+<script type="text/_javascript_">
+
+description("This test checks that calling `scheduleLayout()` during a layout callback delays that callback until the next frame.");
+
+window.jsTestIsAsync = true;
+
+if (window.testRunner)
+ window.testRunner.dumpAsText();
+
+let numberOfFrames = 0;
+
+scheduler.frameWillFire = function()
+{
+ debug(`Frame #${numberOfFrames} will fire`);
+}
+
+scheduler.frameDidFire = function()
+{
+ debug(`Frame #${numberOfFrames} fired`);
+
+ numberOfFrames++;
+
+ if (numberOfFrames === 2)
+ finishJSTest();
+};
+
+function layout()
+{
+ debug(`layout() was called`);
+ if (numberOfFrames !== 0)
+ return;
+
+ // This layout should not be performed right away but delayed until the
+ // next frame since scheduleLayout() is not reentrant.
+ debug(`scheduler.scheduleLayout(layout)`);
+ scheduler.scheduleLayout(layout);
+}
+
+debug(`scheduler.scheduleLayout(layout)`);
+scheduler.scheduleLayout(layout);
+
+</script>
+<script src=""
Added: trunk/LayoutTests/media/modern-media-controls/scheduler/single-callback-when-registered-multiple-times-expected.txt (0 => 206606)
--- trunk/LayoutTests/media/modern-media-controls/scheduler/single-callback-when-registered-multiple-times-expected.txt (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/scheduler/single-callback-when-registered-multiple-times-expected.txt 2016-09-29 20:02:25 UTC (rev 206606)
@@ -0,0 +1,10 @@
+This test checks that calling `scheduleLayout()` multiple times with the same function yields a single call to that function.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS numberOfCalls is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/media/modern-media-controls/scheduler/single-callback-when-registered-multiple-times.html (0 => 206606)
--- trunk/LayoutTests/media/modern-media-controls/scheduler/single-callback-when-registered-multiple-times.html (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/scheduler/single-callback-when-registered-multiple-times.html 2016-09-29 20:02:25 UTC (rev 206606)
@@ -0,0 +1,29 @@
+<script src=""
+<script src="" type="text/_javascript_"></script>
+<script type="text/_javascript_">
+
+description("This test checks that calling `scheduleLayout()` multiple times with the same function yields a single call to that function.");
+
+window.jsTestIsAsync = true;
+
+if (window.testRunner)
+ window.testRunner.dumpAsText();
+
+let numberOfCalls = 0;
+function layout()
+{
+ numberOfCalls++;
+}
+
+scheduler.frameDidFire = function()
+{
+ shouldBe("numberOfCalls", "1");
+ finishJSTest();
+};
+
+scheduler.scheduleLayout(layout);
+scheduler.scheduleLayout(layout);
+scheduler.scheduleLayout(layout);
+
+</script>
+<script src=""
Modified: trunk/Source/WebCore/ChangeLog (206605 => 206606)
--- trunk/Source/WebCore/ChangeLog 2016-09-29 19:49:54 UTC (rev 206605)
+++ trunk/Source/WebCore/ChangeLog 2016-09-29 20:02:25 UTC (rev 206606)
@@ -1,3 +1,26 @@
+2016-09-29 Antoine Quint <grao...@apple.com>
+
+ [Modern Media Controls] scheduler for layout nodes
+ https://bugs.webkit.org/show_bug.cgi?id=162726
+ <rdar://problem/28543043>
+
+ Reviewed by Dean Jackson.
+
+ For the work on the modern media controls we will be using a tree of LayoutNode objects that will
+ commit to the DOM in coordinated `requestAnimationFrame()` calls to ensure all layouts are done
+ in an efficient and coordinated manner. As a preamble, we introduce a `scheduler` singleton which
+ provides a single public method `scheduleLayout(callback)` to queue callbacks to be fired in the
+ next `requestAnimationFrame()` callback.
+
+ Tests: media/modern-media-controls/scheduler/not-reentrant.html
+ media/modern-media-controls/scheduler/single-callback-when-registered-multiple-times.html
+
+ * Modules/modern-media-controls/controls/scheduler.js: Added.
+ (const.scheduler.new.prototype.scheduleLayout):
+ (const.scheduler.new.prototype._requestFrameIfNeeded):
+ (const.scheduler.new.prototype._frameDidFire):
+ (const.scheduler.new.prototype._layout):
+
2016-09-28 Ryosuke Niwa <rn...@webkit.org>
Text nodes assigned to a linked slot are not clickable
Added: trunk/Source/WebCore/Modules/modern-media-controls/controls/scheduler.js (0 => 206606)
--- trunk/Source/WebCore/Modules/modern-media-controls/controls/scheduler.js (rev 0)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/scheduler.js 2016-09-29 20:02:25 UTC (rev 206606)
@@ -0,0 +1,53 @@
+
+const scheduler = new class
+{
+
+ constructor()
+ {
+ this._frameID = -1;
+ this._layoutCallbacks = new Set;
+ }
+
+ // Public
+
+ scheduleLayout(callback)
+ {
+ if (typeof callback !== "function")
+ return;
+
+ this._layoutCallbacks.add(callback);
+ this._requestFrameIfNeeded();
+ }
+
+ // Private
+
+ _requestFrameIfNeeded()
+ {
+ if (this._frameID === -1 && this._layoutCallbacks.size > 0)
+ this._frameID = window.requestAnimationFrame(this._frameDidFire.bind(this));
+ }
+
+ _frameDidFire()
+ {
+ if (typeof scheduler.frameWillFire === "function")
+ scheduler.frameWillFire();
+
+ this._layout();
+ this._frameID = -1;
+ this._requestFrameIfNeeded();
+
+ if (typeof scheduler.frameDidFire === "function")
+ scheduler.frameDidFire();
+ }
+
+ _layout()
+ {
+ // Layouts are not re-entrant.
+ const layoutCallbacks = this._layoutCallbacks;
+ this._layoutCallbacks = new Set;
+
+ for (let callback of layoutCallbacks)
+ callback();
+ }
+
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes