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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 historyCommitType = StandardCommit; | 553 historyCommitType = StandardCommit; |
554 historyItemPolicy = CreateNewHistoryItem; | 554 historyItemPolicy = CreateNewHistoryItem; |
555 } | 555 } |
556 setHistoryItemStateForCommit(historyItemPolicy, sameDocumentNavigationSource
!= SameDocumentNavigationDefault, data); | 556 setHistoryItemStateForCommit(historyItemPolicy, sameDocumentNavigationSource
!= SameDocumentNavigationDefault, data); |
557 m_client->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy
pe); | 557 m_client->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy
pe); |
558 m_client->dispatchDidReceiveTitle(m_frame->document()->title()); | 558 m_client->dispatchDidReceiveTitle(m_frame->document()->title()); |
559 if (m_frame->document()->loadEventFinished()) | 559 if (m_frame->document()->loadEventFinished()) |
560 m_client->postProgressFinishedNotification(); | 560 m_client->postProgressFinishedNotification(); |
561 } | 561 } |
562 | 562 |
563 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, bool isNewNavigation, ClientRedirectPolicy clientRedirect) | 563 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, UpdateBackForwardListPolicy updateBackForwardList, ClientRe
directPolicy clientRedirect) |
564 { | 564 { |
565 // If we have a state object, we cannot also be a new navigation. | 565 // If we have a state object, we cannot also be a new navigation. |
566 ASSERT(!stateObject || (stateObject && !isNewNavigation)); | 566 ASSERT(!stateObject || updateBackForwardList == DoNotUpdateBackForwardList); |
| 567 |
| 568 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. |
| 569 if (m_provisionalDocumentLoader) { |
| 570 m_provisionalDocumentLoader->stopLoading(); |
| 571 if (m_provisionalDocumentLoader) |
| 572 m_provisionalDocumentLoader->detachFromFrame(); |
| 573 m_provisionalDocumentLoader = 0; |
| 574 } |
| 575 saveDocumentAndScrollState(); |
567 | 576 |
568 KURL oldURL = m_frame->document()->url(); | 577 KURL oldURL = m_frame->document()->url(); |
569 // If we were in the autoscroll/panScroll mode we want to stop it before fol
lowing the link to the anchor | 578 // If we were in the autoscroll/panScroll mode we want to stop it before fol
lowing the link to the anchor |
570 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); | 579 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); |
571 if (hashChange) { | 580 if (hashChange) { |
572 m_frame->eventHandler().stopAutoscroll(); | 581 m_frame->eventHandler().stopAutoscroll(); |
573 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url); | 582 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url); |
574 } | 583 } |
575 m_documentLoader->setIsClientRedirect((clientRedirect == ClientRedirect && !
isNewNavigation) || !UserGestureIndicator::processingUserGesture()); | 584 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); |
576 m_documentLoader->setReplacesCurrentHistoryItem(!isNewNavigation); | 585 m_documentLoader->setReplacesCurrentHistoryItem(updateBackForwardList == DoN
otUpdateBackForwardList); |
577 UpdateBackForwardListPolicy updateBackForwardList = isNewNavigation && !shou
ldTreatURLAsSameAsCurrent(url) && !stateObject ? UpdateBackForwardList : DoNotUp
dateBackForwardList; | |
578 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, 0, updat
eBackForwardList); | 586 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, 0, updat
eBackForwardList); |
579 | 587 |
580 // It's important to model this as a load that starts and immediately finish
es. | 588 // It's important to model this as a load that starts and immediately finish
es. |
581 // Otherwise, the parent frame may think we never finished loading. | 589 // Otherwise, the parent frame may think we never finished loading. |
582 started(); | 590 started(); |
583 | 591 |
584 // We need to scroll to the fragment whether or not a hash change occurred,
since | 592 // We need to scroll to the fragment whether or not a hash change occurred,
since |
585 // the user might have scrolled since the previous navigation. | 593 // the user might have scrolled since the previous navigation. |
586 scrollToFragmentWithParentBoundary(url); | 594 scrollToFragmentWithParentBoundary(url); |
587 | 595 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 FrameLoadType newLoadType = determineFrameLoadType(request); | 716 FrameLoadType newLoadType = determineFrameLoadType(request); |
709 NavigationAction action(request.resourceRequest(), newLoadType, request.form
State(), request.triggeringEvent()); | 717 NavigationAction action(request.resourceRequest(), newLoadType, request.form
State(), request.triggeringEvent()); |
710 if ((!targetFrame && !request.frameName().isEmpty()) || action.shouldOpenInN
ewWindow()) { | 718 if ((!targetFrame && !request.frameName().isEmpty()) || action.shouldOpenInN
ewWindow()) { |
711 if (action.policy() == NavigationPolicyDownload) | 719 if (action.policy() == NavigationPolicyDownload) |
712 m_client->loadURLExternally(action.resourceRequest(), NavigationPoli
cyDownload); | 720 m_client->loadURLExternally(action.resourceRequest(), NavigationPoli
cyDownload); |
713 else | 721 else |
714 createWindowForRequest(request, m_frame, action.policy(), request.sh
ouldSendReferrer()); | 722 createWindowForRequest(request, m_frame, action.policy(), request.sh
ouldSendReferrer()); |
715 return; | 723 return; |
716 } | 724 } |
717 | 725 |
718 if (shouldPerformFragmentNavigation(request.formState(), request.resourceReq
uest().httpMethod(), newLoadType, request.resourceRequest().url())) { | 726 const KURL& url = request.resourceRequest().url(); |
719 checkNavigationPolicyAndContinueFragmentScroll(action, newLoadType != Fr
ameLoadTypeRedirectWithLockedBackForwardList, request.clientRedirect()); | 727 if (shouldPerformFragmentNavigation(request.formState(), request.resourceReq
uest().httpMethod(), newLoadType, url)) { |
| 728 m_documentLoader->setTriggeringAction(action); |
| 729 loadInSameDocument(url, 0, newLoadType == FrameLoadTypeStandard ? Update
BackForwardList : DoNotUpdateBackForwardList, request.clientRedirect()); |
720 return; | 730 return; |
721 } | 731 } |
722 bool sameURL = shouldTreatURLAsSameAsCurrent(request.resourceRequest().url()
); | 732 bool sameURL = shouldTreatURLAsSameAsCurrent(url); |
723 loadWithNavigationAction(action, newLoadType, request.formState(), request.s
ubstituteData(), request.clientRedirect()); | 733 loadWithNavigationAction(action, newLoadType, request.formState(), request.s
ubstituteData(), request.clientRedirect()); |
724 // Example of this case are sites that reload the same URL with a different
cookie | 734 // Example of this case are sites that reload the same URL with a different
cookie |
725 // driving the generated content, or a master frame with links that drive a
target | 735 // driving the generated content, or a master frame with links that drive a
target |
726 // frame, where the user has clicked on the same link repeatedly. | 736 // frame, where the user has clicked on the same link repeatedly. |
727 if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoa
dTypeReloadFromOrigin && request.resourceRequest().httpMethod() != "POST") | 737 if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoa
dTypeReloadFromOrigin && request.resourceRequest().httpMethod() != "POST") |
728 m_loadType = FrameLoadTypeSame; | 738 m_loadType = FrameLoadTypeSame; |
729 } | 739 } |
730 | 740 |
731 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) | 741 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) |
732 { | 742 { |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr
or::cancelledError(). | 1161 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr
or::cancelledError(). |
1152 ResourceError c(ResourceError::cancelledError(KURL())); | 1162 ResourceError c(ResourceError::cancelledError(KURL())); |
1153 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) &&
m_frame->ownerElement()) | 1163 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) &&
m_frame->ownerElement()) |
1154 m_frame->ownerElement()->renderFallbackContent(); | 1164 m_frame->ownerElement()->renderFallbackContent(); |
1155 | 1165 |
1156 checkCompleted(); | 1166 checkCompleted(); |
1157 if (m_frame->page()) | 1167 if (m_frame->page()) |
1158 checkLoadComplete(); | 1168 checkLoadComplete(); |
1159 } | 1169 } |
1160 | 1170 |
1161 void FrameLoader::checkNavigationPolicyAndContinueFragmentScroll(const Navigatio
nAction& action, bool isNewNavigation, ClientRedirectPolicy clientRedirect) | |
1162 { | |
1163 m_documentLoader->setTriggeringAction(action); | |
1164 | |
1165 const ResourceRequest& request = action.resourceRequest(); | |
1166 if (!m_documentLoader->shouldContinueForNavigationPolicy(request, DocumentLo
ader::PolicyCheckFragment)) | |
1167 return; | |
1168 | |
1169 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. | |
1170 if (m_provisionalDocumentLoader && !equalIgnoringFragmentIdentifier(m_provis
ionalDocumentLoader->request().url(), request.url())) { | |
1171 m_provisionalDocumentLoader->stopLoading(); | |
1172 if (m_provisionalDocumentLoader) | |
1173 m_provisionalDocumentLoader->detachFromFrame(); | |
1174 m_provisionalDocumentLoader = 0; | |
1175 } | |
1176 saveDocumentAndScrollState(); | |
1177 loadInSameDocument(request.url(), 0, isNewNavigation, clientRedirect); | |
1178 } | |
1179 | |
1180 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S
tring& httpMethod, FrameLoadType loadType, const KURL& url) | 1171 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S
tring& httpMethod, FrameLoadType loadType, const KURL& url) |
1181 { | 1172 { |
1182 ASSERT(loadType != FrameLoadTypeReloadFromOrigin); | 1173 ASSERT(loadType != FrameLoadTypeReloadFromOrigin); |
1183 // We don't do this if we are submitting a form with method other than "GET"
, explicitly reloading, | 1174 // We don't do this if we are submitting a form with method other than "GET"
, explicitly reloading, |
1184 // currently displaying a frameset, or if the URL does not have a fragment. | 1175 // currently displaying a frameset, or if the URL does not have a fragment. |
1185 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET")) | 1176 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET")) |
1186 && loadType != FrameLoadTypeReload | 1177 && loadType != FrameLoadTypeReload |
1187 && loadType != FrameLoadTypeSame | 1178 && loadType != FrameLoadTypeSame |
1188 && loadType != FrameLoadTypeBackForward | 1179 && loadType != FrameLoadTypeBackForward |
1189 && url.hasFragmentIdentifier() | 1180 && url.hasFragmentIdentifier() |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 | 1270 |
1280 if (Frame* parent = m_frame->tree().parent()) | 1271 if (Frame* parent = m_frame->tree().parent()) |
1281 m_policyDocumentLoader->setOverrideEncoding(parent->loader().documentLoa
der()->overrideEncoding()); | 1272 m_policyDocumentLoader->setOverrideEncoding(parent->loader().documentLoa
der()->overrideEncoding()); |
1282 else if (!overrideEncoding.isEmpty()) | 1273 else if (!overrideEncoding.isEmpty()) |
1283 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding); | 1274 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding); |
1284 else if (m_documentLoader) | 1275 else if (m_documentLoader) |
1285 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn
coding()); | 1276 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn
coding()); |
1286 | 1277 |
1287 // stopAllLoaders can detach the Frame, so protect it. | 1278 // stopAllLoaders can detach the Frame, so protect it. |
1288 RefPtr<Frame> protect(m_frame); | 1279 RefPtr<Frame> protect(m_frame); |
1289 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, Doc
umentLoader::PolicyCheckStandard) || !shouldClose()) && m_policyDocumentLoader)
{ | 1280 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request) ||
!shouldClose()) && m_policyDocumentLoader) { |
1290 m_policyDocumentLoader->detachFromFrame(); | 1281 m_policyDocumentLoader->detachFromFrame(); |
1291 m_policyDocumentLoader = 0; | 1282 m_policyDocumentLoader = 0; |
1292 return; | 1283 return; |
1293 } | 1284 } |
1294 | 1285 |
1295 // A new navigation is in progress, so don't clear the history's provisional
item. | 1286 // A new navigation is in progress, so don't clear the history's provisional
item. |
1296 stopAllLoaders(); | 1287 stopAllLoaders(); |
1297 | 1288 |
1298 // <rdar://problem/6250856> - In certain circumstances on pages with multipl
e frames, stopAllLoaders() | 1289 // <rdar://problem/6250856> - In certain circumstances on pages with multipl
e frames, stopAllLoaders() |
1299 // might detach the current FrameLoader, in which case we should bail on thi
s newly defunct load. | 1290 // might detach the current FrameLoader, in which case we should bail on thi
s newly defunct load. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 | 1403 |
1413 if (!activeDocument->canNavigate(frame)) | 1404 if (!activeDocument->canNavigate(frame)) |
1414 return 0; | 1405 return 0; |
1415 return frame; | 1406 return frame; |
1416 } | 1407 } |
1417 | 1408 |
1418 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad
Type, ResourceRequestCachePolicy cachePolicy) | 1409 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad
Type, ResourceRequestCachePolicy cachePolicy) |
1419 { | 1410 { |
1420 m_provisionalItem = item; | 1411 m_provisionalItem = item; |
1421 if (historyLoadType == HistorySameDocumentLoad) { | 1412 if (historyLoadType == HistorySameDocumentLoad) { |
1422 loadInSameDocument(item->url(), item->stateObject(), false, NotClientRed
irect); | 1413 loadInSameDocument(item->url(), item->stateObject(), DoNotUpdateBackForw
ardList, NotClientRedirect); |
1423 restoreScrollPositionAndViewState(ForcedRestoreForSameDocumentHistoryNav
igation); | 1414 restoreScrollPositionAndViewState(ForcedRestoreForSameDocumentHistoryNav
igation); |
1424 return; | 1415 return; |
1425 } | 1416 } |
1426 | 1417 |
1427 RefPtr<FormData> formData = item->formData(); | 1418 RefPtr<FormData> formData = item->formData(); |
1428 ResourceRequest request(item->url()); | 1419 ResourceRequest request(item->url()); |
1429 request.setHTTPReferrer(item->referrer()); | 1420 request.setHTTPReferrer(item->referrer()); |
1430 request.setCachePolicy(cachePolicy); | 1421 request.setCachePolicy(cachePolicy); |
1431 if (formData) { | 1422 if (formData) { |
1432 request.setHTTPMethod("POST"); | 1423 request.setHTTPMethod("POST"); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 { | 1463 { |
1473 SandboxFlags flags = m_forcedSandboxFlags; | 1464 SandboxFlags flags = m_forcedSandboxFlags; |
1474 if (Frame* parentFrame = m_frame->tree().parent()) | 1465 if (Frame* parentFrame = m_frame->tree().parent()) |
1475 flags |= parentFrame->document()->sandboxFlags(); | 1466 flags |= parentFrame->document()->sandboxFlags(); |
1476 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) | 1467 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) |
1477 flags |= ownerElement->sandboxFlags(); | 1468 flags |= ownerElement->sandboxFlags(); |
1478 return flags; | 1469 return flags; |
1479 } | 1470 } |
1480 | 1471 |
1481 } // namespace WebCore | 1472 } // namespace WebCore |
OLD | NEW |