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

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

Issue 1239463005: Replace history.options with history.scrollRestoration attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move setScrollRestorationType to History Created 5 years, 5 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 ea3bd5dbbd232be4911c51cb1358434c4043f7c8..aab102f73bc30b521744e7b96e011ff08dddc881 100644
--- a/Source/core/frame/History.cpp
+++ b/Source/core/frame/History.cpp
@@ -30,7 +30,6 @@
#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"
@@ -78,14 +77,35 @@ SerializedScriptValue* History::stateInternal() const
return 0;
}
-void History::options(StateOptions& options)
+void History::setScrollRestoration(const String& value)
{
- if (!m_frame)
+ ASSERT(value == "manual" || value == "auto");
+ if (!m_frame || !m_frame->loader().client() || !RuntimeEnabledFeatures::scrollRestorationEnabled())
+ return;
+
+ HistoryScrollRestorationType scrollRestoration = value == "manual" ? ScrollRestorationManual : ScrollRestorationAuto;
+ if (scrollRestoration == scrollRestorationInternal())
return;
if (HistoryItem* historyItem = m_frame->loader().currentItem()) {
- options.setScrollRestoration(historyItem->scrollRestorationType() == ScrollRestorationManual ? "manual" : "auto");
+ historyItem->setScrollRestorationType(scrollRestoration);
+ m_frame->loader().client()->didUpdateCurrentHistoryItem();
+ }
+}
+
+String History::scrollRestoration()
+{
+ return scrollRestorationInternal() == ScrollRestorationManual ? "manual" : "auto";
+}
+
+HistoryScrollRestorationType History::scrollRestorationInternal() const
+{
+ if (m_frame && RuntimeEnabledFeatures::scrollRestorationEnabled()) {
+ if (HistoryItem* historyItem = m_frame->loader().currentItem())
+ return historyItem->scrollRestorationType();
}
+
+ return ScrollRestorationAuto;
}
bool History::stateChanged() const
@@ -139,7 +159,7 @@ KURL History::urlForState(const String& urlString)
return KURL(document->baseURL(), urlString);
}
-void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const String& /* title */, const String& urlString, const StateOptions& options, FrameLoadType type, ExceptionState& exceptionState)
+void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const String& /* title */, const String& urlString, HistoryScrollRestorationType restorationType, FrameLoadType type, ExceptionState& exceptionState)
{
if (!m_frame || !m_frame->page() || !m_frame->loader().documentLoader())
return;
@@ -151,10 +171,6 @@ void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const Str
return;
}
- HistoryScrollRestorationType restorationType = ScrollRestorationAuto;
- if (RuntimeEnabledFeatures::scrollRestorationEnabled() && options.scrollRestoration() == "manual")
- restorationType = ScrollRestorationManual;
-
m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavigationHistoryApi, data, restorationType, type);
}
« 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