⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 279481 in webkit


Ignore:
Timestamp:
Jul 1, 2021, 1:28:32 PM (5 years ago)
Author:
dino@apple.com
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.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r279480 r279481  
     12021-07-01  Dean Jackson  <dino@apple.com>
     2
     3        Move BottomControlsBarHeight and InsideMargin to be computed at runtime
     4        https://bugs.webkit.org/show_bug.cgi?id=227505
     5        <rdar://problem/79932256>
     6
     7        Reviewed by Devin Rousso.
     8
     9        Rather than having two JS constants that have to be kept in sync
     10        with CSS, simply retrieve the value from the computed style.
     11
     12        No change in behaviour.
     13
     14        * Modules/modern-media-controls/controls/inline-media-controls.js:
     15        (InlineMediaControls.prototype.layout):
     16        * Modules/modern-media-controls/controls/media-controls.css:
     17        (:host(audio), :host(video.media-document.audio), *):
     18        * Modules/modern-media-controls/controls/layout-node.js: Add two helpers to
     19        retrive computed style values.
     20
    1212021-07-01  Brady Eidson  <beidson@apple.com>
    222
  • trunk/Source/WebCore/Modules/modern-media-controls/controls/inline-media-controls.js

    r275358 r279481  
    2424 */
    2525
    26 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.
    27 const BottomControlsBarHeight = 31; // This constant needs to stay in sync with the --inline-controls-bar-height CSS variable.
    28 
    2926class InlineMediaControls extends MediaControls
    3027{
    … …  
    134131
    135132        // Compute the visible size for the controls bar.
    136         this.bottomControlsBar.width = this._shouldUseAudioLayout ? this.width : (this.width - 2 * InsideMargin);
     133        if (!this._inlineInsideMargin)
     134            this._inlineInsideMargin = this.computedValueForStylePropertyInPx("--inline-controls-inside-margin");
     135        this.bottomControlsBar.width = this._shouldUseAudioLayout ? this.width : (this.width - 2 * this._inlineInsideMargin);
    137136
    138137        // Compute the absolute minimum width to display the center control (status label or time control).
    … …  
    219218        // Ensure we position the bottom controls bar at the bottom of the frame, accounting for
    220219        // the inside margin, unless this would yield a position outside of the frame.
    221         this.bottomControlsBar.y = Math.max(0, this.height - BottomControlsBarHeight - InsideMargin);
     220        if (!this._inlineBottomControlsBarHeight)
     221            this._inlineBottomControlsBarHeight = this.computedValueForStylePropertyInPx("--inline-controls-bar-height");
     222        this.bottomControlsBar.y = Math.max(0, this.height - this._inlineBottomControlsBarHeight - this._inlineInsideMargin);
    222223
    223224        this.bottomControlsBar.children = controlsBarChildren;
  • trunk/Source/WebCore/Modules/modern-media-controls/controls/layout-node.js

    r227904 r279481  
    230230    }
    231231
     232    computedValueForStyleProperty(propertyName)
     233    {
     234        return window.getComputedStyle(this.element).getPropertyValue(propertyName);
     235    }
     236
     237    computedValueForStylePropertyInPx(propertyName)
     238    {
     239        const value = this.computedValueForStyleProperty(propertyName);
     240        if (!value)
     241            return 0;
     242        if (!value.endsWith("px"))
     243            return 0;
     244        return parseFloat(value);
     245    }
     246
    232247    // Protected
    233248
  • trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-inline-media-controls.js

    r279309 r279481  
    6060            return;
    6161
     62        if (!this._inlineInsideMargin)
     63            this._inlineInsideMargin = this.computedValueForStylePropertyInPx("--inline-controls-inside-margin");
     64        if (!this._inlineBottomControlsBarHeight)
     65            this._inlineBottomControlsBarHeight = this.computedValueForStylePropertyInPx("--inline-controls-bar-height");
     66
    6267        this._volumeSliderContainer.x = this.rightContainer.x + this.muteButton.x;
    63         this._volumeSliderContainer.y = this.bottomControlsBar.y - BottomControlsBarHeight - InsideMargin;
     68        this._volumeSliderContainer.y = this.bottomControlsBar.y - this._inlineBottomControlsBarHeight - this._inlineInsideMargin;
    6469    }
    6570
  • trunk/Source/WebCore/Modules/modern-media-controls/controls/media-controls.css

    r274521 r279481  
    3838
    3939* {
    40     /* This constant needs to stay in sync with the InsideMargin JS constant. */
    4140    --inline-controls-inside-margin: 6px;
    4241    --fullscreen-controls-bar-height: 75px;
    … …  
    4645
    4746:host(audio), :host(video.media-document.audio), * {
    48     /* This constant needs to stay in sync with the BottomControlsBarHeight JS constant. */
    4947    --inline-controls-bar-height: 31px;
    5048}
Note: See TracChangeset for help on using the changeset viewer.