2011-05-03 Jer Noble <jer.noble@apple.com>
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 May 2011 00:07:33 +0000 (00:07 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 May 2011 00:07:33 +0000 (00:07 +0000)
        Reviewed by Antti Koivisto.

        Safari: Video at apple.com cannot play at full screen mode with layout distortion
        https://bugs.webkit.org/show_bug.cgi?id=60140

        * fullscreen/full-screen-stacking-context-expected.txt: Added.
        * fullscreen/full-screen-stacking-context.html: Added.
        * platform/mac/fullscreen/full-screen-stacking-context-expected.png: Added.
2011-05-03  Jer Noble  <jer.noble@apple.com>

        Reviewed by Antti Koivisto.

        Safari: Video at apple.com cannot play at full screen mode with layout distortion
        https://bugs.webkit.org/show_bug.cgi?id=60140

        Because a fullscreen element may be in a stacking context with a lower z-index than
        a sibling stacking context, those higher contexts would sometimes "pop" through the
        full screen renderer. To facilitate eliminating all the stacking contexts aside from
        the full screen renderer, added a new pseudo-class specific to video or audio full
        screen elements. Then, added a new UA rule which resets the z-index and opacities of
        all elements under said pseudo-class to auto and 1 respectively. To facilitate quick
        identity checking of HTMLMediaElements, added isMediaElement() virtual function to
        Element and HTMLMediaElement.

        Test: fullscreen/full-screen-stacking-context.html

        * css/CSSSelector.cpp:
        (WebCore::CSSSelector::pseudoId): Support PseudoFullScreenMediaDocument.
        (WebCore::nameToPseudoTypeMap): Support fullScreenMediaDocument.
        (WebCore::CSSSelector::extractPseudoType): Support PseudoFullScreenMediaDocument.
        * css/CSSSelector.h: Add PseudoFullScreenMediaDocument.
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector): Support PseudoFullScreenMediaDocument.
        * css/fullscreen.css:
        (:root:-webkit-full-screen-document:not(:-webkit-full-screen)): Corrected these names,
            which were missing the -webkit prefix.
        (:root:-webkit-full-screen-media-document *:not(-webkit-full-screen)): Added.
        * dom/Element.h:
        (WebCore::Element::isMediaElement): Added, returns false.
        * html/HTMLMediaElement.h:
        (WebCore::HTMLMediaElement::isMediaElement): Added, returns true.
        * rendering/style/RenderStyleConstants.h: Added FULL_SCREEN_MEDIA_DOCUMENT.

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fullscreen/full-screen-stacking-context-expected.txt [new file with mode: 0644]
LayoutTests/fullscreen/full-screen-stacking-context.html [new file with mode: 0644]
LayoutTests/platform/mac/fullscreen/full-screen-stacking-context-expected.png [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSSelector.cpp
Source/WebCore/css/CSSSelector.h
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/fullscreen.css
Source/WebCore/dom/Element.h
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/rendering/style/RenderStyleConstants.h

index 49ac423..8c2b32c 100644 (file)
@@ -1,3 +1,14 @@
+2011-05-03  Jer Noble  <jer.noble@apple.com>
+
+        Reviewed by Antti Koivisto.
+
+        Safari: Video at apple.com cannot play at full screen mode with layout distortion
+        https://bugs.webkit.org/show_bug.cgi?id=60140
+
+        * fullscreen/full-screen-stacking-context-expected.txt: Added.
+        * fullscreen/full-screen-stacking-context.html: Added.
+        * platform/mac/fullscreen/full-screen-stacking-context-expected.png: Added.
+
 2011-05-04  Ojan Vafai  <ojan@chromium.org>
 
         Reviewed by Eric Seidel.
diff --git a/LayoutTests/fullscreen/full-screen-stacking-context-expected.txt b/LayoutTests/fullscreen/full-screen-stacking-context-expected.txt
new file mode 100644 (file)
index 0000000..3dd46fe
--- /dev/null
@@ -0,0 +1,23 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x156
+  RenderBlock {HTML} at (0,0) size 800x156
+    RenderBody {BODY} at (8,8) size 784x140
+      RenderBlock {DIV} at (0,0) size 784x40
+        RenderText {#text} at (0,0) size 767x37
+          text run at (0,0) width 679: "This tests that a full screen element in a lower stacking context blocks a sibling in a higher stacking context. "
+          text run at (679,0) width 88: "After entering"
+          text run at (0,19) width 335: "full screen mode, only a black box should be visible. "
+          text run at (335,19) width 38: "Click "
+        RenderButton {BUTTON} at (375,20) size 89x18 [bgcolor=#C0C0C0] [border: (2px outset #C0C0C0) none (2px outset #C0C0C0)]
+          RenderBlock (anonymous) at (8,2) size 73x13
+            RenderText {#text} at (0,0) size 73x13
+              text run at (0,0) width 73: "go full screen"
+        RenderText {#text} at (466,19) size 93x18
+          text run at (466,19) width 93: " to run the test."
+layer at (58,98) size 100x100
+  RenderBlock (relative positioned) {DIV} at (0,40) size 100x100 [bgcolor=#FF0000]
+layer at (0,0) size 800x600
+  RenderFullScreen zI: 2147483647 at (0,0) size 800x600 [bgcolor=#000000]
+layer at (0,0) size 800x600
+  RenderVideo {VIDEO} at (0,0) size 800x600
diff --git a/LayoutTests/fullscreen/full-screen-stacking-context.html b/LayoutTests/fullscreen/full-screen-stacking-context.html
new file mode 100644 (file)
index 0000000..0f75ea4
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script>
+            var runPixelTests = true;
+            
+            function init() {
+                // Bail out early if the full screen API is not enabled or is missing:
+                if (Element.prototype.webkitRequestFullScreen == undefined) {
+                    logResult(false, "Element.prototype.webkitRequestFullScreen == undefined");
+                    endTest();
+                } else {
+                    waitForEventAndEnd(document, 'webkitfullscreenchange');
+                    runWithKeyDown(goFullScreen);
+                }
+            }
+            
+            function goFullScreen() {
+                document.getElementById('video').webkitRequestFullScreen();
+            }
+        </script>
+        <script src="full-screen-test.js"></script>
+        <style>
+            #one {
+                width: 100px;
+                height: 100px;
+                position: relative;
+                top: 50px;
+                left: 50px;
+                z-index: 1;
+                opacity: 0.5;
+                -webkit-transform: rotate(180);
+                background-color: red;
+            }
+            #zero {
+                position: relative;
+                z-index: 0;
+            }
+            #video {
+                width: 200px;
+                height: 200px;
+                background-color: black;
+            }
+        </style>
+    </head>
+    <body onload="init()">
+        <div>This tests that a full screen element in a lower stacking context blocks a sibling in a higher stacking context.  
+             After entering full screen mode, only a black box should be visible.
+             Click <button onclick="goFullScreen()">go full screen</button> to run the test.</div>
+        <div id="one"></div>
+        <div id="zero">
+            <video id="video"></video>
+        </div>
+    </body>
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fullscreen/full-screen-stacking-context-expected.png b/LayoutTests/platform/mac/fullscreen/full-screen-stacking-context-expected.png
new file mode 100644 (file)
index 0000000..f31ecb1
Binary files /dev/null and b/LayoutTests/platform/mac/fullscreen/full-screen-stacking-context-expected.png differ
index c678b1d..ebc6e64 100644 (file)
@@ -1,3 +1,38 @@
+2011-05-03  Jer Noble  <jer.noble@apple.com>
+
+        Reviewed by Antti Koivisto.
+
+        Safari: Video at apple.com cannot play at full screen mode with layout distortion
+        https://bugs.webkit.org/show_bug.cgi?id=60140
+
+        Because a fullscreen element may be in a stacking context with a lower z-index than
+        a sibling stacking context, those higher contexts would sometimes "pop" through the 
+        full screen renderer. To facilitate eliminating all the stacking contexts aside from
+        the full screen renderer, added a new pseudo-class specific to video or audio full
+        screen elements. Then, added a new UA rule which resets the z-index and opacities of 
+        all elements under said pseudo-class to auto and 1 respectively. To facilitate quick
+        identity checking of HTMLMediaElements, added isMediaElement() virtual function to 
+        Element and HTMLMediaElement. 
+
+        Test: fullscreen/full-screen-stacking-context.html
+
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::pseudoId): Support PseudoFullScreenMediaDocument.
+        (WebCore::nameToPseudoTypeMap): Support fullScreenMediaDocument.
+        (WebCore::CSSSelector::extractPseudoType): Support PseudoFullScreenMediaDocument.
+        * css/CSSSelector.h: Add PseudoFullScreenMediaDocument.
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector): Support PseudoFullScreenMediaDocument.
+        * css/fullscreen.css:
+        (:root:-webkit-full-screen-document:not(:-webkit-full-screen)): Corrected these names, 
+            which were missing the -webkit prefix.
+        (:root:-webkit-full-screen-media-document *:not(-webkit-full-screen)): Added.
+        * dom/Element.h:
+        (WebCore::Element::isMediaElement): Added, returns false.
+        * html/HTMLMediaElement.h:
+        (WebCore::HTMLMediaElement::isMediaElement): Added, returns true.
+        * rendering/style/RenderStyleConstants.h: Added FULL_SCREEN_MEDIA_DOCUMENT.
+
 2011-05-04  Levi Weintraub  <leviw@chromium.org>
 
         Reviewed by Eric Seidel.
index 9cf8c99..8b04b50 100644 (file)
@@ -165,6 +165,8 @@ PseudoId CSSSelector::pseudoId(PseudoType type)
         return FULL_SCREEN;
     case PseudoFullScreenDocument:
         return FULL_SCREEN_DOCUMENT;
+    case PseudoFullScreenMediaDocument:
+        return FULL_SCREEN_MEDIA_DOCUMENT;
 #endif
             
     case PseudoInputListButton:
@@ -319,6 +321,7 @@ static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap(
 #if ENABLE(FULLSCREEN_API)
     DEFINE_STATIC_LOCAL(AtomicString, fullScreen, ("-webkit-full-screen"));
     DEFINE_STATIC_LOCAL(AtomicString, fullScreenDocument, ("-webkit-full-screen-document"));
+    DEFINE_STATIC_LOCAL(AtomicString, fullScreenMediaDocument, ("-webkit-full-screen-media-document"));
 #endif
     DEFINE_STATIC_LOCAL(AtomicString, inRange, ("in-range"));
     DEFINE_STATIC_LOCAL(AtomicString, outOfRange, ("out-of-range"));
@@ -406,6 +409,7 @@ static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap(
 #if ENABLE(FULLSCREEN_API)
         nameToPseudoType->set(fullScreen.impl(), CSSSelector::PseudoFullScreen);
         nameToPseudoType->set(fullScreenDocument.impl(), CSSSelector::PseudoFullScreenDocument);
+        nameToPseudoType->set(fullScreenMediaDocument.impl(), CSSSelector::PseudoFullScreenMediaDocument);
 #endif
         nameToPseudoType->set(inRange.impl(), CSSSelector::PseudoInRange);
         nameToPseudoType->set(outOfRange.impl(), CSSSelector::PseudoOutOfRange);
@@ -515,6 +519,7 @@ void CSSSelector::extractPseudoType() const
 #if ENABLE(FULLSCREEN_API)
     case PseudoFullScreen:
     case PseudoFullScreenDocument:
+    case PseudoFullScreenMediaDocument:
 #endif
     case PseudoInRange:
     case PseudoOutOfRange:
index d841caa..c172276 100644 (file)
@@ -189,6 +189,7 @@ namespace WebCore {
 #if ENABLE(FULLSCREEN_API)
             PseudoFullScreen,
             PseudoFullScreenDocument,
+            PseudoFullScreenMediaDocument,
 #endif
             PseudoInRange,
             PseudoOutOfRange,
index 8ce3a7c..993ef5f 100644 (file)
@@ -2906,6 +2906,12 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
                 if (e != e->document()->webkitCurrentFullScreenElement())
                     return false;
                 return true;
+            case CSSSelector::PseudoFullScreenMediaDocument:
+                if (!e->document()->webkitIsFullScreen())
+                    return false;
+                if (!e->document()->webkitCurrentFullScreenElement() || !e->document()->webkitCurrentFullScreenElement()->isMediaElement())
+                    return false;
+                return true;
             case CSSSelector::PseudoFullScreenDocument:
                 // While a Document is in the fullscreen state, the 'full-screen-document' pseudoclass applies 
                 // to all elements of that Document.
index 4dc7b6d..5350035 100644 (file)
@@ -2,10 +2,16 @@
     background-color: white;
 }
 
-:root:full-screen-document:not(:full-screen) {
+:root:-webkit-full-screen-document:not(:-webkit-full-screen) {
     overflow:hidden;
 }
 
+:root:-webkit-full-screen-media-document *:not(:-webkit-full-screen) {
+    z-index: auto !important;
+    opacity: 1 !important;
+    -webkit-tranform: none !important;
+}
+
 video:-webkit-full-screen {
     background-color: black !important;
     position: static !important;
index 46b53ab..b8715d1 100644 (file)
@@ -303,6 +303,10 @@ public:
     static bool isMathMLElement() { return false; }
 #endif
 
+#if ENABLE(VIDEO)
+    virtual bool isMediaElement() const { return false; }
+#endif
+
 #if ENABLE(INPUT_SPEECH)
     virtual bool isInputFieldSpeechButtonElement() const { return false; }
 #endif
index 604cdf8..89e1add 100644 (file)
@@ -215,6 +215,8 @@ protected:
     enum DisplayMode { Unknown, None, Poster, PosterWaitingForVideo, Video };
     DisplayMode displayMode() const { return m_displayMode; }
     virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; }
+    
+    virtual bool isMediaElement() const { return true; }
 
 private:
     virtual void attributeChanged(Attribute*, bool preserveDecls);
index 277367f..c54eccf 100644 (file)
@@ -74,7 +74,7 @@ enum PseudoId {
     INPUT_LIST_BUTTON, INPUT_SPEECH_BUTTON, INNER_SPIN_BUTTON, OUTER_SPIN_BUTTON, VISITED_LINK,
     METER_BAR, METER_OPTIMUM, METER_SUBOPTIMAL, METER_EVEN_LESS_GOOD,
     AFTER_LAST_INTERNAL_PSEUDOID,
-    FULL_SCREEN, FULL_SCREEN_DOCUMENT,
+    FULL_SCREEN, FULL_SCREEN_DOCUMENT, FULL_SCREEN_MEDIA_DOCUMENT,
     FIRST_PUBLIC_PSEUDOID = FIRST_LINE,
     FIRST_INTERNAL_PSEUDOID = FILE_UPLOAD_BUTTON,
     PUBLIC_PSEUDOID_MASK = ((1 << FIRST_INTERNAL_PSEUDOID) - 1) & ~((1 << FIRST_PUBLIC_PSEUDOID) - 1)