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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 clear(); | 283 clear(); |
284 | 284 |
285 // detachChildren() potentially detaches the frame from the document. The | 285 // detachChildren() potentially detaches the frame from the document. The |
286 // loading cannot continue in that case. | 286 // loading cannot continue in that case. |
287 if (!m_frame->page()) | 287 if (!m_frame->page()) |
288 return; | 288 return; |
289 | 289 |
290 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own
erDocument); | 290 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own
erDocument); |
291 } | 291 } |
292 | 292 |
293 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy
pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject) | 293 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy
pe, bool isPushOrReplaceState, HistoryScrollRestorationType scrollRestorationTyp
e, PassRefPtr<SerializedScriptValue> stateObject) |
294 { | 294 { |
295 if (m_provisionalItem) | 295 if (m_provisionalItem) |
296 m_currentItem = m_provisionalItem.release(); | 296 m_currentItem = m_provisionalItem.release(); |
297 | 297 |
298 if (!m_currentItem || historyCommitType == StandardCommit) { | 298 if (!m_currentItem || historyCommitType == StandardCommit) { |
299 m_currentItem = HistoryItem::create(); | 299 m_currentItem = HistoryItem::create(); |
300 } else if (!isPushOrReplaceState && m_documentLoader->url() != m_currentItem
->url()) { | 300 } else if (!isPushOrReplaceState && m_documentLoader->url() != m_currentItem
->url()) { |
301 m_currentItem->generateNewItemSequenceNumber(); | 301 m_currentItem->generateNewItemSequenceNumber(); |
302 if (!equalIgnoringFragmentIdentifier(m_documentLoader->url(), m_currentI
tem->url())) | 302 if (!equalIgnoringFragmentIdentifier(m_documentLoader->url(), m_currentI
tem->url())) |
303 m_currentItem->generateNewDocumentSequenceNumber(); | 303 m_currentItem->generateNewDocumentSequenceNumber(); |
304 } | 304 } |
305 | 305 |
306 m_currentItem->setURL(m_documentLoader->urlForHistory()); | 306 m_currentItem->setURL(m_documentLoader->urlForHistory()); |
307 m_currentItem->setDocumentState(m_frame->document()->formElementsState()); | 307 m_currentItem->setDocumentState(m_frame->document()->formElementsState()); |
308 m_currentItem->setTarget(m_frame->tree().uniqueName()); | 308 m_currentItem->setTarget(m_frame->tree().uniqueName()); |
309 if (isPushOrReplaceState) | 309 if (isPushOrReplaceState) { |
310 m_currentItem->setStateObject(stateObject); | 310 m_currentItem->setStateObject(stateObject); |
| 311 m_currentItem->setScrollRestorationType(scrollRestorationType); |
| 312 } |
311 m_currentItem->setReferrer(SecurityPolicy::generateReferrer(m_documentLoader
->request().referrerPolicy(), m_currentItem->url(), m_documentLoader->request().
httpReferrer())); | 313 m_currentItem->setReferrer(SecurityPolicy::generateReferrer(m_documentLoader
->request().referrerPolicy(), m_currentItem->url(), m_documentLoader->request().
httpReferrer())); |
312 m_currentItem->setFormInfoFromRequest(m_documentLoader->request()); | 314 m_currentItem->setFormInfoFromRequest(m_documentLoader->request()); |
313 } | 315 } |
314 | 316 |
315 static HistoryCommitType loadTypeToCommitType(FrameLoadType type) | 317 static HistoryCommitType loadTypeToCommitType(FrameLoadType type) |
316 { | 318 { |
317 switch (type) { | 319 switch (type) { |
318 case FrameLoadTypeStandard: | 320 case FrameLoadTypeStandard: |
319 return StandardCommit; | 321 return StandardCommit; |
320 case FrameLoadTypeInitialInChildFrame: | 322 case FrameLoadTypeInitialInChildFrame: |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 // accessible, so bail early. | 552 // accessible, so bail early. |
551 if (!client()) | 553 if (!client()) |
552 return false; | 554 return false; |
553 Settings* settings = m_frame->settings(); | 555 Settings* settings = m_frame->settings(); |
554 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled()
); | 556 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled()
); |
555 if (!allowed && reason == AboutToInstantiatePlugin) | 557 if (!allowed && reason == AboutToInstantiatePlugin) |
556 client()->didNotAllowPlugins(); | 558 client()->didNotAllowPlugins(); |
557 return allowed; | 559 return allowed; |
558 } | 560 } |
559 | 561 |
560 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume
ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu
e> data, FrameLoadType type) | 562 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume
ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu
e> data, HistoryScrollRestorationType scrollRestorationType, FrameLoadType type) |
561 { | 563 { |
562 saveScrollState(); | 564 saveScrollState(); |
563 | 565 |
564 // Update the data source's request with the new URL to fake the URL change | 566 // Update the data source's request with the new URL to fake the URL change |
565 m_frame->document()->setURL(newURL); | 567 m_frame->document()->setURL(newURL); |
566 documentLoader()->setReplacesCurrentHistoryItem(type != FrameLoadTypeStandar
d); | 568 documentLoader()->setReplacesCurrentHistoryItem(type != FrameLoadTypeStandar
d); |
567 documentLoader()->updateForSameDocumentNavigation(newURL, sameDocumentNaviga
tionSource); | 569 documentLoader()->updateForSameDocumentNavigation(newURL, sameDocumentNaviga
tionSource); |
568 | 570 |
569 // Generate start and stop notifications only when loader is completed so th
at we | 571 // Generate start and stop notifications only when loader is completed so th
at we |
570 // don't fire them for fragment redirection that happens in window.onload ha
ndler. | 572 // don't fire them for fragment redirection that happens in window.onload ha
ndler. |
571 // See https://bugs.webkit.org/show_bug.cgi?id=31838 | 573 // See https://bugs.webkit.org/show_bug.cgi?id=31838 |
572 if (m_frame->document()->loadEventFinished()) | 574 if (m_frame->document()->loadEventFinished()) |
573 client()->didStartLoading(NavigationWithinSameDocument); | 575 client()->didStartLoading(NavigationWithinSameDocument); |
574 | 576 |
575 HistoryCommitType historyCommitType = loadTypeToCommitType(type); | 577 HistoryCommitType historyCommitType = loadTypeToCommitType(type); |
576 if (!m_currentItem) | 578 if (!m_currentItem) |
577 historyCommitType = HistoryInertCommit; | 579 historyCommitType = HistoryInertCommit; |
578 | 580 |
579 setHistoryItemStateForCommit(historyCommitType, sameDocumentNavigationSource
== SameDocumentNavigationHistoryApi, data); | 581 setHistoryItemStateForCommit(historyCommitType, sameDocumentNavigationSource
== SameDocumentNavigationHistoryApi, scrollRestorationType, data); |
580 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy
pe); | 582 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy
pe); |
581 client()->dispatchDidReceiveTitle(m_frame->document()->title()); | 583 client()->dispatchDidReceiveTitle(m_frame->document()->title()); |
582 if (m_frame->document()->loadEventFinished()) | 584 if (m_frame->document()->loadEventFinished()) |
583 client()->didStopLoading(); | 585 client()->didStopLoading(); |
584 } | 586 } |
585 | 587 |
586 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, FrameLoadType type, ClientRedirectPolicy clientRedirect) | 588 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, FrameLoadType type, ClientRedirectPolicy clientRedirect) |
587 { | 589 { |
588 // If we have a state object, we cannot also be a new navigation. | 590 // If we have a state object, we cannot also be a new navigation. |
589 ASSERT(!stateObject || type == FrameLoadTypeBackForward); | 591 ASSERT(!stateObject || type == FrameLoadTypeBackForward); |
(...skipping 10 matching lines...) Expand all Loading... |
600 m_loadType = type; | 602 m_loadType = type; |
601 | 603 |
602 KURL oldURL = m_frame->document()->url(); | 604 KURL oldURL = m_frame->document()->url(); |
603 // If we were in the autoscroll/panScroll mode we want to stop it before fol
lowing the link to the anchor | 605 // If we were in the autoscroll/panScroll mode we want to stop it before fol
lowing the link to the anchor |
604 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); | 606 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); |
605 if (hashChange) { | 607 if (hashChange) { |
606 m_frame->eventHandler().stopAutoscroll(); | 608 m_frame->eventHandler().stopAutoscroll(); |
607 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url); | 609 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url); |
608 } | 610 } |
609 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); | 611 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); |
610 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr,
type); | 612 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr,
ScrollRestorationAuto, type); |
611 | 613 |
612 m_frame->view()->setWasScrolledByUser(false); | 614 m_frame->view()->setWasScrolledByUser(false); |
613 | 615 |
614 // We need to scroll to the fragment whether or not a hash change occurred,
since | 616 // We need to scroll to the fragment whether or not a hash change occurred,
since |
615 // the user might have scrolled since the previous navigation. | 617 // the user might have scrolled since the previous navigation. |
616 scrollToFragmentWithParentBoundary(url); | 618 scrollToFragmentWithParentBoundary(url); |
617 checkCompleted(); | 619 checkCompleted(); |
618 | 620 |
619 m_frame->localDOMWindow()->statePopped(stateObject ? stateObject : Serialize
dScriptValue::nullValue()); | 621 m_frame->localDOMWindow()->statePopped(stateObject ? stateObject : Serialize
dScriptValue::nullValue()); |
620 } | 622 } |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 | 1022 |
1021 void FrameLoader::restoreScrollPositionAndViewState() | 1023 void FrameLoader::restoreScrollPositionAndViewState() |
1022 { | 1024 { |
1023 FrameView* view = m_frame->view(); | 1025 FrameView* view = m_frame->view(); |
1024 if (!m_frame->page() || !view || !m_currentItem || !m_stateMachine.committed
FirstRealDocumentLoad()) | 1026 if (!m_frame->page() || !view || !m_currentItem || !m_stateMachine.committed
FirstRealDocumentLoad()) |
1025 return; | 1027 return; |
1026 | 1028 |
1027 if (!needsHistoryItemRestore(m_loadType)) | 1029 if (!needsHistoryItemRestore(m_loadType)) |
1028 return; | 1030 return; |
1029 | 1031 |
| 1032 if (m_currentItem->scrollRestorationType() == ScrollRestorationManual) |
| 1033 return; |
| 1034 |
1030 // This tries to balance 1. restoring as soon as possible, 2. detecting | 1035 // This tries to balance 1. restoring as soon as possible, 2. detecting |
1031 // clamping to avoid repeatedly popping the scroll position down as the | 1036 // clamping to avoid repeatedly popping the scroll position down as the |
1032 // page height increases, 3. ignore clamp detection after load completes | 1037 // page height increases, 3. ignore clamp detection after load completes |
1033 // because that may be because the page will never reach its previous | 1038 // because that may be because the page will never reach its previous |
1034 // height. | 1039 // height. |
1035 bool canRestoreWithoutClamping = view->clampOffsetAtScale(m_currentItem->scr
ollPoint(), 1) == m_currentItem->scrollPoint(); | 1040 bool canRestoreWithoutClamping = view->clampOffsetAtScale(m_currentItem->scr
ollPoint(), 1) == m_currentItem->scrollPoint(); |
1036 bool canRestoreWithoutAnnoyingUser = !view->wasScrolledByUser() && (canResto
reWithoutClamping || m_frame->isLoading()); | 1041 bool canRestoreWithoutAnnoyingUser = !view->wasScrolledByUser() && (canResto
reWithoutClamping || m_frame->isLoading()); |
1037 if (!canRestoreWithoutAnnoyingUser) | 1042 if (!canRestoreWithoutAnnoyingUser) |
1038 return; | 1043 return; |
1039 | 1044 |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 // FIXME: We need a way to propagate insecure requests policy flags to | 1463 // FIXME: We need a way to propagate insecure requests policy flags to |
1459 // out-of-process frames. For now, we'll always use default behavior. | 1464 // out-of-process frames. For now, we'll always use default behavior. |
1460 if (!parentFrame->isLocalFrame()) | 1465 if (!parentFrame->isLocalFrame()) |
1461 return nullptr; | 1466 return nullptr; |
1462 | 1467 |
1463 ASSERT(toLocalFrame(parentFrame)->document()); | 1468 ASSERT(toLocalFrame(parentFrame)->document()); |
1464 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade()
; | 1469 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade()
; |
1465 } | 1470 } |
1466 | 1471 |
1467 } // namespace blink | 1472 } // namespace blink |
OLD | NEW |