<!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>[180885] trunk</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/180885">180885</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2015-03-02 09:37:14 -0800 (Mon, 02 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WK1][WK2][Mac] Fullscreen animation is incorrect when page is scaled.
https://bugs.webkit.org/show_bug.cgi?id=142121

Reviewed by Simon Fraser.

Source/WebKit/mac:

Fullscreening a page with a non-1 scale would result in that scale being applied to the
fullscreen content, breaking fullscreen mode. Set the page scale to 1 when entering
fullscreen and reset it to the original value when exiting fullscreen.

* WebView/WebFullScreenController.h:
* WebView/WebFullScreenController.mm:
(-[WebFullScreenController enterFullScreen:]): Set the page scale to 1.
(-[WebFullScreenController finishedExitFullScreenAnimation:]): Reset the page
        scale to the original value.
* WebView/WebView.mm:
(-[WebView _supportsFullScreenForElement:withKeyboard:]): Drive-by fix. Check the
        WebView's own preferences to see if fullscreen mode is enabled, rather than
        the global object's.

Source/WebKit2:

Change the order of operations when entering or exiting fullscreen. Change the page scale to
1 before entering, so the final screen rect takes that scale into account, and vice-versa on
exiting.

* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController enterFullScreen:]):
(-[WKFullScreenWindowController exitFullScreen]):

Tools:

Add a test which changes the WebView's page scale, then enters fullscreen mode, and verifies
that the initial and final screen rects for the web content are as expected.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.html: Added.
* TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.mm: Added.
(-[FullscreenStateDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:]):
(runJavaScriptAlert):
(TestWebKitAPI::FullscreenZoomInitialFrame::initializeView):
(TestWebKitAPI::FullscreenZoomInitialFrame::teardownView):
(TestWebKitAPI::FullscreenZoomInitialFrame::setPageScale):
(TestWebKitAPI::FullscreenZoomInitialFrame::sendMouseDownEvent):
(TestWebKitAPI::FullscreenZoomInitialFrame::runTest):
(TestWebKitAPI::TEST_F):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebFullScreenControllerh">trunk/Source/WebKit/mac/WebView/WebFullScreenController.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebFullScreenControllermm">trunk/Source/WebKit/mac/WebView/WebFullScreenController.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
<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="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsmacFullscreenZoomInitialFramehtml">trunk/Tools/TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsmacFullscreenZoomInitialFramemm">trunk/Tools/TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (180884 => 180885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2015-03-02 15:34:25 UTC (rev 180884)
+++ trunk/Source/WebKit/mac/ChangeLog        2015-03-02 17:37:14 UTC (rev 180885)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2015-03-02  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        [WK1][WK2][Mac] Fullscreen animation is incorrect when page is scaled.
+        https://bugs.webkit.org/show_bug.cgi?id=142121
+
+        Reviewed by Simon Fraser.
+
+        Fullscreening a page with a non-1 scale would result in that scale being applied to the
+        fullscreen content, breaking fullscreen mode. Set the page scale to 1 when entering
+        fullscreen and reset it to the original value when exiting fullscreen.
+
+        * WebView/WebFullScreenController.h:
+        * WebView/WebFullScreenController.mm:
+        (-[WebFullScreenController enterFullScreen:]): Set the page scale to 1.
+        (-[WebFullScreenController finishedExitFullScreenAnimation:]): Reset the page
+                scale to the original value.
+        * WebView/WebView.mm:
+        (-[WebView _supportsFullScreenForElement:withKeyboard:]): Drive-by fix. Check the
+                WebView's own preferences to see if fullscreen mode is enabled, rather than
+                the global object's.
+
</ins><span class="cx"> 2015-03-01  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make NotificationCenter / Notification suspendable
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebFullScreenControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebFullScreenController.h (180884 => 180885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebFullScreenController.h        2015-03-02 15:34:25 UTC (rev 180884)
+++ trunk/Source/WebKit/mac/WebView/WebFullScreenController.h        2015-03-02 17:37:14 UTC (rev 180885)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx">     NSRect _initialFrame;
</span><span class="cx">     NSRect _finalFrame;
</span><span class="cx">     WebCore::IntPoint _scrollPosition;
</span><ins>+    float _savedScale;
</ins><span class="cx"> 
</span><span class="cx">     BOOL _isEnteringFullScreen;
</span><span class="cx">     BOOL _isExitingFullScreen;
</span><span class="lines">@@ -58,6 +59,9 @@
</span><span class="cx">     BOOL _isPlaying;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+@property (readonly) NSRect initialFrame;
+@property (readonly) NSRect finalFrame;
+
</ins><span class="cx"> - (WebView*)webView;
</span><span class="cx"> - (void)setWebView:(WebView*)webView;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebFullScreenControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebFullScreenController.mm (180884 => 180885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebFullScreenController.mm        2015-03-02 15:34:25 UTC (rev 180884)
+++ trunk/Source/WebKit/mac/WebView/WebFullScreenController.mm        2015-03-02 17:37:14 UTC (rev 180885)
</span><span class="lines">@@ -107,6 +107,9 @@
</span><span class="cx">     [super dealloc];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+@synthesize initialFrame=_initialFrame;
+@synthesize finalFrame=_finalFrame;
+
</ins><span class="cx"> - (void)windowDidLoad
</span><span class="cx"> {
</span><span class="cx">     [super windowDidLoad];
</span><span class="lines">@@ -238,7 +241,9 @@
</span><span class="cx">     [[_webViewPlaceholder.get() window] recalculateKeyViewLoop];
</span><span class="cx">     
</span><span class="cx">     [[self window] makeResponder:webWindowFirstResponder firstResponderIfDescendantOfView:_webView];
</span><del>-    
</del><ins>+
+    _savedScale = [_webView _viewScaleFactor];
+    [_webView _scaleWebView:1 atOrigin:NSMakePoint(0, 0)];
</ins><span class="cx">     [self _document]-&gt;webkitWillEnterFullScreenForElement(_element.get());
</span><span class="cx">     [self _document]-&gt;setAnimatingFullScreen(true);
</span><span class="cx">     [self _document]-&gt;updateLayout();
</span><span class="lines">@@ -344,10 +349,11 @@
</span><span class="cx">     
</span><span class="cx">     // Screen updates to be re-enabled at the end of this function
</span><span class="cx">     NSDisableScreenUpdates();
</span><del>-    
</del><ins>+
</ins><span class="cx">     [self _document]-&gt;setAnimatingFullScreen(false);
</span><span class="cx">     [self _document]-&gt;webkitDidExitFullScreenForElement(_element.get());
</span><del>-    
</del><ins>+    [_webView _scaleWebView:_savedScale atOrigin:NSMakePoint(0, 0)];
+
</ins><span class="cx">     NSResponder *firstResponder = [[self window] firstResponder];
</span><span class="cx">     [self _swapView:_webViewPlaceholder.get() with:_webView];
</span><span class="cx">     [_webView _mainCoreFrame]-&gt;view()-&gt;setScrollPosition(_scrollPosition);
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (180884 => 180885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2015-03-02 15:34:25 UTC (rev 180884)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2015-03-02 17:37:14 UTC (rev 180885)
</span><span class="lines">@@ -8434,7 +8434,7 @@
</span><span class="cx"> #if ENABLE(FULLSCREEN_API) &amp;&amp; !PLATFORM(IOS)
</span><span class="cx"> - (BOOL)_supportsFullScreenForElement:(const WebCore::Element*)element withKeyboard:(BOOL)withKeyboard
</span><span class="cx"> {
</span><del>-    if (![[WebPreferences standardPreferences] fullScreenEnabled])
</del><ins>+    if (![[self preferences] fullScreenEnabled])
</ins><span class="cx">         return NO;
</span><span class="cx"> 
</span><span class="cx">     return !withKeyboard;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (180884 => 180885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-03-02 15:34:25 UTC (rev 180884)
+++ trunk/Source/WebKit2/ChangeLog        2015-03-02 17:37:14 UTC (rev 180885)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-03-02  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        [WK1][WK2][Mac] Fullscreen animation is incorrect when page is scaled.
+        https://bugs.webkit.org/show_bug.cgi?id=142121
+
+        Reviewed by Simon Fraser.
+
+        Change the order of operations when entering or exiting fullscreen. Change the page scale to
+        1 before entering, so the final screen rect takes that scale into account, and vice-versa on
+        exiting.
+
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController enterFullScreen:]):
+        (-[WKFullScreenWindowController exitFullScreen]):
+
</ins><span class="cx"> 2015-03-01  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make clip-path work on &lt;video&gt;, &lt;canvas&gt; etc.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacWKFullScreenWindowControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h (180884 => 180885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h        2015-03-02 15:34:25 UTC (rev 180884)
+++ trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h        2015-03-02 17:37:14 UTC (rev 180885)
</span><span class="lines">@@ -61,6 +61,9 @@
</span><span class="cx">     RefPtr&lt;WebKit::VoidCallback&gt; _repaintCallback;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+@property (readonly) NSRect initialFrame;
+@property (readonly) NSRect finalFrame;
+
</ins><span class="cx"> - (id)initWithWindow:(NSWindow *)window webView:(WKView *)webView;
</span><span class="cx"> 
</span><span class="cx"> - (WebCoreFullScreenPlaceholderView*)webViewPlaceholder;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacWKFullScreenWindowControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm (180884 => 180885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm        2015-03-02 15:34:25 UTC (rev 180884)
+++ trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm        2015-03-02 17:37:14 UTC (rev 180885)
</span><span class="lines">@@ -130,6 +130,9 @@
</span><span class="cx"> #pragma mark -
</span><span class="cx"> #pragma mark Accessors
</span><span class="cx"> 
</span><ins>+@synthesize initialFrame=_initialFrame;
+@synthesize finalFrame=_finalFrame;
+
</ins><span class="cx"> - (BOOL)isFullScreen
</span><span class="cx"> {
</span><span class="cx">     return _fullScreenState == WaitingToEnterFullScreen
</span><span class="lines">@@ -249,10 +252,10 @@
</span><span class="cx"> 
</span><span class="cx">     makeResponderFirstResponderIfDescendantOfView(self.window, webWindowFirstResponder, _webView);
</span><span class="cx"> 
</span><ins>+    _savedScale = [self _page]-&gt;pageScaleFactor();
+    [self _page]-&gt;scalePage(1, IntPoint());
</ins><span class="cx">     [self _manager]-&gt;setAnimatingFullScreen(true);
</span><span class="cx">     [self _manager]-&gt;willEnterFullScreen();
</span><del>-    _savedScale = [self _page]-&gt;pageScaleFactor();
-    [self _page]-&gt;scalePage(1, IntPoint());
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)beganEnterFullScreenWithInitialFrame:(const WebCore::IntRect&amp;)initialFrame finalFrame:(const WebCore::IntRect&amp;)finalFrame
</span><span class="lines">@@ -320,10 +323,10 @@
</span><span class="cx">         makeResponderFirstResponderIfDescendantOfView(_webView.window, firstResponder, _webView);
</span><span class="cx">         [[_webView window] makeKeyAndOrderFront:self];
</span><span class="cx"> 
</span><ins>+        [self _page]-&gt;scalePage(_savedScale, IntPoint());
+        [self _manager]-&gt;restoreScrollPosition();
</ins><span class="cx">         [self _manager]-&gt;didExitFullScreen();
</span><span class="cx">         [self _manager]-&gt;setAnimatingFullScreen(false);
</span><del>-        [self _page]-&gt;scalePage(_savedScale, IntPoint());
-        [self _manager]-&gt;restoreScrollPosition();
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     NSEnableScreenUpdates();
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (180884 => 180885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-03-02 15:34:25 UTC (rev 180884)
+++ trunk/Tools/ChangeLog        2015-03-02 17:37:14 UTC (rev 180885)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2015-03-02  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        [WK1][WK2][Mac] Fullscreen animation is incorrect when page is scaled.
+        https://bugs.webkit.org/show_bug.cgi?id=142121
+
+        Reviewed by Simon Fraser.
+
+        Add a test which changes the WebView's page scale, then enters fullscreen mode, and verifies
+        that the initial and final screen rects for the web content are as expected.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.html: Added.
+        * TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.mm: Added.
+        (-[FullscreenStateDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:]):
+        (runJavaScriptAlert):
+        (TestWebKitAPI::FullscreenZoomInitialFrame::initializeView):
+        (TestWebKitAPI::FullscreenZoomInitialFrame::teardownView):
+        (TestWebKitAPI::FullscreenZoomInitialFrame::setPageScale):
+        (TestWebKitAPI::FullscreenZoomInitialFrame::sendMouseDownEvent):
+        (TestWebKitAPI::FullscreenZoomInitialFrame::runTest):
+        (TestWebKitAPI::TEST_F):
+
</ins><span class="cx"> 2015-03-01  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         LayoutTestRealy: Prepend __XPC_ to the key, not the value!
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (180884 => 180885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2015-03-02 15:34:25 UTC (rev 180884)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2015-03-02 17:37:14 UTC (rev 180885)
</span><span class="lines">@@ -272,6 +272,8 @@
</span><span class="cx">                 C5E1AFFE16B221F1006CC1F2 /* execCopy.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C5E1AFFD16B22179006CC1F2 /* execCopy.html */; };
</span><span class="cx">                 CD59F53419E9110D00CF1835 /* file-with-mse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53219E910AA00CF1835 /* file-with-mse.html */; };
</span><span class="cx">                 CD59F53519E9110D00CF1835 /* test-mse.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53319E910BC00CF1835 /* test-mse.mp4 */; };
</span><ins>+                CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */; };
+                CDBFCC461A9FF49E00A7B691 /* FullscreenZoomInitialFrame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */; };
</ins><span class="cx">                 CE14F1A4181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CE14F1A2181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html */; };
</span><span class="cx">                 CEA6CF2819CCF69D0064F5A7 /* open-and-close-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */; };
</span><span class="cx">                 E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
</span><span class="lines">@@ -341,6 +343,7 @@
</span><span class="cx">                                 1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */,
</span><span class="cx">                                 C5101C4F176B8D9200EE9B15 /* findRanges.html in Copy Resources */,
</span><span class="cx">                                 1A7E8B3618120B2F00AEB74A /* FragmentNavigation.html in Copy Resources */,
</span><ins>+                                CDBFCC461A9FF49E00A7B691 /* FullscreenZoomInitialFrame.html in Copy Resources */,
</ins><span class="cx">                                 26F52EAD1828827B0023D412 /* geolocationGetCurrentPosition.html in Copy Resources */,
</span><span class="cx">                                 26F52EAF18288C230023D412 /* geolocationGetCurrentPositionWithHighAccuracy.html in Copy Resources */,
</span><span class="cx">                                 26F52EB218288F240023D412 /* geolocationWatchPosition.html in Copy Resources */,
</span><span class="lines">@@ -665,6 +668,8 @@
</span><span class="cx">                 CD5497B315857F0C00B5BC30 /* MediaTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTime.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD59F53219E910AA00CF1835 /* file-with-mse.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;file-with-mse.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD59F53319E910BC00CF1835 /* test-mse.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = &quot;test-mse.mp4&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenZoomInitialFrame.html; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenZoomInitialFrame.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 CDC2C7141797089D00E627FB /* TimeRanges.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TimeRanges.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CE14F1A2181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = WillPerformClientRedirectToURLCrash.html; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CE32C7C718184C4900CD8C28 /* WillPerformClientRedirectToURLCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WillPerformClientRedirectToURLCrash.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1144,6 +1149,7 @@
</span><span class="cx">                                 C07E6CAE13FD67650038B22B /* DynamicDeviceScaleFactor.mm */,
</span><span class="cx">                                 4BB4160316815F9100824238 /* ElementAtPointInWebFrame.mm */,
</span><span class="cx">                                 1A7E8B33181208DE00AEB74A /* FragmentNavigation.mm */,
</span><ins>+                                CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */,
</ins><span class="cx">                                 9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */,
</span><span class="cx">                                 9B26FC6B159D061000CC3765 /* HTMLFormCollectionNamedItem.mm */,
</span><span class="cx">                                 C507E8A614C6545B005D6B3B /* InspectorBar.mm */,
</span><span class="lines">@@ -1186,6 +1192,7 @@
</span><span class="cx">                                 37E1064B169767F700B78BD0 /* DOMHTMLTableCellElementCellAbove.html */,
</span><span class="cx">                                 37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */,
</span><span class="cx">                                 1A7E8B351812093600AEB74A /* FragmentNavigation.html */,
</span><ins>+                                CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */,
</ins><span class="cx">                                 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */,
</span><span class="cx">                                 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */,
</span><span class="cx">                                 C2CF975816CEC69E0054E99D /* JSContextBackForwardCache1.html */,
</span><span class="lines">@@ -1402,6 +1409,7 @@
</span><span class="cx">                                 7CCE7F341A411B8E00447C4C /* Functional.cpp in Sources */,
</span><span class="cx">                                 7CCE7EF81A411AE600447C4C /* Geolocation.cpp in Sources */,
</span><span class="cx">                                 7CCE7EE11A411A9A00447C4C /* GetBackingScaleFactor.mm in Sources */,
</span><ins>+                                CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */,
</ins><span class="cx">                                 7CCE7EF91A411AE600447C4C /* GetInjectedBundleInitializationUserDataCallback.cpp in Sources */,
</span><span class="cx">                                 7CCE7EE21A411A9A00447C4C /* GetPIDAfterAbortedProcessLaunch.cpp in Sources */,
</span><span class="cx">                                 7CCE7F351A411B8E00447C4C /* HashMap.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacFullscreenZoomInitialFramehtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.html (0 => 180885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.html        2015-03-02 17:37:14 UTC (rev 180885)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script&gt;
+        document.addEventListener('webkitfullscreenchange', function(event) {
+            // Send a signal to the test controller via alert.
+            alert('visibilitychange');
+        });
+        document.addEventListener('mousedown', function(event) {
+            // Toggle fullscreen
+            var target = document.getElementById('target');
+            if (document.webkitFullscreenElement == target)
+                document.webkitExitFullscreen();
+            else
+                target.webkitRequestFullScreen();
+        });
+    &lt;/script&gt;
+    &lt;style&gt;
+    #target {
+        background-color: red;
+        width: 150px;
+        height: 150px;
+    }
+    #target:-webkit-full-screen {
+        width: 400px;
+        height: 400px;
+    }
+    &lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacFullscreenZoomInitialFramemm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.mm (0 => 180885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.mm        2015-03-02 17:37:14 UTC (rev 180885)
</span><span class="lines">@@ -0,0 +1,193 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+
+#import &quot;JavaScriptTest.h&quot;
+#import &quot;Test.h&quot;
+#import &quot;WebKitAgnosticTest.h&quot;
+#import &lt;Carbon/Carbon.h&gt;
+#import &lt;WebKit/WebViewPrivate.h&gt;
+#import &lt;WebKit/WebPreferencesPrivate.h&gt;
+#import &lt;WebKit/WKViewPrivate.h&gt;
+#import &lt;WebKit/WKPreferencesPrivate.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+@interface NSWindowController (WebKitFullScreenAdditions)
+- (NSRect)initialFrame;
+- (NSRect)finalFrame;
+@end
+
+static bool isWaitingForPageSignalToContinue = false;
+static bool didGetPageSignalToContinue = false;
+
+@interface FullscreenStateDelegate : NSObject &lt;WebUIDelegate&gt;
+@end
+
+@implementation FullscreenStateDelegate
+- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
+{
+    EXPECT_TRUE(isWaitingForPageSignalToContinue);
+    isWaitingForPageSignalToContinue = false;
+    didGetPageSignalToContinue = true;
+}
+@end
+
+// WebKit2 WKPageUIClient
+
+static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
+{
+    EXPECT_TRUE(isWaitingForPageSignalToContinue);
+    isWaitingForPageSignalToContinue = false;
+    didGetPageSignalToContinue = true;
+}
+
+// WebKitAgnosticTest
+
+namespace TestWebKitAPI {
+
+class FullscreenZoomInitialFrame : public WebKitAgnosticTest {
+public:
+    template &lt;typename View&gt; void runTest(View);
+
+    // WebKitAgnosticTest
+    virtual NSURL *url() const override { return [[NSBundle mainBundle] URLForResource:@&quot;FullscreenZoomInitialFrame&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]; }
+    virtual void didLoadURL(WebView *webView) override { runTest(webView); }
+    virtual void didLoadURL(WKView *wkView) override { runTest(wkView); }
+
+    // Setup and teardown the UIDelegate which gets alert() signals from the page.
+    virtual void initializeView(WebView *) override;
+    virtual void initializeView(WKView *) override;
+    virtual void teardownView(WebView *) override;
+    virtual void teardownView(WKView *) override;
+
+    void setPageScale(WebView *, double);
+    void setPageScale(WKView *, double);
+    void sendMouseDownEvent(WebView *, NSEvent *);
+    void sendMouseDownEvent(WKView *, NSEvent *);
+};
+
+void FullscreenZoomInitialFrame::initializeView(WebView *webView)
+{
+    // Released in teardownView.
+    webView.UIDelegate = [[FullscreenStateDelegate alloc] init];
+
+    RetainPtr&lt;WebPreferences&gt; customPreferences = adoptNS([[WebPreferences alloc] initWithIdentifier:@&quot;FullscreenZoomInitialFramePreferences&quot;]);
+    [customPreferences setFullScreenEnabled:YES];
+    webView.preferences = customPreferences.get();
+}
+
+void FullscreenZoomInitialFrame::teardownView(WebView *webView)
+{
+    id uiDelegate = webView.UIDelegate;
+    webView.UIDelegate = nil;
+    [uiDelegate release];
+}
+
+void FullscreenZoomInitialFrame::initializeView(WKView *wkView)
+{
+    WKPageUIClientV0 uiClient;
+    memset(&amp;uiClient, 0, sizeof(uiClient));
+
+    uiClient.base.version = 0;
+    uiClient.runJavaScriptAlert = runJavaScriptAlert;
+
+    WKPageSetPageUIClient(wkView.pageRef, &amp;uiClient.base);
+
+    WKRetainPtr&lt;WKStringRef&gt; identifier(AdoptWK, WKStringCreateWithUTF8CString(&quot;FullscreenZoomInitialFramePreferences&quot;));
+    WKRetainPtr&lt;WKPreferencesRef&gt; customPreferences(AdoptWK, WKPreferencesCreateWithIdentifier(identifier.get()));
+    WKPreferencesSetFullScreenEnabled(customPreferences.get(), true);
+    WKPageGroupSetPreferences(WKPageGetPageGroup(wkView.pageRef), customPreferences.get());
+}
+
+void FullscreenZoomInitialFrame::teardownView(WKView *wkView)
+{
+    // We do not need to teardown the WKPageUIClient.
+}
+
+void FullscreenZoomInitialFrame::setPageScale(WebView *webView, double scale)
+{
+    [webView _scaleWebView:scale atOrigin:NSMakePoint(0, 0)];
+}
+
+void FullscreenZoomInitialFrame::setPageScale(WKView *wkView, double scale)
+{
+    WKPageSetScaleFactor(wkView.pageRef, scale, WKPointMake(0, 0));
+}
+
+void FullscreenZoomInitialFrame::sendMouseDownEvent(WebView *webView, NSEvent *event)
+{
+    [webView.mainFrame.frameView.documentView mouseDown:event];
+}
+
+void FullscreenZoomInitialFrame::sendMouseDownEvent(WKView *wkView, NSEvent *event)
+{
+    [wkView mouseDown:event];
+}
+
+template &lt;typename View&gt;
+void FullscreenZoomInitialFrame::runTest(View view)
+{
+    RetainPtr&lt;NSWindow&gt; window = adoptNS([[NSWindow alloc] initWithContentRect:view.frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
+    [window.get().contentView addSubview:view];
+
+    setPageScale(view, 2);
+
+    NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseDown location:NSMakePoint(5, 5) modifierFlags:0 timestamp:0 windowNumber:window.get().windowNumber context:0 eventNumber:0 clickCount:0 pressure:0];
+
+    isWaitingForPageSignalToContinue = true;
+    didGetPageSignalToContinue = false;
+    sendMouseDownEvent(view, event);
+    Util::run(&amp;didGetPageSignalToContinue);
+
+    id windowController = [[view window] windowController];
+    EXPECT_TRUE([windowController respondsToSelector:@selector(initialFrame)]);
+    EXPECT_TRUE([windowController respondsToSelector:@selector(finalFrame)]);
+
+    NSRect initialFrame = [windowController initialFrame];
+    NSRect finalFrame = [windowController finalFrame];
+
+    EXPECT_EQ(300, initialFrame.size.width);
+    EXPECT_EQ(300, initialFrame.size.height);
+    EXPECT_EQ(400, finalFrame.size.width);
+    EXPECT_EQ(400, finalFrame.size.height);
+
+    isWaitingForPageSignalToContinue = true;
+    didGetPageSignalToContinue = false;
+    sendMouseDownEvent(view, event);
+    Util::run(&amp;didGetPageSignalToContinue);
+}
+    
+TEST_F(FullscreenZoomInitialFrame, WebKit)
+{
+    runWebKit1Test();
+}
+
+TEST_F(FullscreenZoomInitialFrame, WebKit2)
+{
+    runWebKit2Test();
+}
+
+} // namespace TestWebKitAPI
</ins></span></pre>
</div>
</div>

</body>
</html>