| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "ios/web/navigation/navigation_manager_impl.h" | 5 #include "ios/web/navigation/navigation_manager_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 NavigationManagerImpl* navigation_manager) { | 337 NavigationManagerImpl* navigation_manager) { |
| 338 SetSessionController([navigation_manager->GetSessionController() copy]); | 338 SetSessionController([navigation_manager->GetSessionController() copy]); |
| 339 } | 339 } |
| 340 | 340 |
| 341 int NavigationManagerImpl::GetIndexForOffset(int offset) const { | 341 int NavigationManagerImpl::GetIndexForOffset(int offset) const { |
| 342 int result = [session_controller_ pendingEntryIndex] == -1 | 342 int result = [session_controller_ pendingEntryIndex] == -1 |
| 343 ? GetCurrentItemIndex() | 343 ? GetCurrentItemIndex() |
| 344 : static_cast<int>([session_controller_ pendingEntryIndex]); | 344 : static_cast<int>([session_controller_ pendingEntryIndex]); |
| 345 | 345 |
| 346 if (offset < 0) { | 346 if (offset < 0) { |
| 347 if (GetTransientItem()) { | 347 if (GetTransientItem() && [session_controller_ pendingEntryIndex] == -1) { |
| 348 // Going back from transient item is a matter of discarding it and there | 348 // Going back from transient item that added to the end navigation stack |
| 349 // is no need to move navigation index back. | 349 // is a matter of discarding it as there is no need to move navigation |
| 350 // index back. |
| 350 offset++; | 351 offset++; |
| 351 } | 352 } |
| 352 | 353 |
| 353 while (offset < 0 && result > 0) { | 354 while (offset < 0 && result > 0) { |
| 354 // To stop the user getting 'stuck' on redirecting pages they weren't | 355 // To stop the user getting 'stuck' on redirecting pages they weren't |
| 355 // even aware existed, it is necessary to pass over pages that would | 356 // even aware existed, it is necessary to pass over pages that would |
| 356 // immediately result in a redirect (the item *before* the redirected | 357 // immediately result in a redirect (the item *before* the redirected |
| 357 // page). | 358 // page). |
| 358 while (result > 0 && IsRedirectItemAtIndex(result)) { | 359 while (result > 0 && IsRedirectItemAtIndex(result)) { |
| 359 --result; | 360 --result; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } | 397 } |
| 397 | 398 |
| 398 bool NavigationManagerImpl::IsRedirectItemAtIndex(int index) const { | 399 bool NavigationManagerImpl::IsRedirectItemAtIndex(int index) const { |
| 399 DCHECK_GT(index, 0); | 400 DCHECK_GT(index, 0); |
| 400 DCHECK_LT(index, GetItemCount()); | 401 DCHECK_LT(index, GetItemCount()); |
| 401 ui::PageTransition transition = GetItemAtIndex(index)->GetTransitionType(); | 402 ui::PageTransition transition = GetItemAtIndex(index)->GetTransitionType(); |
| 402 return transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK; | 403 return transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK; |
| 403 } | 404 } |
| 404 | 405 |
| 405 } // namespace web | 406 } // namespace web |
| OLD | NEW |