<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[201405] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/201405">201405</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2016-05-25 15:07:17 -0700 (Wed, 25 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Flashiness and jumpiness when entering fullscreen
https://bugs.webkit.org/show_bug.cgi?id=158087

Reviewed by Beth Dakin.

Multiple independant sources of jumpiness and flashiness are addressed here:

- Setting the top content inset on the WKView cause a vertical jump during fullscreen
transition. Instead of setting the content inset to 0, take the existing inset into account
when placing the WKView in the NSWindow.

- The enter fullscreen transition causes a white flash due to the NSWindow needing
display before ordering onscreen. Ensure the window has a backing by calling -displayIfNeeded
before entering fullscreen mode.

- The exit fullscreen transition causes a white background color flash for an unknown
reason, but is solved by not making the window's content view layer-backed. Rather than
directly animating the contentView's background color, create a specific background view
and animate it's background color instead.

* UIProcess/mac/WKFullScreenWindowController.h:
* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController initWithWindow:webView:page:]):
(-[WKFullScreenWindowController enterFullScreen:]):
(-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]):
(-[WKFullScreenWindowController finishedExitFullScreenAnimation:]):
(-[WKFullScreenWindowController _startEnterFullScreenAnimationWithDuration:]):
(-[WKFullScreenWindowController _startExitFullScreenAnimationWithDuration:]):
* WebProcess/FullScreen/WebFullScreenManager.cpp:
(WebKit::WebFullScreenManager::saveScrollPosition): Deleted.
(WebKit::WebFullScreenManager::restoreScrollPosition): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacWKFullScreenWindowControllerh">trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacWKFullScreenWindowControllermm">trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessFullScreenWebFullScreenManagercpp">trunk/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (201404 => 201405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-05-25 21:58:08 UTC (rev 201404)
+++ trunk/Source/WebKit2/ChangeLog        2016-05-25 22:07:17 UTC (rev 201405)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2016-05-25  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Flashiness and jumpiness when entering fullscreen
+        https://bugs.webkit.org/show_bug.cgi?id=158087
+
+        Reviewed by Beth Dakin.
+
+        Multiple independant sources of jumpiness and flashiness are addressed here:
+
+        - Setting the top content inset on the WKView cause a vertical jump during fullscreen
+        transition. Instead of setting the content inset to 0, take the existing inset into account
+        when placing the WKView in the NSWindow.
+
+        - The enter fullscreen transition causes a white flash due to the NSWindow needing
+        display before ordering onscreen. Ensure the window has a backing by calling -displayIfNeeded
+        before entering fullscreen mode.
+
+        - The exit fullscreen transition causes a white background color flash for an unknown
+        reason, but is solved by not making the window's content view layer-backed. Rather than
+        directly animating the contentView's background color, create a specific background view
+        and animate it's background color instead.
+
+        * UIProcess/mac/WKFullScreenWindowController.h:
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController initWithWindow:webView:page:]):
+        (-[WKFullScreenWindowController enterFullScreen:]):
+        (-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]):
+        (-[WKFullScreenWindowController finishedExitFullScreenAnimation:]):
+        (-[WKFullScreenWindowController _startEnterFullScreenAnimationWithDuration:]):
+        (-[WKFullScreenWindowController _startExitFullScreenAnimationWithDuration:]):
+        * WebProcess/FullScreen/WebFullScreenManager.cpp:
+        (WebKit::WebFullScreenManager::saveScrollPosition): Deleted.
+        (WebKit::WebFullScreenManager::restoreScrollPosition): Deleted.
+
</ins><span class="cx"> 2016-05-25  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix CMake build.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacWKFullScreenWindowControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h (201404 => 201405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h        2016-05-25 21:58:08 UTC (rev 201404)
+++ trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h        2016-05-25 22:07:17 UTC (rev 201405)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx">     WebKit::WebPageProxy* _page;
</span><span class="cx">     RetainPtr&lt;WebCoreFullScreenPlaceholderView&gt; _webViewPlaceholder;
</span><span class="cx">     RetainPtr&lt;NSView&gt; _clipView;
</span><ins>+    RetainPtr&lt;NSView&gt; _backgroundView;
</ins><span class="cx">     NSRect _initialFrame;
</span><span class="cx">     NSRect _finalFrame;
</span><span class="cx">     RetainPtr&lt;NSTimer&gt; _watchdogTimer;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacWKFullScreenWindowControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm (201404 => 201405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm        2016-05-25 21:58:08 UTC (rev 201404)
+++ trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm        2016-05-25 22:07:17 UTC (rev 201405)
</span><span class="lines">@@ -94,16 +94,22 @@
</span><span class="cx">     [window setCollectionBehavior:([window collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary)];
</span><span class="cx"> 
</span><span class="cx">     NSView *contentView = [window contentView];
</span><del>-    contentView.wantsLayer = YES;
-    contentView.layer.hidden = YES;
</del><ins>+    contentView.hidden = YES;
</ins><span class="cx">     contentView.autoresizesSubviews = YES;
</span><span class="cx"> 
</span><ins>+    _backgroundView = adoptNS([[NSView alloc] initWithFrame:contentView.bounds]);
+    _backgroundView.get().layer = [CALayer layer];
+    _backgroundView.get().wantsLayer = YES;
+    _backgroundView.get().autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
+    [contentView addSubview:_backgroundView.get()];
+
</ins><span class="cx">     _clipView = adoptNS([[NSView alloc] initWithFrame:contentView.bounds]);
</span><span class="cx">     [_clipView setWantsLayer:YES];
</span><span class="cx">     [_clipView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
</span><del>-    [contentView addSubview:_clipView.get()];
</del><ins>+    [_backgroundView addSubview:_clipView.get()];
</ins><span class="cx"> 
</span><span class="cx">     [self windowDidLoad];
</span><ins>+    [window displayIfNeeded];
</ins><span class="cx">     _webView = webView;
</span><span class="cx">     _page = &amp;page;
</span><span class="cx">     
</span><span class="lines">@@ -234,7 +240,7 @@
</span><span class="cx">     // Then insert the WebView into the full screen window
</span><span class="cx">     NSView *contentView = [[self window] contentView];
</span><span class="cx">     [_clipView addSubview:_webView positioned:NSWindowBelow relativeTo:nil];
</span><del>-    [_webView setFrame:[contentView bounds]];
</del><ins>+    _webView.frame = NSInsetRect(contentView.bounds, 0, -_page-&gt;topContentInset());
</ins><span class="cx"> 
</span><span class="cx">     makeResponderFirstResponderIfDescendantOfView(self.window, webWindowFirstResponder, _webView);
</span><span class="cx"> 
</span><span class="lines">@@ -272,8 +278,7 @@
</span><span class="cx">         [self _manager]-&gt;didEnterFullScreen();
</span><span class="cx">         [self _manager]-&gt;setAnimatingFullScreen(false);
</span><span class="cx"> 
</span><del>-        NSView *contentView = [[self window] contentView];
-        [contentView.layer removeAllAnimations];
</del><ins>+        [_backgroundView.get().layer removeAllAnimations];
</ins><span class="cx">         [[_clipView layer] removeAllAnimations];
</span><span class="cx">         [[_clipView layer] setMask:nil];
</span><span class="cx"> 
</span><span class="lines">@@ -369,7 +374,8 @@
</span><span class="cx">     _page-&gt;setSuppressVisibilityUpdates(true);
</span><span class="cx">     [[self window] orderOut:self];
</span><span class="cx">     NSView *contentView = [[self window] contentView];
</span><del>-    contentView.layer.hidden = YES;
</del><ins>+    contentView.hidden = YES;
+    [_backgroundView.get().layer removeAllAnimations];
</ins><span class="cx">     [[_webViewPlaceholder window] setAutodisplay:NO];
</span><span class="cx"> 
</span><span class="cx">     NSResponder *firstResponder = [[self window] firstResponder];
</span><span class="lines">@@ -576,8 +582,8 @@
</span><span class="cx">     [maskLayer addAnimation:maskAnimation(_initialFrame, _finalFrame, self.window.screen.frame, duration, AnimateIn) forKey:@&quot;fullscreen&quot;];
</span><span class="cx">     [_clipView layer].mask = maskLayer;
</span><span class="cx"> 
</span><del>-    contentView.layer.hidden = NO;
-    [contentView.layer addAnimation:fadeAnimation(duration, AnimateIn) forKey:@&quot;fullscreen&quot;];
</del><ins>+    contentView.hidden = NO;
+    [_backgroundView.get().layer addAnimation:fadeAnimation(duration, AnimateIn) forKey:@&quot;fullscreen&quot;];
</ins><span class="cx"> 
</span><span class="cx">     NSWindow* window = [self window];
</span><span class="cx">     NSWindowCollectionBehavior behavior = [window collectionBehavior];
</span><span class="lines">@@ -605,8 +611,8 @@
</span><span class="cx">     [[_clipView layer].mask addAnimation:maskAnimation(_initialFrame, _finalFrame, self.window.screen.frame, duration, AnimateOut) forKey:@&quot;fullscreen&quot;];
</span><span class="cx"> 
</span><span class="cx">     NSView* contentView = [[self window] contentView];
</span><del>-    contentView.layer.hidden = NO;
-    [contentView.layer addAnimation:fadeAnimation(duration, AnimateOut) forKey:@&quot;fullscreen&quot;];
</del><ins>+    contentView.hidden = NO;
+    [_backgroundView.get().layer addAnimation:fadeAnimation(duration, AnimateOut) forKey:@&quot;fullscreen&quot;];
</ins><span class="cx"> 
</span><span class="cx">     _page-&gt;setSuppressVisibilityUpdates(false);
</span><span class="cx">     [[self window] setAutodisplay:YES];
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessFullScreenWebFullScreenManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp (201404 => 201405)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp        2016-05-25 21:58:08 UTC (rev 201404)
+++ trunk/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp        2016-05-25 22:07:17 UTC (rev 201405)
</span><span class="lines">@@ -157,13 +157,10 @@
</span><span class="cx"> void WebFullScreenManager::saveScrollPosition()
</span><span class="cx"> {
</span><span class="cx">     m_scrollPosition = m_page-&gt;corePage()-&gt;mainFrame().view()-&gt;scrollPosition();
</span><del>-    m_topContentInset = m_page-&gt;corePage()-&gt;topContentInset();
-    m_page-&gt;corePage()-&gt;setTopContentInset(0);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebFullScreenManager::restoreScrollPosition()
</span><span class="cx"> {
</span><del>-    m_page-&gt;corePage()-&gt;setTopContentInset(m_topContentInset);
</del><span class="cx">     m_page-&gt;corePage()-&gt;mainFrame().view()-&gt;setScrollPosition(m_scrollPosition);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>