| Index: ios/web/navigation/crw_session_controller.mm
|
| diff --git a/ios/web/navigation/crw_session_controller.mm b/ios/web/navigation/crw_session_controller.mm
|
| index cf5175e1673d9b538cc846748aede176d338b9c8..58d095a83c8377d39736ad1162c309865a44a407 100644
|
| --- a/ios/web/navigation/crw_session_controller.mm
|
| +++ b/ios/web/navigation/crw_session_controller.mm
|
| @@ -541,21 +541,26 @@ initiationType:(web::NavigationInitiationType)initiationType;
|
| self.items.size());
|
| }
|
|
|
| -- (void)goToItemAtIndex:(NSInteger)index {
|
| +- (void)goToItemAtIndex:(NSInteger)index
|
| + discardNonCommittedItems:(BOOL)discard {
|
| if (index < 0 || static_cast<NSUInteger>(index) >= self.items.size())
|
| return;
|
|
|
| - if (index < _lastCommittedItemIndex) {
|
| - // Going back.
|
| - [self discardNonCommittedItems];
|
| - } else if (_lastCommittedItemIndex < index) {
|
| - // Going forward.
|
| - [self discardTransientItem];
|
| - } else {
|
| - // |delta| is 0, no need to change the last committed item index.
|
| + if (index == _lastCommittedItemIndex) {
|
| + // |delta| is 0, no need to change current navigation index.
|
| return;
|
| }
|
|
|
| + if (discard) {
|
| + if (index < _lastCommittedItemIndex) {
|
| + // Going back.
|
| + [self discardNonCommittedItems];
|
| + } else if (_lastCommittedItemIndex < index) {
|
| + // Going forward.
|
| + [self discardTransientItem];
|
| + }
|
| + }
|
| +
|
| _previousItemIndex = _lastCommittedItemIndex;
|
| _lastCommittedItemIndex = index;
|
| }
|
|
|