addOverflowLayoutFromChild method

void addOverflowLayoutFromChild(
  1. RenderBox child
)

Implementation

void addOverflowLayoutFromChild(RenderBox child) {
  final RenderLayoutParentData childParentData = child.parentData as RenderLayoutParentData;
  if (!child.hasSize || (child is! RenderBoxModel && child is! RenderReplaced)) {
    return;
  }
  // Out-of-flow positioned descendants (absolute/fixed) do not expand the
  // scrollable overflow area of a scroll container per CSS overflow/positioning
  // expectations. They are clipped to the padding edge and scrolled as a part
  // of the content, but must not affect the scroll range calculation.
  if (this is RenderBoxModel) {
    final RenderBoxModel self = this as RenderBoxModel;
    final bool isScrollContainer = self.renderStyle.effectiveOverflowX != CSSOverflowType.visible ||
        self.renderStyle.effectiveOverflowY != CSSOverflowType.visible;
    if (isScrollContainer && child is RenderBoxModel && child.renderStyle.isSelfPositioned()) {
      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);
}