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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 ~HistoryItem(); 52 ~HistoryItem();
53 53
54 const String& UrlString() const; 54 const String& UrlString() const;
55 KURL Url() const; 55 KURL Url() const;
56 56
57 const Referrer& GetReferrer() const; 57 const Referrer& GetReferrer() const;
58 58
59 EncodedFormData* FormData(); 59 EncodedFormData* FormData();
60 const AtomicString& FormContentType() const; 60 const AtomicString& FormContentType() const;
61 61
62 void SetDidSaveScrollOrScaleState(bool did_save_scroll_or_scale_state) { 62 class ViewState {
63 did_save_scroll_or_scale_state_ = did_save_scroll_or_scale_state; 63 public:
64 ViewState() : page_scale_factor_(0) {}
65 ViewState(const ViewState&) = default;
66
67 ScrollOffset visual_viewport_scroll_offset_;
68 ScrollOffset scroll_offset_;
69 float page_scale_factor_;
70 };
71
72 ViewState* GetViewState() const { return view_state_.get(); }
73 void ClearViewState() { view_state_.reset(); }
74 void CopyViewStateFrom(HistoryItem* other) {
75 if (other->view_state_)
76 view_state_ = WTF::MakeUnique<ViewState>(*other->view_state_.get());
77 else
78 view_state_.reset();
64 } 79 }
65 80
66 bool DidSaveScrollOrScaleState() const {
67 return did_save_scroll_or_scale_state_;
68 }
69
70 const ScrollOffset& VisualViewportScrollOffset() const;
71 void SetVisualViewportScrollOffset(const ScrollOffset&); 81 void SetVisualViewportScrollOffset(const ScrollOffset&);
72 const ScrollOffset& GetScrollOffset() const;
73 void SetScrollOffset(const ScrollOffset&); 82 void SetScrollOffset(const ScrollOffset&);
74
75 float PageScaleFactor() const;
76 void SetPageScaleFactor(float); 83 void SetPageScaleFactor(float);
77 84
78 Vector<String> GetReferencedFilePaths(); 85 Vector<String> GetReferencedFilePaths();
79 const Vector<String>& GetDocumentState(); 86 const Vector<String>& GetDocumentState();
80 void SetDocumentState(const Vector<String>&); 87 void SetDocumentState(const Vector<String>&);
81 void SetDocumentState(DocumentState*); 88 void SetDocumentState(DocumentState*);
82 void ClearDocumentState(); 89 void ClearDocumentState();
83 90
84 void SetURL(const KURL&); 91 void SetURL(const KURL&);
85 void SetURLString(const String&); 92 void SetURLString(const String&);
(...skipping 26 matching lines...) Expand all
112 ResourceRequest GenerateResourceRequest(WebCachePolicy); 119 ResourceRequest GenerateResourceRequest(WebCachePolicy);
113 120
114 DECLARE_TRACE(); 121 DECLARE_TRACE();
115 122
116 private: 123 private:
117 HistoryItem(); 124 HistoryItem();
118 125
119 String url_string_; 126 String url_string_;
120 Referrer referrer_; 127 Referrer referrer_;
121 128
122 bool did_save_scroll_or_scale_state_;
123 ScrollOffset visual_viewport_scroll_offset_;
124 ScrollOffset scroll_offset_;
125 float page_scale_factor_;
126 Vector<String> document_state_vector_; 129 Vector<String> document_state_vector_;
127 Member<DocumentState> document_state_; 130 Member<DocumentState> document_state_;
128 131
132 std::unique_ptr<ViewState> view_state_;
133
129 // If two HistoryItems have the same item sequence number, then they are 134 // If two HistoryItems have the same item sequence number, then they are
130 // clones of one another. Traversing history from one such HistoryItem to 135 // clones of one another. Traversing history from one such HistoryItem to
131 // another is a no-op. HistoryItem clones are created for parent and 136 // another is a no-op. HistoryItem clones are created for parent and
132 // sibling frames when only a subframe navigates. 137 // sibling frames when only a subframe navigates.
133 int64_t item_sequence_number_; 138 int64_t item_sequence_number_;
134 139
135 // If two HistoryItems have the same document sequence number, then they 140 // If two HistoryItems have the same document sequence number, then they
136 // refer to the same instance of a document. Traversing history from one 141 // refer to the same instance of a document. Traversing history from one
137 // such HistoryItem to another preserves the document. 142 // such HistoryItem to another preserves the document.
138 int64_t document_sequence_number_; 143 int64_t document_sequence_number_;
139 144
140 // Type of the scroll restoration for the history item determines if scroll 145 // Type of the scroll restoration for the history item determines if scroll
141 // position should be restored when it is loaded during history traversal. 146 // position should be restored when it is loaded during history traversal.
142 HistoryScrollRestorationType scroll_restoration_type_; 147 HistoryScrollRestorationType scroll_restoration_type_;
143 148
144 // Support for HTML5 History 149 // Support for HTML5 History
145 RefPtr<SerializedScriptValue> state_object_; 150 RefPtr<SerializedScriptValue> state_object_;
146 151
147 // info used to repost form data 152 // info used to repost form data
148 RefPtr<EncodedFormData> form_data_; 153 RefPtr<EncodedFormData> form_data_;
149 AtomicString form_content_type_; 154 AtomicString form_content_type_;
150 }; // class HistoryItem 155 }; // class HistoryItem
151 156
152 } // namespace blink 157 } // namespace blink
153 158
154 #endif // HISTORYITEM_H 159 #endif // HISTORYITEM_H
OLDNEW
« 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