Diff
Modified: trunk/Source/WebKit2/ChangeLog (182498 => 182499)
--- trunk/Source/WebKit2/ChangeLog 2015-04-07 22:09:15 UTC (rev 182498)
+++ trunk/Source/WebKit2/ChangeLog 2015-04-07 22:37:11 UTC (rev 182499)
@@ -1,3 +1,38 @@
+2015-04-07 Tim Horton <[email protected]>
+
+ Expose and test fixedLayoutSize via modern WebKit SPI
+ https://bugs.webkit.org/show_bug.cgi?id=143500
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/API/Cocoa/WKViewPrivate.h:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _isFixedLayoutEnabled]):
+ (-[WKWebView _setFixedLayoutEnabled:]):
+ (-[WKWebView _fixedLayoutSize]):
+ (-[WKWebView _setFixedLayoutSize:]):
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView _isFixedLayoutEnabled]):
+ (-[WKView _setFixedLayoutEnabled:]):
+ (-[WKView _fixedLayoutSize]):
+ (-[WKView _setFixedLayoutSize:]):
+ Add API for adjusting the fixed layout size, and whether or not we use it.
+
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage):
+ Repair a mistake I made in r139822, where I brought odd TILED_BACKING_STORE-only
+ logic (which disables scrollbars if fixedLayoutSize is enabled) to the rest of the ports.
+ Put it back as TILED_BACKING_STORE-only.
+
+ Persist the fixedLayoutSize through view creation; we already persist the enabled state,
+ but not the size, which doesn't make any sense.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::fixedLayoutSize):
+ * WebProcess/WebPage/WebPage.h:
+ Add a fixedLayoutSize() getter.
+
2015-04-07 Brady Eidson <[email protected]>
ContextMenuItem refactoring
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h (182498 => 182499)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h 2015-04-07 22:09:15 UTC (rev 182498)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h 2015-04-07 22:37:11 UTC (rev 182499)
@@ -90,6 +90,9 @@
@property (nonatomic, setter=_setTopContentInset:) CGFloat _topContentInset;
@property (nonatomic, setter=_setTotalHeightOfBanners:) CGFloat _totalHeightOfBanners;
+@property (nonatomic, getter=_isFixedLayoutEnabled, setter=_setFixedLayoutEnabled:) BOOL _fixedLayoutEnabled;
+@property (nonatomic, setter=_setFixedLayoutSize:) CGSize _fixedLayoutSize;
+
@property (nonatomic, setter=_setOverrideDeviceScaleFactor:) CGFloat _overrideDeviceScaleFactor WK_AVAILABLE(WK_MAC_TBA, NA);
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (182498 => 182499)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-04-07 22:09:15 UTC (rev 182498)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-04-07 22:37:11 UTC (rev 182499)
@@ -2232,6 +2232,26 @@
return _page->isShowingNavigationGestureSnapshot();
}
+- (BOOL)_isFixedLayoutEnabled
+{
+ return _page->useFixedLayout();
+}
+
+- (void)_setFixedLayoutEnabled:(BOOL)fixedLayoutEnabled
+{
+ _page->setUseFixedLayout(fixedLayoutEnabled);
+}
+
+- (CGSize)_fixedLayoutSize
+{
+ return _page->fixedLayoutSize();
+}
+
+- (void)_setFixedLayoutSize:(CGSize)fixedLayoutSize
+{
+ _page->setFixedLayoutSize(WebCore::expandedIntSize(WebCore::FloatSize(fixedLayoutSize)));
+}
+
#pragma mark scrollperf methods
- (void)_setScrollPerformanceDataCollectionEnabled:(BOOL)enabled
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (182498 => 182499)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2015-04-07 22:09:15 UTC (rev 182498)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2015-04-07 22:37:11 UTC (rev 182499)
@@ -91,6 +91,9 @@
- (void)_close;
+@property (nonatomic, getter=_isFixedLayoutEnabled, setter=_setFixedLayoutEnabled:) BOOL _fixedLayoutEnabled;
+@property (nonatomic, setter=_setFixedLayoutSize:) CGSize _fixedLayoutSize;
+
#if TARGET_OS_IPHONE
// DERECATED: The setters of the three following function are deprecated, please use overrideLayoutParameters.
// Define the smallest size a page take with a regular viewport.
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (182498 => 182499)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-04-07 22:09:15 UTC (rev 182498)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-04-07 22:37:11 UTC (rev 182499)
@@ -4322,6 +4322,26 @@
return _data->_overrideDeviceScaleFactor;
}
+- (BOOL)_isFixedLayoutEnabled
+{
+ return _data->_page->useFixedLayout();
+}
+
+- (void)_setFixedLayoutEnabled:(BOOL)fixedLayoutEnabled
+{
+ _data->_page->setUseFixedLayout(fixedLayoutEnabled);
+}
+
+- (CGSize)_fixedLayoutSize
+{
+ return _data->_page->fixedLayoutSize();
+}
+
+- (void)_setFixedLayoutSize:(NSSize)fixedLayoutSize
+{
+ _data->_page->setFixedLayoutSize(expandedIntSize(FloatSize(fixedLayoutSize)));
+}
+
- (void)_dispatchSetTopContentInset
{
if (!_data->_didScheduleSetTopContentInset)
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (182498 => 182499)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2015-04-07 22:09:15 UTC (rev 182498)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2015-04-07 22:37:11 UTC (rev 182499)
@@ -1257,12 +1257,14 @@
bool isTransparent = !webPage->drawsBackground();
bool shouldUseFixedLayout = isMainFrame && webPage->useFixedLayout();
bool shouldDisableScrolling = isMainFrame && !webPage->mainFrameIsScrollable();
- bool shouldHideScrollbars = shouldUseFixedLayout || shouldDisableScrolling;
+ bool shouldHideScrollbars = shouldDisableScrolling;
IntRect fixedVisibleContentRect;
#if USE(TILED_BACKING_STORE)
if (m_frame->coreFrame()->view())
fixedVisibleContentRect = m_frame->coreFrame()->view()->fixedVisibleContentRect();
+ if (shouldUseFixedLayout)
+ shouldHideScrollbars = true;
#endif
const ResourceResponse& response = m_frame->coreFrame()->loader().documentLoader()->response();
@@ -1272,7 +1274,7 @@
ScrollbarMode defaultScrollbarMode = shouldHideScrollbars ? ScrollbarAlwaysOff : ScrollbarAuto;
m_frame->coreFrame()->createView(webPage->size(), backgroundColor, isTransparent,
- IntSize(), fixedVisibleContentRect, shouldUseFixedLayout,
+ webPage->fixedLayoutSize(), fixedVisibleContentRect, shouldUseFixedLayout,
defaultScrollbarMode, /* lock */ shouldHideScrollbars, defaultScrollbarMode, /* lock */ shouldHideScrollbars);
if (int minimumLayoutWidth = webPage->minimumLayoutSize().width()) {
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (182498 => 182499)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2015-04-07 22:09:15 UTC (rev 182498)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2015-04-07 22:37:11 UTC (rev 182499)
@@ -1494,6 +1494,14 @@
view->setFixedLayoutSize(size);
}
+IntSize WebPage::fixedLayoutSize() const
+{
+ FrameView* view = mainFrameView();
+ if (!view)
+ return IntSize();
+ return view->fixedLayoutSize();
+}
+
void WebPage::listenForLayoutMilestones(uint32_t milestones)
{
if (!m_page)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (182498 => 182499)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2015-04-07 22:09:15 UTC (rev 182498)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2015-04-07 22:37:11 UTC (rev 182499)
@@ -359,6 +359,7 @@
void setUseFixedLayout(bool);
bool useFixedLayout() const { return m_useFixedLayout; }
void setFixedLayoutSize(const WebCore::IntSize&);
+ WebCore::IntSize fixedLayoutSize() const;
void listenForLayoutMilestones(uint32_t /* LayoutMilestones */);
Modified: trunk/Tools/ChangeLog (182498 => 182499)
--- trunk/Tools/ChangeLog 2015-04-07 22:09:15 UTC (rev 182498)
+++ trunk/Tools/ChangeLog 2015-04-07 22:37:11 UTC (rev 182499)
@@ -1,3 +1,18 @@
+2015-04-07 Tim Horton <[email protected]>
+
+ Expose and test fixedLayoutSize via modern WebKit SPI
+ https://bugs.webkit.org/show_bug.cgi?id=143500
+
+ Reviewed by Simon Fraser.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/FixedLayoutSize.mm: Added.
+ (-[FixedLayoutSizeNavigationDelegate webView:didFinishNavigation:]):
+ (TEST):
+ Add a test that verifies that fixedLayoutSize works at all, that
+ it persists through a navigation, and that turning it back off reverts to
+ laying out at the size of the view.
+
2015-04-07 Michael Catanzaro <[email protected]>
Unreviewed. Add myself as a committer.
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (182498 => 182499)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2015-04-07 22:09:15 UTC (rev 182498)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2015-04-07 22:37:11 UTC (rev 182499)
@@ -27,6 +27,7 @@
290A9BB91735F63800D71BBC /* OpenNewWindow.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 290A9BB81735F42300D71BBC /* OpenNewWindow.html */; };
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 */; };
2D950FBE1A2217D300012434 /* ActionMenusBundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D950FBB1A2217D000012434 /* ActionMenusBundle.mm */; };
2D950FC01A230C3A00012434 /* action-menu-targets.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2D950FBF1A230C1E00012434 /* action-menu-targets.html */; };
2DD7D3AF178227B30026E1E3 /* lots-of-text-vertical-lr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */; };
@@ -449,6 +450,7 @@
29AB8A9F164C735800D49BEC /* CustomProtocolsTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CustomProtocolsTest.mm; path = WebKit2ObjC/CustomProtocolsTest.mm; sourceTree = "<group>"; };
29AB8AA2164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestBrowsingContextLoadDelegate.mm; sourceTree = "<group>"; };
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>"; };
2D950FBA1A2217D000012434 /* ActionMenus.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ActionMenus.mm; path = WebKit2ObjC/ActionMenus.mm; sourceTree = "<group>"; };
2D950FBB1A2217D000012434 /* ActionMenusBundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ActionMenusBundle.mm; path = WebKit2ObjC/ActionMenusBundle.mm; sourceTree = "<group>"; };
@@ -811,6 +813,7 @@
children = (
7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */,
A1A4FE5D18DD3DB700B5EA8A /* Download.mm */,
+ 2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */,
1ABC3DED1899BE6D004F0626 /* Navigation.mm */,
CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */,
C95501BE19AD2FAF0049BE3E /* Preferences.mm */,
@@ -1562,6 +1565,7 @@
buildActionMask = 2147483647;
files = (
7AA021BB1AB09EA70052953F /* DateMath.cpp in Sources */,
+ 2D1FE0B01AD465C1006CD9E6 /* FixedLayoutSize.mm in Sources */,
1CB9BC381A67482300FE5678 /* WeakPtr.cpp in Sources */,
2E7765CD16C4D80A00BA2BB1 /* mainIOS.mm in Sources */,
7AA6A1521AAC0B31002B2ED3 /* WorkQueue.cpp in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FixedLayoutSize.mm (0 => 182499)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FixedLayoutSize.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FixedLayoutSize.mm 2015-04-07 22:37:11 UTC (rev 182499)
@@ -0,0 +1,91 @@
+/*
+ * 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/WKPreferences.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+#if WK_API_ENABLED
+
+static bool fixedLayoutSizeDone;
+static bool fixedLayoutSizeAfterNavigationDone;
+static bool fixedLayoutSizeDisabledDone;
+
+@interface FixedLayoutSizeNavigationDelegate : NSObject <WKNavigationDelegate>
+@end
+
+@implementation FixedLayoutSizeNavigationDelegate
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+ // After navigating, fixed layout size should be persisted.
+ [webView evaluateJavaScript:@"document.body.clientWidth" completionHandler:^(id result, NSError *error) {
+ EXPECT_EQ(200, [result integerValue]);
+ fixedLayoutSizeAfterNavigationDone = true;
+ }];
+}
+
+@end
+
+TEST(WebKit2, FixedLayoutSize)
+{
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]);
+
+ FixedLayoutSizeNavigationDelegate *delegate = [[FixedLayoutSizeNavigationDelegate alloc] init];
+ [webView setNavigationDelegate:delegate];
+
+ [webView evaluateJavaScript:@"document.body.clientWidth" completionHandler:^(id result, NSError *error) {
+ EXPECT_EQ(100, [result integerValue]);
+
+ [webView _setFixedLayoutEnabled:YES];
+ [webView _setFixedLayoutSize:NSMakeSize(200, 200)];
+
+ [webView evaluateJavaScript:@"document.body.clientWidth" completionHandler:^(id result, NSError *error) {
+ EXPECT_EQ(200, [result integerValue]);
+
+ fixedLayoutSizeDone = true;
+ }];
+ }];
+
+ TestWebKitAPI::Util::run(&fixedLayoutSizeDone);
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&fixedLayoutSizeAfterNavigationDone);
+
+ [webView _setFixedLayoutEnabled:NO];
+ [webView evaluateJavaScript:@"document.body.clientWidth" completionHandler:^(id result, NSError *error) {
+ EXPECT_EQ(100, [result integerValue]);
+ fixedLayoutSizeDisabledDone = true;
+ }];
+
+ TestWebKitAPI::Util::run(&fixedLayoutSizeDisabledDone);
+}
+
+#endif