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

Side by Side Diff: content/renderer/history_serialization.cc

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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/history/change-viewport-height-in-onpopstate.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/history_serialization.h" 5 #include "content/renderer/history_serialization.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/strings/nullable_string16.h" 9 #include "base/strings/nullable_string16.h"
10 #include "content/child/web_url_request_util.h" 10 #include "content/child/web_url_request_util.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 item.SetStateObject(WebSerializedScriptValue::FromString( 92 item.SetStateObject(WebSerializedScriptValue::FromString(
93 WebString::FromUTF16(state.state_object))); 93 WebString::FromUTF16(state.state_object)));
94 } 94 }
95 WebVector<WebString> document_state(state.document_state.size()); 95 WebVector<WebString> document_state(state.document_state.size());
96 std::transform(state.document_state.begin(), state.document_state.end(), 96 std::transform(state.document_state.begin(), state.document_state.end(),
97 document_state.begin(), [](const base::NullableString16& s) { 97 document_state.begin(), [](const base::NullableString16& s) {
98 return WebString::FromUTF16(s); 98 return WebString::FromUTF16(s);
99 }); 99 });
100 item.SetDocumentState(document_state); 100 item.SetDocumentState(document_state);
101 item.SetScrollRestorationType(state.scroll_restoration_type); 101 item.SetScrollRestorationType(state.scroll_restoration_type);
102 item.SetVisualViewportScrollOffset(state.visual_viewport_scroll_offset); 102
103 item.SetScrollOffset(state.scroll_offset); 103 if (state.did_save_scroll_or_scale_state) {
104 item.SetPageScaleFactor(state.page_scale_factor); 104 item.SetVisualViewportScrollOffset(state.visual_viewport_scroll_offset);
105 item.SetDidSaveScrollOrScaleState(state.did_save_scroll_or_scale_state); 105 item.SetScrollOffset(state.scroll_offset);
106 item.SetPageScaleFactor(state.page_scale_factor);
107 }
106 108
107 // These values are generated at WebHistoryItem construction time, and we 109 // These values are generated at WebHistoryItem construction time, and we
108 // only want to override those new values with old values if the old values 110 // only want to override those new values with old values if the old values
109 // are defined. A value of 0 means undefined in this context. 111 // are defined. A value of 0 means undefined in this context.
110 if (state.item_sequence_number) 112 if (state.item_sequence_number)
111 item.SetItemSequenceNumber(state.item_sequence_number); 113 item.SetItemSequenceNumber(state.item_sequence_number);
112 if (state.document_sequence_number) 114 if (state.document_sequence_number)
113 item.SetDocumentSequenceNumber(state.document_sequence_number); 115 item.SetDocumentSequenceNumber(state.document_sequence_number);
114 116
115 item.SetHTTPContentType( 117 item.SetHTTPContentType(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (!DecodePageState(page_state.ToEncodedData(), &state)) 155 if (!DecodePageState(page_state.ToEncodedData(), &state))
154 return std::unique_ptr<HistoryEntry>(); 156 return std::unique_ptr<HistoryEntry>();
155 157
156 std::unique_ptr<HistoryEntry> entry(new HistoryEntry()); 158 std::unique_ptr<HistoryEntry> entry(new HistoryEntry());
157 RecursivelyGenerateHistoryItem(state.top, entry->root_history_node()); 159 RecursivelyGenerateHistoryItem(state.top, entry->root_history_node());
158 160
159 return entry; 161 return entry;
160 } 162 }
161 163
162 } // namespace content 164 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/history/change-viewport-height-in-onpopstate.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698