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

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: +test Created 3 years, 6 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 ScrollAndViewState : public GarbageCollected<ScrollAndViewState> {
majidvp 2017/06/26 16:19:26 I consider scroll position to be part of the view
Nate Chapin 2017/07/11 22:17:59 Done.
63 did_save_scroll_or_scale_state_ = did_save_scroll_or_scale_state; 63 public:
64 static ScrollAndViewState* Create() { return new ScrollAndViewState; }
65
66 ScrollOffset visual_viewport_scroll_offset_;
67 ScrollOffset scroll_offset_;
68 float page_scale_factor_;
69
70 DEFINE_INLINE_TRACE() {}
71
72 private:
73 ScrollAndViewState() : page_scale_factor_(0) {}
74 };
75
76 ScrollAndViewState* GetScrollAndViewState() const {
77 return scroll_and_view_state_;
78 }
79 void ClearScrollAndViewState() { scroll_and_view_state_ = nullptr; }
80 ScrollAndViewState* CopyScrollAndViewState() const {
81 if (!scroll_and_view_state_)
82 return nullptr;
83 ScrollAndViewState* copy = ScrollAndViewState::Create();
84 copy->visual_viewport_scroll_offset_ =
85 scroll_and_view_state_->visual_viewport_scroll_offset_;
86 copy->scroll_offset_ = scroll_and_view_state_->scroll_offset_;
87 copy->page_scale_factor_ = scroll_and_view_state_->page_scale_factor_;
majidvp 2017/06/26 16:19:26 This feels like it should be a copy constructor on
Nate Chapin 2017/07/11 22:17:59 Reworked class to not be GCed, so it can have a co
88 return copy;
64 } 89 }
65 90
66 bool DidSaveScrollOrScaleState() const {
67 return did_save_scroll_or_scale_state_;
68 }
69
70 const ScrollOffset& VisualViewportScrollOffset() const;
71 void SetVisualViewportScrollOffset(const ScrollOffset&); 91 void SetVisualViewportScrollOffset(const ScrollOffset&);
72 const ScrollOffset& GetScrollOffset() const;
73 void SetScrollOffset(const ScrollOffset&); 92 void SetScrollOffset(const ScrollOffset&);
74
75 float PageScaleFactor() const;
76 void SetPageScaleFactor(float); 93 void SetPageScaleFactor(float);
77 94
78 Vector<String> GetReferencedFilePaths(); 95 Vector<String> GetReferencedFilePaths();
79 const Vector<String>& GetDocumentState(); 96 const Vector<String>& GetDocumentState();
80 void SetDocumentState(const Vector<String>&); 97 void SetDocumentState(const Vector<String>&);
81 void SetDocumentState(DocumentState*); 98 void SetDocumentState(DocumentState*);
82 void ClearDocumentState(); 99 void ClearDocumentState();
83 100
84 void SetURL(const KURL&); 101 void SetURL(const KURL&);
85 void SetURLString(const String&); 102 void SetURLString(const String&);
(...skipping 26 matching lines...) Expand all
112 ResourceRequest GenerateResourceRequest(WebCachePolicy); 129 ResourceRequest GenerateResourceRequest(WebCachePolicy);
113 130
114 DECLARE_TRACE(); 131 DECLARE_TRACE();
115 132
116 private: 133 private:
117 HistoryItem(); 134 HistoryItem();
118 135
119 String url_string_; 136 String url_string_;
120 Referrer referrer_; 137 Referrer referrer_;
121 138
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_; 139 Vector<String> document_state_vector_;
127 Member<DocumentState> document_state_; 140 Member<DocumentState> document_state_;
128 141
142 Member<ScrollAndViewState> scroll_and_view_state_;
143
129 // If two HistoryItems have the same item sequence number, then they are 144 // If two HistoryItems have the same item sequence number, then they are
130 // clones of one another. Traversing history from one such HistoryItem to 145 // clones of one another. Traversing history from one such HistoryItem to
131 // another is a no-op. HistoryItem clones are created for parent and 146 // another is a no-op. HistoryItem clones are created for parent and
132 // sibling frames when only a subframe navigates. 147 // sibling frames when only a subframe navigates.
133 int64_t item_sequence_number_; 148 int64_t item_sequence_number_;
134 149
135 // If two HistoryItems have the same document sequence number, then they 150 // If two HistoryItems have the same document sequence number, then they
136 // refer to the same instance of a document. Traversing history from one 151 // refer to the same instance of a document. Traversing history from one
137 // such HistoryItem to another preserves the document. 152 // such HistoryItem to another preserves the document.
138 int64_t document_sequence_number_; 153 int64_t document_sequence_number_;
139 154
140 // Type of the scroll restoration for the history item determines if scroll 155 // Type of the scroll restoration for the history item determines if scroll
141 // position should be restored when it is loaded during history traversal. 156 // position should be restored when it is loaded during history traversal.
142 HistoryScrollRestorationType scroll_restoration_type_; 157 HistoryScrollRestorationType scroll_restoration_type_;
143 158
144 // Support for HTML5 History 159 // Support for HTML5 History
145 RefPtr<SerializedScriptValue> state_object_; 160 RefPtr<SerializedScriptValue> state_object_;
146 161
147 // info used to repost form data 162 // info used to repost form data
148 RefPtr<EncodedFormData> form_data_; 163 RefPtr<EncodedFormData> form_data_;
149 AtomicString form_content_type_; 164 AtomicString form_content_type_;
150 }; // class HistoryItem 165 }; // class HistoryItem
151 166
152 } // namespace blink 167 } // namespace blink
153 168
154 #endif // HISTORYITEM_H 169 #endif // HISTORYITEM_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698