attachTo method

  1. @override
void attachTo(
  1. Node parent, {
  2. RenderBox? after,
})
override

Attach a renderObject to parent.

Implementation

@override
void attachTo(Node parent, {RenderBox? after}) {
  if (enableWebFProfileTracking) {
    WebFProfiler.instance.startTrackUICommandStep('$this.attachTo');
  }
  applyStyle(style);

  if (parentElement?.renderStyle.display == CSSDisplay.sliver) {
    // Sliver should not create renderer here, but need to trigger
    // render sliver list dynamical rebuild child by element tree.
    parentElement?._renderLayoutBox?.markNeedsLayout();
  } else {
    willAttachRenderer();
  }

  if (renderer != null) {
    // If element attach WidgetElement, render object should be attach to render tree when mount.
    if (parent.renderObjectManagerType == RenderObjectManagerType.WEBF_NODE) {
      RenderBoxModel.attachRenderBox(parent.renderer!, renderer!, after: after);
      if (renderStyle.position != CSSPositionType.static) {
        _updateRenderBoxModelWithPosition(CSSPositionType.static);
      }
      markBeforePseudoElementNeedsUpdate();
      markAfterPseudoElementNeedsUpdate();
    }

    if (!ownerDocument.controller.shouldBlockingFlushingResolvedStyleProperties) {
      // Flush pending style before child attached.
      style.flushPendingProperties();
    }

    didAttachRenderer();
  }

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