findNestedPositionAbsoluteChildren method

List<Element> findNestedPositionAbsoluteChildren()

Implementation

List<Element> findNestedPositionAbsoluteChildren() {
  List<Element> positionAbsoluteChildren = [];

  if (!isRendererAttachedToSegmentTree) return positionAbsoluteChildren;

  children.forEach((Element child) {
    if (!child.isRendererAttachedToSegmentTree) return;

    RenderBoxModel childRenderBoxModel = child.renderBoxModel!;
    RenderStyle childRenderStyle = childRenderBoxModel.renderStyle;
    if (childRenderStyle.position == CSSPositionType.absolute) {
      positionAbsoluteChildren.add(child);
    }
    // No need to loop layout box whose position is not static.
    if (childRenderStyle.position != CSSPositionType.static) {
      return;
    }
    if (childRenderBoxModel is RenderLayoutBox) {
      List<Element> mergedChildren = child.findNestedPositionAbsoluteChildren();
      for (Element child in mergedChildren) {
        positionAbsoluteChildren.add(child);
      }
    }
  });

  return positionAbsoluteChildren;
}