Baseline support #317
@@ -951,7 +951,7 @@ static inline YGDirection YGNodeResolveDirection(const YGNodeRef node,
|
||||
}
|
||||
|
||||
static float YGBaselineOfFirstLine(const YGNodeRef node,
|
||||
const YGFlexDirection mainAxis,
|
||||
const YGFlexDirection crossAxis,
|
||||
const float parentWidth) {
|
||||
|
||||
if (node->baseline != NULL) {
|
||||
![]() uint32_t uint32_t
![]() i++ i++
|
||||
return node->baseline(node);
|
||||
@@ -982,8 +982,8 @@ static float YGBaselineOfFirstLine(const YGNodeRef node,
|
||||
node->style.flexDirection,
|
||||
node->layout.measuredDimensions[YGDimensionWidth]);
|
||||
if (YGFloatIsUndefined(baseline)) {
|
||||
baseline = YGNodeLeadingPaddingAndBorder(baselineChild, mainAxis, parentWidth) +
|
||||
baselineChild->layout.measuredDimensions[dim[mainAxis]];
|
||||
baseline = YGNodeLeadingPaddingAndBorder(baselineChild, node->style.flexDirection, node->layout.measuredDimensions[YGDimensionWidth]) +
|
||||
baselineChild->layout.measuredDimensions[dim[node->style.flexDirection]];
|
||||
}
|
||||
|
||||
return baseline + baselineChild->layout.position[YGEdgeTop];
|
||||
|
Reference in New Issue
Block a user
This will always be height as baseline is undefined for column flex direction. right? in that case I think it is better to be clear and use
YGDimensionHeight
instead ofdim[crossAxis]
Is there a good reason to allow undefined return value for baseline? I would prefer asserting and crashing as it would probably indicate a bug. What do you think?
Why
child->lineIndex > 0
? I understand that it skips multiline children but i'm not sure why.same as above regarding
dim[crossAxis]
The baseline of a container is defined by its first baseline aligned child, but when there is no baseline aligned child then the container's baseline is defined by it's last child. This seems odd. Are you sure we have test cases covering edge cases here to make sure this is how it works on the web?
same as above regarding
pos[crossAxis]
I'm not sure my self about this. I thought this could be a kind of "feature", so if you return undefined, you simply use the nodes height. But crashing would be fine too for me. What I'm not sure about is if we explicitly add the padding-top here or if the implementation of the custom function needs to consider this.
we use only the first line of the children for base layout alignment. At least this is how chrome handles it.
no it's defined by its first child on the first line or the first baseline aligned child if there is one (one the first line). I'll add a test for this.
The custom function should not take padding into account. We don't expect this for the measure function so I would like to preserve that here if possible.
Let's crash for now. If we find a valid reason to have this feature we can implement it later.
yes, but this looks like we are skipping over children with multiple lines instead of just looking at their first line?
So the current code is wrong i think. Right? As it will pick the last child in the case no child is baseline aligned?
oh, yep. We should break instead of continue here!
no as we only use the child if
baselineChild
is stillNULL
. Which is false as seen as we find the first one. We still need to iterate to take any baseline aligned child into account.