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

Unified Diff: Source/core/frame/History.cpp

Issue 927213004: Accept options in history APIs to allow scroll restoration to be disabled (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/History.h ('k') | Source/core/frame/History.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/History.cpp
diff --git a/Source/core/frame/History.cpp b/Source/core/frame/History.cpp
index 4901cfd2ebd75d7397d2f1bed7dcbf5375e11777..3c20c233366f5e229d61d4bbb9fee405a7ce6995 100644
--- a/Source/core/frame/History.cpp
+++ b/Source/core/frame/History.cpp
@@ -30,11 +30,13 @@
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/frame/LocalFrame.h"
+#include "core/frame/StateOptions.h"
#include "core/loader/DocumentLoader.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
#include "core/loader/HistoryItem.h"
#include "core/page/Page.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/weborigin/KURL.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "wtf/MainThread.h"
@@ -76,6 +78,16 @@ SerializedScriptValue* History::stateInternal() const
return 0;
}
+void History::options(StateOptions& options)
+{
+ if (!m_frame)
+ return;
+
+ if (HistoryItem* historyItem = m_frame->loader().currentItem()) {
+ options.setScrollRestoration(historyItem->scrollRestorationType() == ScrollRestorationManual ? "manual" : "auto");
+ }
+}
+
bool History::stateChanged() const
{
return m_lastStateObjectRequested != stateInternal();
@@ -127,7 +139,7 @@ KURL History::urlForState(const String& urlString)
return KURL(document->baseURL(), urlString);
}
-void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const String& /* title */, const String& urlString, FrameLoadType type, ExceptionState& exceptionState)
+void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const String& /* title */, const String& urlString, const StateOptions& options, FrameLoadType type, ExceptionState& exceptionState)
{
if (!m_frame || !m_frame->page() || !m_frame->loader().documentLoader())
return;
@@ -138,7 +150,12 @@ void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const Str
exceptionState.throwSecurityError("A history state object with URL '" + fullURL.elidedString() + "' cannot be created in a document with origin '" + m_frame->document()->securityOrigin()->toString() + "'.");
return;
}
- m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavigationHistoryApi, data, type);
+
+ HistoryScrollRestorationType restorationType = ScrollRestorationAuto;
+ if (RuntimeEnabledFeatures::scrollRestorationEnabled() && options.scrollRestoration() == "manual")
+ restorationType = ScrollRestorationManual;
+
+ m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavigationHistoryApi, data, restorationType, type);
}
} // namespace blink
« no previous file with comments | « Source/core/frame/History.h ('k') | Source/core/frame/History.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698