| 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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 // accessible, so bail early. | 678 // accessible, so bail early. |
| 679 if (!client()) | 679 if (!client()) |
| 680 return false; | 680 return false; |
| 681 Settings* settings = m_frame->settings(); | 681 Settings* settings = m_frame->settings(); |
| 682 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled()
); | 682 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled()
); |
| 683 if (!allowed && reason == AboutToInstantiatePlugin) | 683 if (!allowed && reason == AboutToInstantiatePlugin) |
| 684 client()->didNotAllowPlugins(); | 684 client()->didNotAllowPlugins(); |
| 685 return allowed; | 685 return allowed; |
| 686 } | 686 } |
| 687 | 687 |
| 688 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume
ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu
e> data, HistoryScrollRestorationType scrollRestorationType, FrameLoadType type) | 688 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume
ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu
e> data, HistoryScrollRestorationType scrollRestorationType, FrameLoadType type,
Document* initiatingDocument) |
| 689 { | 689 { |
| 690 // Update the data source's request with the new URL to fake the URL change | 690 // Update the data source's request with the new URL to fake the URL change |
| 691 m_frame->document()->setURL(newURL); | 691 m_frame->document()->setURL(newURL); |
| 692 documentLoader()->setReplacesCurrentHistoryItem(type != FrameLoadTypeStandar
d); | 692 documentLoader()->setReplacesCurrentHistoryItem(type != FrameLoadTypeStandar
d); |
| 693 documentLoader()->updateForSameDocumentNavigation(newURL, sameDocumentNaviga
tionSource); | 693 documentLoader()->updateForSameDocumentNavigation(newURL, sameDocumentNaviga
tionSource); |
| 694 | 694 |
| 695 // Generate start and stop notifications only when loader is completed so th
at we | 695 // Generate start and stop notifications only when loader is completed so th
at we |
| 696 // don't fire them for fragment redirection that happens in window.onload ha
ndler. | 696 // don't fire them for fragment redirection that happens in window.onload ha
ndler. |
| 697 // See https://bugs.webkit.org/show_bug.cgi?id=31838 | 697 // See https://bugs.webkit.org/show_bug.cgi?id=31838 |
| 698 if (m_frame->document()->loadEventFinished()) | 698 if (m_frame->document()->loadEventFinished()) |
| 699 client()->didStartLoading(NavigationWithinSameDocument); | 699 client()->didStartLoading(NavigationWithinSameDocument); |
| 700 | 700 |
| 701 HistoryCommitType historyCommitType = loadTypeToCommitType(type); | 701 HistoryCommitType historyCommitType = loadTypeToCommitType(type); |
| 702 if (!m_currentItem) | 702 if (!m_currentItem) |
| 703 historyCommitType = HistoryInertCommit; | 703 historyCommitType = HistoryInertCommit; |
| 704 | 704 |
| 705 setHistoryItemStateForCommit(historyCommitType, sameDocumentNavigationSource
== SameDocumentNavigationHistoryApi ? HistoryNavigationType::HistoryApi : Histo
ryNavigationType::Fragment); | 705 setHistoryItemStateForCommit(historyCommitType, sameDocumentNavigationSource
== SameDocumentNavigationHistoryApi ? HistoryNavigationType::HistoryApi : Histo
ryNavigationType::Fragment); |
| 706 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { | 706 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { |
| 707 m_currentItem->setStateObject(data); | 707 m_currentItem->setStateObject(data); |
| 708 m_currentItem->setScrollRestorationType(scrollRestorationType); | 708 m_currentItem->setScrollRestorationType(scrollRestorationType); |
| 709 } | 709 } |
| 710 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy
pe); | 710 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy
pe, !!initiatingDocument); |
| 711 client()->dispatchDidReceiveTitle(m_frame->document()->title()); | 711 client()->dispatchDidReceiveTitle(m_frame->document()->title()); |
| 712 if (m_frame->document()->loadEventFinished()) | 712 if (m_frame->document()->loadEventFinished()) |
| 713 client()->didStopLoading(); | 713 client()->didStopLoading(); |
| 714 } | 714 } |
| 715 | 715 |
| 716 void FrameLoader::detachDocumentLoader(Member<DocumentLoader>& loader) | 716 void FrameLoader::detachDocumentLoader(Member<DocumentLoader>& loader) |
| 717 { | 717 { |
| 718 if (!loader) | 718 if (!loader) |
| 719 return; | 719 return; |
| 720 | 720 |
| 721 loader->detachFromFrame(); | 721 loader->detachFromFrame(); |
| 722 loader = nullptr; | 722 loader = nullptr; |
| 723 } | 723 } |
| 724 | 724 |
| 725 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp
e, ClientRedirectPolicy clientRedirect) | 725 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp
e, ClientRedirectPolicy clientRedirect, Document* initiatingDocument) |
| 726 { | 726 { |
| 727 // If we have a state object, we cannot also be a new navigation. | 727 // If we have a state object, we cannot also be a new navigation. |
| 728 ASSERT(!stateObject || frameLoadType == FrameLoadTypeBackForward); | 728 ASSERT(!stateObject || frameLoadType == FrameLoadTypeBackForward); |
| 729 | 729 |
| 730 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. | 730 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. |
| 731 detachDocumentLoader(m_provisionalDocumentLoader); | 731 detachDocumentLoader(m_provisionalDocumentLoader); |
| 732 if (!m_frame->host()) | 732 if (!m_frame->host()) |
| 733 return; | 733 return; |
| 734 TemporaryChange<FrameLoadType> loadTypeChange(m_loadType, frameLoadType); | 734 TemporaryChange<FrameLoadType> loadTypeChange(m_loadType, frameLoadType); |
| 735 saveScrollState(); | 735 saveScrollState(); |
| 736 | 736 |
| 737 KURL oldURL = m_frame->document()->url(); | 737 KURL oldURL = m_frame->document()->url(); |
| 738 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); | 738 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); |
| 739 if (hashChange) { | 739 if (hashChange) { |
| 740 // If we were in the autoscroll/panScroll mode we want to stop it before
following the link to the anchor | 740 // If we were in the autoscroll/panScroll mode we want to stop it before
following the link to the anchor |
| 741 m_frame->eventHandler().stopAutoscroll(); | 741 m_frame->eventHandler().stopAutoscroll(); |
| 742 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url); | 742 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url); |
| 743 } | 743 } |
| 744 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirectPolicy
::ClientRedirect); | 744 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirectPolicy
::ClientRedirect); |
| 745 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr,
ScrollRestorationAuto, frameLoadType); | 745 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr,
ScrollRestorationAuto, frameLoadType, initiatingDocument); |
| 746 | 746 |
| 747 m_documentLoader->initialScrollState().wasScrolledByUser = false; | 747 m_documentLoader->initialScrollState().wasScrolledByUser = false; |
| 748 | 748 |
| 749 checkCompleted(); | 749 checkCompleted(); |
| 750 | 750 |
| 751 m_frame->localDOMWindow()->statePopped(stateObject ? stateObject : Serialize
dScriptValue::nullValue()); | 751 m_frame->localDOMWindow()->statePopped(stateObject ? stateObject : Serialize
dScriptValue::nullValue()); |
| 752 | 752 |
| 753 if (historyLoadType == HistorySameDocumentLoad) | 753 if (historyLoadType == HistorySameDocumentLoad) |
| 754 restoreScrollPositionAndViewState(); | 754 restoreScrollPositionAndViewState(); |
| 755 | 755 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 RefPtr<SerializedScriptValue> stateObject = sameDocumentHistoryNavigatio
n ? | 970 RefPtr<SerializedScriptValue> stateObject = sameDocumentHistoryNavigatio
n ? |
| 971 historyItem->stateObject() : nullptr; | 971 historyItem->stateObject() : nullptr; |
| 972 | 972 |
| 973 if (!sameDocumentHistoryNavigation) { | 973 if (!sameDocumentHistoryNavigation) { |
| 974 m_documentLoader->setNavigationType(determineNavigationType( | 974 m_documentLoader->setNavigationType(determineNavigationType( |
| 975 newLoadType, false, request.triggeringEvent())); | 975 newLoadType, false, request.triggeringEvent())); |
| 976 if (shouldTreatURLAsSameAsCurrent(url)) | 976 if (shouldTreatURLAsSameAsCurrent(url)) |
| 977 newLoadType = FrameLoadTypeReplaceCurrentItem; | 977 newLoadType = FrameLoadTypeReplaceCurrentItem; |
| 978 } | 978 } |
| 979 | 979 |
| 980 loadInSameDocument(url, stateObject, newLoadType, historyLoadType, reque
st.clientRedirect()); | 980 loadInSameDocument(url, stateObject, newLoadType, historyLoadType, reque
st.clientRedirect(), request.originDocument()); |
| 981 return; | 981 return; |
| 982 } | 982 } |
| 983 | 983 |
| 984 startLoad(request, newLoadType, policy); | 984 startLoad(request, newLoadType, policy); |
| 985 } | 985 } |
| 986 | 986 |
| 987 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) | 987 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) |
| 988 { | 988 { |
| 989 if (!shouldTreatURLAsSrcdocDocument(url)) | 989 if (!shouldTreatURLAsSrcdocDocument(url)) |
| 990 return SubstituteData(); | 990 return SubstituteData(); |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa
der->url() : String()); | 1564 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa
der->url() : String()); |
| 1565 return tracedValue.release(); | 1565 return tracedValue.release(); |
| 1566 } | 1566 } |
| 1567 | 1567 |
| 1568 inline void FrameLoader::takeObjectSnapshot() const | 1568 inline void FrameLoader::takeObjectSnapshot() const |
| 1569 { | 1569 { |
| 1570 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced
Value()); | 1570 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced
Value()); |
| 1571 } | 1571 } |
| 1572 | 1572 |
| 1573 } // namespace blink | 1573 } // namespace blink |
| OLD | NEW |