addOverflowLayoutFromChild method

void addOverflowLayoutFromChild(
  1. RenderBox child
)

Implementation

void addOverflowLayoutFromChild(RenderBox child) {
  final RenderLayoutParentData childParentData = child.parentData as RenderLayoutParentData;
  // TODO not support custom element and inline element overflowRect
  if (!child.hasSize || (child is! RenderBoxModel && child is! RenderReplaced)) {
    return;
  }
  CSSRenderStyle style = (child as RenderBoxModel).renderStyle;
  Rect overflowRect = Rect.fromLTWH(
      childParentData.offset.dx, childParentData.offset.dy, child.boxSize!.width, child.boxSize!.height);

  if (style.effectiveTransformOffset != null) {
    overflowRect = overflowRect.shift(style.effectiveTransformOffset!);
  }
  // child overflowLayout effect parent overflowLayout when child effectiveOverflow is visible or auto
  if (child.renderStyle.effectiveOverflowX == CSSOverflowType.visible ||
      child.renderStyle.effectiveOverflowX == CSSOverflowType.auto ||
      child.renderStyle.effectiveOverflowY == CSSOverflowType.auto ||
      child.renderStyle.effectiveOverflowY == CSSOverflowType.visible) {
    Rect childOverflowLayoutRect = child.overflowRect!.shift(Offset.zero);

    // child overflowLayout rect need transform for parent`s cartesian coordinates
    final Matrix4 transform = Matrix4.identity();
    applyLayoutTransform(child, transform, false);
    Offset tlOffset =
    MatrixUtils.transformPoint(transform, Offset(childOverflowLayoutRect.left, childOverflowLayoutRect.top));
    overflowRect = Rect.fromLTRB(
        math.min(overflowRect.left, tlOffset.dx),
        math.min(overflowRect.top, tlOffset.dy),
        math.max(overflowRect.right, tlOffset.dx + childOverflowLayoutRect.width),
        math.max(overflowRect.bottom, tlOffset.dy + childOverflowLayoutRect.height));
  }

  addLayoutOverflow(overflowRect);
}