2011-05-14 Jeremy Noble <jer.noble@apple.com>
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 May 2011 17:29:14 +0000 (17:29 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 May 2011 17:29:14 +0000 (17:29 +0000)
        Reviewed by Darin Adler.

        Exiting full screen causes <video> element inline controls to become visible
        https://bugs.webkit.org/show_bug.cgi?id=60142

        * fullscreen/video-controls-override-expected.txt: Added.
        * fullscreen/video-controls-override.html: Added.
2011-05-14  Jeremy Noble  <jer.noble@apple.com>

        Reviewed by Darin Adler.

        Exiting full screen causes <video> element inline controls to become visible
        https://bugs.webkit.org/show_bug.cgi?id=60142

        Create a queue of elements who must be targeted with webkitfullscreenchange events. Instead of dispatching
        a single event with whatever the current value of m_fullScreenElement is (which may have been cleared, or
        changed since the timer was asked to fire), dispatch one event for each entry in the queue.

        Test: fullscreen/video-controls-override.html

        * dom/Document.cpp:
        (WebCore::Document::webkitDidEnterFullScreenForElement): Push current full screen element onto the
            webkitfullscreenchange event delay queue.
        (WebCore::Document::webkitDidExitFullScreenForElement): Ditto.
        (WebCore::Document::fullScreenElementRemoved): Ditto.
        (WebCore::Document::fullScreenChangeDelayTimerFired): Empty the queue, dispatching a
            webkitfullscreenchange event for each entry.
        * dom/Document.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@86488 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fullscreen/video-controls-override-expected.txt [new file with mode: 0644]
LayoutTests/fullscreen/video-controls-override.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h

index ca84afc..21cbc35 100644 (file)
@@ -1,3 +1,13 @@
+2011-05-14  Jeremy Noble  <jer.noble@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Exiting full screen causes <video> element inline controls to become visible
+        https://bugs.webkit.org/show_bug.cgi?id=60142
+
+        * fullscreen/video-controls-override-expected.txt: Added.
+        * fullscreen/video-controls-override.html: Added.
+
 2011-05-14  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Kevin Decker.
diff --git a/LayoutTests/fullscreen/video-controls-override-expected.txt b/LayoutTests/fullscreen/video-controls-override-expected.txt
new file mode 100644 (file)
index 0000000..93573b1
--- /dev/null
@@ -0,0 +1,11 @@
+This tests that the video element's "controls" attribute is overridden in full screen mode, and that the controls are correctly hidden upon exiting full screen. Press any key to continue.
+
+EVENT(webkitfullscreenchange)
+EXPECTED (shadowRoot = layoutTestController.shadowRoot(video) != 'null') OK
+EXPECTED (panel = shadowRoot.firstChild.firstChild != 'null') OK
+EXPECTED (layoutTestController.shadowPseudoId(panel) == '-webkit-media-controls-panel') OK
+EXPECTED (document.defaultView.getComputedStyle(panel)['display'] != 'none') OK
+EVENT(webkitfullscreenchange)
+EXPECTED (document.defaultView.getComputedStyle(panel)['display'] == 'none') OK
+END OF TEST
+
diff --git a/LayoutTests/fullscreen/video-controls-override.html b/LayoutTests/fullscreen/video-controls-override.html
new file mode 100644 (file)
index 0000000..5c5def0
--- /dev/null
@@ -0,0 +1,39 @@
+<body>
+    <p>This tests that the video element's "controls" attribute is overridden in full screen mode, and that the controls are correctly hidden upon exiting full screen.  Press any key to continue.</p>
+    <video id="video" width="300"></video>
+    <script src="full-screen-test.js"></script>
+    <script>
+        var callback;
+        var shadowRoot;
+        var panel;
+
+        var fullscreenChanged = function(event)
+        {
+            if (callback)
+                callback(event)
+        };
+        waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged);
+
+        var video = document.getElementById('video');
+
+        var videoEnteredFullScreen = function() {
+            if (layoutTestController) {
+                testExpected("shadowRoot = layoutTestController.shadowRoot(video)", null, "!=");
+                testExpected("panel = shadowRoot.firstChild.firstChild", null, "!=");
+                testExpected("layoutTestController.shadowPseudoId(panel)", "-webkit-media-controls-panel");
+                testExpected("document.defaultView.getComputedStyle(panel)['display']", 'none', "!=");
+            }
+            callback = cancelledFullScreen;
+            document.webkitCancelFullScreen();
+        };
+
+        var cancelledFullScreen = function() {
+            if (layoutTestController)
+                testExpected("document.defaultView.getComputedStyle(panel)['display']", 'none');
+            endTest();
+        };
+
+        callback = videoEnteredFullScreen;
+        runWithKeyDown(function(){video.webkitRequestFullScreen()});
+    </script>
+</body>
\ No newline at end of file
index a84238a..a3b08a9 100644 (file)
@@ -1,3 +1,25 @@
+2011-05-14  Jeremy Noble  <jer.noble@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Exiting full screen causes <video> element inline controls to become visible
+        https://bugs.webkit.org/show_bug.cgi?id=60142
+
+        Create a queue of elements who must be targeted with webkitfullscreenchange events. Instead of dispatching
+        a single event with whatever the current value of m_fullScreenElement is (which may have been cleared, or
+        changed since the timer was asked to fire), dispatch one event for each entry in the queue.
+
+        Test: fullscreen/video-controls-override.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::webkitDidEnterFullScreenForElement): Push current full screen element onto the
+            webkitfullscreenchange event delay queue.
+        (WebCore::Document::webkitDidExitFullScreenForElement): Ditto.
+        (WebCore::Document::fullScreenElementRemoved): Ditto.
+        (WebCore::Document::fullScreenChangeDelayTimerFired): Empty the queue, dispatching a 
+            webkitfullscreenchange event for each entry.
+        * dom/Document.h:
+
 2011-05-14  Patrick Gansterer  <paroga@webkit.org>
 
         Reviewed by Andreas Kling.
index d56b22a..7a41c99 100644 (file)
@@ -4897,6 +4897,7 @@ void Document::webkitDidEnterFullScreenForElement(Element*)
         page()->chrome()->client()->setRootFullScreenLayer(0);
 #endif
     }
+    m_fullScreenChangeEventTargetQueue.append(m_fullScreenElement);
     m_fullScreenChangeDelayTimer.startOneShot(0);
 }
 
@@ -4924,7 +4925,7 @@ void Document::webkitDidExitFullScreenForElement(Element*)
     if (m_fullScreenElement != documentElement())
         m_fullScreenElement->detach();
 
-    m_fullScreenElement = 0;
+    m_fullScreenChangeEventTargetQueue.append(m_fullScreenElement.release());
     setFullScreenRenderer(0);
 #if USE(ACCELERATED_COMPOSITING)
     page()->chrome()->client()->setRootFullScreenLayer(0);
@@ -4977,11 +4978,13 @@ void Document::setFullScreenRendererBackgroundColor(Color backgroundColor)
     
 void Document::fullScreenChangeDelayTimerFired(Timer<Document>*)
 {
-    Element* element = m_fullScreenElement.get();
-    if (!element)
-        element = documentElement();
-    
-    element->dispatchEvent(Event::create(eventNames().webkitfullscreenchangeEvent, true, false));
+    while (!m_fullScreenChangeEventTargetQueue.isEmpty()) {
+        RefPtr<Element> element = m_fullScreenChangeEventTargetQueue.takeFirst();
+        if (!element)
+            element = documentElement();
+        
+        element->dispatchEvent(Event::create(eventNames().webkitfullscreenchangeEvent, true, false));
+    }
 }
 
 void Document::fullScreenElementRemoved()
@@ -4991,11 +4994,16 @@ void Document::fullScreenElementRemoved()
     // clients of the DOM.
     if (m_fullScreenRenderer)
         m_fullScreenRenderer->remove();
-    
     setFullScreenRenderer(0);
+
+    m_fullScreenChangeEventTargetQueue.append(m_fullScreenElement.release());
     m_fullScreenElement = documentElement();
     recalcStyle(Force);
-    m_fullScreenChangeDelayTimer.startOneShot(0);
+    
+    // Dispatch this event manually, before the element is actually removed from the DOM
+    // so that the message cascades as expected.
+    fullScreenChangeDelayTimerFired(&m_fullScreenChangeDelayTimer);
+    m_fullScreenChangeDelayTimer.stop();
 }
 
 void Document::removeFullScreenElementOfSubtree(Node* node, bool amongChildrenOnly)
index 95051bf..525c8e5 100644 (file)
@@ -41,6 +41,7 @@
 #include "Timer.h"
 #include "TreeScope.h"
 #include "ViewportArguments.h"
+#include <wtf/Deque.h>
 #include <wtf/FixedArray.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
@@ -1379,6 +1380,7 @@ private:
     RefPtr<Element> m_fullScreenElement;
     RenderFullScreen* m_fullScreenRenderer;
     Timer<Document> m_fullScreenChangeDelayTimer;
+    Deque<RefPtr<Element> > m_fullScreenChangeEventTargetQueue;
 #endif
 
     int m_loadEventDelayCount;