From b426cbccb4c3f92c194be5b2243ccce1068f5f91 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 23 Dec 2020 10:06:35 -0800 Subject: [PATCH] Back out "Use ConcreteStateTeller in RCTTextInputComponentView" Summary: Original commit changeset: 2b82e2d43cc6 ConcreteStateTeller is being replaced with a new built-in state autorepeat mechanism. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25687699 fbshipit-source-id: d318155509b00064e29fc32efe893151a9723fd5 --- .../TextInput/RCTTextInputComponentView.mm | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index deb8c930487..f5d280a59e9 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -29,7 +29,7 @@ using namespace facebook::react; @end @implementation RCTTextInputComponentView { - TextInputShadowNode::ConcreteStateTeller _stateTeller; + TextInputShadowNode::ConcreteState::Shared _state; UIView *_backedTextInputView; NSUInteger _mostRecentEventCount; NSAttributedString *_lastStringStateWasUpdatedWith; @@ -216,21 +216,21 @@ using namespace facebook::react; - (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState { - _stateTeller.setConcreteState(state); + _state = std::static_pointer_cast(state); - if (!_stateTeller.isValid()) { + if (!_state) { assert(false && "State is `null` for component."); _backedTextInputView.attributedText = nil; return; } - auto data = _stateTeller.getData().value(); + auto data = _state->getData(); if (!oldState) { - _mostRecentEventCount = data.mostRecentEventCount; + _mostRecentEventCount = _state->getData().mostRecentEventCount; } - if (_mostRecentEventCount == data.mostRecentEventCount) { + if (_mostRecentEventCount == _state->getData().mostRecentEventCount) { _comingFromJS = YES; [self _setAttributedString:RCTNSAttributedStringFromAttributedStringBox(data.attributedStringBox)]; _comingFromJS = NO; @@ -251,7 +251,7 @@ using namespace facebook::react; - (void)prepareForRecycle { [super prepareForRecycle]; - _stateTeller.invalidate(); + _state.reset(); _backedTextInputView.attributedText = nil; _mostRecentEventCount = 0; _comingFromJS = NO; @@ -488,17 +488,16 @@ using namespace facebook::react; - (void)_updateState { - if (!_stateTeller.isValid()) { + if (!_state) { return; } - NSAttributedString *attributedString = _backedTextInputView.attributedText; - auto data = _stateTeller.getData().value(); + auto data = _state->getData(); _lastStringStateWasUpdatedWith = attributedString; data.attributedStringBox = RCTAttributedStringBoxFromNSAttributedString(attributedString); _mostRecentEventCount += _comingFromJS ? 0 : 1; data.mostRecentEventCount = _mostRecentEventCount; - _stateTeller.updateState(std::move(data)); + _state->updateState(std::move(data)); } - (AttributedString::Range)_selectionRange