Changeset 293658 in webkit
- Timestamp:
- May 1, 2022 6:48:01 PM (3 months ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
Modules/modern-media-controls/controls/inline-media-controls.js (modified) (3 diffs)
-
Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js (modified) (2 diffs)
-
Modules/modern-media-controls/controls/overflow-button.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r293650 r293658 1 2022-05-01 Devin Rousso <drousso@apple.com> 2 3 [Modern Media Controls] the overflow button sometimes flickers 4 https://bugs.webkit.org/show_bug.cgi?id=239921 5 <rdar://problem/91329468> 6 7 Reviewed by Eric Carlson. 8 9 There are two things that control the visibility of the `OverflowButton`: 10 1. whether any of the "default" actions (e.g. playback speed, chapters, etc.) are possible 11 2. if any other buttons that have `contextMenuOptions` are dropped (i.e. there's not enough 12 room for it because the `<video>` is narrow or there are already too many buttons) 13 14 (1) is recalculated for most JS media events (e.g. whenever tracks are changed, if 15 the `readyState` changes, etc.). 16 17 (2) is recalculated in `layout` of `MediaControls`, which is (relatively) less frequent. 18 19 In the case that the only contextmenu options are provided by (2) (i.e. none of the "default" 20 actions are possible), the frequent recalculation of (1) will combined with the fact that 21 `layout` uses a `requestAnimationFrame` to delay/batch work will cause there to be a short 22 period of time after the recalculation of (1) and before the recalculation of (2) where 23 there are no contextmenu options, resulting in the `OverflowButton` being hidden. 24 25 * Modules/modern-media-controls/controls/overflow-button.js: 26 (OverflowButton): 27 (OverflowButton.prototype.set visible): 28 (OverflowButton.prototype.set visible.isEmpty): Added. 29 (OverflowButton.prototype.get contextMenuOptions): 30 (OverflowButton.prototype.addExtraContextMenuOptions): Renamed from `addContextMenuOptions`. 31 (OverflowButton.prototype.clearExtraContextMenuOptions): Renamed from `clearContextMenuOptions`. 32 (OverflowButton.prototype.set defaultContextMenuOptions): 33 * Modules/modern-media-controls/controls/inline-media-controls.js: 34 (InlineMediaControls.prototype.layout): 35 * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js: 36 (MacOSFullscreenMediaControls.prototype.layout): 37 Instead of having a single `_contextMenuOptions` that is modified by both (1) and (2), have 38 a separate member variable for each. This way, the recalculation of (1) doesn't also clear 39 the state left over from the last time (2) was calculated (which will be recalculated by (2) 40 shortly thereafter). Use both member variables to decide whether the `OverflowButton` should 41 be `visible`, allowing (1) and (2) to update independent of eachother. 42 1 43 2022-04-30 Andres Gonzalez <andresg_22@apple.com> 2 44 -
trunk/Source/WebCore/Modules/modern-media-controls/controls/inline-media-controls.js
r289751 r293658 170 170 this.rightContainer.children.concat(this.leftContainer.children).forEach(button => delete button.dropped); 171 171 this.muteButton.style = this.preferredMuteButtonStyle; 172 this.overflowButton.clear ContextMenuOptions();172 this.overflowButton.clearExtraContextMenuOptions(); 173 173 174 174 for (let button of this._droppableButtons()) { … … 189 189 190 190 if (button !== this.overflowButton) 191 this.overflowButton.add ContextMenuOptions(button.contextMenuOptions);191 this.overflowButton.addExtraContextMenuOptions(button.contextMenuOptions); 192 192 } 193 193 … … 201 201 202 202 button.dropped = true; 203 this.overflowButton.add ContextMenuOptions(button.contextMenuOptions);203 this.overflowButton.addExtraContextMenuOptions(button.contextMenuOptions); 204 204 } 205 205 -
trunk/Source/WebCore/Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js
r292730 r293658 115 115 116 116 this._rightContainer.children.forEach(button => delete button.dropped) 117 this.overflowButton.clear ContextMenuOptions();117 this.overflowButton.clearExtraContextMenuOptions(); 118 118 119 119 this._leftContainer.visible = this.muteButton.enabled; … … 129 129 130 130 button.dropped = true; 131 this.overflowButton.add ContextMenuOptions(button.contextMenuOptions);131 this.overflowButton.addExtraContextMenuOptions(button.contextMenuOptions); 132 132 } 133 133 -
trunk/Source/WebCore/Modules/modern-media-controls/controls/overflow-button.js
r290133 r293658 35 35 }); 36 36 37 this.clearContextMenuOptions();38 37 this._defaultContextMenuOptions = {}; 38 this._extraContextMenuOptions = {}; 39 39 } 40 40 … … 48 48 set visible(flag) 49 49 { 50 let hasContextMenuOptions = false;51 for (let key in this._contextMenuOptions) {52 hasContextMenuOptions = true;53 break;50 function isEmpty(contextMenuOptions) { 51 for (let key in contextMenuOptions) 52 return false; 53 return true; 54 54 } 55 55 56 super.visible = flag && hasContextMenuOptions;56 super.visible = flag && (!isEmpty(this._defaultContextMenuOptions) || !isEmpty(this._extraContextMenuOptions)); 57 57 } 58 58 59 59 get contextMenuOptions() 60 60 { 61 return this._contextMenuOptions; 61 return { 62 ...this._defaultContextMenuOptions, 63 ...this._extraContextMenuOptions, 64 }; 62 65 } 63 66 64 add ContextMenuOptions(contextMenuOptions)67 addExtraContextMenuOptions(contextMenuOptions) 65 68 { 66 69 if (!this.enabled) … … 68 71 69 72 for (let key in contextMenuOptions) 70 this._ contextMenuOptions[key] = contextMenuOptions[key];73 this._extraContextMenuOptions[key] = contextMenuOptions[key]; 71 74 72 75 this.visible = true; 73 76 } 74 77 75 clear ContextMenuOptions()78 clearExtraContextMenuOptions() 76 79 { 77 this._ contextMenuOptions = {};80 this._extraContextMenuOptions = {}; 78 81 79 82 this.visible = false; 80 81 this.addContextMenuOptions(this._defaultContextMenuOptions);82 83 } 83 84 … … 86 87 this._defaultContextMenuOptions = defaultContextMenuOptions || {}; 87 88 88 this.clearContextMenuOptions(); 89 90 if (this.layoutDelegate) 91 this.layoutDelegate.needsLayout = true; 89 this.visible = true; 92 90 } 93 91
Note: See TracChangeset
for help on using the changeset viewer.