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

Unified Diff: third_party/WebKit/Source/core/loader/HistoryItem.h

Issue 2949073002: Changing scroll and view state in onpopstate shouldn't overwrite back/forward state restore (Closed)
Patch Set: Reset ViewState when trying to copy from a nullptr Created 3 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: third_party/WebKit/Source/core/loader/HistoryItem.h
diff --git a/third_party/WebKit/Source/core/loader/HistoryItem.h b/third_party/WebKit/Source/core/loader/HistoryItem.h
index 4c5729c8ed32229d3eb78f877733ffbe24e79783..42c270e4396575e028a9f3b1c7d84f8e746e5b55 100644
--- a/third_party/WebKit/Source/core/loader/HistoryItem.h
+++ b/third_party/WebKit/Source/core/loader/HistoryItem.h
@@ -59,20 +59,27 @@ class CORE_EXPORT HistoryItem final
EncodedFormData* FormData();
const AtomicString& FormContentType() const;
- void SetDidSaveScrollOrScaleState(bool did_save_scroll_or_scale_state) {
- did_save_scroll_or_scale_state_ = did_save_scroll_or_scale_state;
+ class ViewState {
+ public:
+ ViewState() : page_scale_factor_(0) {}
+ ViewState(const ViewState&) = default;
+
+ ScrollOffset visual_viewport_scroll_offset_;
+ ScrollOffset scroll_offset_;
+ float page_scale_factor_;
+ };
+
+ ViewState* GetViewState() const { return view_state_.get(); }
+ void ClearViewState() { view_state_.reset(); }
+ void CopyViewStateFrom(HistoryItem* other) {
+ if (other->view_state_)
+ view_state_ = WTF::MakeUnique<ViewState>(*other->view_state_.get());
+ else
+ view_state_.reset();
}
- bool DidSaveScrollOrScaleState() const {
- return did_save_scroll_or_scale_state_;
- }
-
- const ScrollOffset& VisualViewportScrollOffset() const;
void SetVisualViewportScrollOffset(const ScrollOffset&);
- const ScrollOffset& GetScrollOffset() const;
void SetScrollOffset(const ScrollOffset&);
-
- float PageScaleFactor() const;
void SetPageScaleFactor(float);
Vector<String> GetReferencedFilePaths();
@@ -119,13 +126,11 @@ class CORE_EXPORT HistoryItem final
String url_string_;
Referrer referrer_;
- bool did_save_scroll_or_scale_state_;
- ScrollOffset visual_viewport_scroll_offset_;
- ScrollOffset scroll_offset_;
- float page_scale_factor_;
Vector<String> document_state_vector_;
Member<DocumentState> document_state_;
+ std::unique_ptr<ViewState> view_state_;
+
// If two HistoryItems have the same item sequence number, then they are
// clones of one another. Traversing history from one such HistoryItem to
// another is a no-op. HistoryItem clones are created for parent and
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameLoader.cpp ('k') | third_party/WebKit/Source/core/loader/HistoryItem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698