RenderFullScreen needs to clear override sizes when exiting full screen
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Mar 2013 18:27:59 +0000 (18:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Mar 2013 18:27:59 +0000 (18:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=111775

Patch by Christian Biesinger <cbiesinger@chromium.org> on 2013-03-08
Reviewed by Ojan Vafai.

Source/WebCore:

Test: fullscreen/full-screen-with-flex-item.html

* rendering/RenderFullScreen.cpp:
(RenderFullScreen::unwrapRenderer):
RenderFullScreen is a flexbox, so it will potentially set override
sizes on its children while in fullscreen mode. When we exit
fullscreen mode, we need to clear this override size, otherwise the
the leftover override size may affect layout. See the testcase for an
example.

LayoutTests:

* fullscreen/full-screen-with-flex-item-expected.txt: Added.
* fullscreen/full-screen-with-flex-item.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fullscreen/full-screen-with-flex-item-expected.txt [new file with mode: 0644]
LayoutTests/fullscreen/full-screen-with-flex-item.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderFullScreen.cpp

index 46ae726..b9d2afe 100644 (file)
@@ -1,3 +1,13 @@
+2013-03-08  Christian Biesinger  <cbiesinger@chromium.org>
+
+        RenderFullScreen needs to clear override sizes when exiting full screen
+        https://bugs.webkit.org/show_bug.cgi?id=111775
+
+        Reviewed by Ojan Vafai.
+
+        * fullscreen/full-screen-with-flex-item-expected.txt: Added.
+        * fullscreen/full-screen-with-flex-item.html: Added.
+
 2013-03-08  Julien Chaffraix  <jchaffraix@webkit.org>
 
         [CSS Grid Layout] Handle 2 positions with one 'auto' properly
diff --git a/LayoutTests/fullscreen/full-screen-with-flex-item-expected.txt b/LayoutTests/fullscreen/full-screen-with-flex-item-expected.txt
new file mode 100644 (file)
index 0000000..b5c66b7
--- /dev/null
@@ -0,0 +1,6 @@
+Enter Fullscreen
+EVENT(webkitfullscreenchange)
+EVENT(webkitfullscreenchange)
+EXPECTED (584 == '584') OK
+END OF TEST
+
diff --git a/LayoutTests/fullscreen/full-screen-with-flex-item.html b/LayoutTests/fullscreen/full-screen-with-flex-item.html
new file mode 100644 (file)
index 0000000..f809e72
--- /dev/null
@@ -0,0 +1,58 @@
+<style>
+  div {
+    background-color: pink;
+    -webkit-align-self: stretch;
+    -webkit-flex: 1;
+    position: relative;
+  }
+  .vertical {
+    -webkit-writing-mode: vertical-lr;
+  }
+  .inner {
+    display: inline-block;
+    height: 500px;
+  }
+</style>
+<script src="full-screen-test.js"></script>
+<body>
+  <div><div class=vertical>
+      <div class="inner">This div becomes a stretched flex item in fullscreen mode, and should
+        become normal-sized again once leaving it.</div>
+      <div class="inner">Number 2</div>
+      <div class="inner">Number 3</div>
+      <div class="inner">Number 4</div>
+  </div></div>
+<script>
+    // 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 {
+        var callback;
+        var fullscreenChanged = function(event)
+        {
+            if (callback)
+                callback(event)
+        };
+        waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged);
+
+        var div = document.getElementsByTagName('div')[0];
+        var oldHeight = div.offsetHeight;
+
+        var divEnteredFullScreen = function(event) {
+            callback = divExitedFullScreen;
+            document.webkitExitFullscreen();
+        };
+
+        var divExitedFullScreen = function(event) {
+            callback = null;
+            testExpected(div.offsetHeight, oldHeight);
+            div.innerHTML = "";  // simplify the text dump
+            endTest();
+        };
+
+        callback = divEnteredFullScreen;
+        runWithKeyDown(function(){div.webkitRequestFullScreen()});
+    }
+</script>
+<button onclick="div.webkitRequestFullScreen()">Enter Fullscreen</button>
index c9f9a1d..3e43c6d 100644 (file)
@@ -1,3 +1,20 @@
+2013-03-08  Christian Biesinger  <cbiesinger@chromium.org>
+
+        RenderFullScreen needs to clear override sizes when exiting full screen
+        https://bugs.webkit.org/show_bug.cgi?id=111775
+
+        Reviewed by Ojan Vafai.
+
+        Test: fullscreen/full-screen-with-flex-item.html
+
+        * rendering/RenderFullScreen.cpp:
+        (RenderFullScreen::unwrapRenderer):
+        RenderFullScreen is a flexbox, so it will potentially set override
+        sizes on its children while in fullscreen mode. When we exit
+        fullscreen mode, we need to clear this override size, otherwise the
+        the leftover override size may affect layout. See the testcase for an
+        example.
+
 2013-03-08  Julien Chaffraix  <jchaffraix@webkit.org>
 
         [CSS Grid Layout] Handle 2 positions with one 'auto' properly
index 2044bc4..af11971 100644 (file)
@@ -152,6 +152,11 @@ void RenderFullScreen::unwrapRenderer()
     if (parent()) {
         RenderObject* child;
         while ((child = firstChild())) {
+            // We have to clear the override size, because as a flexbox, we
+            // may have set one on the child, and we don't want to leave that
+            // lying around on the child.
+            if (child->isBox())
+                toRenderBox(child)->clearOverrideSize();
             child->remove();
             parent()->addChild(child, this);
             parent()->setNeedsLayoutAndPrefWidthsRecalc();