| 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 430ff519e3430404bca69eb035a1ce4f253c4084..9f38b2ac70d337b9e3f2f6edafff38fd1c3b04ca 100644
|
| --- a/ios/web/navigation/crw_session_controller.mm
|
| +++ b/ios/web/navigation/crw_session_controller.mm
|
| @@ -636,39 +636,36 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
|
| }
|
|
|
| - (void)goDelta:(int)delta {
|
| - if (delta == 0 || ![self canGoDelta:delta])
|
| - return;
|
| + if (delta != 0 && [self canGoDelta:delta]) {
|
| + NSInteger newNavigationIndex = [self indexOfEntryForDelta:delta];
|
| + [self goToEntry:_entries[newNavigationIndex]];
|
| + }
|
| +}
|
|
|
| - NSInteger oldNavigationIndex = self.currentNavigationIndex;
|
| - NSInteger newNavigationIndex = [self indexOfEntryForDelta:delta];
|
| +- (void)goToEntry:(CRWSessionEntry*)entry {
|
| + DCHECK(entry);
|
| + if (![_entries containsObject:entry])
|
| + return;
|
|
|
| + NSInteger newNavigationIndex = [_entries indexOfObject:entry];
|
| + NSInteger delta = newNavigationIndex - _currentNavigationIndex;
|
| if (delta < 0) {
|
| - [self discardNonCommittedEntries];
|
| for (int i = delta; i < 0; i++) {
|
| base::RecordAction(UserMetricsAction("Back"));
|
| }
|
| - } else if (delta > 0) {
|
| - [self discardTransientEntry];
|
| + [self discardNonCommittedEntries];
|
| + } else if (0 < delta) {
|
| for (int i = 0; i < delta; i++) {
|
| base::RecordAction(UserMetricsAction("Forward"));
|
| }
|
| + [self discardTransientEntry];
|
| + } else {
|
| + // delta is 0, no need to change current navigation index.
|
| + return;
|
| }
|
|
|
| + _previousNavigationIndex = _currentNavigationIndex;
|
| _currentNavigationIndex = newNavigationIndex;
|
| - _previousNavigationIndex = oldNavigationIndex;
|
| -}
|
| -
|
| -- (void)goToEntry:(CRWSessionEntry*)entry {
|
| - DCHECK(entry);
|
| -
|
| - [self discardTransientEntry];
|
| -
|
| - // Check that |entries_| still contains |entry|. |entry| could have been
|
| - // removed by -clearForwardEntries.
|
| - if ([_entries containsObject:entry]) {
|
| - _previousNavigationIndex = self.currentNavigationIndex;
|
| - self.currentNavigationIndex = [_entries indexOfObject:entry];
|
| - }
|
| }
|
|
|
| - (void)removeEntryAtIndex:(NSInteger)index {
|
|
|