You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@weex.apache.org by GitBox <gi...@apache.org> on 2018/09/12 13:00:35 UTC

[GitHub] wqyfavor closed pull request #1516: Fix nan cell/header height

wqyfavor closed pull request #1516: Fix nan cell/header height
URL: https://github.com/apache/incubator-weex/pull/1516
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ios/sdk/WeexSDK/Sources/Component/WXCellComponent.mm b/ios/sdk/WeexSDK/Sources/Component/WXCellComponent.mm
index bb59c8b78e..2f149c0f21 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXCellComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/WXCellComponent.mm
@@ -24,6 +24,7 @@
 #import "WXComponent_internal.h"
 #import "WXDiffUtil.h"
 #import "WXComponent+Layout.h"
+#import "WXAssert.h"
 
 @interface WXCellComponent ()
 
@@ -154,6 +155,11 @@ - (void)_assignCalculatedFrame:(CGRect)frame
     else {
         frame.origin.y = 0.0f; // only ignore y
     }
+    
+    WXAssert(!isnan(frame.size.height), @"Height of cell should not be NAN.");
+    if (isnan(frame.size.height)) {
+        frame.size.height = 0.0f;
+    }
     _calculatedFrame = frame;
 }
 
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXHeaderComponent.mm b/ios/sdk/WeexSDK/Sources/Component/WXHeaderComponent.mm
index b97057e032..d627a13852 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXHeaderComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/WXHeaderComponent.mm
@@ -20,6 +20,7 @@
 #import "WXHeaderComponent.h"
 #import "WXComponent_internal.h"
 #import "WXComponent+Layout.h"
+#import "WXAssert.h"
 
 @implementation WXHeaderComponent
 {
@@ -75,6 +76,11 @@ - (BOOL)_isCaculatedFrameChanged:(CGRect)frame
 - (void)_assignCalculatedFrame:(CGRect)frame
 {
     frame.origin = CGPointZero;
+    
+    WXAssert(!isnan(frame.size.height), @"Height of header should not be NAN.");
+    if (isnan(frame.size.height)) {
+        frame.size.height = 0.0f;
+    }
     _calculatedFrame = frame;
 }
 
diff --git a/ios/sdk/WeexSDK/Sources/Layout/WXLayoutConstraint.h b/ios/sdk/WeexSDK/Sources/Layout/WXLayoutConstraint.h
deleted file mode 100644
index 8a10df4a49..0000000000
--- a/ios/sdk/WeexSDK/Sources/Layout/WXLayoutConstraint.h
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-//  WXLayoutConstraint.h
-//  Pods-WeexDemo
-//
-//  Created by 邹明 on 2018/6/26.
-//
-
-#import <Foundation/Foundation.h>
-
-@interface WXLayoutMargin : NSObject
-
-@property (nonatomic,assign,readonly) float top;
-@property (nonatomic,assign,readonly) float bottom;
-@property (nonatomic,assign,readonly) float left;
-@property (nonatomic,assign,readonly) float right;
-
-- (instancetype)initWithTop:(float)top bottom:(float)bottom left:(float)left right:(float)right;
-
-@end
-
-@interface WXLayoutPadding : NSObject
-
-@property (nonatomic,assign,readonly) float top;
-@property (nonatomic,assign,readonly) float bottom;
-@property (nonatomic,assign,readonly) float left;
-@property (nonatomic,assign,readonly) float right;
-
-- (instancetype)initWithTop:(float)top bottom:(float)bottom left:(float)left right:(float)right;
-
-@end
-
-@interface WXLayoutBorderWidth : NSObject
-
-@property (nonatomic,assign,readonly) float top;
-@property (nonatomic,assign,readonly) float bottom;
-@property (nonatomic,assign,readonly) float left;
-@property (nonatomic,assign,readonly) float right;
-
-- (instancetype)initWithTop:(float)top bottom:(float)bottom left:(float)left right:(float)right;
-
-@end
diff --git a/ios/sdk/WeexSDK/Sources/Layout/WXLayoutConstraint.m b/ios/sdk/WeexSDK/Sources/Layout/WXLayoutConstraint.m
deleted file mode 100644
index 22c6960146..0000000000
--- a/ios/sdk/WeexSDK/Sources/Layout/WXLayoutConstraint.m
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-//  WXLayoutConstraint.m
-//  Pods-WeexDemo
-//
-//  Created by 邹明 on 2018/6/26.
-//
-
-#import "WXLayoutConstraint.h"
-
-@implementation WXLayoutMargin
-
-- (instancetype)initWithTop:(float)top bottom:(float)bottom left:(float)left right:(float)right{
-    if (self = [super init]) {
-        _top = top;
-        _bottom = bottom;
-        _left = left;
-        _right = right;
-    }
-    return self;
-}
-
-@end
-
-@implementation WXLayoutPadding
-
-- (instancetype)initWithTop:(float)top bottom:(float)bottom left:(float)left right:(float)right{
-    if (self = [super init]) {
-        _top = top;
-        _bottom = bottom;
-        _left = left;
-        _right = right;
-    }
-    return self;
-}
-
-@end
-
-@implementation WXLayoutBorderWidth
-
-- (instancetype)initWithTop:(float)top bottom:(float)bottom left:(float)left right:(float)right{
-    if (self = [super init]) {
-        _top = top;
-        _bottom = bottom;
-        _left = left;
-        _right = right;
-    }
-    return self;
-}
-
-@end


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services