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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 | 517 |
518 bool FrameLoader::allowPlugins(ReasonForCallingAllowPlugins reason) | 518 bool FrameLoader::allowPlugins(ReasonForCallingAllowPlugins reason) |
519 { | 519 { |
520 Settings* settings = m_frame->settings(); | 520 Settings* settings = m_frame->settings(); |
521 bool allowed = m_client->allowPlugins(settings && settings->pluginsEnabled()
); | 521 bool allowed = m_client->allowPlugins(settings && settings->pluginsEnabled()
); |
522 if (!allowed && reason == AboutToInstantiatePlugin) | 522 if (!allowed && reason == AboutToInstantiatePlugin) |
523 m_client->didNotAllowPlugins(); | 523 m_client->didNotAllowPlugins(); |
524 return allowed; | 524 return allowed; |
525 } | 525 } |
526 | 526 |
527 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume
ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu
e> data, UpdateBackForwardListPolicy updateBackForwardList) | 527 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume
ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu
e> data, FrameLoadType type) |
528 { | 528 { |
529 // Update the data source's request with the new URL to fake the URL change | 529 // Update the data source's request with the new URL to fake the URL change |
530 m_frame->document()->setURL(newURL); | 530 m_frame->document()->setURL(newURL); |
531 documentLoader()->updateForSameDocumentNavigation(newURL); | 531 documentLoader()->updateForSameDocumentNavigation(newURL); |
532 | 532 |
533 // Generate start and stop notifications only when loader is completed so th
at we | 533 // Generate start and stop notifications only when loader is completed so th
at we |
534 // don't fire them for fragment redirection that happens in window.onload ha
ndler. | 534 // don't fire them for fragment redirection that happens in window.onload ha
ndler. |
535 // See https://bugs.webkit.org/show_bug.cgi?id=31838 | 535 // See https://bugs.webkit.org/show_bug.cgi?id=31838 |
536 if (m_frame->document()->loadEventFinished()) | 536 if (m_frame->document()->loadEventFinished()) |
537 m_client->didStartLoading(NavigationWithinSameDocument); | 537 m_client->didStartLoading(NavigationWithinSameDocument); |
538 | 538 |
539 HistoryCommitType historyCommitType = updateBackForwardList == UpdateBackFor
wardList && m_currentItem ? StandardCommit : HistoryInertCommit; | 539 HistoryCommitType historyCommitType = loadTypeToCommitType(type); |
| 540 if (!m_currentItem) |
| 541 historyCommitType = HistoryInertCommit; |
| 542 |
540 setHistoryItemStateForCommit(historyCommitType, sameDocumentNavigationSource
== SameDocumentNavigationHistoryApi, data); | 543 setHistoryItemStateForCommit(historyCommitType, sameDocumentNavigationSource
== SameDocumentNavigationHistoryApi, data); |
541 m_client->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy
pe); | 544 m_client->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy
pe); |
542 m_client->dispatchDidReceiveTitle(m_frame->document()->title()); | 545 m_client->dispatchDidReceiveTitle(m_frame->document()->title()); |
543 if (m_frame->document()->loadEventFinished()) | 546 if (m_frame->document()->loadEventFinished()) |
544 m_client->didStopLoading(); | 547 m_client->didStopLoading(); |
545 } | 548 } |
546 | 549 |
547 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, UpdateBackForwardListPolicy updateBackForwardList, ClientRe
directPolicy clientRedirect) | 550 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, FrameLoadType type, ClientRedirectPolicy clientRedirect) |
548 { | 551 { |
549 // If we have a state object, we cannot also be a new navigation. | 552 // If we have a state object, we cannot also be a new navigation. |
550 ASSERT(!stateObject || updateBackForwardList == DoNotUpdateBackForwardList); | 553 ASSERT(!stateObject || type == FrameLoadTypeBackForward); |
551 | 554 |
552 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. | 555 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. |
553 if (m_provisionalDocumentLoader) { | 556 if (m_provisionalDocumentLoader) { |
554 m_provisionalDocumentLoader->stopLoading(); | 557 m_provisionalDocumentLoader->stopLoading(); |
555 if (m_provisionalDocumentLoader) | 558 if (m_provisionalDocumentLoader) |
556 m_provisionalDocumentLoader->detachFromFrame(); | 559 m_provisionalDocumentLoader->detachFromFrame(); |
557 m_provisionalDocumentLoader = nullptr; | 560 m_provisionalDocumentLoader = nullptr; |
558 } | 561 } |
559 saveScrollState(); | 562 saveScrollState(); |
560 | 563 |
561 KURL oldURL = m_frame->document()->url(); | 564 KURL oldURL = m_frame->document()->url(); |
562 // If we were in the autoscroll/panScroll mode we want to stop it before fol
lowing the link to the anchor | 565 // If we were in the autoscroll/panScroll mode we want to stop it before fol
lowing the link to the anchor |
563 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); | 566 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); |
564 if (hashChange) { | 567 if (hashChange) { |
565 m_frame->eventHandler().stopAutoscroll(); | 568 m_frame->eventHandler().stopAutoscroll(); |
566 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url); | 569 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url); |
567 } | 570 } |
568 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); | 571 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); |
569 bool replacesCurrentHistoryItem = updateBackForwardList == DoNotUpdateBackFo
rwardList; | 572 m_documentLoader->setReplacesCurrentHistoryItem(m_loadType == FrameLoadTypeS
tandard); |
570 m_documentLoader->setReplacesCurrentHistoryItem(replacesCurrentHistoryItem); | 573 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr,
type); |
571 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr,
updateBackForwardList); | |
572 | 574 |
573 m_frame->view()->setWasScrolledByUser(false); | 575 m_frame->view()->setWasScrolledByUser(false); |
574 | 576 |
575 // It's important to model this as a load that starts and immediately finish
es. | 577 // It's important to model this as a load that starts and immediately finish
es. |
576 // Otherwise, the parent frame may think we never finished loading. | 578 // Otherwise, the parent frame may think we never finished loading. |
577 started(); | 579 started(); |
578 | 580 |
579 // We need to scroll to the fragment whether or not a hash change occurred,
since | 581 // We need to scroll to the fragment whether or not a hash change occurred,
since |
580 // the user might have scrolled since the previous navigation. | 582 // the user might have scrolled since the previous navigation. |
581 scrollToFragmentWithParentBoundary(url); | 583 scrollToFragmentWithParentBoundary(url); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 if (action.policy() == NavigationPolicyDownload) | 716 if (action.policy() == NavigationPolicyDownload) |
715 m_client->loadURLExternally(action.resourceRequest(), NavigationPoli
cyDownload); | 717 m_client->loadURLExternally(action.resourceRequest(), NavigationPoli
cyDownload); |
716 else | 718 else |
717 createWindowForRequest(request, *m_frame, action.policy(), request.s
houldSendReferrer()); | 719 createWindowForRequest(request, *m_frame, action.policy(), request.s
houldSendReferrer()); |
718 return; | 720 return; |
719 } | 721 } |
720 | 722 |
721 const KURL& url = request.resourceRequest().url(); | 723 const KURL& url = request.resourceRequest().url(); |
722 if (!action.shouldOpenInNewWindow() && shouldPerformFragmentNavigation(reque
st.formState(), request.resourceRequest().httpMethod(), newLoadType, url)) { | 724 if (!action.shouldOpenInNewWindow() && shouldPerformFragmentNavigation(reque
st.formState(), request.resourceRequest().httpMethod(), newLoadType, url)) { |
723 m_documentLoader->setTriggeringAction(action); | 725 m_documentLoader->setTriggeringAction(action); |
724 loadInSameDocument(url, nullptr, newLoadType == FrameLoadTypeStandard &&
!shouldTreatURLAsSameAsCurrent(url) ? UpdateBackForwardList : DoNotUpdateBackFo
rwardList, request.clientRedirect()); | 726 if (shouldTreatURLAsSameAsCurrent(url)) |
| 727 newLoadType = FrameLoadTypeRedirectWithLockedBackForwardList; |
| 728 loadInSameDocument(url, nullptr, newLoadType, request.clientRedirect()); |
725 return; | 729 return; |
726 } | 730 } |
727 bool sameURL = url == m_documentLoader->urlForHistory(); | 731 bool sameURL = url == m_documentLoader->urlForHistory(); |
728 loadWithNavigationAction(action, newLoadType, request.formState(), request.s
ubstituteData(), request.clientRedirect()); | 732 loadWithNavigationAction(action, newLoadType, request.formState(), request.s
ubstituteData(), request.clientRedirect()); |
729 // Example of this case are sites that reload the same URL with a different
cookie | 733 // Example of this case are sites that reload the same URL with a different
cookie |
730 // driving the generated content, or a master frame with links that drive a
target | 734 // driving the generated content, or a master frame with links that drive a
target |
731 // frame, where the user has clicked on the same link repeatedly. | 735 // frame, where the user has clicked on the same link repeatedly. |
732 if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoa
dTypeReloadFromOrigin && request.resourceRequest().httpMethod() != "POST") | 736 if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoa
dTypeReloadFromOrigin && request.resourceRequest().httpMethod() != "POST") |
733 m_loadType = FrameLoadTypeSame; | 737 m_loadType = FrameLoadTypeSame; |
734 } | 738 } |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 { | 1390 { |
1387 RefPtr<LocalFrame> protect(m_frame); | 1391 RefPtr<LocalFrame> protect(m_frame); |
1388 if (m_frame->page()->defersLoading()) { | 1392 if (m_frame->page()->defersLoading()) { |
1389 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache
Policy); | 1393 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache
Policy); |
1390 return; | 1394 return; |
1391 } | 1395 } |
1392 | 1396 |
1393 m_provisionalItem = item; | 1397 m_provisionalItem = item; |
1394 if (historyLoadType == HistorySameDocumentLoad) { | 1398 if (historyLoadType == HistorySameDocumentLoad) { |
1395 m_loadType = FrameLoadTypeBackForward; | 1399 m_loadType = FrameLoadTypeBackForward; |
1396 loadInSameDocument(item->url(), item->stateObject(), DoNotUpdateBackForw
ardList, NotClientRedirect); | 1400 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo
rward, NotClientRedirect); |
1397 restoreScrollPositionAndViewState(); | 1401 restoreScrollPositionAndViewState(); |
1398 return; | 1402 return; |
1399 } | 1403 } |
1400 loadWithNavigationAction(NavigationAction(requestFromHistoryItem(item, cache
Policy), FrameLoadTypeBackForward), FrameLoadTypeBackForward, nullptr, Substitut
eData()); | 1404 loadWithNavigationAction(NavigationAction(requestFromHistoryItem(item, cache
Policy), FrameLoadTypeBackForward), FrameLoadTypeBackForward, nullptr, Substitut
eData()); |
1401 } | 1405 } |
1402 | 1406 |
1403 void FrameLoader::dispatchDocumentElementAvailable() | 1407 void FrameLoader::dispatchDocumentElementAvailable() |
1404 { | 1408 { |
1405 m_client->documentElementAvailable(); | 1409 m_client->documentElementAvailable(); |
1406 } | 1410 } |
(...skipping 26 matching lines...) Expand all Loading... |
1433 { | 1437 { |
1434 SandboxFlags flags = m_forcedSandboxFlags; | 1438 SandboxFlags flags = m_forcedSandboxFlags; |
1435 if (LocalFrame* parentFrame = m_frame->tree().parent()) | 1439 if (LocalFrame* parentFrame = m_frame->tree().parent()) |
1436 flags |= parentFrame->document()->sandboxFlags(); | 1440 flags |= parentFrame->document()->sandboxFlags(); |
1437 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) | 1441 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) |
1438 flags |= ownerElement->sandboxFlags(); | 1442 flags |= ownerElement->sandboxFlags(); |
1439 return flags; | 1443 return flags; |
1440 } | 1444 } |
1441 | 1445 |
1442 } // namespace WebCore | 1446 } // namespace WebCore |
OLD | NEW |