updateStyleIfNeeded method

void updateStyleIfNeeded()

Implementation

void updateStyleIfNeeded() {
  if (ownerView.enableBlink) return;
  // If a debounced update was previously scheduled, cancel it now since we are
  // about to run a synchronous update. This prevents stray pending timers in
  // tests when callers explicitly flush styles (e.g., after class changes).
  _styleUpdateDebounceTimer?.cancel();
  _styleUpdateDebounceTimer = null;
  _styleUpdateScheduled = false;
  // Only early-return when there are truly no pending updates of any kind:
  // - no pending stylesheet changes
  // - no candidate sheet node changes
  // - no element-level dirty marks
  if (!styleNodeManager.hasPendingStyleSheet &&
      !styleNodeManager.isStyleSheetCandidateNodeChanged &&
      _styleDirtyElements.isEmpty) {
    return;
  }
  if (_recalculating) {
    return;
  }
  _recalculating = true;
  if (styleSheets.isEmpty && styleNodeManager.hasPendingStyleSheet) {
    flushStyle(rebuild: true);
    return;
  }

  flushStyle();
}