Title: [279481] trunk/Source/WebCore
Revision
279481
Author
[email protected]
Date
2021-07-01 13:28:32 -0700 (Thu, 01 Jul 2021)

Log Message

Move BottomControlsBarHeight and InsideMargin to be computed at runtime
https://bugs.webkit.org/show_bug.cgi?id=227505
<rdar://problem/79932256>

Reviewed by Devin Rousso.

Rather than having two JS constants that have to be kept in sync
with CSS, simply retrieve the value from the computed style.

No change in behaviour.

* Modules/modern-media-controls/controls/inline-media-controls.js:
(InlineMediaControls.prototype.layout):
* Modules/modern-media-controls/controls/media-controls.css:
(:host(audio), :host(video.media-document.audio), *):
* Modules/modern-media-controls/controls/layout-node.js: Add two helpers to
retrive computed style values.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (279480 => 279481)


--- trunk/Source/WebCore/ChangeLog	2021-07-01 20:22:16 UTC (rev 279480)
+++ trunk/Source/WebCore/ChangeLog	2021-07-01 20:28:32 UTC (rev 279481)
@@ -1,3 +1,23 @@
+2021-07-01  Dean Jackson  <[email protected]>
+
+        Move BottomControlsBarHeight and InsideMargin to be computed at runtime
+        https://bugs.webkit.org/show_bug.cgi?id=227505
+        <rdar://problem/79932256>
+
+        Reviewed by Devin Rousso.
+
+        Rather than having two JS constants that have to be kept in sync
+        with CSS, simply retrieve the value from the computed style.
+
+        No change in behaviour.
+
+        * Modules/modern-media-controls/controls/inline-media-controls.js:
+        (InlineMediaControls.prototype.layout):
+        * Modules/modern-media-controls/controls/media-controls.css:
+        (:host(audio), :host(video.media-document.audio), *):
+        * Modules/modern-media-controls/controls/layout-node.js: Add two helpers to
+        retrive computed style values.
+
 2021-07-01  Brady Eidson  <[email protected]>
 
         HIDGamepadProvider adds an extra 50ms to all inputs

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/inline-media-controls.js (279480 => 279481)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/inline-media-controls.js	2021-07-01 20:22:16 UTC (rev 279480)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/inline-media-controls.js	2021-07-01 20:28:32 UTC (rev 279481)
@@ -23,9 +23,6 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-const InsideMargin = 6; // Minimum margin to guarantee around all controls, this constant needs to stay in sync with the --inline-controls-inside-margin CSS variable.
-const BottomControlsBarHeight = 31; // This constant needs to stay in sync with the --inline-controls-bar-height CSS variable.
-
 class InlineMediaControls extends MediaControls
 {
 
@@ -133,7 +130,9 @@
         this.topLeftControlsBar.visible = this._topLeftControlsBarContainer.children.some(button => button.visible);
 
         // Compute the visible size for the controls bar.
-        this.bottomControlsBar.width = this._shouldUseAudioLayout ? this.width : (this.width - 2 * InsideMargin);
+        if (!this._inlineInsideMargin)
+            this._inlineInsideMargin = this.computedValueForStylePropertyInPx("--inline-controls-inside-margin");
+        this.bottomControlsBar.width = this._shouldUseAudioLayout ? this.width : (this.width - 2 * this._inlineInsideMargin);
 
         // Compute the absolute minimum width to display the center control (status label or time control).
         const centerControl = this.statusLabel.enabled ? this.statusLabel : this.timeControl;
@@ -218,7 +217,9 @@
 
         // Ensure we position the bottom controls bar at the bottom of the frame, accounting for
         // the inside margin, unless this would yield a position outside of the frame.
-        this.bottomControlsBar.y = Math.max(0, this.height - BottomControlsBarHeight - InsideMargin);
+        if (!this._inlineBottomControlsBarHeight)
+            this._inlineBottomControlsBarHeight = this.computedValueForStylePropertyInPx("--inline-controls-bar-height");
+        this.bottomControlsBar.y = Math.max(0, this.height - this._inlineBottomControlsBarHeight - this._inlineInsideMargin);
 
         this.bottomControlsBar.children = controlsBarChildren;
         if (!this._shouldUseAudioLayout && !this._shouldUseSingleBarLayout)

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/layout-node.js (279480 => 279481)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/layout-node.js	2021-07-01 20:22:16 UTC (rev 279480)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/layout-node.js	2021-07-01 20:28:32 UTC (rev 279481)
@@ -229,6 +229,21 @@
             this._updateDirtyState();
     }
 
+    computedValueForStyleProperty(propertyName)
+    {
+        return window.getComputedStyle(this.element).getPropertyValue(propertyName);
+    }
+
+    computedValueForStylePropertyInPx(propertyName)
+    {
+        const value = this.computedValueForStyleProperty(propertyName);
+        if (!value)
+            return 0;
+        if (!value.endsWith("px"))
+            return 0;
+        return parseFloat(value);
+    }
+
     // Protected
 
     layout()

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


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js	2021-07-01 20:22:16 UTC (rev 279480)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js	2021-07-01 20:28:32 UTC (rev 279481)
@@ -59,8 +59,13 @@
         if (!this._volumeSliderContainer)
             return;
 
+        if (!this._inlineInsideMargin)
+            this._inlineInsideMargin = this.computedValueForStylePropertyInPx("--inline-controls-inside-margin");
+        if (!this._inlineBottomControlsBarHeight)
+            this._inlineBottomControlsBarHeight = this.computedValueForStylePropertyInPx("--inline-controls-bar-height");
+
         this._volumeSliderContainer.x = this.rightContainer.x + this.muteButton.x;
-        this._volumeSliderContainer.y = this.bottomControlsBar.y - BottomControlsBarHeight - InsideMargin;
+        this._volumeSliderContainer.y = this.bottomControlsBar.y - this._inlineBottomControlsBarHeight - this._inlineInsideMargin;
     }
 
     get preferredMuteButtonStyle()

Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/media-controls.css (279480 => 279481)


--- trunk/Source/WebCore/Modules/modern-media-controls/controls/media-controls.css	2021-07-01 20:22:16 UTC (rev 279480)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/media-controls.css	2021-07-01 20:28:32 UTC (rev 279481)
@@ -37,7 +37,6 @@
 }
 
 * {
-    /* This constant needs to stay in sync with the InsideMargin JS constant. */
     --inline-controls-inside-margin: 6px;
     --fullscreen-controls-bar-height: 75px;
     --primary-glyph-color: rgba(255, 255, 255, 0.75);
@@ -45,7 +44,6 @@
 }
 
 :host(audio), :host(video.media-document.audio), * {
-    /* This constant needs to stay in sync with the BottomControlsBarHeight JS constant. */
     --inline-controls-bar-height: 31px;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to