Title: [115125] trunk
Revision
115125
Author
[email protected]
Date
2012-04-24 15:50:05 -0700 (Tue, 24 Apr 2012)

Log Message

Extra display logic for the media control panel element
https://bugs.webkit.org/show_bug.cgi?id=82476

Patch by Victor Carbune <[email protected]> on 2012-04-24
Reviewed by Eric Carlson.

Source/WebCore:

This patch fixes a bug which caused the controls to be displayed
when they should remain hidden. Added an extra variable to the
panel elements which properly keeps the state of the panel (visible or not).

Test: media/video-controls-toggling.html

* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlPanelElement::MediaControlPanelElement): Added the
variable m_isDisplayed to hold the state whether the panel is visible or not.
(WebCore::MediaControlPanelElement::makeOpaque): Showing the panel only if it
is visible.
(WebCore::MediaControlPanelElement::makeTransparent): Enabled the transition
timer which sets the display:none property on the controls.
(WebCore::MediaControlPanelElement::setIsDisplayed): Setter for the state variable.
(WebCore):
* html/shadow/MediaControlElements.h:
(MediaControlPanelElement):
* html/shadow/MediaControlRootElement.cpp:
(WebCore::MediaControlRootElement::show): Updated the panel visibility state.
(WebCore::MediaControlRootElement::hide): Updated the panel visibility state.
* html/shadow/MediaControlRootElementChromium.cpp:
(WebCore::MediaControlRootElementChromium::show): Updated the panel visibility state.
(WebCore::MediaControlRootElementChromium::hide): Updated the panel visibility state.

LayoutTests:

Added test to ensure that controls are not displayed when
the controls attribute is not set.

* media/video-controls-toggling-expected.txt: Added.
* media/video-controls-toggling.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (115124 => 115125)


--- trunk/LayoutTests/ChangeLog	2012-04-24 22:46:32 UTC (rev 115124)
+++ trunk/LayoutTests/ChangeLog	2012-04-24 22:50:05 UTC (rev 115125)
@@ -1,3 +1,16 @@
+2012-04-24  Victor Carbune  <[email protected]>
+
+        Extra display logic for the media control panel element
+        https://bugs.webkit.org/show_bug.cgi?id=82476
+
+        Reviewed by Eric Carlson.
+
+        Added test to ensure that controls are not displayed when
+        the controls attribute is not set.
+
+        * media/video-controls-toggling-expected.txt: Added.
+        * media/video-controls-toggling.html: Added.
+
 2012-04-24  Alexandru Chiculita  <[email protected]>
 
         CSS Shaders: Custom filters painting is broken

Added: trunk/LayoutTests/media/video-controls-toggling-expected.txt (0 => 115125)


--- trunk/LayoutTests/media/video-controls-toggling-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/video-controls-toggling-expected.txt	2012-04-24 22:50:05 UTC (rev 115125)
@@ -0,0 +1,28 @@
+Tests that showing / hiding video controls uses the sets the display:none property
+
+** Playing the video **
+RUN(video.play())
+
+** Move mouse somewhere over the panel **
+RUN(eventSender.mouseMoveTo(muteButtonCoordinates[0], muteButtonCoordinates[1]))
+
+** Test that controls are shown when controls attribute is present **
+EXPECTED (panel.style['display'] != 'none') OK
+
+** Move mouse outside the video **
+RUN(eventSender.mouseMoveTo(video.offsetLeft, video.offsetTop + 2 * video.offsetHeight))
+
+** The controls should have the display property set to none
+EXPECTED (panel.style['display'] == 'none') OK
+
+** Remove controls attribute**
+RUN(video.removeAttribute('controls'))
+
+** Move mouse back over the panel **
+RUN(eventSender.mouseMoveTo(muteButtonCoordinates[0], muteButtonCoordinates[1]))
+
+** Video controls should not be shown **
+EXPECTED (panel.style['display'] == 'none') OK
+
+END OF TEST
+

Added: trunk/LayoutTests/media/video-controls-toggling.html (0 => 115125)


--- trunk/LayoutTests/media/video-controls-toggling.html	                        (rev 0)
+++ trunk/LayoutTests/media/video-controls-toggling.html	2012-04-24 22:50:05 UTC (rev 115125)
@@ -0,0 +1,87 @@
+<html>
+<head>
+    <title>Test rendering of volume slider of video tag</title>
+    <script src=""
+    <script src=""
+    <script src=""
+    <script>
+        var video;
+        var panel;
+        var muteButtonCoordinates;
+        var fadeoutTime = 300;
+
+        function init()
+        {
+            video = document.getElementsByTagName("video")[0];
+            video.src = "" "content/test");
+
+            consoleWrite("");
+            consoleWrite("** Playing the video **");
+            run("video.play()");
+        }
+
+        function test()
+        {
+            panel = mediaControlsElement(internals.shadowRoot(video).firstChild, "-webkit-media-controls-panel");
+
+            if (window.eventSender) {
+                try {
+                    muteButtonCoordinates = mediaControlsButtonCoordinates(video, "mute-button");
+                } catch (exception) {
+                    layoutTestController.notifyDone();
+                    return;
+                }
+
+                consoleWrite("");
+                consoleWrite("** Move mouse somewhere over the panel **");
+                run("eventSender.mouseMoveTo(muteButtonCoordinates[0], muteButtonCoordinates[1])");
+            }
+
+            consoleWrite("");
+            consoleWrite("** Test that controls are shown when controls attribute is present **");
+            testExpected("panel.style['display']", 'none', "!=");
+
+            if (window.eventSender) {
+                consoleWrite("");
+                consoleWrite("** Move mouse outside the video **");
+                run("eventSender.mouseMoveTo(video.offsetLeft, video.offsetTop + 2 * video.offsetHeight)");
+            }
+
+            setTimeout(continueTest, fadeoutTime);
+        }
+
+        function continueTest()
+        {
+            if (panel.style['display'] != 'none') {
+                setTimeout(continueTest, fadeoutTime);
+                return;
+            }
+
+            consoleWrite("");
+            consoleWrite("** The controls should have the display property set to none");
+            testExpected("panel.style['display']", 'none', "==");
+
+            consoleWrite("");
+            consoleWrite("** Remove controls attribute**");
+            run("video.removeAttribute('controls')");
+
+            consoleWrite("");
+            consoleWrite("** Move mouse back over the panel **");
+            run("eventSender.mouseMoveTo(muteButtonCoordinates[0], muteButtonCoordinates[1])");
+
+            consoleWrite("");
+            consoleWrite("** Video controls should not be shown **");
+            testExpected("panel.style['display']", 'none', "==");
+
+            consoleWrite("");
+
+            endTest();
+        }
+
+    </script>
+</head>
+<body _onload_="init()">
+    Tests that showing / hiding video controls uses the sets the display:none property<br>
+    <video _onplay_="test()" controls></video>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (115124 => 115125)


--- trunk/Source/WebCore/ChangeLog	2012-04-24 22:46:32 UTC (rev 115124)
+++ trunk/Source/WebCore/ChangeLog	2012-04-24 22:50:05 UTC (rev 115125)
@@ -1,3 +1,34 @@
+2012-04-24  Victor Carbune  <[email protected]>
+
+        Extra display logic for the media control panel element
+        https://bugs.webkit.org/show_bug.cgi?id=82476
+
+        Reviewed by Eric Carlson.
+
+        This patch fixes a bug which caused the controls to be displayed
+        when they should remain hidden. Added an extra variable to the
+        panel elements which properly keeps the state of the panel (visible or not).
+
+        Test: media/video-controls-toggling.html
+
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlPanelElement::MediaControlPanelElement): Added the
+        variable m_isDisplayed to hold the state whether the panel is visible or not.
+        (WebCore::MediaControlPanelElement::makeOpaque): Showing the panel only if it
+        is visible.
+        (WebCore::MediaControlPanelElement::makeTransparent): Enabled the transition
+        timer which sets the display:none property on the controls.
+        (WebCore::MediaControlPanelElement::setIsDisplayed): Setter for the state variable.
+        (WebCore):
+        * html/shadow/MediaControlElements.h:
+        (MediaControlPanelElement):
+        * html/shadow/MediaControlRootElement.cpp:
+        (WebCore::MediaControlRootElement::show): Updated the panel visibility state.
+        (WebCore::MediaControlRootElement::hide): Updated the panel visibility state.
+        * html/shadow/MediaControlRootElementChromium.cpp:
+        (WebCore::MediaControlRootElementChromium::show): Updated the panel visibility state.
+        (WebCore::MediaControlRootElementChromium::hide): Updated the panel visibility state.
+
 2012-04-24  Alexandru Chiculita  <[email protected]>
 
         CSS Shaders: Custom filters painting is broken

Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.cpp (115124 => 115125)


--- trunk/Source/WebCore/html/shadow/MediaControlElements.cpp	2012-04-24 22:46:32 UTC (rev 115124)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.cpp	2012-04-24 22:50:05 UTC (rev 115125)
@@ -108,6 +108,7 @@
     : MediaControlElement(document)
     , m_canBeDragged(false)
     , m_isBeingDragged(false)
+    , m_isDisplayed(false)
     , m_opaque(true)
     , m_transitionTimer(this, &MediaControlPanelElement::transitionTimerFired)
 {
@@ -241,9 +242,8 @@
 
     m_opaque = true;
 
-    // FIXME(BUG 79347): The display:none property should be toggled below only
-    // when display logic is introduced.
-    // show();
+    if (m_isDisplayed)
+        show();
 }
 
 void MediaControlPanelElement::makeTransparent()
@@ -257,9 +257,7 @@
 
     m_opaque = false;
 
-    // FIXME(BUG 79347): The display:none property should be toggled below
-    // (through the timer start) when display logic is introduced.
-    // startTimer();
+    startTimer();
 }
 
 void MediaControlPanelElement::defaultEventHandler(Event* event)
@@ -292,6 +290,11 @@
         endDrag();
 }
 
+void MediaControlPanelElement::setIsDisplayed(bool isDisplayed)
+{
+    m_isDisplayed = isDisplayed;
+}
+
 // ----------------------------
 
 inline MediaControlTimelineContainerElement::MediaControlTimelineContainerElement(Document* document)

Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.h (115124 => 115125)


--- trunk/Source/WebCore/html/shadow/MediaControlElements.h	2012-04-24 22:46:32 UTC (rev 115124)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.h	2012-04-24 22:50:05 UTC (rev 115125)
@@ -109,6 +109,8 @@
     static PassRefPtr<MediaControlPanelElement> create(Document*);
 
     void setCanBeDragged(bool);
+    void setIsDisplayed(bool);
+
     void resetPosition();
     void makeOpaque();
     void makeTransparent();
@@ -131,6 +133,7 @@
 
     bool m_canBeDragged;
     bool m_isBeingDragged;
+    bool m_isDisplayed;
     bool m_opaque;
     LayoutPoint m_dragStartEventLocation;
 

Modified: trunk/Source/WebCore/html/shadow/MediaControlRootElement.cpp (115124 => 115125)


--- trunk/Source/WebCore/html/shadow/MediaControlRootElement.cpp	2012-04-24 22:46:32 UTC (rev 115124)
+++ trunk/Source/WebCore/html/shadow/MediaControlRootElement.cpp	2012-04-24 22:50:05 UTC (rev 115125)
@@ -284,11 +284,13 @@
 
 void MediaControlRootElement::show()
 {
+    m_panel->setIsDisplayed(true);
     m_panel->show();
 }
 
 void MediaControlRootElement::hide()
 {
+    m_panel->setIsDisplayed(false);
     m_panel->hide();
 }
 

Modified: trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp (115124 => 115125)


--- trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp	2012-04-24 22:46:32 UTC (rev 115124)
+++ trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp	2012-04-24 22:50:05 UTC (rev 115125)
@@ -170,11 +170,13 @@
 
 void MediaControlRootElementChromium::show()
 {
+    m_panel->setIsDisplayed(true);
     m_panel->show();
 }
 
 void MediaControlRootElementChromium::hide()
 {
+    m_panel->setIsDisplayed(false);
     m_panel->hide();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to