This is an automated email from the ASF dual-hosted git repository.
jianhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new 4553f0f [iOS] Set overflow to hidden by default on iOS to conform to
Android. (#2521)
4553f0f is described below
commit 4553f0ff6bc70d3fb717377655cff06f7f9a36c4
Author: wqyfavor <[email protected]>
AuthorDate: Fri Jun 7 20:36:15 2019 +0800
[iOS] Set overflow to hidden by default on iOS to conform to Android.
(#2521)
---
ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m | 3 +++
ios/sdk/WeexSDK/Sources/Utility/WXUtility.h | 4 +++-
ios/sdk/WeexSDK/Sources/Utility/WXUtility.m | 13 ++++++++++++
.../Sources/View/WXComponent+ViewManagement.mm | 24 ++++++++++++++++++----
ios/sdk/WeexSDKTests/WXComponentTests.m | 1 -
5 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index a2a5689..ba052fe 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -517,6 +517,9 @@ typedef enum : NSUInteger {
if ([configCenter
respondsToSelector:@selector(configForKey:defaultValue:isDefault:)]) {
BOOL enableRTLLayoutDirection = [[configCenter
configForKey:@"iOS_weex_ext_config.enableRTLLayoutDirection"
defaultValue:@(YES) isDefault:NULL] boolValue];
[WXUtility setEnableRTLLayoutDirection:enableRTLLayoutDirection];
+
+ BOOL overflowHiddenByDefault = [[configCenter
configForKey:@"iOS_weex_ext_config.overflowHiddenByDefault" defaultValue:@(YES)
isDefault:NULL] boolValue];
+ [WXUtility setOverflowHiddenByDefault:overflowHiddenByDefault];
}
return NO;
}
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
index 71c77d5..3714a82 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
@@ -494,9 +494,11 @@ BOOL WXFloatGreaterThanWithPrecision(CGFloat a,CGFloat
b,double precision);
+ (NSData *_Nonnull)base64DictToData:(NSDictionary *_Nullable)base64Dict;
+ (void)setEnableRTLLayoutDirection:(BOOL)value;
-
+ (BOOL)enableRTLLayoutDirection;
++ (void)setOverflowHiddenByDefault:(BOOL)value;
++ (BOOL)overflowHiddenByDefault;
+
+ (long) getUnixFixTimeMillis;
+ (NSArray<NSString *> *_Nullable)extractPropertyNamesOfJSValueObject:(JSValue
*_Nullable)jsvalue;
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
index e94c40e..a6ba757 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
@@ -43,6 +43,7 @@
#define KEY_USERNAME_PASSWORD @"com.taobao.Weex.weex123456"
static BOOL enableRTLLayoutDirection = YES;
+static BOOL overflowHiddenByDefault = YES;
void WXPerformBlockOnMainThread(void (^ _Nonnull block)(void))
{
@@ -770,6 +771,18 @@ CGFloat WXFloorPixelValue(CGFloat value)
return enableRTLLayoutDirection;
}
+# pragma mark - Overflow
+
++ (void)setOverflowHiddenByDefault:(BOOL)value
+{
+ overflowHiddenByDefault = value;
+}
+
++ (BOOL)overflowHiddenByDefault
+{
+ return overflowHiddenByDefault;
+}
+
#pragma mark - get deviceID
+ (NSString *)getDeviceID {
NSMutableDictionary *usernamepasswordKVPairs = (NSMutableDictionary
*)[self load:KEY_USERNAME_PASSWORD];
diff --git a/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.mm
b/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.mm
index 896c2fb..e987704 100644
--- a/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.mm
+++ b/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.mm
@@ -177,7 +177,15 @@ do {\
_backgroundColor = styles[@"backgroundColor"] ? [WXConvert
UIColor:styles[@"backgroundColor"]] : [UIColor clearColor];
_backgroundImage = styles[@"backgroundImage"] ? [WXConvert
NSString:styles[@"backgroundImage"]]: nil;
_opacity = styles[@"opacity"] ? [WXConvert CGFloat:styles[@"opacity"]] :
1.0;
- _clipToBounds = styles[@"overflow"] ? [WXConvert
WXClipType:styles[@"overflow"]] : NO;
+ if ([WXUtility overflowHiddenByDefault]) {
+ /* If we enable overflow:hidden by default, we cannot use original
"overflow" style value.
+ Unless js explicitly define "ios-overflow: visible", we disable
clipToBounds.
+ */
+ _clipToBounds = styles[@"iosOverflow"] ? [WXConvert
WXClipType:styles[@"iosOverflow"]] : YES;
+ }
+ else {
+ _clipToBounds = styles[@"overflow"] ? [WXConvert
WXClipType:styles[@"overflow"]] : NO;
+ }
_visibility = styles[@"visibility"] ? [WXConvert
WXVisibility:styles[@"visibility"]] : WXVisibilityShow;
_positionType = styles[@"position"] ? [WXConvert
WXPositionType:styles[@"position"]] : WXPositionTypeRelative;
_transform = styles[@"transform"] || styles[@"transformOrigin"] ?
@@ -227,9 +235,17 @@ do {\
_layer.opacity = _opacity;
}
- if (styles[@"overflow"]) {
- _clipToBounds = [WXConvert WXClipType:styles[@"overflow"]];
- _view.clipsToBounds = _clipToBounds;
+ if ([WXUtility overflowHiddenByDefault]) {
+ if (styles[@"iosOverflow"]) {
+ _clipToBounds = [WXConvert WXClipType:styles[@"iosOverflow"]];
+ _view.clipsToBounds = _clipToBounds;
+ }
+ }
+ else {
+ if (styles[@"overflow"]) {
+ _clipToBounds = [WXConvert WXClipType:styles[@"overflow"]];
+ _view.clipsToBounds = _clipToBounds;
+ }
}
if (styles[@"position"]) {
diff --git a/ios/sdk/WeexSDKTests/WXComponentTests.m
b/ios/sdk/WeexSDKTests/WXComponentTests.m
index 0ca4cc7..12685a6 100644
--- a/ios/sdk/WeexSDKTests/WXComponentTests.m
+++ b/ios/sdk/WeexSDKTests/WXComponentTests.m
@@ -71,7 +71,6 @@
* View
*/
XCTAssertEqual(component->_backgroundColor, [UIColor clearColor]);
- XCTAssertEqual(component->_clipToBounds, NO);
XCTAssertNil(component->_view);
XCTAssertEqual(component->_opacity, 1.0);
XCTAssertEqual(component->_visibility, WXVisibilityShow);