@@ -293,12 +293,13 @@ class YG_EXPORT Style {
293293 Direction direction,
294294 Dimension axis,
295295 float referenceLength,
296- float ownerWidth) const {
296+ float ownerWidth,
297+ YGNodeConstRef node) const {
297298 const auto handle = minDimensions_[yoga::to_underlying (axis)];
298299 if (handle.isUndefined ()) {
299300 return FloatOptional{};
300301 }
301- FloatOptional value = resolve (handle, referenceLength);
302+ FloatOptional value = resolve (handle, referenceLength, node );
302303 if (boxSizing () == BoxSizing::BorderBox || !value.isDefined ()) {
303304 return value;
304305 }
@@ -322,12 +323,13 @@ class YG_EXPORT Style {
322323 Direction direction,
323324 Dimension axis,
324325 float referenceLength,
325- float ownerWidth) const {
326+ float ownerWidth,
327+ YGNodeConstRef node) const {
326328 const auto handle = maxDimensions_[yoga::to_underlying (axis)];
327329 if (handle.isUndefined ()) {
328330 return FloatOptional{};
329331 }
330- FloatOptional value = resolve (handle, referenceLength);
332+ FloatOptional value = resolve (handle, referenceLength, node );
331333 if (boxSizing () == BoxSizing::BorderBox || !value.isDefined ()) {
332334 return value;
333335 }
@@ -416,72 +418,87 @@ class YG_EXPORT Style {
416418 float computeFlexStartPosition (
417419 FlexDirection axis,
418420 Direction direction,
419- float axisSize) const {
420- return resolve (computePosition (flexStartEdge (axis), direction), axisSize)
421+ float axisSize,
422+ YGNodeConstRef node) const {
423+ return resolve (
424+ computePosition (flexStartEdge (axis), direction), axisSize, node)
421425 .unwrapOrDefault (0 .0f );
422426 }
423427
424428 float computeInlineStartPosition (
425429 FlexDirection axis,
426430 Direction direction,
427- float axisSize) const {
431+ float axisSize,
432+ YGNodeConstRef node) const {
428433 return resolve (
429434 computePosition (inlineStartEdge (axis, direction), direction),
430- axisSize)
435+ axisSize,
436+ node)
431437 .unwrapOrDefault (0 .0f );
432438 }
433439
434440 float computeFlexEndPosition (
435441 FlexDirection axis,
436442 Direction direction,
437- float axisSize) const {
438- return resolve (computePosition (flexEndEdge (axis), direction), axisSize)
443+ float axisSize,
444+ YGNodeConstRef node) const {
445+ return resolve (
446+ computePosition (flexEndEdge (axis), direction), axisSize, node)
439447 .unwrapOrDefault (0 .0f );
440448 }
441449
442450 float computeInlineEndPosition (
443451 FlexDirection axis,
444452 Direction direction,
445- float axisSize) const {
453+ float axisSize,
454+ YGNodeConstRef node) const {
446455 return resolve (
447456 computePosition (inlineEndEdge (axis, direction), direction),
448- axisSize)
457+ axisSize,
458+ node)
449459 .unwrapOrDefault (0 .0f );
450460 }
451461
452462 float computeFlexStartMargin (
453463 FlexDirection axis,
454464 Direction direction,
455- float widthSize) const {
456- return resolve (computeMargin (flexStartEdge (axis), direction), widthSize)
465+ float widthSize,
466+ YGNodeConstRef node) const {
467+ return resolve (
468+ computeMargin (flexStartEdge (axis), direction), widthSize, node)
457469 .unwrapOrDefault (0 .0f );
458470 }
459471
460472 float computeInlineStartMargin (
461473 FlexDirection axis,
462474 Direction direction,
463- float widthSize) const {
475+ float widthSize,
476+ YGNodeConstRef node) const {
464477 return resolve (
465478 computeMargin (inlineStartEdge (axis, direction), direction),
466- widthSize)
479+ widthSize,
480+ node)
467481 .unwrapOrDefault (0 .0f );
468482 }
469483
470484 float computeFlexEndMargin (
471485 FlexDirection axis,
472486 Direction direction,
473- float widthSize) const {
474- return resolve (computeMargin (flexEndEdge (axis), direction), widthSize)
487+ float widthSize,
488+ YGNodeConstRef node) const {
489+ return resolve (computeMargin (flexEndEdge (axis), direction), widthSize, node)
475490 .unwrapOrDefault (0 .0f );
476491 }
477492
478493 float computeInlineEndMargin (
479494 FlexDirection axis,
480495 Direction direction,
481- float widthSize) const {
496+ float widthSize,
497+ YGNodeConstRef node) const {
482498 return resolve (
483499 computeMargin (inlineEndEdge (axis, direction), direction),
484- widthSize)
500+ widthSize,
501+ node)
485502 .unwrapOrDefault (0 .0f );
486503 }
487504
@@ -490,7 +507,8 @@ class YG_EXPORT Style {
490507 Direction direction,
491508 YGNodeConstRef node) const {
492509 return maxOrDefined (
493- resolve (computeBorder (flexStartEdge (axis), direction), 0 .0f ).unwrap (),
510+ resolve (computeBorder (flexStartEdge (axis), direction), 0 .0f , node)
511+ .unwrap (),
494512 0 .0f );
495513 }
496514
@@ -500,7 +518,9 @@ class YG_EXPORT Style {
500518 YGNodeConstRef node) const {
501519 return maxOrDefined (
502520 resolve (
503- computeBorder (inlineStartEdge (axis, direction), direction), 0 .0f )
521+ computeBorder (inlineStartEdge (axis, direction), direction),
522+ 0 .0f ,
523+ node)
504524 .unwrap (),
505525 0 .0f );
506526 }
@@ -510,7 +530,8 @@ class YG_EXPORT Style {
510530 Direction direction,
511531 YGNodeConstRef node) const {
512532 return maxOrDefined (
513- resolve (computeBorder (flexEndEdge (axis), direction), 0 .0f ).unwrap (),
533+ resolve (computeBorder (flexEndEdge (axis), direction), 0 .0f , node)
534+ .unwrap (),
514535 0 .0f );
515536 }
516537
@@ -519,7 +540,10 @@ class YG_EXPORT Style {
519540 Direction direction,
520541 YGNodeConstRef node) const {
521542 return maxOrDefined (
522- resolve (computeBorder (inlineEndEdge (axis, direction), direction), 0 .0f )
543+ resolve (
544+ computeBorder (inlineEndEdge (axis, direction), direction),
545+ 0 .0f ,
546+ node)
523547 .unwrap (),
524548 0 .0f );
525549 }
@@ -530,7 +554,7 @@ class YG_EXPORT Style {
530554 float widthSize,
531555 YGNodeConstRef node) const {
532556 return maxOrDefined (
533- resolve (computePadding (flexStartEdge (axis), direction), widthSize)
557+ resolve (computePadding (flexStartEdge (axis), direction), widthSize, node )
534558 .unwrap (),
535559 0 .0f );
536560 }
@@ -543,7 +567,8 @@ class YG_EXPORT Style {
543567 return maxOrDefined (
544568 resolve (
545569 computePadding (inlineStartEdge (axis, direction), direction),
546- widthSize)
570+ widthSize,
571+ node)
547572 .unwrap (),
548573 0 .0f );
549574 }
@@ -554,7 +579,7 @@ class YG_EXPORT Style {
554579 float widthSize,
555580 YGNodeConstRef node) const {
556581 return maxOrDefined (
557- resolve (computePadding (flexEndEdge (axis), direction), widthSize)
582+ resolve (computePadding (flexEndEdge (axis), direction), widthSize, node )
558583 .unwrap (),
559584 0 .0f );
560585 }
@@ -567,7 +592,8 @@ class YG_EXPORT Style {
567592 return maxOrDefined (
568593 resolve (
569594 computePadding (inlineEndEdge (axis, direction), direction),
570- widthSize)
595+ widthSize,
596+ node)
571597 .unwrap (),
572598 0 .0f );
573599 }
@@ -632,6 +658,8 @@ class YG_EXPORT Style {
632658 FlexDirection axis,
633659 float widthSize,
634660 YGNodeConstRef node) const {
661+ // The total margin for a given axis does not depend on the direction
662+ // so hardcoding LTR here to avoid piping direction to this function
635663 return computeInlineStartMargin (axis, Direction::LTR , widthSize, node) +
636664 computeInlineEndMargin (axis, Direction::LTR , widthSize, node);
637665 }
@@ -641,7 +669,7 @@ class YG_EXPORT Style {
641669 float ownerSize,
642670 YGNodeConstRef node) const {
643671 auto gap = isRow (axis) ? computeColumnGap () : computeRowGap ();
644- return maxOrDefined (resolve (gap, ownerSize).unwrap (), 0 .0f );
672+ return maxOrDefined (resolve (gap, ownerSize, node ).unwrap (), 0 .0f );
645673 }
646674
647675 float computeGapForDimension (
@@ -650,7 +678,7 @@ class YG_EXPORT Style {
650678 YGNodeConstRef node) const {
651679 auto gap =
652680 dimension == Dimension::Width ? computeColumnGap () : computeRowGap ();
653- return maxOrDefined (resolve (gap, ownerSize).unwrap (), 0 .0f );
681+ return maxOrDefined (resolve (gap, ownerSize, node ).unwrap (), 0 .0f );
654682 }
655683
656684 bool flexStartMarginIsAuto (FlexDirection axis, Direction direction) const {
@@ -913,14 +941,28 @@ class YG_EXPORT Style {
913941 * StyleLength/StyleSizeLength object on the stack during hot-path overhead
914942 * calculations.
915943 */
916- FloatOptional resolve (StyleValueHandle handle, float referenceLength) const {
944+ FloatOptional resolve (
945+ StyleValueHandle handle,
946+ float referenceLength,
947+ YGNodeConstRef node) const {
917948 if (handle.isPoint ()) {
918949 return FloatOptional{pool_.getStoredValue (handle)};
919950 }
920951 if (handle.isPercent ()) {
921952 return FloatOptional{
922953 pool_.getStoredValue (handle) * referenceLength * 0 .01f };
923954 }
955+ if (handle.isDynamic ()) {
956+ auto callback = pool_.getDynamicCallback (handle);
957+ if (callback) {
958+ return FloatOptional{callback (
959+ node,
960+ pool_.getDynamicCallbackID (handle),
961+ YGValueDynamicContext{referenceLength})
962+ .value };
963+ }
964+ }
965+
924966 return FloatOptional{};
925967 }
926968
0 commit comments