Chromium Code Reviews| Index: Source/core/frame/History.cpp |
| diff --git a/Source/core/frame/History.cpp b/Source/core/frame/History.cpp |
| index 4901cfd2ebd75d7397d2f1bed7dcbf5375e11777..60534501004c740bc6f36b92d355e2e7ad0ad47a 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.setWillRestoreScroll(!historyItem->shouldRestoreScroll()); |
|
Nate Chapin
2015/05/07 20:26:59
The name of this function implies it's a getter, b
majidvp
2015/05/08 21:00:46
Done.
|
| + } |
| +} |
| + |
| 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); |
| + |
| + bool shouldRestoreScroll = true; |
| + if (RuntimeEnabledFeatures::scrollRestorationEnabled()) |
| + shouldRestoreScroll = !options.willRestoreScroll(); |
|
Nate Chapin
2015/05/07 20:26:59
This inversion doesn't make sense, given the names
majidvp
2015/05/08 21:00:46
Done.
|
| + |
| + m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavigationHistoryApi, data, shouldRestoreScroll, type); |
| } |
| } // namespace blink |