| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008, 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 static long long GenerateSequenceNumber() { | 37 static long long GenerateSequenceNumber() { |
| 38 // Initialize to the current time to reduce the likelihood of generating | 38 // Initialize to the current time to reduce the likelihood of generating |
| 39 // identifiers that overlap with those from past/future browser sessions. | 39 // identifiers that overlap with those from past/future browser sessions. |
| 40 static long long next = static_cast<long long>(CurrentTime() * 1000000.0); | 40 static long long next = static_cast<long long>(CurrentTime() * 1000000.0); |
| 41 return ++next; | 41 return ++next; |
| 42 } | 42 } |
| 43 | 43 |
| 44 HistoryItem::HistoryItem() | 44 HistoryItem::HistoryItem() |
| 45 : did_save_scroll_or_scale_state_(false), | 45 : scroll_and_view_state_(nullptr), |
| 46 page_scale_factor_(0), | |
| 47 item_sequence_number_(GenerateSequenceNumber()), | 46 item_sequence_number_(GenerateSequenceNumber()), |
| 48 document_sequence_number_(GenerateSequenceNumber()), | 47 document_sequence_number_(GenerateSequenceNumber()), |
| 49 scroll_restoration_type_(kScrollRestorationAuto) {} | 48 scroll_restoration_type_(kScrollRestorationAuto) {} |
| 50 | 49 |
| 51 HistoryItem::~HistoryItem() {} | 50 HistoryItem::~HistoryItem() {} |
| 52 | 51 |
| 53 const String& HistoryItem::UrlString() const { | 52 const String& HistoryItem::UrlString() const { |
| 54 return url_string_; | 53 return url_string_; |
| 55 } | 54 } |
| 56 | 55 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 70 void HistoryItem::SetURL(const KURL& url) { | 69 void HistoryItem::SetURL(const KURL& url) { |
| 71 SetURLString(url.GetString()); | 70 SetURLString(url.GetString()); |
| 72 } | 71 } |
| 73 | 72 |
| 74 void HistoryItem::SetReferrer(const Referrer& referrer) { | 73 void HistoryItem::SetReferrer(const Referrer& referrer) { |
| 75 // This should be a CHECK. | 74 // This should be a CHECK. |
| 76 referrer_ = SecurityPolicy::GenerateReferrer(referrer.referrer_policy, Url(), | 75 referrer_ = SecurityPolicy::GenerateReferrer(referrer.referrer_policy, Url(), |
| 77 referrer.referrer); | 76 referrer.referrer); |
| 78 } | 77 } |
| 79 | 78 |
| 80 const ScrollOffset& HistoryItem::VisualViewportScrollOffset() const { | |
| 81 return visual_viewport_scroll_offset_; | |
| 82 } | |
| 83 | |
| 84 void HistoryItem::SetVisualViewportScrollOffset(const ScrollOffset& offset) { | 79 void HistoryItem::SetVisualViewportScrollOffset(const ScrollOffset& offset) { |
| 85 visual_viewport_scroll_offset_ = offset; | 80 if (!scroll_and_view_state_) |
| 86 SetDidSaveScrollOrScaleState(true); | 81 scroll_and_view_state_ = ScrollAndViewState::Create(); |
| 87 } | 82 scroll_and_view_state_->visual_viewport_scroll_offset_ = offset; |
| 88 | |
| 89 const ScrollOffset& HistoryItem::GetScrollOffset() const { | |
| 90 return scroll_offset_; | |
| 91 } | 83 } |
| 92 | 84 |
| 93 void HistoryItem::SetScrollOffset(const ScrollOffset& offset) { | 85 void HistoryItem::SetScrollOffset(const ScrollOffset& offset) { |
| 94 scroll_offset_ = offset; | 86 if (!scroll_and_view_state_) |
| 95 SetDidSaveScrollOrScaleState(true); | 87 scroll_and_view_state_ = ScrollAndViewState::Create(); |
| 96 } | 88 scroll_and_view_state_->scroll_offset_ = offset; |
| 97 | |
| 98 float HistoryItem::PageScaleFactor() const { | |
| 99 return page_scale_factor_; | |
| 100 } | 89 } |
| 101 | 90 |
| 102 void HistoryItem::SetPageScaleFactor(float scale_factor) { | 91 void HistoryItem::SetPageScaleFactor(float scale_factor) { |
| 103 page_scale_factor_ = scale_factor; | 92 if (!scroll_and_view_state_) |
| 104 SetDidSaveScrollOrScaleState(true); | 93 scroll_and_view_state_ = ScrollAndViewState::Create(); |
| 94 scroll_and_view_state_->page_scale_factor_ = scale_factor; |
| 105 } | 95 } |
| 106 | 96 |
| 107 void HistoryItem::SetDocumentState(const Vector<String>& state) { | 97 void HistoryItem::SetDocumentState(const Vector<String>& state) { |
| 108 DCHECK(!document_state_); | 98 DCHECK(!document_state_); |
| 109 document_state_vector_ = state; | 99 document_state_vector_ = state; |
| 110 } | 100 } |
| 111 | 101 |
| 112 void HistoryItem::SetDocumentState(DocumentState* state) { | 102 void HistoryItem::SetDocumentState(DocumentState* state) { |
| 113 document_state_ = state; | 103 document_state_ = state; |
| 114 } | 104 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 request.SetHTTPMethod(HTTPNames::POST); | 160 request.SetHTTPMethod(HTTPNames::POST); |
| 171 request.SetHTTPBody(form_data_); | 161 request.SetHTTPBody(form_data_); |
| 172 request.SetHTTPContentType(form_content_type_); | 162 request.SetHTTPContentType(form_content_type_); |
| 173 request.AddHTTPOriginIfNeeded(referrer_.referrer); | 163 request.AddHTTPOriginIfNeeded(referrer_.referrer); |
| 174 } | 164 } |
| 175 return request; | 165 return request; |
| 176 } | 166 } |
| 177 | 167 |
| 178 DEFINE_TRACE(HistoryItem) { | 168 DEFINE_TRACE(HistoryItem) { |
| 179 visitor->Trace(document_state_); | 169 visitor->Trace(document_state_); |
| 170 visitor->Trace(scroll_and_view_state_); |
| 180 } | 171 } |
| 181 | 172 |
| 182 } // namespace blink | 173 } // namespace blink |
| OLD | NEW |