Ported ChangeHistoryState (and related dependencies)