OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
6 * (http://www.torchmobile.com/) | 6 * (http://www.torchmobile.com/) |
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
10 * Copyright (C) 2011 Google Inc. All rights reserved. | 10 * Copyright (C) 2011 Google Inc. All rights reserved. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 return; | 133 return; |
134 } | 134 } |
135 if (SchemeRegistry::shouldTreatURLSchemeAsLegacy( | 135 if (SchemeRegistry::shouldTreatURLSchemeAsLegacy( |
136 document->getSecurityOrigin()->protocol())) { | 136 document->getSecurityOrigin()->protocol())) { |
137 return; | 137 return; |
138 } | 138 } |
139 Deprecation::countDeprecation( | 139 Deprecation::countDeprecation( |
140 document, UseCounter::LegacyProtocolEmbeddedAsSubresource); | 140 document, UseCounter::LegacyProtocolEmbeddedAsSubresource); |
141 } | 141 } |
142 | 142 |
143 // static | |
144 ResourceRequest FrameLoader::resourceRequestFromHistoryItem( | |
Nate Chapin
2017/03/27 21:02:01
Moved to HistoryItem, since it actually depends on
| |
145 HistoryItem* item, | |
146 WebCachePolicy cachePolicy) { | |
147 RefPtr<EncodedFormData> formData = item->formData(); | |
148 ResourceRequest request(item->url()); | |
149 request.setHTTPReferrer(item->referrer()); | |
150 request.setCachePolicy(cachePolicy); | |
151 if (formData) { | |
152 request.setHTTPMethod(HTTPNames::POST); | |
153 request.setHTTPBody(formData); | |
154 request.setHTTPContentType(item->formContentType()); | |
155 request.addHTTPOriginIfNeeded(item->referrer().referrer); | |
156 } | |
157 return request; | |
158 } | |
159 | |
160 ResourceRequest FrameLoader::resourceRequestForReload( | 143 ResourceRequest FrameLoader::resourceRequestForReload( |
161 FrameLoadType frameLoadType, | 144 FrameLoadType frameLoadType, |
162 const KURL& overrideURL, | 145 const KURL& overrideURL, |
163 ClientRedirectPolicy clientRedirectPolicy) { | 146 ClientRedirectPolicy clientRedirectPolicy) { |
164 DCHECK(isReloadLoadType(frameLoadType)); | 147 DCHECK(isReloadLoadType(frameLoadType)); |
165 WebCachePolicy cachePolicy = | 148 WebCachePolicy cachePolicy = |
166 frameLoadType == FrameLoadTypeReloadBypassingCache | 149 frameLoadType == FrameLoadTypeReloadBypassingCache |
167 ? WebCachePolicy::BypassingCache | 150 ? WebCachePolicy::BypassingCache |
168 : WebCachePolicy::ValidatingCacheData; | 151 : WebCachePolicy::ValidatingCacheData; |
169 if (!m_currentItem) | 152 if (!m_documentLoader || !m_documentLoader->historyItem()) |
170 return ResourceRequest(); | 153 return ResourceRequest(); |
171 ResourceRequest request = | 154 ResourceRequest request = |
172 resourceRequestFromHistoryItem(m_currentItem.get(), cachePolicy); | 155 m_documentLoader->historyItem()->generateResourceRequest(cachePolicy); |
173 | 156 |
174 // ClientRedirectPolicy is an indication that this load was triggered by some | 157 // ClientRedirectPolicy is an indication that this load was triggered by some |
175 // direct interaction with the page. If this reload is not a client redirect, | 158 // direct interaction with the page. If this reload is not a client redirect, |
176 // we should reuse the referrer from the original load of the current | 159 // we should reuse the referrer from the original load of the current |
177 // document. If this reload is a client redirect (e.g., location.reload()), it | 160 // document. If this reload is a client redirect (e.g., location.reload()), it |
178 // was initiated by something in the current document and should therefore | 161 // was initiated by something in the current document and should therefore |
179 // show the current document's url as the referrer. | 162 // show the current document's url as the referrer. |
180 if (clientRedirectPolicy == ClientRedirectPolicy::ClientRedirect) { | 163 if (clientRedirectPolicy == ClientRedirectPolicy::ClientRedirect) { |
181 request.setHTTPReferrer(SecurityPolicy::generateReferrer( | 164 request.setHTTPReferrer(SecurityPolicy::generateReferrer( |
182 m_frame->document()->getReferrerPolicy(), m_frame->document()->url(), | 165 m_frame->document()->getReferrerPolicy(), m_frame->document()->url(), |
(...skipping 29 matching lines...) Expand all Loading... | |
212 FrameLoader::~FrameLoader() { | 195 FrameLoader::~FrameLoader() { |
213 // Verify that this FrameLoader has been detached. | 196 // Verify that this FrameLoader has been detached. |
214 DCHECK(!m_progressTracker); | 197 DCHECK(!m_progressTracker); |
215 } | 198 } |
216 | 199 |
217 DEFINE_TRACE(FrameLoader) { | 200 DEFINE_TRACE(FrameLoader) { |
218 visitor->trace(m_frame); | 201 visitor->trace(m_frame); |
219 visitor->trace(m_progressTracker); | 202 visitor->trace(m_progressTracker); |
220 visitor->trace(m_documentLoader); | 203 visitor->trace(m_documentLoader); |
221 visitor->trace(m_provisionalDocumentLoader); | 204 visitor->trace(m_provisionalDocumentLoader); |
222 visitor->trace(m_currentItem); | |
223 visitor->trace(m_provisionalItem); | |
224 visitor->trace(m_deferredHistoryLoad); | 205 visitor->trace(m_deferredHistoryLoad); |
225 } | 206 } |
226 | 207 |
227 void FrameLoader::init() { | 208 void FrameLoader::init() { |
228 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString)); | 209 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString)); |
229 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); | 210 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); |
230 initialRequest.setFrameType(m_frame->isMainFrame() | 211 initialRequest.setFrameType(m_frame->isMainFrame() |
231 ? WebURLRequest::FrameTypeTopLevel | 212 ? WebURLRequest::FrameTypeTopLevel |
232 : WebURLRequest::FrameTypeNested); | 213 : WebURLRequest::FrameTypeNested); |
233 m_provisionalDocumentLoader = | 214 m_provisionalDocumentLoader = |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 m_deferredHistoryLoad->m_item.get(), | 253 m_deferredHistoryLoad->m_item.get(), |
273 m_deferredHistoryLoad->m_historyLoadType); | 254 m_deferredHistoryLoad->m_historyLoadType); |
274 m_deferredHistoryLoad.clear(); | 255 m_deferredHistoryLoad.clear(); |
275 } | 256 } |
276 m_frame->navigationScheduler().startTimer(); | 257 m_frame->navigationScheduler().startTimer(); |
277 scheduleCheckCompleted(); | 258 scheduleCheckCompleted(); |
278 } | 259 } |
279 } | 260 } |
280 | 261 |
281 void FrameLoader::saveScrollState() { | 262 void FrameLoader::saveScrollState() { |
282 if (!m_currentItem || !m_frame->view()) | 263 if (!m_documentLoader || !m_documentLoader->historyItem() || !m_frame->view()) |
283 return; | 264 return; |
284 | 265 |
285 // Shouldn't clobber anything if we might still restore later. | 266 // Shouldn't clobber anything if we might still restore later. |
286 if (m_documentLoader && | 267 if (needsHistoryItemRestore(m_documentLoader->loadType()) && |
287 needsHistoryItemRestore(m_documentLoader->loadType()) && | |
288 !m_documentLoader->initialScrollState().wasScrolledByUser) | 268 !m_documentLoader->initialScrollState().wasScrolledByUser) |
289 return; | 269 return; |
290 | 270 |
271 HistoryItem* historyItem = m_documentLoader->historyItem(); | |
291 if (ScrollableArea* layoutScrollableArea = | 272 if (ScrollableArea* layoutScrollableArea = |
292 m_frame->view()->layoutViewportScrollableArea()) | 273 m_frame->view()->layoutViewportScrollableArea()) |
293 m_currentItem->setScrollOffset(layoutScrollableArea->getScrollOffset()); | 274 historyItem->setScrollOffset(layoutScrollableArea->getScrollOffset()); |
294 m_currentItem->setVisualViewportScrollOffset(toScrollOffset( | 275 historyItem->setVisualViewportScrollOffset(toScrollOffset( |
295 m_frame->page()->visualViewport().visibleRect().location())); | 276 m_frame->page()->visualViewport().visibleRect().location())); |
296 | 277 |
297 if (m_frame->isMainFrame()) | 278 if (m_frame->isMainFrame()) |
298 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor()); | 279 historyItem->setPageScaleFactor(m_frame->page()->pageScaleFactor()); |
299 | 280 |
300 client()->didUpdateCurrentHistoryItem(); | 281 client()->didUpdateCurrentHistoryItem(); |
301 } | 282 } |
302 | 283 |
303 void FrameLoader::dispatchUnloadEvent() { | 284 void FrameLoader::dispatchUnloadEvent() { |
304 FrameNavigationDisabler navigationDisabler(*m_frame); | 285 FrameNavigationDisabler navigationDisabler(*m_frame); |
305 | 286 |
306 // If the frame is unloading, the provisional loader should no longer be | 287 // If the frame is unloading, the provisional loader should no longer be |
307 // protected. It will be detached soon. | 288 // protected. It will be detached soon. |
308 m_protectProvisionalLoader = false; | 289 m_protectProvisionalLoader = false; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 | 372 |
392 // detachChildren() potentially detaches the frame from the document. The | 373 // detachChildren() potentially detaches the frame from the document. The |
393 // loading cannot continue in that case. | 374 // loading cannot continue in that case. |
394 if (!m_frame->page()) | 375 if (!m_frame->page()) |
395 return; | 376 return; |
396 | 377 |
397 client()->transitionToCommittedForNewPage(); | 378 client()->transitionToCommittedForNewPage(); |
398 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source); | 379 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source); |
399 } | 380 } |
400 | 381 |
401 void FrameLoader::clearProvisionalHistoryItem() { | |
402 m_provisionalItem.clear(); | |
403 } | |
404 | |
405 void FrameLoader::setHistoryItemStateForCommit( | |
406 FrameLoadType loadType, | |
407 HistoryCommitType historyCommitType, | |
408 HistoryNavigationType navigationType) { | |
409 HistoryItem* oldItem = m_currentItem; | |
410 if (isBackForwardLoadType(loadType) && m_provisionalItem) | |
411 m_currentItem = m_provisionalItem.release(); | |
412 else | |
413 m_currentItem = HistoryItem::create(); | |
414 m_currentItem->setURL(m_documentLoader->urlForHistory()); | |
415 m_currentItem->setDocumentState(m_frame->document()->formElementsState()); | |
416 m_currentItem->setReferrer(SecurityPolicy::generateReferrer( | |
417 m_documentLoader->getRequest().getReferrerPolicy(), m_currentItem->url(), | |
418 m_documentLoader->getRequest().httpReferrer())); | |
419 m_currentItem->setFormInfoFromRequest(m_documentLoader->getRequest()); | |
420 | |
421 // Don't propagate state from the old item to the new item if there isn't an | |
422 // old item (obviously), or if this is a back/forward navigation, since we | |
423 // explicitly want to restore the state we just committed. | |
424 if (!oldItem || isBackForwardLoadType(loadType)) | |
425 return; | |
426 // Don't propagate state from the old item if this is a different-document | |
427 // navigation, unless the before and after pages are logically related. This | |
428 // means they have the same url (ignoring fragment) and the new item was | |
429 // loaded via reload or client redirect. | |
430 if (navigationType == HistoryNavigationType::DifferentDocument && | |
431 (historyCommitType != HistoryInertCommit || | |
432 !equalIgnoringFragmentIdentifier(oldItem->url(), m_currentItem->url()))) | |
433 return; | |
434 m_currentItem->setDocumentSequenceNumber(oldItem->documentSequenceNumber()); | |
435 m_currentItem->setScrollOffset(oldItem->getScrollOffset()); | |
436 m_currentItem->setDidSaveScrollOrScaleState( | |
437 oldItem->didSaveScrollOrScaleState()); | |
438 m_currentItem->setVisualViewportScrollOffset( | |
439 oldItem->visualViewportScrollOffset()); | |
440 m_currentItem->setPageScaleFactor(oldItem->pageScaleFactor()); | |
441 m_currentItem->setScrollRestorationType(oldItem->scrollRestorationType()); | |
442 | |
443 // The item sequence number determines whether items are "the same", such | |
444 // back/forward navigation between items with the same item sequence number is | |
445 // a no-op. Only treat this as identical if the navigation did not create a | |
446 // back/forward entry and the url is identical or it was loaded via | |
447 // history.replaceState(). | |
448 if (historyCommitType == HistoryInertCommit && | |
449 (navigationType == HistoryNavigationType::HistoryApi || | |
450 oldItem->url() == m_currentItem->url())) { | |
451 m_currentItem->setStateObject(oldItem->stateObject()); | |
452 m_currentItem->setItemSequenceNumber(oldItem->itemSequenceNumber()); | |
453 } | |
454 } | |
455 | |
456 static HistoryCommitType loadTypeToCommitType(FrameLoadType type) { | |
457 switch (type) { | |
458 case FrameLoadTypeStandard: | |
459 return StandardCommit; | |
460 case FrameLoadTypeInitialInChildFrame: | |
461 case FrameLoadTypeInitialHistoryLoad: | |
462 return InitialCommitInChildFrame; | |
463 case FrameLoadTypeBackForward: | |
464 return BackForwardCommit; | |
465 default: | |
466 break; | |
467 } | |
468 return HistoryInertCommit; | |
469 } | |
470 | |
471 void FrameLoader::receivedFirstData() { | |
472 FrameLoadType loadType = m_documentLoader->loadType(); | |
473 HistoryCommitType historyCommitType = loadTypeToCommitType(loadType); | |
474 if (historyCommitType == StandardCommit && | |
475 (m_documentLoader->urlForHistory().isEmpty() || | |
476 (opener() && !m_currentItem && | |
477 m_documentLoader->originalRequest().url().isEmpty()))) | |
478 historyCommitType = HistoryInertCommit; | |
479 setHistoryItemStateForCommit(loadType, historyCommitType, | |
480 HistoryNavigationType::DifferentDocument); | |
481 | |
482 if (!m_stateMachine.committedMultipleRealLoads() && | |
483 loadType == FrameLoadTypeStandard) { | |
484 m_stateMachine.advanceTo( | |
485 FrameLoaderStateMachine::CommittedMultipleRealLoads); | |
486 } | |
487 | |
488 client()->dispatchDidCommitLoad(m_currentItem.get(), historyCommitType); | |
489 | |
490 // When the embedder gets notified (above) that the new navigation has | |
491 // committed, the embedder will drop the old Content Security Policy and | |
492 // therefore now is a good time to report to the embedder the Content Security | |
493 // Policies that have accumulated so far for the new navigation. | |
494 m_frame->securityContext()->contentSecurityPolicy()->reportAccumulatedHeaders( | |
495 client()); | |
496 } | |
497 | |
498 void FrameLoader::didInstallNewDocument() { | |
499 if (m_provisionalItem && | |
500 isBackForwardLoadType(m_documentLoader->loadType())) { | |
501 m_frame->document()->setStateForNewFormElements( | |
502 m_provisionalItem->getDocumentState()); | |
503 } | |
504 } | |
505 | |
506 void FrameLoader::finishedParsing() { | 382 void FrameLoader::finishedParsing() { |
507 if (m_stateMachine.creatingInitialEmptyDocument()) | 383 if (m_stateMachine.creatingInitialEmptyDocument()) |
508 return; | 384 return; |
509 | 385 |
510 m_progressTracker->finishedParsing(); | 386 m_progressTracker->finishedParsing(); |
511 | 387 |
512 if (client()) { | 388 if (client()) { |
513 ScriptForbiddenScope forbidScripts; | 389 ScriptForbiddenScope forbidScripts; |
514 client()->dispatchDidFinishDocumentLoad(); | 390 client()->dispatchDidFinishDocumentLoad(); |
515 } | 391 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
690 | 566 |
691 void FrameLoader::updateForSameDocumentNavigation( | 567 void FrameLoader::updateForSameDocumentNavigation( |
692 const KURL& newURL, | 568 const KURL& newURL, |
693 SameDocumentNavigationSource sameDocumentNavigationSource, | 569 SameDocumentNavigationSource sameDocumentNavigationSource, |
694 PassRefPtr<SerializedScriptValue> data, | 570 PassRefPtr<SerializedScriptValue> data, |
695 HistoryScrollRestorationType scrollRestorationType, | 571 HistoryScrollRestorationType scrollRestorationType, |
696 FrameLoadType type, | 572 FrameLoadType type, |
697 Document* initiatingDocument) { | 573 Document* initiatingDocument) { |
698 TRACE_EVENT1("blink", "FrameLoader::updateForSameDocumentNavigation", "url", | 574 TRACE_EVENT1("blink", "FrameLoader::updateForSameDocumentNavigation", "url", |
699 newURL.getString().ascii().data()); | 575 newURL.getString().ascii().data()); |
700 // Update the data source's request with the new URL to fake the URL change | |
701 m_frame->document()->setURL(newURL); | |
702 documentLoader()->setReplacesCurrentHistoryItem(type != | |
703 FrameLoadTypeStandard); | |
704 documentLoader()->updateForSameDocumentNavigation( | |
705 newURL, sameDocumentNavigationSource); | |
706 | 576 |
707 // Generate start and stop notifications only when loader is completed so that | 577 // Generate start and stop notifications only when loader is completed so that |
708 // we don't fire them for fragment redirection that happens in window.onload | 578 // we don't fire them for fragment redirection that happens in window.onload |
709 // handler. See https://bugs.webkit.org/show_bug.cgi?id=31838 | 579 // handler. See https://bugs.webkit.org/show_bug.cgi?id=31838 |
710 // Do not fire the notifications if the frame is concurrently navigating away | 580 // Do not fire the notifications if the frame is concurrently navigating away |
711 // from the document, since a new document is already loading. | 581 // from the document, since a new document is already loading. |
712 if (m_frame->document()->loadEventFinished() && !m_provisionalDocumentLoader) | 582 if (m_frame->document()->loadEventFinished() && !m_provisionalDocumentLoader) |
713 client()->didStartLoading(NavigationWithinSameDocument); | 583 client()->didStartLoading(NavigationWithinSameDocument); |
714 | 584 |
715 HistoryCommitType historyCommitType = loadTypeToCommitType(type); | 585 // Update the data source's request with the new URL to fake the URL change |
716 if (!m_currentItem) | 586 m_frame->document()->setURL(newURL); |
Nate Chapin
2017/03/27 21:02:01
I couldn't find any evidence this clause is needed
| |
717 historyCommitType = HistoryInertCommit; | 587 documentLoader()->updateForSameDocumentNavigation( |
718 if (m_frame->settings()->getHistoryEntryRequiresUserGesture() && | 588 newURL, sameDocumentNavigationSource, std::move(data), |
719 initiatingDocument && | 589 scrollRestorationType, type, initiatingDocument); |
720 !initiatingDocument->frame()->hasReceivedUserGesture()) { | |
721 historyCommitType = HistoryInertCommit; | |
722 } | |
723 | 590 |
724 setHistoryItemStateForCommit( | |
725 type, historyCommitType, | |
726 sameDocumentNavigationSource == SameDocumentNavigationHistoryApi | |
727 ? HistoryNavigationType::HistoryApi | |
728 : HistoryNavigationType::Fragment); | |
729 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { | |
730 m_currentItem->setStateObject(std::move(data)); | |
731 m_currentItem->setScrollRestorationType(scrollRestorationType); | |
732 } | |
733 client()->dispatchDidNavigateWithinPage( | |
734 m_currentItem.get(), historyCommitType, !!initiatingDocument); | |
735 client()->dispatchDidReceiveTitle(m_frame->document()->title()); | 591 client()->dispatchDidReceiveTitle(m_frame->document()->title()); |
736 if (m_frame->document()->loadEventFinished() && !m_provisionalDocumentLoader) | 592 if (m_frame->document()->loadEventFinished() && !m_provisionalDocumentLoader) |
737 client()->didStopLoading(); | 593 client()->didStopLoading(); |
738 } | 594 } |
739 | 595 |
740 void FrameLoader::detachDocumentLoader(Member<DocumentLoader>& loader) { | 596 void FrameLoader::detachDocumentLoader(Member<DocumentLoader>& loader) { |
741 if (!loader) | 597 if (!loader) |
742 return; | 598 return; |
743 | 599 |
744 FrameNavigationDisabler navigationDisabler(*m_frame); | 600 FrameNavigationDisabler navigationDisabler(*m_frame); |
745 loader->detachFromFrame(); | 601 loader->detachFromFrame(); |
746 loader = nullptr; | 602 loader = nullptr; |
747 } | 603 } |
748 | 604 |
749 void FrameLoader::loadInSameDocument( | 605 void FrameLoader::loadInSameDocument( |
750 const KURL& url, | 606 const KURL& url, |
751 PassRefPtr<SerializedScriptValue> stateObject, | 607 PassRefPtr<SerializedScriptValue> stateObject, |
752 FrameLoadType frameLoadType, | 608 FrameLoadType frameLoadType, |
753 HistoryLoadType historyLoadType, | 609 HistoryItem* historyItem, |
754 ClientRedirectPolicy clientRedirect, | 610 ClientRedirectPolicy clientRedirect, |
755 Document* initiatingDocument) { | 611 Document* initiatingDocument) { |
756 // If we have a state object, we cannot also be a new navigation. | 612 // If we have a state object, we cannot also be a new navigation. |
757 DCHECK(!stateObject || frameLoadType == FrameLoadTypeBackForward); | 613 DCHECK(!stateObject || frameLoadType == FrameLoadTypeBackForward); |
758 | 614 |
759 // If we have a provisional request for a different document, a fragment | 615 // If we have a provisional request for a different document, a fragment |
760 // scroll should cancel it. | 616 // scroll should cancel it. |
761 detachDocumentLoader(m_provisionalDocumentLoader); | 617 detachDocumentLoader(m_provisionalDocumentLoader); |
762 | 618 |
763 if (!m_frame->host()) | 619 if (!m_frame->host()) |
764 return; | 620 return; |
765 saveScrollState(); | 621 saveScrollState(); |
766 | 622 |
767 KURL oldURL = m_frame->document()->url(); | 623 KURL oldURL = m_frame->document()->url(); |
768 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && | 624 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && |
769 url.fragmentIdentifier() != oldURL.fragmentIdentifier(); | 625 url.fragmentIdentifier() != oldURL.fragmentIdentifier(); |
770 if (hashChange) { | 626 if (hashChange) { |
771 // If we were in the autoscroll/middleClickAutoscroll mode we want to stop | 627 // If we were in the autoscroll/middleClickAutoscroll mode we want to stop |
772 // it before following the link to the anchor | 628 // it before following the link to the anchor |
773 m_frame->eventHandler().stopAutoscroll(); | 629 m_frame->eventHandler().stopAutoscroll(); |
774 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url); | 630 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url); |
775 } | 631 } |
776 m_documentLoader->setIsClientRedirect(clientRedirect == | 632 m_documentLoader->setIsClientRedirect(clientRedirect == |
777 ClientRedirectPolicy::ClientRedirect); | 633 ClientRedirectPolicy::ClientRedirect); |
634 if (historyItem) | |
635 m_documentLoader->setItemForHistoryNavigation(historyItem); | |
778 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr, | 636 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr, |
779 ScrollRestorationAuto, frameLoadType, | 637 ScrollRestorationAuto, frameLoadType, |
780 initiatingDocument); | 638 initiatingDocument); |
781 | 639 |
782 m_documentLoader->initialScrollState().wasScrolledByUser = false; | 640 m_documentLoader->initialScrollState().wasScrolledByUser = false; |
783 | 641 |
784 checkCompleted(); | 642 checkCompleted(); |
785 | 643 |
786 m_frame->domWindow()->statePopped(stateObject | 644 m_frame->domWindow()->statePopped(stateObject |
787 ? std::move(stateObject) | 645 ? std::move(stateObject) |
788 : SerializedScriptValue::nullValue()); | 646 : SerializedScriptValue::nullValue()); |
789 | 647 |
790 if (historyLoadType == HistorySameDocumentLoad) | 648 if (historyItem) |
791 restoreScrollPositionAndViewStateForLoadType(frameLoadType); | 649 restoreScrollPositionAndViewStateForLoadType(frameLoadType); |
792 | 650 |
793 // We need to scroll to the fragment whether or not a hash change occurred, | 651 // We need to scroll to the fragment whether or not a hash change occurred, |
794 // since the user might have scrolled since the previous navigation. | 652 // since the user might have scrolled since the previous navigation. |
795 processFragment(url, frameLoadType, NavigationWithinSameDocument); | 653 processFragment(url, frameLoadType, NavigationWithinSameDocument); |
796 takeObjectSnapshot(); | 654 takeObjectSnapshot(); |
797 } | 655 } |
798 | 656 |
799 // static | 657 // static |
800 void FrameLoader::setReferrerForFrameRequest(FrameLoadRequest& frameRequest) { | 658 void FrameLoader::setReferrerForFrameRequest(FrameLoadRequest& frameRequest) { |
(...skipping 18 matching lines...) Expand all Loading... | |
819 | 677 |
820 request.setHTTPReferrer(referrer); | 678 request.setHTTPReferrer(referrer); |
821 request.addHTTPOriginIfNeeded(referrer.referrer); | 679 request.addHTTPOriginIfNeeded(referrer.referrer); |
822 } | 680 } |
823 | 681 |
824 FrameLoadType FrameLoader::determineFrameLoadType( | 682 FrameLoadType FrameLoader::determineFrameLoadType( |
825 const FrameLoadRequest& request) { | 683 const FrameLoadRequest& request) { |
826 if (m_frame->tree().parent() && | 684 if (m_frame->tree().parent() && |
827 !m_stateMachine.committedFirstRealDocumentLoad()) | 685 !m_stateMachine.committedFirstRealDocumentLoad()) |
828 return FrameLoadTypeInitialInChildFrame; | 686 return FrameLoadTypeInitialInChildFrame; |
829 if (!m_frame->tree().parent() && !client()->backForwardLength()) | 687 if (!m_frame->tree().parent() && !client()->backForwardLength()) { |
688 if (opener() && request.resourceRequest().url().isEmpty()) | |
Nate Chapin
2017/03/27 21:02:01
Was a special case in FrameLoader::receivedFirstDa
| |
689 return FrameLoadTypeReplaceCurrentItem; | |
830 return FrameLoadTypeStandard; | 690 return FrameLoadTypeStandard; |
831 if (m_provisionalDocumentLoader && | 691 } |
832 request.substituteData().failingURL() == | |
833 m_provisionalDocumentLoader->url() && | |
834 m_provisionalDocumentLoader->loadType() == FrameLoadTypeBackForward) | |
Nate Chapin
2017/03/27 21:02:01
This clause moved to WebLocalFrameImpl::loadData()
| |
835 return FrameLoadTypeBackForward; | |
836 if (request.resourceRequest().getCachePolicy() == | 692 if (request.resourceRequest().getCachePolicy() == |
837 WebCachePolicy::ValidatingCacheData) | 693 WebCachePolicy::ValidatingCacheData) |
838 return FrameLoadTypeReload; | 694 return FrameLoadTypeReload; |
839 if (request.resourceRequest().getCachePolicy() == | 695 if (request.resourceRequest().getCachePolicy() == |
840 WebCachePolicy::BypassingCache) | 696 WebCachePolicy::BypassingCache) |
841 return FrameLoadTypeReloadBypassingCache; | 697 return FrameLoadTypeReloadBypassingCache; |
842 // From the HTML5 spec for location.assign(): | 698 // From the HTML5 spec for location.assign(): |
843 // "If the browsing context's session history contains only one Document, | 699 // "If the browsing context's session history contains only one Document, |
844 // and that was the about:blank Document created when the browsing context | 700 // and that was the about:blank Document created when the browsing context |
845 // was created, then the navigation must be done with replacement enabled." | 701 // was created, then the navigation must be done with replacement enabled." |
(...skipping 13 matching lines...) Expand all Loading... | |
859 if (request.substituteData().failingURL() == | 715 if (request.substituteData().failingURL() == |
860 m_documentLoader->urlForHistory() && | 716 m_documentLoader->urlForHistory() && |
861 m_documentLoader->loadType() == FrameLoadTypeReload) | 717 m_documentLoader->loadType() == FrameLoadTypeReload) |
862 return FrameLoadTypeReload; | 718 return FrameLoadTypeReload; |
863 | 719 |
864 if (m_frame->settings()->getHistoryEntryRequiresUserGesture() && | 720 if (m_frame->settings()->getHistoryEntryRequiresUserGesture() && |
865 request.originDocument() && | 721 request.originDocument() && |
866 !request.originDocument()->frame()->hasReceivedUserGesture()) | 722 !request.originDocument()->frame()->hasReceivedUserGesture()) |
867 return FrameLoadTypeReplaceCurrentItem; | 723 return FrameLoadTypeReplaceCurrentItem; |
868 | 724 |
725 if (request.resourceRequest().url().isEmpty() && | |
726 request.substituteData().failingURL().isEmpty()) { | |
Nate Chapin
2017/03/27 21:02:01
Was a special case in FrameLoader::receivedFirstDa
| |
727 return FrameLoadTypeReplaceCurrentItem; | |
728 } | |
729 | |
869 return FrameLoadTypeStandard; | 730 return FrameLoadTypeStandard; |
870 } | 731 } |
871 | 732 |
872 bool FrameLoader::prepareRequestForThisFrame(FrameLoadRequest& request) { | 733 bool FrameLoader::prepareRequestForThisFrame(FrameLoadRequest& request) { |
873 // If no origin Document* was specified, skip remaining security checks and | 734 // If no origin Document* was specified, skip remaining security checks and |
874 // assume the caller has fully initialized the FrameLoadRequest. | 735 // assume the caller has fully initialized the FrameLoadRequest. |
875 if (!request.originDocument()) | 736 if (!request.originDocument()) |
876 return true; | 737 return true; |
877 | 738 |
878 KURL url = request.resourceRequest().url(); | 739 KURL url = request.resourceRequest().url(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1009 return; | 870 return; |
1010 } | 871 } |
1011 | 872 |
1012 FrameLoadRequest request(passedRequest); | 873 FrameLoadRequest request(passedRequest); |
1013 request.resourceRequest().setHasUserGesture( | 874 request.resourceRequest().setHasUserGesture( |
1014 UserGestureIndicator::processingUserGesture()); | 875 UserGestureIndicator::processingUserGesture()); |
1015 | 876 |
1016 if (!prepareRequestForThisFrame(request)) | 877 if (!prepareRequestForThisFrame(request)) |
1017 return; | 878 return; |
1018 | 879 |
1019 if (isBackForwardLoadType(frameLoadType)) { | |
Nate Chapin
2017/03/27 21:02:01
Equivalent moved to startLoad(), after the provisi
| |
1020 DCHECK(historyItem); | |
1021 m_provisionalItem = historyItem; | |
1022 } | |
1023 | |
1024 // Form submissions appear to need their special-case of finding the target at | 880 // Form submissions appear to need their special-case of finding the target at |
1025 // schedule rather than at fire. | 881 // schedule rather than at fire. |
1026 Frame* targetFrame = request.form() | 882 Frame* targetFrame = request.form() |
1027 ? nullptr | 883 ? nullptr |
1028 : m_frame->findFrameForNavigation( | 884 : m_frame->findFrameForNavigation( |
1029 AtomicString(request.frameName()), *m_frame); | 885 AtomicString(request.frameName()), *m_frame); |
1030 | 886 |
1031 NavigationPolicy policy = navigationPolicyForRequest(request); | 887 NavigationPolicy policy = navigationPolicyForRequest(request); |
1032 if (targetFrame && targetFrame != m_frame && | 888 if (targetFrame && targetFrame != m_frame && |
1033 shouldNavigateTargetFrame(policy)) { | 889 shouldNavigateTargetFrame(policy)) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1081 RefPtr<SerializedScriptValue> stateObject = | 937 RefPtr<SerializedScriptValue> stateObject = |
1082 sameDocumentHistoryNavigation ? historyItem->stateObject() : nullptr; | 938 sameDocumentHistoryNavigation ? historyItem->stateObject() : nullptr; |
1083 | 939 |
1084 if (!sameDocumentHistoryNavigation) { | 940 if (!sameDocumentHistoryNavigation) { |
1085 m_documentLoader->setNavigationType(determineNavigationType( | 941 m_documentLoader->setNavigationType(determineNavigationType( |
1086 newLoadType, false, request.triggeringEvent())); | 942 newLoadType, false, request.triggeringEvent())); |
1087 if (shouldTreatURLAsSameAsCurrent(url)) | 943 if (shouldTreatURLAsSameAsCurrent(url)) |
1088 newLoadType = FrameLoadTypeReplaceCurrentItem; | 944 newLoadType = FrameLoadTypeReplaceCurrentItem; |
1089 } | 945 } |
1090 | 946 |
1091 loadInSameDocument(url, stateObject, newLoadType, historyLoadType, | 947 loadInSameDocument(url, stateObject, newLoadType, historyItem, |
1092 request.clientRedirect(), request.originDocument()); | 948 request.clientRedirect(), request.originDocument()); |
1093 return; | 949 return; |
1094 } | 950 } |
1095 | 951 |
1096 // PlzNavigate | 952 // PlzNavigate |
1097 // If the loader classifies this navigation as a different document navigation | 953 // If the loader classifies this navigation as a different document navigation |
1098 // while the browser intended the navigation to be same-document, it means | 954 // while the browser intended the navigation to be same-document, it means |
1099 // that a different navigation must have committed while the IPC was sent. | 955 // that a different navigation must have committed while the IPC was sent. |
1100 // This navigation is no more same-document. The navigation is simply dropped. | 956 // This navigation is no more same-document. The navigation is simply dropped. |
1101 if (request.resourceRequest().isSameDocumentNavigation()) | 957 if (request.resourceRequest().isSameDocumentNavigation()) |
1102 return; | 958 return; |
1103 | 959 |
1104 startLoad(request, newLoadType, policy); | 960 startLoad(request, newLoadType, policy, historyItem); |
1105 } | 961 } |
1106 | 962 |
1107 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) { | 963 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) { |
1108 if (!shouldTreatURLAsSrcdocDocument(url)) | 964 if (!shouldTreatURLAsSrcdocDocument(url)) |
1109 return SubstituteData(); | 965 return SubstituteData(); |
1110 String srcdoc = m_frame->deprecatedLocalOwner()->fastGetAttribute(srcdocAttr); | 966 String srcdoc = m_frame->deprecatedLocalOwner()->fastGetAttribute(srcdocAttr); |
1111 DCHECK(!srcdoc.isNull()); | 967 DCHECK(!srcdoc.isNull()); |
1112 CString encodedSrcdoc = srcdoc.utf8(); | 968 CString encodedSrcdoc = srcdoc.utf8(); |
1113 return SubstituteData( | 969 return SubstituteData( |
1114 SharedBuffer::create(encodedSrcdoc.data(), encodedSrcdoc.length()), | 970 SharedBuffer::create(encodedSrcdoc.data(), encodedSrcdoc.length()), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1151 detachDocumentLoader(m_provisionalDocumentLoader); | 1007 detachDocumentLoader(m_provisionalDocumentLoader); |
1152 | 1008 |
1153 m_checkTimer.stop(); | 1009 m_checkTimer.stop(); |
1154 m_frame->navigationScheduler().cancel(); | 1010 m_frame->navigationScheduler().cancel(); |
1155 | 1011 |
1156 // It's possible that the above actions won't have stopped loading if load | 1012 // It's possible that the above actions won't have stopped loading if load |
1157 // completion had been blocked on parsing or if we were in the middle of | 1013 // completion had been blocked on parsing or if we were in the middle of |
1158 // committing an empty document. In that case, emulate a failed navigation. | 1014 // committing an empty document. In that case, emulate a failed navigation. |
1159 if (!m_provisionalDocumentLoader && m_documentLoader && | 1015 if (!m_provisionalDocumentLoader && m_documentLoader && |
1160 m_frame->isLoading()) { | 1016 m_frame->isLoading()) { |
1161 loadFailed(m_documentLoader.get(), | 1017 m_documentLoader->loadFailed( |
1162 ResourceError::cancelledError(m_documentLoader->url())); | 1018 ResourceError::cancelledError(m_documentLoader->url())); |
1163 } | 1019 } |
1164 | 1020 |
1165 m_inStopAllLoaders = false; | 1021 m_inStopAllLoaders = false; |
1166 takeObjectSnapshot(); | 1022 takeObjectSnapshot(); |
1167 } | 1023 } |
1168 | 1024 |
1169 void FrameLoader::didAccessInitialDocument() { | 1025 void FrameLoader::didAccessInitialDocument() { |
1170 // We only need to notify the client for the main frame. | 1026 // We only need to notify the client for the main frame. |
1171 if (isLoadingMainFrame()) { | 1027 if (isLoadingMainFrame()) { |
1172 // Forbid script execution to prevent re-entering V8, since this is called | 1028 // Forbid script execution to prevent re-entering V8, since this is called |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1222 // 'abort' listeners can also detach the frame. | 1078 // 'abort' listeners can also detach the frame. |
1223 if (!m_frame->client()) | 1079 if (!m_frame->client()) |
1224 return false; | 1080 return false; |
1225 DCHECK_EQ(m_provisionalDocumentLoader, pdl); | 1081 DCHECK_EQ(m_provisionalDocumentLoader, pdl); |
1226 // No more events will be dispatched so detach the Document. | 1082 // No more events will be dispatched so detach the Document. |
1227 // TODO(yoav): Should we also be nullifying domWindow's document (or | 1083 // TODO(yoav): Should we also be nullifying domWindow's document (or |
1228 // domWindow) since the doc is now detached? | 1084 // domWindow) since the doc is now detached? |
1229 if (m_frame->document()) | 1085 if (m_frame->document()) |
1230 m_frame->document()->shutdown(); | 1086 m_frame->document()->shutdown(); |
1231 m_documentLoader = m_provisionalDocumentLoader.release(); | 1087 m_documentLoader = m_provisionalDocumentLoader.release(); |
1088 if (m_documentLoader) | |
1089 m_documentLoader->markAsCommitted(); | |
Nate Chapin
2017/03/27 21:02:01
(1) m_documentLoader can be nullptr here, which is
| |
1232 takeObjectSnapshot(); | 1090 takeObjectSnapshot(); |
1233 | 1091 |
1234 return true; | 1092 return true; |
1235 } | 1093 } |
1236 | 1094 |
1237 void FrameLoader::commitProvisionalLoad() { | 1095 void FrameLoader::commitProvisionalLoad() { |
1238 DCHECK(client()->hasWebView()); | 1096 DCHECK(client()->hasWebView()); |
1239 | 1097 |
1240 // Check if the destination page is allowed to access the previous page's | 1098 // Check if the destination page is allowed to access the previous page's |
1241 // timing information. | 1099 // timing information. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1287 | 1145 |
1288 void FrameLoader::restoreScrollPositionAndViewState() { | 1146 void FrameLoader::restoreScrollPositionAndViewState() { |
1289 if (!m_frame->page() || !documentLoader()) | 1147 if (!m_frame->page() || !documentLoader()) |
1290 return; | 1148 return; |
1291 restoreScrollPositionAndViewStateForLoadType(documentLoader()->loadType()); | 1149 restoreScrollPositionAndViewStateForLoadType(documentLoader()->loadType()); |
1292 } | 1150 } |
1293 | 1151 |
1294 void FrameLoader::restoreScrollPositionAndViewStateForLoadType( | 1152 void FrameLoader::restoreScrollPositionAndViewStateForLoadType( |
1295 FrameLoadType loadType) { | 1153 FrameLoadType loadType) { |
1296 FrameView* view = m_frame->view(); | 1154 FrameView* view = m_frame->view(); |
1297 if (!view || !view->layoutViewportScrollableArea() || !m_currentItem || | 1155 if (!view || !view->layoutViewportScrollableArea() || |
1298 !m_stateMachine.committedFirstRealDocumentLoad()) { | 1156 !m_stateMachine.committedFirstRealDocumentLoad()) { |
1299 return; | 1157 return; |
1300 } | 1158 } |
1301 if (!needsHistoryItemRestore(loadType)) | 1159 if (!needsHistoryItemRestore(loadType)) |
1302 return; | 1160 return; |
1303 if (!m_currentItem->didSaveScrollOrScaleState()) | 1161 HistoryItem* historyItem = m_documentLoader->historyItem(); |
1162 if (!historyItem || !historyItem->didSaveScrollOrScaleState()) | |
1304 return; | 1163 return; |
1305 | 1164 |
1306 bool shouldRestoreScroll = | 1165 bool shouldRestoreScroll = |
1307 m_currentItem->scrollRestorationType() != ScrollRestorationManual; | 1166 historyItem->scrollRestorationType() != ScrollRestorationManual; |
1308 bool shouldRestoreScale = m_currentItem->pageScaleFactor(); | 1167 bool shouldRestoreScale = historyItem->pageScaleFactor(); |
1309 | 1168 |
1310 // This tries to balance: | 1169 // This tries to balance: |
1311 // 1. restoring as soon as possible | 1170 // 1. restoring as soon as possible |
1312 // 2. not overriding user scroll (TODO(majidvp): also respect user scale) | 1171 // 2. not overriding user scroll (TODO(majidvp): also respect user scale) |
1313 // 3. detecting clamping to avoid repeatedly popping the scroll position down | 1172 // 3. detecting clamping to avoid repeatedly popping the scroll position down |
1314 // as the page height increases | 1173 // as the page height increases |
1315 // 4. ignore clamp detection if we are not restoring scroll or after load | 1174 // 4. ignore clamp detection if we are not restoring scroll or after load |
1316 // completes because that may be because the page will never reach its | 1175 // completes because that may be because the page will never reach its |
1317 // previous height | 1176 // previous height |
1318 bool canRestoreWithoutClamping = | 1177 bool canRestoreWithoutClamping = |
1319 view->layoutViewportScrollableArea()->clampScrollOffset( | 1178 view->layoutViewportScrollableArea()->clampScrollOffset( |
1320 m_currentItem->getScrollOffset()) == m_currentItem->getScrollOffset(); | 1179 historyItem->getScrollOffset()) == historyItem->getScrollOffset(); |
1321 bool canRestoreWithoutAnnoyingUser = | 1180 bool canRestoreWithoutAnnoyingUser = |
1322 !documentLoader()->initialScrollState().wasScrolledByUser && | 1181 !documentLoader()->initialScrollState().wasScrolledByUser && |
1323 (canRestoreWithoutClamping || !m_frame->isLoading() || | 1182 (canRestoreWithoutClamping || !m_frame->isLoading() || |
1324 !shouldRestoreScroll); | 1183 !shouldRestoreScroll); |
1325 if (!canRestoreWithoutAnnoyingUser) | 1184 if (!canRestoreWithoutAnnoyingUser) |
1326 return; | 1185 return; |
1327 | 1186 |
1328 if (shouldRestoreScroll) { | 1187 if (shouldRestoreScroll) { |
1329 view->layoutViewportScrollableArea()->setScrollOffset( | 1188 view->layoutViewportScrollableArea()->setScrollOffset( |
1330 m_currentItem->getScrollOffset(), ProgrammaticScroll); | 1189 historyItem->getScrollOffset(), ProgrammaticScroll); |
1331 } | 1190 } |
1332 | 1191 |
1333 // For main frame restore scale and visual viewport position | 1192 // For main frame restore scale and visual viewport position |
1334 if (m_frame->isMainFrame()) { | 1193 if (m_frame->isMainFrame()) { |
1335 ScrollOffset visualViewportOffset( | 1194 ScrollOffset visualViewportOffset( |
1336 m_currentItem->visualViewportScrollOffset()); | 1195 historyItem->visualViewportScrollOffset()); |
1337 | 1196 |
1338 // If the visual viewport's offset is (-1, -1) it means the history item | 1197 // If the visual viewport's offset is (-1, -1) it means the history item |
1339 // is an old version of HistoryItem so distribute the scroll between | 1198 // is an old version of HistoryItem so distribute the scroll between |
1340 // the main frame and the visual viewport as best as we can. | 1199 // the main frame and the visual viewport as best as we can. |
1341 if (visualViewportOffset.width() == -1 && | 1200 if (visualViewportOffset.width() == -1 && |
1342 visualViewportOffset.height() == -1) { | 1201 visualViewportOffset.height() == -1) { |
1343 visualViewportOffset = | 1202 visualViewportOffset = |
1344 m_currentItem->getScrollOffset() - | 1203 historyItem->getScrollOffset() - |
1345 view->layoutViewportScrollableArea()->getScrollOffset(); | 1204 view->layoutViewportScrollableArea()->getScrollOffset(); |
1346 } | 1205 } |
1347 | 1206 |
1348 VisualViewport& visualViewport = m_frame->page()->visualViewport(); | 1207 VisualViewport& visualViewport = m_frame->page()->visualViewport(); |
1349 if (shouldRestoreScale && shouldRestoreScroll) { | 1208 if (shouldRestoreScale && shouldRestoreScroll) { |
1350 visualViewport.setScaleAndLocation(m_currentItem->pageScaleFactor(), | 1209 visualViewport.setScaleAndLocation(historyItem->pageScaleFactor(), |
1351 FloatPoint(visualViewportOffset)); | 1210 FloatPoint(visualViewportOffset)); |
1352 } else if (shouldRestoreScale) { | 1211 } else if (shouldRestoreScale) { |
1353 visualViewport.setScale(m_currentItem->pageScaleFactor()); | 1212 visualViewport.setScale(historyItem->pageScaleFactor()); |
1354 } else if (shouldRestoreScroll) { | 1213 } else if (shouldRestoreScroll) { |
1355 visualViewport.setLocation(FloatPoint(visualViewportOffset)); | 1214 visualViewport.setLocation(FloatPoint(visualViewportOffset)); |
1356 } | 1215 } |
1357 | 1216 |
1358 if (ScrollingCoordinator* scrollingCoordinator = | 1217 if (ScrollingCoordinator* scrollingCoordinator = |
1359 m_frame->page()->scrollingCoordinator()) | 1218 m_frame->page()->scrollingCoordinator()) |
1360 scrollingCoordinator->frameViewRootLayerDidChange(view); | 1219 scrollingCoordinator->frameViewRootLayerDidChange(view); |
1361 } | 1220 } |
1362 | 1221 |
1363 documentLoader()->initialScrollState().didRestoreFromHistory = true; | 1222 documentLoader()->initialScrollState().didRestoreFromHistory = true; |
(...skipping 13 matching lines...) Expand all Loading... | |
1377 if (parent && parent->isLocalFrame()) | 1236 if (parent && parent->isLocalFrame()) |
1378 toLocalFrame(parent)->loader().scheduleCheckCompleted(); | 1237 toLocalFrame(parent)->loader().scheduleCheckCompleted(); |
1379 if (m_progressTracker) { | 1238 if (m_progressTracker) { |
1380 m_progressTracker->dispose(); | 1239 m_progressTracker->dispose(); |
1381 m_progressTracker.clear(); | 1240 m_progressTracker.clear(); |
1382 } | 1241 } |
1383 | 1242 |
1384 TRACE_EVENT_OBJECT_DELETED_WITH_ID("loading", "FrameLoader", this); | 1243 TRACE_EVENT_OBJECT_DELETED_WITH_ID("loading", "FrameLoader", this); |
1385 } | 1244 } |
1386 | 1245 |
1387 void FrameLoader::loadFailed(DocumentLoader* loader, | 1246 void FrameLoader::detachProvisionalDocumentLoader(DocumentLoader* loader) { |
Nate Chapin
2017/03/27 21:02:01
I don't like having this, but a DocumentLoader nee
| |
1388 const ResourceError& error) { | 1247 DCHECK_EQ(loader, m_provisionalDocumentLoader); |
1389 if (!error.isCancellation() && m_frame->owner()) { | 1248 detachDocumentLoader(m_provisionalDocumentLoader); |
1390 // FIXME: For now, fallback content doesn't work cross process. | |
1391 if (m_frame->owner()->isLocal()) | |
1392 m_frame->deprecatedLocalOwner()->renderFallbackContent(); | |
1393 } | |
1394 | |
1395 HistoryCommitType historyCommitType = | |
1396 loadTypeToCommitType(loader->loadType()); | |
1397 if (loader == m_provisionalDocumentLoader) { | |
1398 if (!m_provisionalDocumentLoader->didStart()) | |
1399 probe::frameClearedScheduledClientNavigation(m_frame); | |
1400 m_provisionalDocumentLoader->setSentDidFinishLoad(); | |
1401 client()->dispatchDidFailProvisionalLoad(error, historyCommitType); | |
1402 if (loader != m_provisionalDocumentLoader) | |
1403 return; | |
1404 detachDocumentLoader(m_provisionalDocumentLoader); | |
1405 } else { | |
1406 DCHECK_EQ(loader, m_documentLoader); | |
1407 if (m_frame->document()->parser()) | |
1408 m_frame->document()->parser()->stopParsing(); | |
1409 if (!m_documentLoader->sentDidFinishLoad()) { | |
1410 m_documentLoader->setSentDidFinishLoad(); | |
1411 client()->dispatchDidFailLoad(error, historyCommitType); | |
1412 } | |
1413 } | |
1414 checkCompleted(); | |
1415 } | 1249 } |
1416 | 1250 |
1417 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, | 1251 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, |
1418 const String& httpMethod, | 1252 const String& httpMethod, |
1419 FrameLoadType loadType, | 1253 FrameLoadType loadType, |
1420 const KURL& url) { | 1254 const KURL& url) { |
1421 // We don't do this if we are submitting a form with method other than "GET", | 1255 // We don't do this if we are submitting a form with method other than "GET", |
1422 // explicitly reloading, currently displaying a frameset, or if the URL does | 1256 // explicitly reloading, currently displaying a frameset, or if the URL does |
1423 // not have a fragment. | 1257 // not have a fragment. |
1424 return equalIgnoringCase(httpMethod, HTTPNames::GET) && | 1258 return equalIgnoringCase(httpMethod, HTTPNames::GET) && |
(...skipping 25 matching lines...) Expand all Loading... | |
1450 ->view() | 1284 ->view() |
1451 ->setSafeToPropagateScrollToParent(false); | 1285 ->setSafeToPropagateScrollToParent(false); |
1452 } | 1286 } |
1453 | 1287 |
1454 // If scroll position is restored from history fragment or scroll | 1288 // If scroll position is restored from history fragment or scroll |
1455 // restoration type is manual, then we should not override it unless this | 1289 // restoration type is manual, then we should not override it unless this |
1456 // is a same document reload. | 1290 // is a same document reload. |
1457 bool shouldScrollToFragment = | 1291 bool shouldScrollToFragment = |
1458 (loadStartType == NavigationWithinSameDocument && | 1292 (loadStartType == NavigationWithinSameDocument && |
1459 !isBackForwardLoadType(frameLoadType)) || | 1293 !isBackForwardLoadType(frameLoadType)) || |
1460 (documentLoader() && | 1294 (!documentLoader()->initialScrollState().didRestoreFromHistory && |
yhirano
2017/03/29 09:38:13
Can you tell me why this can be removed safely?
Nate Chapin
2017/03/29 18:23:06
The FrameView null-check at the top of processFrag
| |
1461 !documentLoader()->initialScrollState().didRestoreFromHistory && | 1295 !(documentLoader()->historyItem() && |
1462 !(m_currentItem && | 1296 documentLoader()->historyItem()->scrollRestorationType() == |
1463 m_currentItem->scrollRestorationType() == ScrollRestorationManual)); | 1297 ScrollRestorationManual)); |
1464 | 1298 |
1465 view->processUrlFragment(url, shouldScrollToFragment | 1299 view->processUrlFragment(url, shouldScrollToFragment |
1466 ? FrameView::UrlFragmentScroll | 1300 ? FrameView::UrlFragmentScroll |
1467 : FrameView::UrlFragmentDontScroll); | 1301 : FrameView::UrlFragmentDontScroll); |
1468 | 1302 |
1469 if (boundaryFrame && boundaryFrame->isLocalFrame()) | 1303 if (boundaryFrame && boundaryFrame->isLocalFrame()) |
1470 toLocalFrame(boundaryFrame)->view()->setSafeToPropagateScrollToParent(true); | 1304 toLocalFrame(boundaryFrame)->view()->setSafeToPropagateScrollToParent(true); |
1471 } | 1305 } |
1472 | 1306 |
1473 bool FrameLoader::shouldClose(bool isReload) { | 1307 bool FrameLoader::shouldClose(bool isReload) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1609 return shouldContinueForNavigationPolicy( | 1443 return shouldContinueForNavigationPolicy( |
1610 resourceRequest, frameLoadRequest.substituteData(), nullptr, | 1444 resourceRequest, frameLoadRequest.substituteData(), nullptr, |
1611 frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), | 1445 frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), |
1612 navigationType, navigationPolicy, type, | 1446 navigationType, navigationPolicy, type, |
1613 frameLoadRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect, | 1447 frameLoadRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect, |
1614 frameLoadRequest.form()); | 1448 frameLoadRequest.form()); |
1615 } | 1449 } |
1616 | 1450 |
1617 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, | 1451 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, |
1618 FrameLoadType type, | 1452 FrameLoadType type, |
1619 NavigationPolicy navigationPolicy) { | 1453 NavigationPolicy navigationPolicy, |
1454 HistoryItem* historyItem) { | |
1620 DCHECK(client()->hasWebView()); | 1455 DCHECK(client()->hasWebView()); |
1621 ResourceRequest& resourceRequest = frameLoadRequest.resourceRequest(); | 1456 ResourceRequest& resourceRequest = frameLoadRequest.resourceRequest(); |
1622 NavigationType navigationType = determineNavigationType( | 1457 NavigationType navigationType = determineNavigationType( |
1623 type, resourceRequest.httpBody() || frameLoadRequest.form(), | 1458 type, resourceRequest.httpBody() || frameLoadRequest.form(), |
1624 frameLoadRequest.triggeringEvent()); | 1459 frameLoadRequest.triggeringEvent()); |
1625 resourceRequest.setRequestContext( | 1460 resourceRequest.setRequestContext( |
1626 determineRequestContextFromNavigationType(navigationType)); | 1461 determineRequestContextFromNavigationType(navigationType)); |
1627 resourceRequest.setFrameType(m_frame->isMainFrame() | 1462 resourceRequest.setFrameType(m_frame->isMainFrame() |
1628 ? WebURLRequest::FrameTypeTopLevel | 1463 ? WebURLRequest::FrameTypeTopLevel |
1629 : WebURLRequest::FrameTypeNested); | 1464 : WebURLRequest::FrameTypeNested); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1670 navigationPolicy == NavigationPolicyHandledByClient) { | 1505 navigationPolicy == NavigationPolicyHandledByClient) { |
1671 m_frame->navigationScheduler().cancel(); | 1506 m_frame->navigationScheduler().cancel(); |
1672 m_checkTimer.stop(); | 1507 m_checkTimer.stop(); |
1673 } | 1508 } |
1674 | 1509 |
1675 if (frameLoadRequest.form()) | 1510 if (frameLoadRequest.form()) |
1676 client()->dispatchWillSubmitForm(frameLoadRequest.form()); | 1511 client()->dispatchWillSubmitForm(frameLoadRequest.form()); |
1677 | 1512 |
1678 m_provisionalDocumentLoader->appendRedirect( | 1513 m_provisionalDocumentLoader->appendRedirect( |
1679 m_provisionalDocumentLoader->getRequest().url()); | 1514 m_provisionalDocumentLoader->getRequest().url()); |
1515 | |
1516 if (isBackForwardLoadType(type)) { | |
1517 DCHECK(historyItem); | |
1518 m_provisionalDocumentLoader->setItemForHistoryNavigation(historyItem); | |
1519 } | |
1520 | |
1680 // TODO(ananta): | 1521 // TODO(ananta): |
1681 // We should get rid of the dependency on the DocumentLoader in consumers of | 1522 // We should get rid of the dependency on the DocumentLoader in consumers of |
1682 // the didStartProvisionalLoad() notification. | 1523 // the didStartProvisionalLoad() notification. |
1683 client()->dispatchDidStartProvisionalLoad(m_provisionalDocumentLoader, | 1524 client()->dispatchDidStartProvisionalLoad(m_provisionalDocumentLoader, |
1684 resourceRequest); | 1525 resourceRequest); |
1685 DCHECK(m_provisionalDocumentLoader); | 1526 DCHECK(m_provisionalDocumentLoader); |
1686 | 1527 |
1687 if (navigationPolicy == NavigationPolicyCurrentTab) { | 1528 if (navigationPolicy == NavigationPolicyCurrentTab) { |
1688 m_provisionalDocumentLoader->startLoadingMainResource(); | 1529 m_provisionalDocumentLoader->startLoadingMainResource(); |
1689 // This should happen after the request is sent, so that the state | 1530 // This should happen after the request is sent, so that the state |
(...skipping 13 matching lines...) Expand all Loading... | |
1703 takeObjectSnapshot(); | 1544 takeObjectSnapshot(); |
1704 } | 1545 } |
1705 | 1546 |
1706 void FrameLoader::applyUserAgent(ResourceRequest& request) { | 1547 void FrameLoader::applyUserAgent(ResourceRequest& request) { |
1707 String userAgent = this->userAgent(); | 1548 String userAgent = this->userAgent(); |
1708 DCHECK(!userAgent.isNull()); | 1549 DCHECK(!userAgent.isNull()); |
1709 request.setHTTPUserAgent(AtomicString(userAgent)); | 1550 request.setHTTPUserAgent(AtomicString(userAgent)); |
1710 } | 1551 } |
1711 | 1552 |
1712 bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const { | 1553 bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const { |
1713 return m_currentItem && url == m_currentItem->url(); | 1554 return m_documentLoader->historyItem() && |
1555 url == m_documentLoader->historyItem()->url(); | |
1714 } | 1556 } |
1715 | 1557 |
1716 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const { | 1558 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const { |
1717 if (!url.isAboutSrcdocURL()) | 1559 if (!url.isAboutSrcdocURL()) |
1718 return false; | 1560 return false; |
1719 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); | 1561 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); |
1720 if (!isHTMLIFrameElement(ownerElement)) | 1562 if (!isHTMLIFrameElement(ownerElement)) |
1721 return false; | 1563 return false; |
1722 return ownerElement->fastHasAttribute(srcdocAttr); | 1564 return ownerElement->fastHasAttribute(srcdocAttr); |
1723 } | 1565 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1896 FrameLoadType loadType, | 1738 FrameLoadType loadType, |
1897 NavigationType navigationType) { | 1739 NavigationType navigationType) { |
1898 DocumentLoader* loader = client()->createDocumentLoader( | 1740 DocumentLoader* loader = client()->createDocumentLoader( |
1899 m_frame, request, frameLoadRequest.substituteData().isValid() | 1741 m_frame, request, frameLoadRequest.substituteData().isValid() |
1900 ? frameLoadRequest.substituteData() | 1742 ? frameLoadRequest.substituteData() |
1901 : defaultSubstituteDataForURL(request.url()), | 1743 : defaultSubstituteDataForURL(request.url()), |
1902 frameLoadRequest.clientRedirect()); | 1744 frameLoadRequest.clientRedirect()); |
1903 | 1745 |
1904 loader->setLoadType(loadType); | 1746 loader->setLoadType(loadType); |
1905 loader->setNavigationType(navigationType); | 1747 loader->setNavigationType(navigationType); |
1906 loader->setReplacesCurrentHistoryItem(loadType == | 1748 bool replaceCurrentItem = loadType == FrameLoadTypeReplaceCurrentItem && |
Nate Chapin
2017/03/27 21:02:01
The browser process DCHECKS when it received a bla
kinuko
2017/03/30 05:04:59
Could we have some of this note as a code comment?
Nate Chapin
2017/03/30 20:13:56
Added an explanation/TODO.
| |
1907 FrameLoadTypeReplaceCurrentItem); | 1749 (!opener() || !request.url().isEmpty()); |
1750 loader->setReplacesCurrentHistoryItem(replaceCurrentItem); | |
1908 return loader; | 1751 return loader; |
1909 } | 1752 } |
1910 | 1753 |
1911 } // namespace blink | 1754 } // namespace blink |
OLD | NEW |