Title: [185661] trunk
Revision
185661
Author
[email protected]
Date
2015-06-17 12:23:08 -0700 (Wed, 17 Jun 2015)

Log Message

Safari tabs still have shrunken content after coming out of fullscreen
https://bugs.webkit.org/show_bug.cgi?id=146037
<rdar://problem/21105960>

Reviewed by Simon Fraser and Darin Adler.

* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::useFixedLayoutDidChange):
(WebKit::WebPageProxy::fixedLayoutSizeDidChange):
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setUseFixedLayout):
(WebKit::WebPage::setFixedLayoutSize):
Keep the UI process up-to-date when fixed layout is enabled or the size changes.
This is important because these things can change from the Web process side too,
and the UI process uses its (potentially stale) version to do some short-circuiting.
This was causing us to fail to turn off fixed layout when it was turned
on from the Web process side (by TiledCoreAnimationDrawingArea).

* UIProcess/mac/WKViewLayoutStrategy.mm:
(-[WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy willChangeLayoutStrategy]):
Reset the view scale, which WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy
makes heavy use of, just like the others.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/ShrinkToFit.mm: Added.
(-[ShrinkToFitNavigationDelegate webView:didFinishNavigation:]):
(TEST):
Add a test that ensures that disabling scale-to-fit mode correctly updates
the page's layout.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (185660 => 185661)


--- trunk/Source/WebKit2/ChangeLog	2015-06-17 19:18:30 UTC (rev 185660)
+++ trunk/Source/WebKit2/ChangeLog	2015-06-17 19:23:08 UTC (rev 185661)
@@ -1,3 +1,29 @@
+2015-06-17  Tim Horton  <[email protected]>
+
+        Safari tabs still have shrunken content after coming out of fullscreen
+        https://bugs.webkit.org/show_bug.cgi?id=146037
+        <rdar://problem/21105960>
+
+        Reviewed by Simon Fraser and Darin Adler.
+
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::useFixedLayoutDidChange):
+        (WebKit::WebPageProxy::fixedLayoutSizeDidChange):
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setUseFixedLayout):
+        (WebKit::WebPage::setFixedLayoutSize):
+        Keep the UI process up-to-date when fixed layout is enabled or the size changes.
+        This is important because these things can change from the Web process side too,
+        and the UI process uses its (potentially stale) version to do some short-circuiting.
+        This was causing us to fail to turn off fixed layout when it was turned
+        on from the Web process side (by TiledCoreAnimationDrawingArea).
+
+        * UIProcess/mac/WKViewLayoutStrategy.mm:
+        (-[WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy willChangeLayoutStrategy]):
+        Reset the view scale, which WKViewDynamicSizeComputedFromMinimumDocumentSizeLayoutStrategy
+        makes heavy use of, just like the others.
+
 2015-06-17  Dan Bernstein  <[email protected]>
 
         [Cocoa] Expose UIDelegate::UIClient::close via WKUIDelegate

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (185660 => 185661)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2015-06-17 19:18:30 UTC (rev 185660)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2015-06-17 19:23:08 UTC (rev 185661)
@@ -1447,6 +1447,9 @@
     void didPerformImmediateActionHitTest(const WebHitTestResult::Data&, bool contentPreventsDefault, const UserData&);
 #endif
 
+    void useFixedLayoutDidChange(bool useFixedLayout) { m_useFixedLayout = useFixedLayout; }
+    void fixedLayoutSizeDidChange(WebCore::IntSize fixedLayoutSize) { m_fixedLayoutSize = fixedLayoutSize; }
+
     void handleAutoFillButtonClick(const UserData&);
 
     void handleMessage(IPC::Connection&, const String& messageName, const UserData& messageBody);

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (185660 => 185661)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2015-06-17 19:18:30 UTC (rev 185660)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2015-06-17 19:23:08 UTC (rev 185661)
@@ -439,4 +439,6 @@
     PlaybackTargetPickerClientStateDidChange(uint64_t contextId, unsigned mediaState)
 #endif
 
+    UseFixedLayoutDidChange(bool useFixedLayout)
+    FixedLayoutSizeDidChange(WebCore::IntSize fixedLayoutSize)
 }

Modified: trunk/Source/WebKit2/UIProcess/mac/WKViewLayoutStrategy.mm (185660 => 185661)


--- trunk/Source/WebKit2/UIProcess/mac/WKViewLayoutStrategy.mm	2015-06-17 19:18:30 UTC (rev 185660)
+++ trunk/Source/WebKit2/UIProcess/mac/WKViewLayoutStrategy.mm	2015-06-17 19:23:08 UTC (rev 185661)
@@ -401,6 +401,7 @@
 - (void)willChangeLayoutStrategy
 {
     _page->setShouldScaleViewToFitDocument(false);
+    _page->scaleView(1);
 }
 
 @end

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (185660 => 185661)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2015-06-17 19:18:30 UTC (rev 185660)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2015-06-17 19:23:08 UTC (rev 185661)
@@ -1537,6 +1537,8 @@
     view->setUseFixedLayout(fixed);
     if (!fixed)
         setFixedLayoutSize(IntSize());
+
+    send(Messages::WebPageProxy::UseFixedLayoutDidChange(fixed));
 }
 
 void WebPage::setFixedLayoutSize(const IntSize& size)
@@ -1546,6 +1548,8 @@
         return;
 
     view->setFixedLayoutSize(size);
+
+    send(Messages::WebPageProxy::FixedLayoutSizeDidChange(size));
 }
 
 IntSize WebPage::fixedLayoutSize() const

Modified: trunk/Tools/ChangeLog (185660 => 185661)


--- trunk/Tools/ChangeLog	2015-06-17 19:18:30 UTC (rev 185660)
+++ trunk/Tools/ChangeLog	2015-06-17 19:23:08 UTC (rev 185661)
@@ -1,3 +1,18 @@
+2015-06-17  Tim Horton  <[email protected]>
+
+        Safari tabs still have shrunken content after coming out of fullscreen
+        https://bugs.webkit.org/show_bug.cgi?id=146037
+        <rdar://problem/21105960>
+
+        Reviewed by Simon Fraser and Darin Adler.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/ShrinkToFit.mm: Added.
+        (-[ShrinkToFitNavigationDelegate webView:didFinishNavigation:]):
+        (TEST):
+        Add a test that ensures that disabling scale-to-fit mode correctly updates
+        the page's layout.
+
 2015-06-17  Dan Bernstein  <[email protected]>
 
         [Cocoa] Expose UIDelegate::UIClient::close via WKUIDelegate

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (185660 => 185661)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2015-06-17 19:18:30 UTC (rev 185660)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2015-06-17 19:23:08 UTC (rev 185661)
@@ -30,6 +30,7 @@
 		290F4275172A221C00939FF0 /* custom-protocol-sync-xhr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */; };
 		297234B7173AFAC700983601 /* CustomProtocolsInvalidScheme_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 297234B5173AFAC700983601 /* CustomProtocolsInvalidScheme_Bundle.cpp */; };
 		2D1FE0B01AD465C1006CD9E6 /* FixedLayoutSize.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */; };
+		2D9A53AF1B31FA8D0074D5AA /* ShrinkToFit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D9A53AE1B31FA8D0074D5AA /* ShrinkToFit.mm */; };
 		2DD7D3AF178227B30026E1E3 /* lots-of-text-vertical-lr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */; };
 		2E7765CD16C4D80A00BA2BB1 /* mainIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */; };
 		2E7765CF16C4D81100BA2BB1 /* mainMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E7765CE16C4D81100BA2BB1 /* mainMac.mm */; };
@@ -468,6 +469,7 @@
 		29AB8AA3164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestBrowsingContextLoadDelegate.h; sourceTree = "<group>"; };
 		2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FixedLayoutSize.mm; sourceTree = "<group>"; };
 		2D640B5417875DFF00BFAF99 /* ScrollPinningBehaviors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollPinningBehaviors.cpp; sourceTree = "<group>"; };
+		2D9A53AE1B31FA8D0074D5AA /* ShrinkToFit.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ShrinkToFit.mm; sourceTree = "<group>"; };
 		2DD7D3A9178205D00026E1E3 /* ResizeReversePaginatedWebView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResizeReversePaginatedWebView.cpp; sourceTree = "<group>"; };
 		2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "lots-of-text-vertical-lr.html"; sourceTree = "<group>"; };
 		2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainIOS.mm; sourceTree = "<group>"; };
@@ -842,6 +844,7 @@
 				CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */,
 				C95501BE19AD2FAF0049BE3E /* Preferences.mm */,
 				37D36F311B004DD400BAF5D9 /* ProvisionalURLChange.mm */,
+				2D9A53AE1B31FA8D0074D5AA /* ShrinkToFit.mm */,
 				7CC3E1FA197E234100BE6252 /* UserContentController.mm */,
 				0F3B94A51A77266C00DE3272 /* WKWebViewEvaluateJavaScript.mm */,
 			);
@@ -1602,6 +1605,7 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				2D9A53AF1B31FA8D0074D5AA /* ShrinkToFit.mm in Sources */,
 				7AA021BB1AB09EA70052953F /* DateMath.cpp in Sources */,
 				2D1FE0B01AD465C1006CD9E6 /* FixedLayoutSize.mm in Sources */,
 				1CB9BC381A67482300FE5678 /* WeakPtr.cpp in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/ShrinkToFit.mm (0 => 185661)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/ShrinkToFit.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/ShrinkToFit.mm	2015-06-17 19:23:08 UTC (rev 185661)
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+
+#import "PlatformUtilities.h"
+#import <WebKit/WKWebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+#if WK_API_ENABLED && !PLATFORM(IOS)
+
+static bool shrinkToFitDone;
+static bool shrinkToFitAfterNavigationDone;
+static bool shrinkToFitDisabledDone;
+
+@interface ShrinkToFitNavigationDelegate : NSObject <WKNavigationDelegate>
+@end
+
+@implementation ShrinkToFitNavigationDelegate
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+    // After loading a wide page, the view should be scaled to fit the width of the document.
+    [webView evaluateJavaScript:@"document.body.clientWidth" completionHandler:^(id result, NSError *error) {
+        EXPECT_EQ(808, [result integerValue]);
+        shrinkToFitAfterNavigationDone = true;
+    }];
+}
+
+@end
+
+TEST(WebKit2, ShrinkToFit)
+{
+    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]);
+
+    ShrinkToFitNavigationDelegate *delegate = [[ShrinkToFitNavigationDelegate alloc] init];
+    [webView setNavigationDelegate:delegate];
+
+    [webView evaluateJavaScript:@"document.body.clientWidth" completionHandler:^(id result, NSError *error) {
+        EXPECT_EQ(100, [result integerValue]);
+
+        [webView _setLayoutMode:_WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize];
+        shrinkToFitDone = true;
+    }];
+
+    TestWebKitAPI::Util::run(&shrinkToFitDone);
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"lots-of-text" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&shrinkToFitAfterNavigationDone);
+
+    [webView _setLayoutMode:_WKLayoutModeViewSize];
+    [webView evaluateJavaScript:@"document.body.clientWidth" completionHandler:^(id result, NSError *error) {
+        EXPECT_EQ(100, [result integerValue]);
+        shrinkToFitDisabledDone = true;
+    }];
+
+    TestWebKitAPI::Util::run(&shrinkToFitDisabledDone);
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to