Diff
Modified: trunk/LayoutTests/ChangeLog (206744 => 206745)
--- trunk/LayoutTests/ChangeLog 2016-10-03 20:27:33 UTC (rev 206744)
+++ trunk/LayoutTests/ChangeLog 2016-10-03 20:31:06 UTC (rev 206745)
@@ -1,3 +1,18 @@
+2016-10-03 Antoine Quint <[email protected]>
+
+ [Modern Media Controls] LayoutItem and Button classes
+ https://bugs.webkit.org/show_bug.cgi?id=162868
+ <rdar://problem/28590166>
+
+ Reviewed by Dean Jackson.
+
+ Testing all public properties and methods of the LayoutItem and Button classes.
+
+ * media/modern-media-controls/button/button-expected.txt: Added.
+ * media/modern-media-controls/button/button.html: Added.
+ * media/modern-media-controls/layout-item/layout-item-expected.txt: Added.
+ * media/modern-media-controls/layout-item/layout-item.html: Added.
+
2016-10-03 Andy Estes <[email protected]>
ASSERTION FAILED: url.containsOnlyASCII() in WebCore::checkEncodedString() when parsing an invalid CSS cursor URL
Added: trunk/LayoutTests/media/modern-media-controls/button/button-expected.txt (0 => 206745)
--- trunk/LayoutTests/media/modern-media-controls/button/button-expected.txt (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/button/button-expected.txt 2016-10-03 20:31:06 UTC (rev 206745)
@@ -0,0 +1,23 @@
+Testing the Button class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Default values
+PASS button.enabled is true
+PASS button.uiDelegate is undefined.
+PASS button.element.localName is "button"
+
+Responds to click events
+PASS clickedButton === button is true
+
+Doesn't respond to click events when disabled
+
+Has all the appropriate styles
+PASS style.position is "absolute"
+PASS style.borderWidth is "0px"
+PASS style.webkitAppearance is "none"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/media/modern-media-controls/button/button.html (0 => 206745)
--- trunk/LayoutTests/media/modern-media-controls/button/button.html (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/button/button.html 2016-10-03 20:31:06 UTC (rev 206745)
@@ -0,0 +1,48 @@
+<link rel="stylesheet" href="" type="text/css" media="screen">
+<script src=""
+<script src="" type="text/_javascript_"></script>
+<script src="" type="text/_javascript_"></script>
+<script src="" type="text/_javascript_"></script>
+<script src="" type="text/_javascript_"></script>
+<body>
+<script type="text/_javascript_">
+
+description("Testing the <code>Button</code> class.");
+
+debug("Default values");
+const button = new Button;
+shouldBeTrue("button.enabled");
+shouldBeUndefined("button.uiDelegate");
+shouldBeEqualToString("button.element.localName", "button");
+
+let clickedButton;
+
+debug("");
+debug("Responds to click events");
+button.uiDelegate = {
+
+ buttonWasClicked: function(aButton)
+ {
+ clickedButton = aButton;
+ shouldBeTrue("clickedButton === button");
+ }
+
+}
+button.element.dispatchEvent(new MouseEvent("click"));
+
+debug("");
+debug("Doesn't respond to click events when disabled");
+button.enabled = false;
+button.element.dispatchEvent(new MouseEvent("click"));
+
+debug("");
+debug("Has all the appropriate styles")
+document.body.appendChild(button.element);
+const style = window.getComputedStyle(button.element);
+shouldBeEqualToString("style.position", "absolute");
+shouldBeEqualToString("style.borderWidth", "0px");
+shouldBeEqualToString("style.webkitAppearance", "none");
+
+</script>
+<script src=""
+</body>
Added: trunk/LayoutTests/media/modern-media-controls/layout-item/layout-item-expected.txt (0 => 206745)
--- trunk/LayoutTests/media/modern-media-controls/layout-item/layout-item-expected.txt (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/layout-item/layout-item-expected.txt 2016-10-03 20:31:06 UTC (rev 206745)
@@ -0,0 +1,17 @@
+Testing the LayoutItem class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Creating a LayoutItem and setting a layout delegate after construction.
+PASS itemWithNoParameter.layoutTraits === LayoutTraits.Unknown is true
+PASS !!(itemWithNoParameter.layoutTraits | LayoutTraits.Mac) is true
+PASS !!(itemWithNoParameter.layoutTraits | LayoutTraits.Fullscreen) is true
+
+Creating a LayoutItem with a layout delegate set at construction.
+PASS !!(itemWithLayoutDelegate.layoutTraits | LayoutTraits.Mac) is true
+PASS !!(itemWithLayoutDelegate.layoutTraits | LayoutTraits.Fullscreen) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/media/modern-media-controls/layout-item/layout-item.html (0 => 206745)
--- trunk/LayoutTests/media/modern-media-controls/layout-item/layout-item.html (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/layout-item/layout-item.html 2016-10-03 20:31:06 UTC (rev 206745)
@@ -0,0 +1,32 @@
+<script src=""
+<script src="" type="text/_javascript_"></script>
+<script src="" type="text/_javascript_"></script>
+<script src="" type="text/_javascript_"></script>
+<script type="text/_javascript_">
+
+description("Testing the <code>LayoutItem</code> class.");
+
+const layoutDelegate = new class
+{
+ get layoutTraits()
+ {
+ return LayoutTraits.Mac | LayoutTraits.Fullscreen;
+ }
+};
+
+debug("Creating a LayoutItem and setting a layout delegate after construction.");
+const itemWithNoParameter = new LayoutItem;
+shouldBeTrue("itemWithNoParameter.layoutTraits === LayoutTraits.Unknown");
+
+itemWithNoParameter.layoutDelegate = layoutDelegate;
+shouldBeTrue("!!(itemWithNoParameter.layoutTraits | LayoutTraits.Mac)");
+shouldBeTrue("!!(itemWithNoParameter.layoutTraits | LayoutTraits.Fullscreen)");
+
+debug("");
+debug("Creating a LayoutItem with a layout delegate set at construction.");
+const itemWithLayoutDelegate = new LayoutItem({ layoutDelegate });
+shouldBeTrue("!!(itemWithLayoutDelegate.layoutTraits | LayoutTraits.Mac)");
+shouldBeTrue("!!(itemWithLayoutDelegate.layoutTraits | LayoutTraits.Fullscreen)");
+
+</script>
+<script src=""
Modified: trunk/Source/WebCore/ChangeLog (206744 => 206745)
--- trunk/Source/WebCore/ChangeLog 2016-10-03 20:27:33 UTC (rev 206744)
+++ trunk/Source/WebCore/ChangeLog 2016-10-03 20:31:06 UTC (rev 206745)
@@ -1,3 +1,33 @@
+2016-10-03 Antoine Quint <[email protected]>
+
+ [Modern Media Controls] LayoutItem and Button classes
+ https://bugs.webkit.org/show_bug.cgi?id=162868
+ <rdar://problem/28590166>
+
+ Reviewed by Dean Jackson.
+
+ We introduce the new Button class and its parent class LayoutItem. We will subclass Button
+ a lot in coming patches, as it provides a way to create a button and provide a delegate to
+ respond to UI events via the `uiDelegate` property. A Button extends a LayoutItem, another
+ class that we'll subclass heavily in coming patches, which is simply a LayoutNode with a
+ `layoutDelegate` which allows to set the node's `layoutTraits`, a bit-mask allowing to
+ specify layout attributes such as the platform and playback styles.
+
+ Tests: media/modern-media-controls/button/button.html
+ media/modern-media-controls/layout-item/layout-item.html
+
+ * Modules/modern-media-controls/controls/button.css: Added.
+ (button):
+ * Modules/modern-media-controls/controls/button.js: Added.
+ (Button):
+ (Button.prototype.get enabled):
+ (Button.prototype.set enabled):
+ (Button.prototype.handleEvent):
+ (Button.prototype._handleUIEvent):
+ * Modules/modern-media-controls/controls/layout-item.js: Added.
+ (LayoutItem.prototype.get layoutTraits):
+ (LayoutItem):
+
2016-10-03 Andy Estes <[email protected]>
ASSERTION FAILED: url.containsOnlyASCII() in WebCore::checkEncodedString() when parsing an invalid CSS cursor URL
Added: trunk/Source/WebCore/Modules/modern-media-controls/controls/button.css (0 => 206745)
--- trunk/Source/WebCore/Modules/modern-media-controls/controls/button.css (rev 0)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/button.css 2016-10-03 20:31:06 UTC (rev 206745)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+button {
+ position: absolute;
+ border: 0;
+ -webkit-appearance: none;
+}
Added: trunk/Source/WebCore/Modules/modern-media-controls/controls/button.js (0 => 206745)
--- trunk/Source/WebCore/Modules/modern-media-controls/controls/button.js (rev 0)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/button.js 2016-10-03 20:31:06 UTC (rev 206745)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+class Button extends LayoutItem
+{
+
+ constructor(layoutDelegate)
+ {
+ super({
+ element: "<button>",
+ layoutDelegate
+ });
+
+ this._enabled = true;
+
+ this.element.addEventListener("click", this);
+ }
+
+ // Public
+
+ get enabled()
+ {
+ return this._enabled;
+ }
+
+ set enabled(flag)
+ {
+ this._enabled = flag;
+ if (flag && this.layoutDelegate && typeof this.layoutDelegate.layout === "function")
+ this.layoutDelegate.layout();
+ }
+
+ // Protected
+
+ handleEvent(event)
+ {
+ if (event.currentTarget === this.element)
+ this._handleUIEvent(event);
+ }
+
+ // Private
+
+ _handleUIEvent(event)
+ {
+ if (this._enabled && event.type === "click" && this.uiDelegate && typeof this.uiDelegate.buttonWasClicked === "function")
+ this.uiDelegate.buttonWasClicked(this);
+ }
+
+}
Added: trunk/Source/WebCore/Modules/modern-media-controls/controls/layout-item.js (0 => 206745)
--- trunk/Source/WebCore/Modules/modern-media-controls/controls/layout-item.js (rev 0)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/layout-item.js 2016-10-03 20:31:06 UTC (rev 206745)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+const LayoutTraits = {
+ Unknown : 0,
+ Mac : 1 << 0,
+ iOS : 1 << 1,
+ Fullscreen : 1 << 2
+};
+
+class LayoutItem extends LayoutNode
+{
+
+ constructor({ element = null, layoutDelegate = null } = {})
+ {
+ super(element);
+
+ this.layoutDelegate = layoutDelegate;
+ }
+
+ // Public
+
+ get layoutTraits()
+ {
+ return (this.layoutDelegate && this.layoutDelegate.layoutTraits) || LayoutTraits.Unknown;
+ }
+
+}