updateRenderBoxModelWithOverflowX method

void updateRenderBoxModelWithOverflowX(
  1. ScrollListener scrollListener
)

Implementation

void updateRenderBoxModelWithOverflowX(ScrollListener scrollListener) {
  if (enableWebFProfileTracking) {
    WebFProfiler.instance.startTrackUICommandStep('$this.updateRenderBoxModelWithOverflowX');
  }
  if (renderBoxModel is RenderSliverListLayout) {
    RenderSliverListLayout renderBoxModel = this.renderBoxModel as RenderSliverListLayout;
    renderBoxModel.scrollOffsetX = renderBoxModel.axis == Axis.horizontal ? renderBoxModel.scrollable.position : null;
  } else if (renderBoxModel != null) {
    RenderBoxModel renderBoxModel = this.renderBoxModel!;
    CSSOverflowType overflowX = renderStyle.effectiveOverflowX;
    switch (overflowX) {
      case CSSOverflowType.clip:
        _scrollableX = null;
        break;
      case CSSOverflowType.hidden:
      case CSSOverflowType.auto:
      case CSSOverflowType.scroll:
        // If the render has been offset when previous overflow is auto or scroll, _scrollableX should not reset.
        if (_scrollableX == null) {
          _scrollableX = WebFScrollable(
              axisDirection: AxisDirection.right,
              scrollListener: scrollListener,
              overflowType: overflowX,
              currentView: renderStyle.currentFlutterView);
          renderBoxModel.scrollOffsetX = _scrollableX!.position;
        }
        // Reset canDrag by overflow because hidden is can't drag.
        bool canDrag = overflowX != CSSOverflowType.hidden;
        _scrollableX!.overflowType = overflowX;
        _scrollableX!.setCanDrag(canDrag);
        break;
      case CSSOverflowType.visible:
      default:
        _scrollableX = null;
        break;
    }

    renderBoxModel.scrollListener = scrollListener;
    renderBoxModel.scrollablePointerListener = _scrollablePointerListener;
  }
  if (enableWebFProfileTracking) {
    WebFProfiler.instance.finishTrackUICommandStep();
  }
}