Replace setFixedLayoutSizeEnabled: with an enum of layout modes
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Apr 2015 20:22:38 +0000 (20:22 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Apr 2015 20:22:38 +0000 (20:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143576

Reviewed by Simon Fraser.

* UIProcess/API/C/WKLayoutMode.h: Added.
* UIProcess/API/Cocoa/WKViewPrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _layoutMode]):
(-[WKWebView _setLayoutMode:]):
(-[WKWebView _isFixedLayoutEnabled]): Deleted.
(-[WKWebView _setFixedLayoutEnabled:]): Deleted.
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/Cocoa/_WKLayoutMode.h: Added.
* UIProcess/API/mac/WKView.mm:
(-[WKView _layoutMode]):
(-[WKView _setLayoutMode:]):
(-[WKView _isFixedLayoutEnabled]): Deleted.
(-[WKView _setFixedLayoutEnabled:]): Deleted.
* WebKit2.xcodeproj/project.pbxproj:
Add enums for "layout mode". Currently we have two values: "ViewSize",
which is the normal behavior, and "FixedSize", which is fixed layout mode.
More values will come in the future.

* TestWebKitAPI/Tests/WebKit2Cocoa/FixedLayoutSize.mm:
(TEST):
Adopt.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182640 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKLayoutMode.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/API/Cocoa/_WKLayoutMode.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FixedLayoutSize.mm

index 2ac2cc2..f7c56cf 100644 (file)
@@ -1,3 +1,29 @@
+2015-04-10  Tim Horton  <timothy_horton@apple.com>
+
+        Replace setFixedLayoutSizeEnabled: with an enum of layout modes
+        https://bugs.webkit.org/show_bug.cgi?id=143576
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/API/C/WKLayoutMode.h: Added.
+        * UIProcess/API/Cocoa/WKViewPrivate.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _layoutMode]):
+        (-[WKWebView _setLayoutMode:]):
+        (-[WKWebView _isFixedLayoutEnabled]): Deleted.
+        (-[WKWebView _setFixedLayoutEnabled:]): Deleted.
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/API/Cocoa/_WKLayoutMode.h: Added.
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _layoutMode]):
+        (-[WKView _setLayoutMode:]):
+        (-[WKView _isFixedLayoutEnabled]): Deleted.
+        (-[WKView _setFixedLayoutEnabled:]): Deleted.
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add enums for "layout mode". Currently we have two values: "ViewSize",
+        which is the normal behavior, and "FixedSize", which is fixed layout mode.
+        More values will come in the future.
+
 2015-04-10  Anders Carlsson  <andersca@apple.com>
 
         _WKWebsiteDataStore doesn't track and remove offline application cache entries
diff --git a/Source/WebKit2/UIProcess/API/C/WKLayoutMode.h b/Source/WebKit2/UIProcess/API/C/WKLayoutMode.h
new file mode 100644 (file)
index 0000000..f4a4f17
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#ifndef WKLayoutMode_h
+#define WKLayoutMode_h
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+    kWKLayoutModeViewSize,
+    kWKLayoutModeFixedSize,
+};
+typedef uint32_t WKLayoutMode;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKLayoutMode_h */
index ba5434e..417d12c 100644 (file)
@@ -26,6 +26,7 @@
 #import <WebKit/WKActionMenuTypes.h>
 #import <WebKit/WKBase.h>
 #import <WebKit/WKImmediateActionTypes.h>
+#import <WebKit/WKLayoutMode.h>
 #import <WebKit/WKView.h>
 
 @interface WKView (Private)
@@ -90,7 +91,7 @@
 @property (nonatomic, setter=_setTopContentInset:) CGFloat _topContentInset;
 @property (nonatomic, setter=_setTotalHeightOfBanners:) CGFloat _totalHeightOfBanners;
 
-@property (nonatomic, getter=_isFixedLayoutEnabled, setter=_setFixedLayoutEnabled:) BOOL _fixedLayoutEnabled;
+@property (nonatomic, setter=_setLayoutMode:) WKLayoutMode _layoutMode;
 @property (nonatomic, setter=_setFixedLayoutSize:) CGSize _fixedLayoutSize;
 
 @property (nonatomic, setter=_setOverrideDeviceScaleFactor:) CGFloat _overrideDeviceScaleFactor WK_AVAILABLE(WK_MAC_TBA, NA);
index 06a2f73..790295a 100644 (file)
@@ -2242,14 +2242,14 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
     return _page->isShowingNavigationGestureSnapshot();
 }
 
-- (BOOL)_isFixedLayoutEnabled
+- (_WKLayoutMode)_layoutMode
 {
-    return _page->useFixedLayout();
+    return _page->useFixedLayout() ? _WKLayoutModeFixedSize : _WKLayoutModeViewSize;
 }
 
-- (void)_setFixedLayoutEnabled:(BOOL)fixedLayoutEnabled
+- (void)_setLayoutMode:(_WKLayoutMode)layoutMode
 {
-    _page->setUseFixedLayout(fixedLayoutEnabled);
+    _page->setUseFixedLayout(layoutMode == _WKLayoutModeFixedSize);
 }
 
 - (CGSize)_fixedLayoutSize
index f27c8a3..3650442 100644 (file)
@@ -28,6 +28,7 @@
 #if WK_API_ENABLED
 
 #import <WebKit/_WKFindOptions.h>
+#import <WebKit/_WKLayoutMode.h>
 #import <WebKit/_WKRenderingProgressEvents.h>
 
 typedef NS_ENUM(NSInteger, _WKPaginationMode) {
@@ -91,7 +92,7 @@ typedef NS_ENUM(NSInteger, _WKPaginationMode) {
 
 - (void)_close;
 
-@property (nonatomic, getter=_isFixedLayoutEnabled, setter=_setFixedLayoutEnabled:) BOOL _fixedLayoutEnabled;
+@property (nonatomic, setter=_setLayoutMode:) _WKLayoutMode _layoutMode;
 @property (nonatomic, setter=_setFixedLayoutSize:) CGSize _fixedLayoutSize;
 
 #if TARGET_OS_IPHONE
diff --git a/Source/WebKit2/UIProcess/API/Cocoa/_WKLayoutMode.h b/Source/WebKit2/UIProcess/API/Cocoa/_WKLayoutMode.h
new file mode 100644 (file)
index 0000000..077dac1
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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 <WebKit/WKFoundation.h>
+
+#if WK_API_ENABLED
+
+typedef NS_ENUM(NSUInteger, _WKLayoutMode) {
+    _WKLayoutModeViewSize,
+    _WKLayoutModeFixedSize,
+} WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+
+#endif
index 16eb146..b4778b6 100644 (file)
@@ -59,6 +59,7 @@
 #import "WKActionMenuItemTypes.h"
 #import "WKFullScreenWindowController.h"
 #import "WKImmediateActionController.h"
+#import "WKLayoutMode.h"
 #import "WKPrintingView.h"
 #import "WKProcessPoolInternal.h"
 #import "WKStringCF.h"
@@ -4343,14 +4344,14 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path)
     return _data->_overrideDeviceScaleFactor;
 }
 
-- (BOOL)_isFixedLayoutEnabled
+- (WKLayoutMode)_layoutMode
 {
-    return _data->_page->useFixedLayout();
+    return _data->_page->useFixedLayout() ? kWKLayoutModeFixedSize : kWKLayoutModeViewSize;
 }
 
-- (void)_setFixedLayoutEnabled:(BOOL)fixedLayoutEnabled
+- (void)_setLayoutMode:(WKLayoutMode)layoutMode
 {
-    _data->_page->setUseFixedLayout(fixedLayoutEnabled);
+    _data->_page->setUseFixedLayout(layoutMode == kWKLayoutModeFixedSize);
 }
 
 - (CGSize)_fixedLayoutSize
index 6d8266a..03b2ca9 100644 (file)
                2D6CD119189058A500E5A4A0 /* ViewSnapshotStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D6CD117189058A500E5A4A0 /* ViewSnapshotStore.h */; };
                2D6CD11A189058A500E5A4A0 /* ViewSnapshotStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D6CD118189058A500E5A4A0 /* ViewSnapshotStore.mm */; };
                2D7303791A7C2B7500F8F487 /* WKPageNavigationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D7303781A7C2B7500F8F487 /* WKPageNavigationClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               2D790A9D1AD7050D00AB90B3 /* _WKLayoutMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D790A9C1AD7050D00AB90B3 /* _WKLayoutMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               2D790A9F1AD7164900AB90B3 /* WKLayoutMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D790A9E1AD7164900AB90B3 /* WKLayoutMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2D7AAFD318C8640600A7ACD4 /* WKWebViewContentProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D7AAFD218C8640600A7ACD4 /* WKWebViewContentProvider.h */; };
                2D7AAFD618C956AF00A7ACD4 /* WKWebViewConfigurationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D7AAFD518C956AF00A7ACD4 /* WKWebViewConfigurationInternal.h */; };
                2D7F13101A702FBA009A6FBD /* ProcessType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D7F130F1A702FBA009A6FBD /* ProcessType.h */; };
                2D70AB1318A1D51A00026D6E /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-iOS.plist"; sourceTree = "<group>"; };
                2D70AB1418A1D57C00026D6E /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-iOS.plist"; sourceTree = "<group>"; };
                2D7303781A7C2B7500F8F487 /* WKPageNavigationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageNavigationClient.h; sourceTree = "<group>"; };
+               2D790A9C1AD7050D00AB90B3 /* _WKLayoutMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKLayoutMode.h; sourceTree = "<group>"; };
+               2D790A9E1AD7164900AB90B3 /* WKLayoutMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKLayoutMode.h; sourceTree = "<group>"; };
                2D7AAFD218C8640600A7ACD4 /* WKWebViewContentProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewContentProvider.h; sourceTree = "<group>"; };
                2D7AAFD518C956AF00A7ACD4 /* WKWebViewConfigurationInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewConfigurationInternal.h; sourceTree = "<group>"; };
                2D7F130F1A702FBA009A6FBD /* ProcessType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessType.h; sourceTree = "<group>"; };
                                2DEAC5CE1AC368BB00A195D8 /* _WKFindOptions.h */,
                                37A64E5418F38E3C00EB30F1 /* _WKFormDelegate.h */,
                                37A64E5618F38F4600EB30F1 /* _WKFormInputSession.h */,
+                               2D790A9C1AD7050D00AB90B3 /* _WKLayoutMode.h */,
                                1A43E828188F3CDC009E4D30 /* _WKProcessPoolConfiguration.h */,
                                1A43E827188F3CDC009E4D30 /* _WKProcessPoolConfiguration.mm */,
                                7C89D2D61A6C6BE6003A5FDE /* _WKProcessPoolConfigurationInternal.h */,
                                1C8E293712761E5B00BC7BD0 /* WKInspector.h */,
                                51A9E1081315CD18009E7031 /* WKKeyValueStorageManager.cpp */,
                                51A9E1091315CD18009E7031 /* WKKeyValueStorageManager.h */,
+                               2D790A9E1AD7164900AB90B3 /* WKLayoutMode.h */,
                                33D3A3B31339600B00709BE4 /* WKMediaCacheManager.cpp */,
                                33D3A3B41339600B00709BE4 /* WKMediaCacheManager.h */,
                                C09AE5E8125257C20025825D /* WKNativeEvent.h */,
                                1A57109F1ABA0027002FABBE /* WKWebsiteDataStoreRef.h in Headers */,
                                1A002D49196B345D00B9AD44 /* SessionStateCoding.h in Headers */,
                                753E3E0E1887398900188496 /* SessionTracker.h in Headers */,
+                               2D790A9F1AD7164900AB90B3 /* WKLayoutMode.h in Headers */,
                                1A6420E512DCE2FF00CAAE2C /* ShareableBitmap.h in Headers */,
                                51217461164C20E30037A5C1 /* ShareableResource.h in Headers */,
                                1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */,
                                BCD597D7112B56DC00EC8C23 /* WKPage.h in Headers */,
                                1AB8A1F818400BB800E9AE69 /* WKPageContextMenuClient.h in Headers */,
                                1AB8A1F418400B8F00E9AE69 /* WKPageFindClient.h in Headers */,
+                               2D790A9D1AD7050D00AB90B3 /* _WKLayoutMode.h in Headers */,
                                1AB8A1F618400B9D00E9AE69 /* WKPageFindMatchesClient.h in Headers */,
                                1AB8A1F018400B0000E9AE69 /* WKPageFormClient.h in Headers */,
                                BC7B633712A45ABA00D174A4 /* WKPageGroup.h in Headers */,
index f654981..331464c 100644 (file)
@@ -1,3 +1,14 @@
+2015-04-10  Tim Horton  <timothy_horton@apple.com>
+
+        Replace setFixedLayoutSizeEnabled: with an enum of layout modes
+        https://bugs.webkit.org/show_bug.cgi?id=143576
+
+        Reviewed by Simon Fraser.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/FixedLayoutSize.mm:
+        (TEST):
+        Adopt.
+
 2015-04-09  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
 
         Update my email address and expertise.
index 849cb88..ea47390 100644 (file)
@@ -62,7 +62,7 @@ TEST(WebKit2, FixedLayoutSize)
     [webView evaluateJavaScript:@"document.body.clientWidth" completionHandler:^(id result, NSError *error) {
         EXPECT_EQ(100, [result integerValue]);
 
-        [webView _setFixedLayoutEnabled:YES];
+        [webView _setLayoutMode:_WKLayoutModeFixedSize];
         [webView _setFixedLayoutSize:NSMakeSize(200, 200)];
 
         [webView evaluateJavaScript:@"document.body.clientWidth" completionHandler:^(id result, NSError *error) {
@@ -79,7 +79,7 @@ TEST(WebKit2, FixedLayoutSize)
 
     TestWebKitAPI::Util::run(&fixedLayoutSizeAfterNavigationDone);
 
-    [webView _setFixedLayoutEnabled:NO];
+    [webView _setLayoutMode:_WKLayoutModeViewSize];
     [webView evaluateJavaScript:@"document.body.clientWidth" completionHandler:^(id result, NSError *error) {
         EXPECT_EQ(100, [result integerValue]);
         fixedLayoutSizeDisabledDone = true;