Title: [211209] trunk
Revision
211209
Author
commit-qu...@webkit.org
Date
2017-01-26 06:58:10 -0800 (Thu, 26 Jan 2017)

Log Message

[Modern Media Controls] Hiding controls, changing their width and showing them again shows an incorrect layout
https://bugs.webkit.org/show_bug.cgi?id=167160
<rdar://problem/29612318>

Patch by Antoine Quint <grao...@apple.com> on 2017-01-26
Reviewed by Dean Jackson.

Source/WebCore:

When we toggle visibility of the controls bar, we notify the hosting media controls and in the case of the
macOS inline media controls, we update the controls layout which would have failed to run last time it tried
due to the controls bar being hidden.

Test: media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-resize-with-hidden-controls-bar.html

* Modules/modern-media-controls/controls/controls-bar.js:
(ControlsBar.prototype.set visible):
* Modules/modern-media-controls/controls/macos-inline-media-controls.js:
(MacOSInlineMediaControls.prototype.controlsBarVisibilityDidChange):
* Modules/modern-media-controls/controls/media-controls.js:
(MediaControls.prototype.controlsBarVisibilityDidChange):

LayoutTests:

Add a new test that creates media controls at a given width, hides the controls bar, increases the width, makes
the controls bar visible again, and checks that the layout was correctly updated as a result.

* media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-resize-with-hidden-controls-bar-expected.txt: Added.
* media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-resize-with-hidden-controls-bar.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (211208 => 211209)


--- trunk/LayoutTests/ChangeLog	2017-01-26 10:52:20 UTC (rev 211208)
+++ trunk/LayoutTests/ChangeLog	2017-01-26 14:58:10 UTC (rev 211209)
@@ -1,3 +1,17 @@
+2017-01-26  Antoine Quint  <grao...@apple.com>
+
+        [Modern Media Controls] Hiding controls, changing their width and showing them again shows an incorrect layout
+        https://bugs.webkit.org/show_bug.cgi?id=167160
+        <rdar://problem/29612318>
+
+        Reviewed by Dean Jackson.
+
+        Add a new test that creates media controls at a given width, hides the controls bar, increases the width, makes
+        the controls bar visible again, and checks that the layout was correctly updated as a result.
+
+        * media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-resize-with-hidden-controls-bar-expected.txt: Added.
+        * media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-resize-with-hidden-controls-bar.html: Added.
+
 2017-01-25  Ryosuke Niwa  <rn...@webkit.org>
 
         Crash under DOMSelection::deleteFromDocument()

Added: trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-resize-with-hidden-controls-bar-expected.txt (0 => 211209)


--- trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-resize-with-hidden-controls-bar-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-resize-with-hidden-controls-bar-expected.txt	2017-01-26 14:58:10 UTC (rev 211209)
@@ -0,0 +1,16 @@
+Testing MacOSInlineMediaControls width change while the controls bar is hidden.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Making the controls bar invisible.
+
+Making the controls 100px wider
+
+Making the controls bar visible again.
+PASS rightContainer.x is expectedRightContainerX + 100
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-resize-with-hidden-controls-bar.html (0 => 211209)


--- trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-resize-with-hidden-controls-bar.html	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-resize-with-hidden-controls-bar.html	2017-01-26 14:58:10 UTC (rev 211209)
@@ -0,0 +1,52 @@
+<script src=""
+<script src="" type="text/_javascript_"></script>
+<script src="" type="text/_javascript_"></script>
+<body>
+<script type="text/_javascript_">
+
+description("Testing <code>MacOSInlineMediaControls</code> width change while the controls bar is hidden.");
+
+window.jsTestIsAsync = true;
+
+const mediaControls = new MacOSInlineMediaControls({ width: 600 });
+
+const leftContainer = mediaControls.controlsBar.children[0];
+const rightContainer = mediaControls.controlsBar.children[1];
+const buttons = leftContainer.buttons.concat(rightContainer.buttons);
+
+let numberOfFrames = 0;
+let expectedRightContainerX = 0;
+scheduler.frameDidFire = function()
+{
+    if (buttons.some(button => button.width == 0))
+        return;
+
+    numberOfFrames++;
+
+    switch (numberOfFrames) {
+    case 1:
+        mediaControls.controlsBar.visible = false;
+        debug("Making the controls bar invisible.");
+        expectedRightContainerX = rightContainer.x;
+        break;
+    case 2:
+        debug("");
+        debug("Making the controls 100px wider");
+        mediaControls.width += 100;
+        break;
+    case 3:
+        mediaControls.controlsBar.visible = true;
+        debug("");
+        debug("Making the controls bar visible again.");
+        shouldBe("rightContainer.x", "expectedRightContainerX + 100");
+
+        debug("");
+        finishMediaControlsTest();
+        break;
+    }
+
+};
+
+</script>
+<script src=""
+</body>

Modified: trunk/Source/WebCore/ChangeLog (211208 => 211209)


--- trunk/Source/WebCore/ChangeLog	2017-01-26 10:52:20 UTC (rev 211208)
+++ trunk/Source/WebCore/ChangeLog	2017-01-26 14:58:10 UTC (rev 211209)
@@ -1,3 +1,24 @@
+2017-01-26  Antoine Quint  <grao...@apple.com>
+
+        [Modern Media Controls] Hiding controls, changing their width and showing them again shows an incorrect layout
+        https://bugs.webkit.org/show_bug.cgi?id=167160
+        <rdar://problem/29612318>
+
+        Reviewed by Dean Jackson.
+
+        When we toggle visibility of the controls bar, we notify the hosting media controls and in the case of the
+        macOS inline media controls, we update the controls layout which would have failed to run last time it tried
+        due to the controls bar being hidden.
+
+        Test: media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-resize-with-hidden-controls-bar.html
+
+        * Modules/modern-media-controls/controls/controls-bar.js:
+        (ControlsBar.prototype.set visible):
+        * Modules/modern-media-controls/controls/macos-inline-media-controls.js:
+        (MacOSInlineMediaControls.prototype.controlsBarVisibilityDidChange):
+        * Modules/modern-media-controls/controls/media-controls.js:
+        (MediaControls.prototype.controlsBarVisibilityDidChange):
+
 2017-01-26  Csaba Osztrogonác  <o...@webkit.org>
 
         [Mac][cmake] Unreviewed speculative buildfix after r211161.

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/controls-bar.js (211208 => 211209)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/controls-bar.js	2017-01-26 10:52:20 UTC (rev 211208)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/controls-bar.js	2017-01-26 14:58:10 UTC (rev 211209)
@@ -111,6 +111,9 @@
 
     set visible(flag)
     {
+        if (this.visible === flag)
+            return;
+
         // If we just got made visible again, let's fade the controls in.
         if (flag && !this.visible)
             this.faded = false;
@@ -118,6 +121,8 @@
             this._cancelAutoHideTimer();
 
         super.visible = flag;
+
+        this._mediaControls.controlsBarVisibilityDidChange(this);
     }
 
     get faded()

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js (211208 => 211209)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js	2017-01-26 10:52:20 UTC (rev 211208)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js	2017-01-26 14:58:10 UTC (rev 211209)
@@ -131,4 +131,10 @@
         this._volumeSliderContainer.visible = event.type === "mouseenter" || event.relatedTarget === this._volumeSliderContainer.element;
     }
 
+    controlsBarVisibilityDidChange(controlsBar)
+    {
+        if (controlsBar.visible)
+            this.layout();
+    }
+
 }

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/media-controls.js (211208 => 211209)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/media-controls.js	2017-01-26 10:52:20 UTC (rev 211208)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/media-controls.js	2017-01-26 14:58:10 UTC (rev 211209)
@@ -132,6 +132,11 @@
             super.commitProperty(propertyName);
     }
 
+    controlsBarVisibilityDidChange(controlsBar)
+    {
+        // Implemented by subclasses as needed.
+    }
+
     // Private
 
     _invalidateChildren()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to