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

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: minor cleanup 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
Index: Source/core/frame/History.cpp
diff --git a/Source/core/frame/History.cpp b/Source/core/frame/History.cpp
index ea3bd5dbbd232be4911c51cb1358434c4043f7c8..df19eb4ae844df01bac5e14d328fa091cf7fb97c 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,31 @@ SerializedScriptValue* History::stateInternal() const
return 0;
}
-void History::options(StateOptions& options)
+void History::setScrollRestoration(const String& value)
{
- if (!m_frame)
+ if (!m_frame || !m_frame->page() || !m_frame->loader().documentLoader() || !RuntimeEnabledFeatures::scrollRestorationEnabled())
+ return;
+
+ HistoryScrollRestorationType scrollRestoration = value == "manual" ? ScrollRestorationManual : ScrollRestorationAuto;
Nate Chapin 2015/07/16 21:34:01 My knowledge of the v8 bindings is outdated. Are w
majidvp 2015/07/16 22:11:49 Yes V8 bindings validates that only valid values a
+ if (scrollRestoration == scrollRestorationInternal())
return;
+ // Equivalent to calling replace on the same entry but with new scroll restoration option
+ m_frame->loader().updateForSameDocumentNavigation(m_frame->loader().currentItem()->url(), SameDocumentNavigationHistoryApi, stateInternal(), scrollRestoration, FrameLoadTypeReplaceCurrentItem);
Nate Chapin 2015/07/16 21:34:01 Why is this modeled as a navigation?
majidvp 2015/07/16 22:11:49 Hmm, perhaps it can be made simpler. I think all i
Nate Chapin 2015/07/16 22:19:32 It may not even need to notify FrameLoaderClient.
+}
+
+String History::scrollRestoration()
+{
+ return scrollRestorationInternal() == ScrollRestorationManual ? "manual" : "auto";
+}
- if (HistoryItem* historyItem = m_frame->loader().currentItem()) {
- options.setScrollRestoration(historyItem->scrollRestorationType() == 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 +155,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 +167,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);
}

Powered by Google App Engine
This is Rietveld 408576698