[ 
https://issues.apache.org/jira/browse/WEEX-555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16574752#comment-16574752
 ] 

ASF GitHub Bot commented on WEEX-555:
-------------------------------------

YorkShen closed pull request #1414: [WEEX-555][iOS] fix layout engin bug
URL: https://github.com/apache/incubator-weex/pull/1414
 
 
   

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/Layout/WXCoreLayout.cpp 
b/ios/sdk/WeexSDK/Sources/Layout/WXCoreLayout.cpp
index 1d771ab6ce..5451853e3a 100644
--- a/ios/sdk/WeexSDK/Sources/Layout/WXCoreLayout.cpp
+++ b/ios/sdk/WeexSDK/Sources/Layout/WXCoreLayout.cpp
@@ -18,6 +18,7 @@
  */
 
 #include "WXCoreLayout.h"
+#include <tuple>
 
 using namespace WeexCore;
 
@@ -192,7 +193,14 @@ namespace WeexCore {
         (widthMeasureMode == kUnspecified
             || heightMeasureMode == kUnspecified)) {
       float constrainsWidth = width;
-      if(widthMeasureMode == kExactly && !isnan(width)){
+      if(isnan(width)){
+        if(!isnan(mCssStyle->mMaxWidth)){
+          constrainsWidth = mCssStyle->mMaxWidth;
+        }
+      }
+
+      if((!isnan(width)&&widthMeasureMode == kExactly) ||
+          (isnan(width) && !isnan(mCssStyle->mMaxWidth))) {
         constrainsWidth -= sumPaddingBorderAlongAxis(this, true);
       }
       WXCoreSize dimension = measureFunc(this, constrainsWidth,
@@ -240,7 +248,6 @@ namespace WeexCore {
       }
     }
 
-
   /**
    * @param flexDirection         the flex direction attribute
    * @param width                 stylewidth by this node
@@ -335,9 +342,11 @@ namespace WeexCore {
           child->hypotheticalMeasure(childWidth, childHeight, stretch);
         } else {
           if(isSingleFlexLine(isMainAxisHorizontal(this) ? parentWidth : 
parentHeight)
-              && !isMainAxisHorizontal(this) && child->widthMeasureMode == 
kUnspecified){
-            child->setLayoutWidth(parentWidth - 
sumPaddingBorderAlongAxis(this, true)
-                                      
-child->mCssStyle->sumMarginOfDirection(true));
+              && !isMainAxisHorizontal(this)){
+            if(child->widthMeasureMode == kUnspecified) {
+              child->setLayoutWidth(parentWidth - 
sumPaddingBorderAlongAxis(this, true)
+                                        - 
child->mCssStyle->sumMarginOfDirection(true));
+            }
             if(child->heightMeasureMode == kUnspecified && child->widthDirty) {
               child->mLayoutResult->mLayoutSize.height = NAN;
             }
@@ -464,6 +473,11 @@ namespace WeexCore {
       if (isMainAxisHorizontal(this)) {
         child->setWidthMeasureMode(kExactly);
         child->setLayoutWidth(childMainSize);
+        //TODO Fix 
https://jsplayground.taobao.org/raxplayground/97efee70-775f-45a6-b07d-d84c8d1b4387
+        //TODO This is just a temporary fix, we need to make things beauty and 
clean.
+        if(child->heightMeasureMode == kUnspecified && child->measureFunc != 
nullptr && child->getChildCount() == 0){
+          child->setLayoutHeight(NAN);
+        }
       } else {
         child->setHeightMeasureMode(kExactly);
         child->setLayoutHeight(childMainSize);
@@ -494,10 +508,11 @@ namespace WeexCore {
 
     void WXCoreLayoutNode::stretchViewCrossSize(WXCoreLayoutNode* const child, 
float crossSize){
       if (isMainAxisHorizontal(this)) {
-        if (child->heightMeasureMode != kExactly) {
-            crossSize -=
-                child->mCssStyle->mMargin.getMargin(kMarginTop) +
-                    child->mCssStyle->mMargin.getMargin(kMarginBottom);
+        if (child->heightMeasureMode != kExactly &&
+            !(child->measureFunc != nullptr && child->getChildCount() == 0)) {
+          crossSize -=
+              child->mCssStyle->mMargin.getMargin(kMarginTop) +
+                  child->mCssStyle->mMargin.getMargin(kMarginBottom);
           child->setHeightMeasureMode(kExactly);
           child->setLayoutHeight(std::max(0.f, crossSize));
         }


 

----------------------------------------------------------------
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:
[email protected]


> [iOS] fix layout enging text height /flex-grow bug 
> ---------------------------------------------------
>
>                 Key: WEEX-555
>                 URL: https://issues.apache.org/jira/browse/WEEX-555
>             Project: Weex
>          Issue Type: Bug
>          Components: iOS
>            Reporter: peihan
>            Assignee: XuYouyang
>            Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to