fillDeferredIntegrals static method

List<NodeLayout> fillDeferredIntegrals({
  1. required List<LatexNode> nodes,
  2. required List<NodeLayout?> layouts,
  3. required RenderContext context,
  4. LayoutCache? cache,
})

Fills deferred integral nodes.

In the initial phase, DISPLAY mode integrals are marked as null (deferred). This method injects the bigOpHeightHint based on the measured right-hand neighbors

Implementation

static List<NodeLayout> fillDeferredIntegrals({
  required List<LatexNode> nodes,
  required List<NodeLayout?> layouts,
  required RenderContext context,
  LayoutCache? cache,
}) {
  final result = <NodeLayout>[];

  for (int index = 0; index < nodes.length; index++) {
    final node = nodes[index];
    NodeLayout? layout = layouts[index];

    if (layout == null) {
      // This node is a deferred integral
      final rightContentHeight = _computeRightContentHeight(
        nodes,
        layouts,
        index,
      );

      final hintedContext = rightContentHeight > 0.0
          ? context.copyWith(
              layoutHints: context.layoutHints.copyWith(
                bigOpHeightHint: rightContentHeight,
              ),
            )
          : context;

      layout = measureNode(node, hintedContext, cache: cache);
    }

    result.add(layout);
  }

  return result;
}