getConstraints method

  1. @override
BoxConstraints getConstraints()
override

Implementation

@override
BoxConstraints getConstraints() {
  if (enableWebFProfileTracking) {
    WebFProfiler.instance.startTrackLayoutStep('RenderLayoutBox.getConstraints()');
  }

  BoxConstraints boxConstraints = super.getConstraints();
  if (isScrollingContentBox) {
    // fix overflow:scroll/auto nested overflow:scroll/auto
    BoxConstraints parentConstraints = (parent as RenderBoxModel).constraints;
    RenderStyle parentRenderStyle = (parent as RenderBoxModel).renderStyle;
    CSSOverflowType effectiveOverflowY = parentRenderStyle.effectiveOverflowY;
    CSSOverflowType effectiveOverflowX = parentRenderStyle.effectiveOverflowX;
    // not processing effectiveOverflow=hidden/clip is to reduce the scope of influence
    bool shouldInheritY = (effectiveOverflowY == CSSOverflowType.auto || effectiveOverflowY == CSSOverflowType.scroll) && scrollShouldInheritConstraints(this, false);
    bool shouldInheritX = (effectiveOverflowX == CSSOverflowType.auto || effectiveOverflowX == CSSOverflowType.scroll) && scrollShouldInheritConstraints(this, true);
    if (shouldInheritY || shouldInheritX) {
      boxConstraints = BoxConstraints(
        minWidth: boxConstraints.minWidth,
        maxWidth: shouldInheritX ? parentConstraints.maxWidth : boxConstraints.maxWidth,
        minHeight: boxConstraints.minHeight,
        maxHeight: shouldInheritY ? parentConstraints.maxHeight : boxConstraints.maxHeight,
      );
    }
  }

  if (enableWebFProfileTracking) {
    WebFProfiler.instance.finishTrackLayoutStep();
  }

  return boxConstraints;
}