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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 | 677 |
678 void FrameLoader::detachDocumentLoader(RefPtrWillBeMember<DocumentLoader>& loade
r) | 678 void FrameLoader::detachDocumentLoader(RefPtrWillBeMember<DocumentLoader>& loade
r) |
679 { | 679 { |
680 if (!loader) | 680 if (!loader) |
681 return; | 681 return; |
682 | 682 |
683 loader->detachFromFrame(); | 683 loader->detachFromFrame(); |
684 loader = nullptr; | 684 loader = nullptr; |
685 } | 685 } |
686 | 686 |
687 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, FrameLoadType type, ClientRedirectPolicy clientRedirect) | 687 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp
e, ClientRedirectPolicy clientRedirect) |
688 { | 688 { |
689 // If we have a state object, we cannot also be a new navigation. | 689 // If we have a state object, we cannot also be a new navigation. |
690 ASSERT(!stateObject || type == FrameLoadTypeBackForward); | 690 ASSERT(!stateObject || frameLoadType == FrameLoadTypeBackForward); |
691 | 691 |
692 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. | 692 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. |
693 if (m_provisionalDocumentLoader) { | 693 if (m_provisionalDocumentLoader) { |
694 m_provisionalDocumentLoader->stopLoading(); | 694 m_provisionalDocumentLoader->stopLoading(); |
695 detachDocumentLoader(m_provisionalDocumentLoader); | 695 detachDocumentLoader(m_provisionalDocumentLoader); |
696 if (!m_frame->host()) | 696 if (!m_frame->host()) |
697 return; | 697 return; |
698 } | 698 } |
699 m_loadType = type; | 699 TemporaryChange<FrameLoadType> loadTypeChange(m_loadType, frameLoadType); |
700 saveScrollState(); | 700 saveScrollState(); |
701 | 701 |
702 KURL oldURL = m_frame->document()->url(); | 702 KURL oldURL = m_frame->document()->url(); |
703 // If we were in the autoscroll/panScroll mode we want to stop it before fol
lowing the link to the anchor | |
704 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); | 703 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); |
705 if (hashChange) { | 704 if (hashChange) { |
| 705 // If we were in the autoscroll/panScroll mode we want to stop it before
following the link to the anchor |
706 m_frame->eventHandler().stopAutoscroll(); | 706 m_frame->eventHandler().stopAutoscroll(); |
707 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url); | 707 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url); |
708 } | 708 } |
709 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); | 709 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); |
710 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr,
ScrollRestorationAuto, type); | 710 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr,
ScrollRestorationAuto, frameLoadType); |
711 | 711 |
712 m_documentLoader->initialScrollState().wasScrolledByUser = false; | 712 m_documentLoader->initialScrollState().wasScrolledByUser = false; |
713 | 713 |
714 checkCompleted(); | 714 checkCompleted(); |
715 | 715 |
716 m_frame->localDOMWindow()->statePopped(stateObject ? stateObject : Serialize
dScriptValue::nullValue()); | 716 m_frame->localDOMWindow()->statePopped(stateObject ? stateObject : Serialize
dScriptValue::nullValue()); |
| 717 |
| 718 if (historyLoadType == HistorySameDocumentLoad) |
| 719 restoreScrollPositionAndViewState(); |
| 720 |
| 721 // We need to scroll to the fragment whether or not a hash change occurred,
since |
| 722 // the user might have scrolled since the previous navigation. |
| 723 processFragment(url, NavigationWithinSameDocument); |
717 } | 724 } |
718 | 725 |
719 void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSen
dReferrer shouldSendReferrer, Document* originDocument) | 726 void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSen
dReferrer shouldSendReferrer, Document* originDocument) |
720 { | 727 { |
721 if (!originDocument) | 728 if (!originDocument) |
722 return; | 729 return; |
723 // Anchor elements with the 'referrerpolicy' attribute will have | 730 // Anchor elements with the 'referrerpolicy' attribute will have |
724 // already set the referrer on the request. | 731 // already set the referrer on the request. |
725 if (request.didSetHTTPReferrer()) | 732 if (request.didSetHTTPReferrer()) |
726 return; | 733 return; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 RefPtr<SerializedScriptValue> stateObject = sameDocumentHistoryNavigatio
n ? | 933 RefPtr<SerializedScriptValue> stateObject = sameDocumentHistoryNavigatio
n ? |
927 historyItem->stateObject() : nullptr; | 934 historyItem->stateObject() : nullptr; |
928 | 935 |
929 if (!sameDocumentHistoryNavigation) { | 936 if (!sameDocumentHistoryNavigation) { |
930 m_documentLoader->setNavigationType(determineNavigationType( | 937 m_documentLoader->setNavigationType(determineNavigationType( |
931 newLoadType, false, request.triggeringEvent())); | 938 newLoadType, false, request.triggeringEvent())); |
932 if (shouldTreatURLAsSameAsCurrent(url)) | 939 if (shouldTreatURLAsSameAsCurrent(url)) |
933 newLoadType = FrameLoadTypeReplaceCurrentItem; | 940 newLoadType = FrameLoadTypeReplaceCurrentItem; |
934 } | 941 } |
935 | 942 |
936 loadInSameDocument(url, stateObject, newLoadType, request.clientRedirect
()); | 943 loadInSameDocument(url, stateObject, newLoadType, historyLoadType, reque
st.clientRedirect()); |
937 | |
938 if (sameDocumentHistoryNavigation) | |
939 restoreScrollPositionAndViewState(); | |
940 | |
941 // We need to scroll to the fragment whether or not a hash change occurr
ed, since | |
942 // the user might have scrolled since the previous navigation. | |
943 processFragment(url, NavigationWithinSameDocument); | |
944 return; | 944 return; |
945 } | 945 } |
946 | 946 |
947 startLoad(request, newLoadType, policy); | 947 startLoad(request, newLoadType, policy); |
948 } | 948 } |
949 | 949 |
950 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) | 950 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) |
951 { | 951 { |
952 if (!shouldTreatURLAsSrcdocDocument(url)) | 952 if (!shouldTreatURLAsSrcdocDocument(url)) |
953 return SubstituteData(); | 953 return SubstituteData(); |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 // FIXME: We need a way to propagate insecure requests policy flags to | 1549 // FIXME: We need a way to propagate insecure requests policy flags to |
1550 // out-of-process frames. For now, we'll always use default behavior. | 1550 // out-of-process frames. For now, we'll always use default behavior. |
1551 if (!parentFrame->isLocalFrame()) | 1551 if (!parentFrame->isLocalFrame()) |
1552 return nullptr; | 1552 return nullptr; |
1553 | 1553 |
1554 ASSERT(toLocalFrame(parentFrame)->document()); | 1554 ASSERT(toLocalFrame(parentFrame)->document()); |
1555 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade()
; | 1555 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade()
; |
1556 } | 1556 } |
1557 | 1557 |
1558 } // namespace blink | 1558 } // namespace blink |
OLD | NEW |