Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/web/navigation/crw_session_controller.h" | 5 #import "ios/web/navigation/crw_session_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 NSInteger forwardItemStartIndex = _lastCommittedItemIndex + 1; | 362 NSInteger forwardItemStartIndex = _lastCommittedItemIndex + 1; |
| 363 DCHECK(forwardItemStartIndex >= 0); | 363 DCHECK(forwardItemStartIndex >= 0); |
| 364 | 364 |
| 365 size_t itemCount = self.items.size(); | 365 size_t itemCount = self.items.size(); |
| 366 if (forwardItemStartIndex >= static_cast<NSInteger>(itemCount)) | 366 if (forwardItemStartIndex >= static_cast<NSInteger>(itemCount)) |
| 367 return; | 367 return; |
| 368 | 368 |
| 369 if (_previousItemIndex >= forwardItemStartIndex) | 369 if (_previousItemIndex >= forwardItemStartIndex) |
| 370 _previousItemIndex = -1; | 370 _previousItemIndex = -1; |
| 371 | 371 |
| 372 // Remove the NavigationItems and notify the NavigationManater | 372 // Remove the NavigationItems and notify the NavigationManager. |
| 373 _items.erase(_items.begin() + forwardItemStartIndex, _items.end()); | 373 _items.erase(_items.begin() + forwardItemStartIndex, _items.end()); |
| 374 if (_navigationManager) { | 374 if (_navigationManager) { |
| 375 _navigationManager->OnNavigationItemsPruned(itemCount - | 375 _navigationManager->OnNavigationItemsPruned(itemCount - |
| 376 forwardItemStartIndex); | 376 forwardItemStartIndex); |
| 377 } | 377 } |
| 378 } | 378 } |
| 379 | 379 |
| 380 - (void)commitPendingItem { | 380 - (void)commitPendingItem { |
| 381 if (self.pendingItem) { | 381 if (self.pendingItem) { |
| 382 // Once an item is committed it's not renderer-initiated any more. (Matches | 382 // Once an item is committed it's not renderer-initiated any more. (Matches |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 DCHECK(index != _lastCommittedItemIndex); | 537 DCHECK(index != _lastCommittedItemIndex); |
| 538 DCHECK(index >= 0); | 538 DCHECK(index >= 0); |
| 539 | 539 |
| 540 [self discardNonCommittedItems]; | 540 [self discardNonCommittedItems]; |
| 541 | 541 |
| 542 _items.erase(_items.begin() + index); | 542 _items.erase(_items.begin() + index); |
| 543 if (_lastCommittedItemIndex > index) | 543 if (_lastCommittedItemIndex > index) |
| 544 _lastCommittedItemIndex--; | 544 _lastCommittedItemIndex--; |
| 545 if (_previousItemIndex >= index) | 545 if (_previousItemIndex >= index) |
| 546 _previousItemIndex--; | 546 _previousItemIndex--; |
| 547 | |
|
liaoyuke
2017/03/27 16:22:43
I see the following code in clearForwardItems:
if
Eugene But (OOO till 7-30)
2017/03/27 17:15:47
Sounds reasonable, but it would be better to make
liaoyuke
2017/03/28 00:16:40
Acknowledged.
| |
| 548 if (_navigationManager) { | |
| 549 _navigationManager->OnNavigationItemsPruned(1U); | |
| 550 } | |
| 547 } | 551 } |
| 548 | 552 |
| 549 - (BOOL)isSameDocumentNavigationBetweenItem:(web::NavigationItem*)firstItem | 553 - (BOOL)isSameDocumentNavigationBetweenItem:(web::NavigationItem*)firstItem |
| 550 andItem:(web::NavigationItem*)secondItem { | 554 andItem:(web::NavigationItem*)secondItem { |
| 551 if (!firstItem || !secondItem || firstItem == secondItem) | 555 if (!firstItem || !secondItem || firstItem == secondItem) |
| 552 return NO; | 556 return NO; |
| 553 NSUInteger firstIndex = [self indexOfItem:firstItem]; | 557 NSUInteger firstIndex = [self indexOfItem:firstItem]; |
| 554 NSUInteger secondIndex = [self indexOfItem:secondItem]; | 558 NSUInteger secondIndex = [self indexOfItem:secondItem]; |
| 555 if (firstIndex == NSNotFound || secondIndex == NSNotFound) | 559 if (firstIndex == NSNotFound || secondIndex == NSNotFound) |
| 556 return NO; | 560 return NO; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 return item; | 625 return item; |
| 622 } | 626 } |
| 623 | 627 |
| 624 - (BOOL)isRedirectTransitionForItemAtIndex:(size_t)index { | 628 - (BOOL)isRedirectTransitionForItemAtIndex:(size_t)index { |
| 625 DCHECK_LT(index, self.items.size()); | 629 DCHECK_LT(index, self.items.size()); |
| 626 ui::PageTransition transition = self.items[index]->GetTransitionType(); | 630 ui::PageTransition transition = self.items[index]->GetTransitionType(); |
| 627 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; | 631 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; |
| 628 } | 632 } |
| 629 | 633 |
| 630 @end | 634 @end |
| OLD | NEW |