* [ios] fix issue https://issues.apache.org/jira/projects/WEEX/issues/WEEX-91?  
taking max-width into consideration when meassuring text


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/5896a612
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/5896a612
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/5896a612

Branch: refs/heads/master
Commit: 5896a612ac0a41b128dfda12bb3ee954f8ac612a
Parents: e1f3344
Author: acton393 <zhangxing610...@gmail.com>
Authored: Sun Nov 5 12:56:55 2017 +0800
Committer: acton393 <zhangxing610...@gmail.com>
Committed: Sun Nov 5 12:56:55 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/WXTextComponent.m  | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/5896a612/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m 
b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
index 1470189..8b292d4 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -317,6 +317,16 @@ do {\
     return ^CGSize (CGSize constrainedSize) {
         CGSize computedSize = CGSizeZero;
         NSTextStorage *textStorage = nil;
+        
+        //TODO:more elegant way to use max and min constrained size
+        if (!isnan(weakSelf.cssNode->style.minDimensions[CSS_WIDTH])) {
+            constrainedSize.width = MAX(constrainedSize.width, 
weakSelf.cssNode->style.minDimensions[CSS_WIDTH]);
+        }
+        
+        if (!isnan(weakSelf.cssNode->style.maxDimensions[CSS_WIDTH])) {
+            constrainedSize.width = MIN(constrainedSize.width, 
weakSelf.cssNode->style.maxDimensions[CSS_WIDTH]);
+        }
+        
         if (![self useCoreText]) {
             textStorage = [weakSelf 
textStorageWithWidth:constrainedSize.width];
             NSLayoutManager *layoutManager = 
textStorage.layoutManagers.firstObject;
@@ -325,15 +335,6 @@ do {\
         } else {
             computedSize = [weakSelf 
calculateTextHeightWithWidth:constrainedSize.width];
         }
-    
-        //TODO:more elegant way to use max and min constrained size
-        if (!isnan(weakSelf.cssNode->style.minDimensions[CSS_WIDTH])) {
-            computedSize.width = MAX(computedSize.width, 
weakSelf.cssNode->style.minDimensions[CSS_WIDTH]);
-        }
-        
-        if (!isnan(weakSelf.cssNode->style.maxDimensions[CSS_WIDTH])) {
-            computedSize.width = MIN(computedSize.width, 
weakSelf.cssNode->style.maxDimensions[CSS_WIDTH]);
-        }
         
         if (!isnan(weakSelf.cssNode->style.minDimensions[CSS_HEIGHT])) {
             computedSize.height = MAX(computedSize.height, 
weakSelf.cssNode->style.minDimensions[CSS_HEIGHT]);

Reply via email to