OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
8 * Copyright (C) 2011 Google Inc. All rights reserved. | 8 * Copyright (C) 2011 Google Inc. All rights reserved. |
9 * | 9 * |
10 * Redistribution and use in source and binary forms, with or without | 10 * Redistribution and use in source and binary forms, with or without |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 // Don't propagate state from the old item if this is a different-document n
avigation, unless the before | 370 // Don't propagate state from the old item if this is a different-document n
avigation, unless the before |
371 // and after pages are logically related. This means they have the same url
(ignoring fragment) and | 371 // and after pages are logically related. This means they have the same url
(ignoring fragment) and |
372 // the new item was loaded via reload or client redirect. | 372 // the new item was loaded via reload or client redirect. |
373 if (navigationType == HistoryNavigationType::DifferentDocument && (historyCo
mmitType != HistoryInertCommit || !equalIgnoringFragmentIdentifier(oldItem->url(
), m_currentItem->url()))) | 373 if (navigationType == HistoryNavigationType::DifferentDocument && (historyCo
mmitType != HistoryInertCommit || !equalIgnoringFragmentIdentifier(oldItem->url(
), m_currentItem->url()))) |
374 return; | 374 return; |
375 m_currentItem->setDocumentSequenceNumber(oldItem->documentSequenceNumber()); | 375 m_currentItem->setDocumentSequenceNumber(oldItem->documentSequenceNumber()); |
376 m_currentItem->setScrollPoint(oldItem->scrollPoint()); | 376 m_currentItem->setScrollPoint(oldItem->scrollPoint()); |
377 m_currentItem->setPinchViewportScrollPoint(oldItem->pinchViewportScrollPoint
()); | 377 m_currentItem->setPinchViewportScrollPoint(oldItem->pinchViewportScrollPoint
()); |
378 m_currentItem->setPageScaleFactor(oldItem->pageScaleFactor()); | 378 m_currentItem->setPageScaleFactor(oldItem->pageScaleFactor()); |
379 m_currentItem->setStateObject(oldItem->stateObject()); | 379 m_currentItem->setStateObject(oldItem->stateObject()); |
| 380 m_currentItem->setScrollRestorationType(oldItem->scrollRestorationType()); |
| 381 |
380 // The item sequence number determines whether items are "the same", such ba
ck/forward navigation | 382 // The item sequence number determines whether items are "the same", such ba
ck/forward navigation |
381 // between items with the same item sequence number is a no-op. Only treat t
his as identical if the | 383 // between items with the same item sequence number is a no-op. Only treat t
his as identical if the |
382 // navigation did not create a back/forward entry and the url is identical o
r it was loaded via | 384 // navigation did not create a back/forward entry and the url is identical o
r it was loaded via |
383 // history.replaceState(). | 385 // history.replaceState(). |
384 if (historyCommitType == HistoryInertCommit && (navigationType == HistoryNav
igationType::HistoryApi || oldItem->url() == m_currentItem->url())) | 386 if (historyCommitType == HistoryInertCommit && (navigationType == HistoryNav
igationType::HistoryApi || oldItem->url() == m_currentItem->url())) |
385 m_currentItem->setItemSequenceNumber(oldItem->itemSequenceNumber()); | 387 m_currentItem->setItemSequenceNumber(oldItem->itemSequenceNumber()); |
386 } | 388 } |
387 | 389 |
388 static HistoryCommitType loadTypeToCommitType(FrameLoadType type) | 390 static HistoryCommitType loadTypeToCommitType(FrameLoadType type) |
389 { | 391 { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 m_frame->navigationScheduler().startTimer(); | 566 m_frame->navigationScheduler().startTimer(); |
565 | 567 |
566 if (m_frame->view()) | 568 if (m_frame->view()) |
567 m_frame->view()->handleLoadCompleted(); | 569 m_frame->view()->handleLoadCompleted(); |
568 | 570 |
569 if (shouldSendCompleteNotifications(m_frame)) { | 571 if (shouldSendCompleteNotifications(m_frame)) { |
570 m_loadType = FrameLoadTypeStandard; | 572 m_loadType = FrameLoadTypeStandard; |
571 m_progressTracker->progressCompleted(); | 573 m_progressTracker->progressCompleted(); |
572 // Retry restoring scroll offset since finishing loading disables conten
t | 574 // Retry restoring scroll offset since finishing loading disables conten
t |
573 // size clamping. | 575 // size clamping. |
| 576 // TODO(majidvp): Remove this call as it appears to be a no-op because |
| 577 // we set load type to |FrameLoadTypeStandard| just above. |
574 restoreScrollPositionAndViewState(); | 578 restoreScrollPositionAndViewState(); |
575 m_frame->localDOMWindow()->finishedLoading(); | 579 m_frame->localDOMWindow()->finishedLoading(); |
576 | 580 |
577 // Report mobile vs. desktop page statistics. This will only report on A
ndroid. | 581 // Report mobile vs. desktop page statistics. This will only report on A
ndroid. |
578 if (m_frame->isMainFrame()) | 582 if (m_frame->isMainFrame()) |
579 m_frame->document()->viewportDescription().reportMobilePageStats(m_f
rame); | 583 m_frame->document()->viewportDescription().reportMobilePageStats(m_f
rame); |
580 client()->dispatchDidFinishLoad(); | 584 client()->dispatchDidFinishLoad(); |
581 } | 585 } |
582 | 586 |
583 Frame* parent = m_frame->tree().parent(); | 587 Frame* parent = m_frame->tree().parent(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); | 687 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); |
684 if (hashChange) { | 688 if (hashChange) { |
685 m_frame->eventHandler().stopAutoscroll(); | 689 m_frame->eventHandler().stopAutoscroll(); |
686 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url); | 690 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url); |
687 } | 691 } |
688 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); | 692 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); |
689 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr,
ScrollRestorationAuto, type); | 693 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr,
ScrollRestorationAuto, type); |
690 | 694 |
691 m_frame->view()->setWasScrolledByUser(false); | 695 m_frame->view()->setWasScrolledByUser(false); |
692 | 696 |
693 // We need to scroll to the fragment whether or not a hash change occurred,
since | |
694 // the user might have scrolled since the previous navigation. | |
695 processFragment(url, NavigationWithinSameDocument); | |
696 checkCompleted(); | 697 checkCompleted(); |
697 | 698 |
698 m_frame->localDOMWindow()->statePopped(stateObject ? stateObject : Serialize
dScriptValue::nullValue()); | 699 m_frame->localDOMWindow()->statePopped(stateObject ? stateObject : Serialize
dScriptValue::nullValue()); |
699 } | 700 } |
700 | 701 |
701 void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSen
dReferrer shouldSendReferrer, Document* originDocument) | 702 void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSen
dReferrer shouldSendReferrer, Document* originDocument) |
702 { | 703 { |
703 if (!originDocument) | 704 if (!originDocument) |
704 return; | 705 return; |
705 // FIXME: This should be an assertion, but there's some plugin code in the c
hromium repo | 706 // FIXME: This should be an assertion, but there's some plugin code in the c
hromium repo |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 m_documentLoader->setNavigationType(determineNavigationType( | 908 m_documentLoader->setNavigationType(determineNavigationType( |
908 newLoadType, false, request.triggeringEvent())); | 909 newLoadType, false, request.triggeringEvent())); |
909 if (shouldTreatURLAsSameAsCurrent(url)) | 910 if (shouldTreatURLAsSameAsCurrent(url)) |
910 newLoadType = FrameLoadTypeReplaceCurrentItem; | 911 newLoadType = FrameLoadTypeReplaceCurrentItem; |
911 } | 912 } |
912 | 913 |
913 loadInSameDocument(url, stateObject, newLoadType, request.clientRedirect
()); | 914 loadInSameDocument(url, stateObject, newLoadType, request.clientRedirect
()); |
914 | 915 |
915 if (sameDocumentHistoryNavigation) | 916 if (sameDocumentHistoryNavigation) |
916 restoreScrollPositionAndViewState(); | 917 restoreScrollPositionAndViewState(); |
| 918 |
| 919 // We need to scroll to the fragment whether or not a hash change occurr
ed, since |
| 920 // the user might have scrolled since the previous navigation. |
| 921 processFragment(url, NavigationWithinSameDocument); |
917 return; | 922 return; |
918 } | 923 } |
919 | 924 |
920 // Perform navigation to a different document. | 925 // Perform navigation to a different document. |
921 bool sameURL = url == m_documentLoader->urlForHistory(); | 926 bool sameURL = url == m_documentLoader->urlForHistory(); |
922 startLoad(request, newLoadType, policy); | 927 startLoad(request, newLoadType, policy); |
923 | 928 |
924 // Example of this case are sites that reload the same URL with a different
cookie | 929 // Example of this case are sites that reload the same URL with a different
cookie |
925 // driving the generated content, or a master frame with links that drive a
target | 930 // driving the generated content, or a master frame with links that drive a
target |
926 // frame, where the user has clicked on the same link repeatedly. | 931 // frame, where the user has clicked on the same link repeatedly. |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 | 1106 |
1102 void FrameLoader::restoreScrollPositionAndViewState() | 1107 void FrameLoader::restoreScrollPositionAndViewState() |
1103 { | 1108 { |
1104 FrameView* view = m_frame->view(); | 1109 FrameView* view = m_frame->view(); |
1105 if (!m_frame->page() || !view || !m_currentItem || !m_stateMachine.committed
FirstRealDocumentLoad()) | 1110 if (!m_frame->page() || !view || !m_currentItem || !m_stateMachine.committed
FirstRealDocumentLoad()) |
1106 return; | 1111 return; |
1107 | 1112 |
1108 if (!needsHistoryItemRestore(m_loadType)) | 1113 if (!needsHistoryItemRestore(m_loadType)) |
1109 return; | 1114 return; |
1110 | 1115 |
1111 if (m_currentItem->scrollRestorationType() == ScrollRestorationManual) | 1116 if (m_currentItem->scrollRestorationType() == ScrollRestorationManual) { |
| 1117 documentLoader()->initialScrollState().didRestoreFromHistory = true; |
1112 return; | 1118 return; |
| 1119 } |
1113 | 1120 |
1114 // This tries to balance 1. restoring as soon as possible, 2. detecting | 1121 // This tries to balance 1. restoring as soon as possible, 2. detecting |
1115 // clamping to avoid repeatedly popping the scroll position down as the | 1122 // clamping to avoid repeatedly popping the scroll position down as the |
1116 // page height increases, 3. ignore clamp detection after load completes | 1123 // page height increases, 3. ignore clamp detection after load completes |
1117 // because that may be because the page will never reach its previous | 1124 // because that may be because the page will never reach its previous |
1118 // height. | 1125 // height. |
1119 bool canRestoreWithoutClamping = view->clampOffsetAtScale(m_currentItem->scr
ollPoint(), 1) == m_currentItem->scrollPoint(); | 1126 bool canRestoreWithoutClamping = view->clampOffsetAtScale(m_currentItem->scr
ollPoint(), 1) == m_currentItem->scrollPoint(); |
1120 bool canRestoreWithoutAnnoyingUser = !view->wasScrolledByUser() && (canResto
reWithoutClamping || m_frame->isLoading()); | 1127 bool canRestoreWithoutAnnoyingUser = !view->wasScrolledByUser() && (canResto
reWithoutClamping || m_frame->isLoading()); |
1121 if (!canRestoreWithoutAnnoyingUser) | 1128 if (!canRestoreWithoutAnnoyingUser) |
1122 return; | 1129 return; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 if (!view) | 1236 if (!view) |
1230 return; | 1237 return; |
1231 | 1238 |
1232 // Leaking scroll position to a cross-origin ancestor would permit the so-ca
lled "framesniffing" attack. | 1239 // Leaking scroll position to a cross-origin ancestor would permit the so-ca
lled "framesniffing" attack. |
1233 RefPtrWillBeRawPtr<Frame> boundaryFrame = url.hasFragmentIdentifier() ? m_fr
ame->findUnsafeParentScrollPropagationBoundary() : 0; | 1240 RefPtrWillBeRawPtr<Frame> boundaryFrame = url.hasFragmentIdentifier() ? m_fr
ame->findUnsafeParentScrollPropagationBoundary() : 0; |
1234 | 1241 |
1235 // FIXME: Handle RemoteFrames | 1242 // FIXME: Handle RemoteFrames |
1236 if (boundaryFrame && boundaryFrame->isLocalFrame()) | 1243 if (boundaryFrame && boundaryFrame->isLocalFrame()) |
1237 toLocalFrame(boundaryFrame.get())->view()->setSafeToPropagateScrollToPar
ent(false); | 1244 toLocalFrame(boundaryFrame.get())->view()->setSafeToPropagateScrollToPar
ent(false); |
1238 | 1245 |
1239 view->processUrlFragment(url, | 1246 // If scroll position is restored from history fragment then we should not o
verride it unless |
1240 loadStartType == NavigationToDifferentDocument && documentLoader()->init
ialScrollState().didRestoreFromHistory ? | 1247 // this is a same document reload. |
1241 FrameView::UrlFragmentDontScroll : FrameView::UrlFragmentScroll); | 1248 bool shouldScrollToFragment = (loadStartType == NavigationWithinSameDocument
&& !isBackForwardLoadType(m_loadType)) |
| 1249 || !documentLoader()->initialScrollState().didRestoreFromHistory; |
| 1250 |
| 1251 view->processUrlFragment(url, shouldScrollToFragment ? |
| 1252 FrameView::UrlFragmentScroll : FrameView::UrlFragmentDontScroll); |
1242 | 1253 |
1243 if (boundaryFrame && boundaryFrame->isLocalFrame()) | 1254 if (boundaryFrame && boundaryFrame->isLocalFrame()) |
1244 toLocalFrame(boundaryFrame.get())->view()->setSafeToPropagateScrollToPar
ent(true); | 1255 toLocalFrame(boundaryFrame.get())->view()->setSafeToPropagateScrollToPar
ent(true); |
1245 } | 1256 } |
1246 | 1257 |
1247 bool FrameLoader::shouldClose() | 1258 bool FrameLoader::shouldClose() |
1248 { | 1259 { |
1249 Page* page = m_frame->page(); | 1260 Page* page = m_frame->page(); |
1250 if (!page || !page->chromeClient().canOpenBeforeUnloadConfirmPanel()) | 1261 if (!page || !page->chromeClient().canOpenBeforeUnloadConfirmPanel()) |
1251 return true; | 1262 return true; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 // FIXME: We need a way to propagate insecure requests policy flags to | 1505 // FIXME: We need a way to propagate insecure requests policy flags to |
1495 // out-of-process frames. For now, we'll always use default behavior. | 1506 // out-of-process frames. For now, we'll always use default behavior. |
1496 if (!parentFrame->isLocalFrame()) | 1507 if (!parentFrame->isLocalFrame()) |
1497 return nullptr; | 1508 return nullptr; |
1498 | 1509 |
1499 ASSERT(toLocalFrame(parentFrame)->document()); | 1510 ASSERT(toLocalFrame(parentFrame)->document()); |
1500 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade()
; | 1511 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade()
; |
1501 } | 1512 } |
1502 | 1513 |
1503 } // namespace blink | 1514 } // namespace blink |
OLD | NEW |