Skip to content
Permalink
Browse files
[Modern Media Controls] macCatalyst should not use touch events
https://bugs.webkit.org/show_bug.cgi?id=240704
<rdar://problem/84570717>

Reviewed by Eric Carlson.

* Source/WebCore/Modules/modern-media-controls/controls/layout-traits.js:
(LayoutTraits.prototype.supportsTouches): Added.
* Source/WebCore/Modules/modern-media-controls/controls/macos-layout-traits.js:
(MacOSLayoutTraits.prototype.supportsTouches): Added.
Allow `LayoutTraits` to indicate whether touches are supported.

* Source/WebCore/Modules/modern-media-controls/controls/auto-hide-controller.js:
(AutoHideController):
* Source/WebCore/Modules/modern-media-controls/controls/button.js:
(Button):
* Source/WebCore/Modules/modern-media-controls/controls/range-button.js:
(RangeButton):
* Source/WebCore/Modules/modern-media-controls/controls/slider.js:
(Slider.prototype._interactionEndTarget):
* Source/WebCore/Modules/modern-media-controls/media/media-document-controller.js:
(MediaDocumentController):
Use `LayoutTraits.prototype.supportsTouches` instead of `GestureRecognizer.SupportsTouches` so that
macOS (including macCatalyst) can always act as though touches are not supported (which is fine
since mouse events are fully functional on macOS).

* LayoutTests/media/modern-media-controls/button/button-icon-name.html:
* LayoutTests/media/modern-media-controls/button/button.html:
* LayoutTests/media/modern-media-controls/buttons-container/buttons-container-buttons-property.html:
* LayoutTests/media/modern-media-controls/buttons-container/buttons-container-constructor.html:
* LayoutTests/media/modern-media-controls/buttons-container/buttons-container-layout.html:
Add `layoutDelegate`/`layoutTraits` where needed.

Canonical link: https://commits.webkit.org/250814@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294573 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
dcrousso committed May 20, 2022
1 parent 292aafc commit b8c7704519020e3b9dd394f682ee0732db0bc698
Showing 12 changed files with 43 additions and 14 deletions.
@@ -8,7 +8,7 @@

description("Testing the <code>Button</code> class <code>iconName</code> property.");

const layoutDelegate = {};
const layoutDelegate = { layoutTraits: new MacOSLayoutTraits(LayoutTraits.Mode.Inline) };

const button = new Button({ layoutDelegate });

@@ -18,6 +18,7 @@

debug("");
debug("Setting an iconName with invalid layout traits should throw");
layoutDelegate.layoutTraits = null;
shouldThrow(function() { button.iconName = Icons.Pause });
shouldBeEqualToString("button.iconName", "");

@@ -17,7 +17,9 @@

description("Testing the <code>Button</code> class.");

const button = new Button;
const layoutDelegate = { layoutTraits: new MacOSLayoutTraits(LayoutTraits.Mode.Inline) };

const button = new Button({ layoutDelegate });
document.body.appendChild(button.element);

debug("Default values");
@@ -8,13 +8,19 @@

window.jsTestIsAsync = true;

const layoutDelegate = { layoutTraits: new MacOSLayoutTraits(LayoutTraits.Mode.Inline) };

const container = new ButtonsContainer({
leftMargin: 20,
rightMargin: 20,
buttonMargin: 10
});

container.children = [new Button, new Button, new Button];
container.children = [
new Button({ layoutDelegate }),
new Button({ layoutDelegate }),
new Button({ layoutDelegate }),
];

scheduler.frameDidFire = function()
{
@@ -5,6 +5,8 @@

description("Testing the <code>ButtonsContainer</code> constructor.");

const layoutDelegate = { layoutTraits: new MacOSLayoutTraits(LayoutTraits.Mode.Inline) };

const defaultContainer = new ButtonsContainer;
shouldBeEqualToString("defaultContainer.element.localName", "div");
shouldBeEqualToString("defaultContainer.element.className.trim()", "buttons-container");
@@ -13,7 +15,11 @@
shouldBe("defaultContainer.rightMargin", "16");
shouldBe("defaultContainer.children", "[]");

const buttons = [new Button, new Button];
const buttons = [
new Button({ layoutDelegate }),
new Button({ layoutDelegate }),
];

const containerWithParameters = new ButtonsContainer({
buttonMargin: 10,
leftMargin: 20,
@@ -5,22 +5,24 @@

description("Testing <code>ButtonsContainer</code> layout.");

const tenPtWideButton = new Button;
const layoutDelegate = { layoutTraits: new MacOSLayoutTraits(LayoutTraits.Mode.Inline) };

const tenPtWideButton = new Button({ layoutDelegate });
tenPtWideButton.width = 10;

const twentyPtWideButton = new Button;
const twentyPtWideButton = new Button({ layoutDelegate });
twentyPtWideButton.width = 20;

const thirtyPtWideButton = new Button;
const thirtyPtWideButton = new Button({ layoutDelegate });
thirtyPtWideButton.width = 30;

// Should be disregarded by the container.
const disabledButton = new Button;
const disabledButton = new Button({ layoutDelegate });
disabledButton.width = 15;
disabledButton.enabled = false;

// Should be disregarded by the container.
const droppedButton = new Button;
const droppedButton = new Button({ layoutDelegate });
droppedButton.width = 25;
droppedButton.dropped = true;

@@ -41,7 +41,7 @@ class AutoHideController
this._mediaControls.element.addEventListener("pointerleave", this);
this._mediaControls.element.addEventListener("pointerout", this);

if (GestureRecognizer.SupportsTouches)
if (this._mediaControls.layoutTraits.supportsTouches())
this._tapGestureRecognizer = new TapGestureRecognizer(this._mediaControls.element, this);

this.autoHideDelay = AutoHideDelayMS;
@@ -48,7 +48,7 @@ class Button extends LayoutItem

this._enabled = true;

if (GestureRecognizer.SupportsTouches)
if (this.layoutTraits.supportsTouches())
this._tapGestureRecognizer = new TapGestureRecognizer(this.element, this);
else
this.element.addEventListener("click", this);
@@ -91,6 +91,13 @@ class LayoutTraits
return false;
}

supportsTouches()
{
// Can be overridden by subclasses.

return GestureRecognizer.SupportsTouches;
}

additionalControlScaleFactor()
{
return 1;
@@ -76,6 +76,11 @@ class MacOSLayoutTraits extends LayoutTraits
{
return true;
}

supportsTouches()
{
return false;
}

toString()
{
@@ -41,7 +41,7 @@ class RangeButton extends Button

this._indicator.visible = false;

if (GestureRecognizer.SupportsTouches)
if (this.layoutTraits.supportsTouches())
this._tapGestureRecognizer.enabled = false;
else
this.element.removeEventListener("click", this);
@@ -209,7 +209,7 @@ class Slider extends LayoutNode
_interactionEndTarget()
{
const mediaControls = this.parentOfType(MediaControls);
if (GestureRecognizer.SupportsTouches)
if (mediaControls?.layoutTraits.supportsTouches())
return mediaControls.element;
return (!mediaControls || !mediaControls.layoutTraits.isFullscreen) ? window : mediaControls.element;
}
@@ -42,7 +42,7 @@ class MediaDocumentController

let deviceType = window.navigator.platform;
if (deviceType == "MacIntel")
deviceType = GestureRecognizer.SupportsTouches ? "ipad" : "mac";
deviceType = mediaController.layoutTraits.supportsTouches() ? "ipad" : "mac";

media.classList.add(deviceType);

0 comments on commit b8c7704

Please sign in to comment.