Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(630)

Side by Side Diff: Source/core/loader/FrameLoader.cpp

Issue 1063573002: history.pushState() should take care of scrolling state (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/http/tests/navigation/same-document-scroll-position-restore-pushstate-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 return false; 546 return false;
547 Settings* settings = m_frame->settings(); 547 Settings* settings = m_frame->settings();
548 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled() ); 548 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled() );
549 if (!allowed && reason == AboutToInstantiatePlugin) 549 if (!allowed && reason == AboutToInstantiatePlugin)
550 client()->didNotAllowPlugins(); 550 client()->didNotAllowPlugins();
551 return allowed; 551 return allowed;
552 } 552 }
553 553
554 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu e> data, FrameLoadType type) 554 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu e> data, FrameLoadType type)
555 { 555 {
556 saveScrollState();
557
556 // Update the data source's request with the new URL to fake the URL change 558 // Update the data source's request with the new URL to fake the URL change
557 m_frame->document()->setURL(newURL); 559 m_frame->document()->setURL(newURL);
558 documentLoader()->setReplacesCurrentHistoryItem(type != FrameLoadTypeStandar d); 560 documentLoader()->setReplacesCurrentHistoryItem(type != FrameLoadTypeStandar d);
559 documentLoader()->updateForSameDocumentNavigation(newURL, sameDocumentNaviga tionSource); 561 documentLoader()->updateForSameDocumentNavigation(newURL, sameDocumentNaviga tionSource);
560 562
561 // Generate start and stop notifications only when loader is completed so th at we 563 // Generate start and stop notifications only when loader is completed so th at we
562 // don't fire them for fragment redirection that happens in window.onload ha ndler. 564 // don't fire them for fragment redirection that happens in window.onload ha ndler.
563 // See https://bugs.webkit.org/show_bug.cgi?id=31838 565 // See https://bugs.webkit.org/show_bug.cgi?id=31838
564 if (m_frame->document()->loadEventFinished()) 566 if (m_frame->document()->loadEventFinished())
565 client()->didStartLoading(NavigationWithinSameDocument); 567 client()->didStartLoading(NavigationWithinSameDocument);
(...skipping 17 matching lines...) Expand all
583 // If we have a provisional request for a different document, a fragment scr oll should cancel it. 585 // If we have a provisional request for a different document, a fragment scr oll should cancel it.
584 if (m_provisionalDocumentLoader) { 586 if (m_provisionalDocumentLoader) {
585 m_provisionalDocumentLoader->stopLoading(); 587 m_provisionalDocumentLoader->stopLoading();
586 if (m_provisionalDocumentLoader) 588 if (m_provisionalDocumentLoader)
587 m_provisionalDocumentLoader->detachFromFrame(); 589 m_provisionalDocumentLoader->detachFromFrame();
588 m_provisionalDocumentLoader = nullptr; 590 m_provisionalDocumentLoader = nullptr;
589 if (!m_frame->host()) 591 if (!m_frame->host())
590 return; 592 return;
591 } 593 }
592 m_loadType = type; 594 m_loadType = type;
593 saveScrollState();
594 595
595 KURL oldURL = m_frame->document()->url(); 596 KURL oldURL = m_frame->document()->url();
596 // If we were in the autoscroll/panScroll mode we want to stop it before fol lowing the link to the anchor 597 // If we were in the autoscroll/panScroll mode we want to stop it before fol lowing the link to the anchor
597 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme ntIdentifier() != oldURL.fragmentIdentifier(); 598 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme ntIdentifier() != oldURL.fragmentIdentifier();
598 if (hashChange) { 599 if (hashChange) {
599 m_frame->eventHandler().stopAutoscroll(); 600 m_frame->eventHandler().stopAutoscroll();
600 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url); 601 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url);
601 } 602 }
602 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); 603 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect);
603 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr, type); 604 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr, type);
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 // FIXME: We need a way to propagate insecure requests policy flags to 1436 // FIXME: We need a way to propagate insecure requests policy flags to
1436 // out-of-process frames. For now, we'll always use default behavior. 1437 // out-of-process frames. For now, we'll always use default behavior.
1437 if (!parentFrame->isLocalFrame()) 1438 if (!parentFrame->isLocalFrame())
1438 return nullptr; 1439 return nullptr;
1439 1440
1440 ASSERT(toLocalFrame(parentFrame)->document()); 1441 ASSERT(toLocalFrame(parentFrame)->document());
1441 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; 1442 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ;
1442 } 1443 }
1443 1444
1444 } // namespace blink 1445 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/navigation/same-document-scroll-position-restore-pushstate-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698