- Revision
- 202120
- Author
- [email protected]
- Date
- 2016-06-15 19:20:04 -0700 (Wed, 15 Jun 2016)
Log Message
Expose _shouldExpandContentToViewHeightForAutoLayout SPI on WKWebView
https://bugs.webkit.org/show_bug.cgi?id=158824
<rdar://problem/23713857>
Reviewed by Simon Fraser.
Test: TestWebKitAPI/WebKit2.AutoLayoutIntegration
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _shouldExpandContentToViewHeightForAutoLayout]):
(-[WKWebView _setShouldExpandContentToViewHeightForAutoLayout:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
This property exists on WKView; expose it on WKWebView.
* TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm:
(-[AutoLayoutWKWebView load:withWidth:expectingContentSize:]):
(-[AutoLayoutWKWebView load:withWidth:expectingContentSize:resettingWidth:]):
(-[AutoLayoutWKWebView layoutAtMinimumWidth:andExpectContentSizeChange:resettingWidth:]):
(TEST):
Add a test for _shouldExpandContentToViewHeightForAutoLayout.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (202119 => 202120)
--- trunk/Source/WebKit2/ChangeLog 2016-06-16 01:28:54 UTC (rev 202119)
+++ trunk/Source/WebKit2/ChangeLog 2016-06-16 02:20:04 UTC (rev 202120)
@@ -1,3 +1,19 @@
+2016-06-15 Tim Horton <[email protected]>
+
+ Expose _shouldExpandContentToViewHeightForAutoLayout SPI on WKWebView
+ https://bugs.webkit.org/show_bug.cgi?id=158824
+ <rdar://problem/23713857>
+
+ Reviewed by Simon Fraser.
+
+ Test: TestWebKitAPI/WebKit2.AutoLayoutIntegration
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _shouldExpandContentToViewHeightForAutoLayout]):
+ (-[WKWebView _setShouldExpandContentToViewHeightForAutoLayout:]):
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ This property exists on WKView; expose it on WKWebView.
+
2016-06-15 Alex Christensen <[email protected]>
Revert part of r196034
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (202119 => 202120)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2016-06-16 01:28:54 UTC (rev 202119)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2016-06-16 02:20:04 UTC (rev 202120)
@@ -4400,6 +4400,16 @@
_impl->setClipsToVisibleRect(expandsToFit);
}
+- (BOOL)_shouldExpandContentToViewHeightForAutoLayout
+{
+ return _impl->shouldExpandToViewHeightForAutoLayout();
+}
+
+- (void)_setShouldExpandContentToViewHeightForAutoLayout:(BOOL)shouldExpand
+{
+ return _impl->setShouldExpandToViewHeightForAutoLayout(shouldExpand);
+}
+
- (NSPrintOperation *)_printOperationWithPrintInfo:(NSPrintInfo *)printInfo
{
if (auto webFrameProxy = _page->mainFrame())
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (202119 => 202120)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2016-06-16 01:28:54 UTC (rev 202119)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2016-06-16 02:20:04 UTC (rev 202120)
@@ -190,6 +190,10 @@
@property (nonatomic, setter=_setMinimumLayoutWidth:) CGFloat _minimumLayoutWidth WK_AVAILABLE(WK_MAC_TBA, NA);
+// When using _minimumLayoutWidth, the web content will lay out to the intrinsic height
+// of the content; use this property to force it to lay out to the height of the view instead.
+@property (nonatomic, setter=_setShouldExpandContentToViewHeightForAutoLayout:) BOOL _shouldExpandContentToViewHeightForAutoLayout WK_AVAILABLE(WK_MAC_TBA, NA);
+
- (NSPrintOperation *)_printOperationWithPrintInfo:(NSPrintInfo *)printInfo;
- (NSPrintOperation *)_printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(_WKFrameHandle *)frameHandle WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
Modified: trunk/Tools/ChangeLog (202119 => 202120)
--- trunk/Tools/ChangeLog 2016-06-16 01:28:54 UTC (rev 202119)
+++ trunk/Tools/ChangeLog 2016-06-16 02:20:04 UTC (rev 202120)
@@ -1,3 +1,18 @@
+2016-06-15 Tim Horton <[email protected]>
+
+ Expose _shouldExpandContentToViewHeightForAutoLayout SPI on WKWebView
+ https://bugs.webkit.org/show_bug.cgi?id=158824
+ <rdar://problem/23713857>
+
+ Reviewed by Simon Fraser.
+
+ * TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm:
+ (-[AutoLayoutWKWebView load:withWidth:expectingContentSize:]):
+ (-[AutoLayoutWKWebView load:withWidth:expectingContentSize:resettingWidth:]):
+ (-[AutoLayoutWKWebView layoutAtMinimumWidth:andExpectContentSizeChange:resettingWidth:]):
+ (TEST):
+ Add a test for _shouldExpandContentToViewHeightForAutoLayout.
+
2016-06-13 Simon Fraser <[email protected]>
[iOS WK2] Make it possible to test the Next/Previous buttons in the keyboard accessory bar
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm (202119 => 202120)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm 2016-06-16 01:28:54 UTC (rev 202119)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AutoLayoutIntegration.mm 2016-06-16 02:20:04 UTC (rev 202120)
@@ -33,6 +33,7 @@
static bool didFinishNavigation;
static bool didInvalidateIntrinsicContentSize;
+static bool didEvaluateJavaScript;
@interface AutoLayoutNavigationDelegate : NSObject <WKNavigationDelegate>
@end
@@ -56,6 +57,11 @@
- (void)load:(NSString *)HTMLString withWidth:(CGFloat)width expectingContentSize:(NSSize)size
{
+ [self load:HTMLString withWidth:width expectingContentSize:size resettingWidth:YES];
+}
+
+- (void)load:(NSString *)HTMLString withWidth:(CGFloat)width expectingContentSize:(NSSize)size resettingWidth:(BOOL)resetAfter
+{
EXPECT_FALSE(_expectingIntrinsicContentSizeChange);
NSString *baseHTML = @"<style>"
@@ -71,10 +77,10 @@
[self loadHTMLString:[baseHTML stringByAppendingString:HTMLString] baseURL:nil];
TestWebKitAPI::Util::run(&didFinishNavigation);
- [self layoutAtMinimumWidth:width andExpectContentSizeChange:size];
+ [self layoutAtMinimumWidth:width andExpectContentSizeChange:size resettingWidth:resetAfter];
}
-- (void)layoutAtMinimumWidth:(CGFloat)width andExpectContentSizeChange:(NSSize)size
+- (void)layoutAtMinimumWidth:(CGFloat)width andExpectContentSizeChange:(NSSize)size resettingWidth:(BOOL)resetAfter
{
[self _setMinimumLayoutWidth:width];
@@ -86,7 +92,8 @@
didInvalidateIntrinsicContentSize = false;
TestWebKitAPI::Util::run(&didInvalidateIntrinsicContentSize);
- [self _setMinimumLayoutWidth:0];
+ if (resetAfter)
+ [self _setMinimumLayoutWidth:0];
}
- (void)invalidateIntrinsicContentSize
@@ -125,13 +132,37 @@
[webView load:@"<div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div>" withWidth:50 expectingContentSize:NSMakeSize(50, 20)];
// Changing the width to 10 should result in ten rows of one; with the constraint (width >= 10) -> 10x100
- [webView layoutAtMinimumWidth:10 andExpectContentSizeChange:NSMakeSize(10, 100)];
+ [webView layoutAtMinimumWidth:10 andExpectContentSizeChange:NSMakeSize(10, 100) resettingWidth:YES];
// Changing the width to 100 should result in one rows of ten; with the constraint (width >= 100) -> 100x10
- [webView layoutAtMinimumWidth:100 andExpectContentSizeChange:NSMakeSize(100, 10)];
+ [webView layoutAtMinimumWidth:100 andExpectContentSizeChange:NSMakeSize(100, 10) resettingWidth:YES];
// One 100x100 rect and ten 10x10 rects, inline; with the constraint (width >= 20) -> 100x110
[webView load:@"<div class='large'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div><div class='small inline'></div>" withWidth:20 expectingContentSize:NSMakeSize(100, 110)];
+
+ // With _shouldExpandContentToViewHeightForAutoLayout off (the default), the page should lay out to the intrinsic height
+ // of the content.
+ [webView load:@"<div class='small'></div>" withWidth:50 expectingContentSize:NSMakeSize(50, 10) resettingWidth:NO];
+ [webView evaluateJavaScript:@"window.innerHeight" completionHandler:^(id value, NSError *error) {
+ EXPECT_TRUE([value isKindOfClass:[NSNumber class]]);
+ EXPECT_EQ(10, [value integerValue]);
+ didEvaluateJavaScript = true;
+ }];
+ TestWebKitAPI::Util::run(&didEvaluateJavaScript);
+ didEvaluateJavaScript = false;
+
+ // Enabling _shouldExpandContentToViewHeightForAutoLayout should make the page lay out to the view height, regardless
+ // of the intrinsic height of the content. We have to load differently-sized content so that we can wait for
+ // the intrinsic size change callback.
+ [webView _setShouldExpandContentToViewHeightForAutoLayout:YES];
+ [webView load:@"<div class='large'></div>" withWidth:50 expectingContentSize:NSMakeSize(100, 100) resettingWidth:NO];
+ [webView evaluateJavaScript:@"window.innerHeight" completionHandler:^(id value, NSError *error) {
+ EXPECT_TRUE([value isKindOfClass:[NSNumber class]]);
+ EXPECT_EQ(1000, [value integerValue]);
+ didEvaluateJavaScript = true;
+ }];
+ TestWebKitAPI::Util::run(&didEvaluateJavaScript);
+ didEvaluateJavaScript = false;
}
#endif