Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YGNodeSetMeasureFunc api error #488

Closed
anql opened this issue Mar 22, 2017 · 1 comment
Closed

YGNodeSetMeasureFunc api error #488

anql opened this issue Mar 22, 2017 · 1 comment

Comments

@anql
Copy link

anql commented Mar 22, 2017

Report

Issues and Steps to Reproduce

  1. Run the code below
  2. Uncomment the line of 'YGNodeSetMeasureFunc', run again.

Expected Behavior

Expected the child node's width should be 282.

{layout: {width: 282, height: 200, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', alignContent: 'stretch', flexGrow: 0, flexShrink: 0, flexBasis: nan%, overflow: 'hidden', width: nan%, height: 200pt, children: [
  {layout: {width: 282, height: 200, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', alignContent: 'stretch', alignSelf: 'stretch', flexGrow: 0, flexShrink: 0, flexBasis: nan%, overflow: 'hidden', padding: 100pt, width: nan%, height: nan%, },
]},

Actual Behavior

Get different calculation results while set 'YGNodeSetMeasureFunc' or not even if the function was never invoked actually both cases.

{layout: {width: 282, height: 200, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', alignContent: 'stretch', flexGrow: 0, flexShrink: 0, flexBasis: nan%, overflow: 'hidden', width: nan%, height: 200pt, children: [
  {layout: {width: 200, height: 200, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', alignContent: 'stretch', alignSelf: 'stretch', flexGrow: 0, flexShrink: 0, flexBasis: nan%, overflow: 'hidden', padding: 100pt, width: nan%, height: nan%, },
]},

Link to Code

#include <iostream>
#include "Yoga.h"
#include <stdlib.h>
#include <stdio.h>
#include <vector>


static YGSize YGMeasureFuncForLabel(YGNodeRef node,
                                    float width,
                                    YGMeasureMode widthMode,
                                    float height,
                                    YGMeasureMode heightMode) {
    // this function was never invoked.
    YGSize size;
    size.width = 8;
    size.height = 16;
    return size;
}

int main(int argc, const char * argv[]) {
    
    const YGNodeRef root = YGNodeNew();
    YGNodeStyleSetHeight(root, 200);
    YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn);
    YGNodeStyleSetAlignItems(root, YGAlignStretch);
    YGNodeStyleSetAlignContent(root, YGAlignStretch);
    YGNodeStyleSetFlexGrow(root, 0);
    YGNodeStyleSetOverflow(root, YGOverflowHidden);
    YGNodeStyleSetAlignSelf(root, YGAlignAuto);
    YGNodeStyleSetPositionType(root, YGPositionTypeRelative);
    YGNodeStyleSetJustifyContent(root, YGJustifyFlexStart);
    
    const YGNodeRef root_child0 = YGNodeNew();
    YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumn);
    YGNodeStyleSetAlignItems(root_child0, YGAlignStretch);
    YGNodeStyleSetAlignContent(root_child0, YGAlignStretch);
    YGNodeStyleSetAlignSelf(root_child0, YGAlignStretch);
    YGNodeStyleSetJustifyContent(root_child0, YGJustifyFlexStart);
    YGNodeStyleSetOverflow(root_child0, YGOverflowHidden);
    YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 100);
    YGNodeStyleSetPadding(root_child0, YGEdgeTop, 100);
    YGNodeStyleSetPadding(root_child0, YGEdgeRight, 100);
    YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 100);
    
    YGNodeInsertChild(root, root_child0, 0);

    //YGNodeSetMeasureFunc(root_child0, &YGMeasureFuncForLabel);
    YGNodeCalculateLayout(root, 282, YGUndefined, YGDirectionLTR);
    
    YGNodeFreeRecursive(root);
}

When applicable, use this fiddle to post a web repro.

@anql
Copy link
Author

anql commented Mar 28, 2017

@woehrl01 Would you like to fix this issue?

facebook-github-bot pushed a commit to facebook/litho that referenced this issue Apr 13, 2017
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488
Closes facebook/yoga#499

Differential Revision: D4850458

Pulled By: emilsjolander

fbshipit-source-id: be5e35a670ddcbf3cd426fc3c2a0c9b60a874cdc
facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Apr 13, 2017
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488
Closes facebook/yoga#499

Differential Revision: D4850458

Pulled By: emilsjolander

fbshipit-source-id: be5e35a670ddcbf3cd426fc3c2a0c9b60a874cdc
Maxwell2022 pushed a commit to Maxwell2022/react-native that referenced this issue Apr 19, 2017
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488
Closes facebook/yoga#499

Differential Revision: D4850458

Pulled By: emilsjolander

fbshipit-source-id: be5e35a670ddcbf3cd426fc3c2a0c9b60a874cdc
facebook-github-bot pushed a commit that referenced this issue Apr 27, 2017
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix #488
Closes #499

Reviewed By: astreet

Differential Revision: D4954008

Pulled By: emilsjolander

fbshipit-source-id: 5b6d9afae0cdebe33f8b82b67620b3b4527d1efc
facebook-github-bot pushed a commit to facebook/litho that referenced this issue Apr 27, 2017
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488
Closes facebook/yoga#499

Reviewed By: astreet

Differential Revision: D4954008

Pulled By: emilsjolander

fbshipit-source-id: 5b6d9afae0cdebe33f8b82b67620b3b4527d1efc
facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Apr 27, 2017
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488
Closes facebook/yoga#499

Reviewed By: astreet

Differential Revision: D4954008

Pulled By: emilsjolander

fbshipit-source-id: 5b6d9afae0cdebe33f8b82b67620b3b4527d1efc
thotegowda pushed a commit to thotegowda/react-native that referenced this issue May 7, 2017
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488
Closes facebook/yoga#499

Differential Revision: D4850458

Pulled By: emilsjolander

fbshipit-source-id: be5e35a670ddcbf3cd426fc3c2a0c9b60a874cdc
thotegowda pushed a commit to thotegowda/react-native that referenced this issue May 7, 2017
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488
Closes facebook/yoga#499

Reviewed By: astreet

Differential Revision: D4954008

Pulled By: emilsjolander

fbshipit-source-id: 5b6d9afae0cdebe33f8b82b67620b3b4527d1efc
vincentriemer pushed a commit to vincentriemer/yoga-dom that referenced this issue May 9, 2018
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488
Closes facebook/yoga#499

Differential Revision: D4850458

Pulled By: emilsjolander

fbshipit-source-id: be5e35a670ddcbf3cd426fc3c2a0c9b60a874cdc
vincentriemer pushed a commit to vincentriemer/yoga-dom that referenced this issue May 9, 2018
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488
Closes facebook/yoga#499

Reviewed By: astreet

Differential Revision: D4954008

Pulled By: emilsjolander

fbshipit-source-id: 5b6d9afae0cdebe33f8b82b67620b3b4527d1efc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant