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

Side by Side Diff: third_party/WebKit/Source/core/loader/DocumentLoader.cpp

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, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. 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 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 // Don't propagate state from the old item if this is a different-document 347 // Don't propagate state from the old item if this is a different-document
348 // navigation, unless the before and after pages are logically related. This 348 // navigation, unless the before and after pages are logically related. This
349 // means they have the same url (ignoring fragment) and the new item was 349 // means they have the same url (ignoring fragment) and the new item was
350 // loaded via reload or client redirect. 350 // loaded via reload or client redirect.
351 HistoryCommitType history_commit_type = LoadTypeToCommitType(load_type); 351 HistoryCommitType history_commit_type = LoadTypeToCommitType(load_type);
352 if (navigation_type == HistoryNavigationType::kDifferentDocument && 352 if (navigation_type == HistoryNavigationType::kDifferentDocument &&
353 (history_commit_type != kHistoryInertCommit || 353 (history_commit_type != kHistoryInertCommit ||
354 !EqualIgnoringFragmentIdentifier(old_item->Url(), history_item_->Url()))) 354 !EqualIgnoringFragmentIdentifier(old_item->Url(), history_item_->Url())))
355 return; 355 return;
356 history_item_->SetDocumentSequenceNumber(old_item->DocumentSequenceNumber()); 356 history_item_->SetDocumentSequenceNumber(old_item->DocumentSequenceNumber());
357 history_item_->SetScrollOffset(old_item->GetScrollOffset()); 357
358 history_item_->SetDidSaveScrollOrScaleState( 358 if (HistoryItem::ScrollAndViewState* scroll_and_scale_state =
majidvp 2017/06/26 16:19:26 s/scroll_and_scale_state/scroll_and_view_state/ I
Nate Chapin 2017/07/11 22:17:59 Done.
359 old_item->DidSaveScrollOrScaleState()); 359 old_item->GetScrollAndViewState()) {
360 history_item_->SetVisualViewportScrollOffset( 360 history_item_->SetScrollOffset(scroll_and_scale_state->scroll_offset_);
361 old_item->VisualViewportScrollOffset()); 361 history_item_->SetVisualViewportScrollOffset(
362 history_item_->SetPageScaleFactor(old_item->PageScaleFactor()); 362 scroll_and_scale_state->visual_viewport_scroll_offset_);
363 history_item_->SetPageScaleFactor(
364 scroll_and_scale_state->page_scale_factor_);
365 }
366
363 history_item_->SetScrollRestorationType(old_item->ScrollRestorationType()); 367 history_item_->SetScrollRestorationType(old_item->ScrollRestorationType());
364 368
365 // The item sequence number determines whether items are "the same", such 369 // The item sequence number determines whether items are "the same", such
366 // back/forward navigation between items with the same item sequence number is 370 // back/forward navigation between items with the same item sequence number is
367 // a no-op. Only treat this as identical if the navigation did not create a 371 // a no-op. Only treat this as identical if the navigation did not create a
368 // back/forward entry and the url is identical or it was loaded via 372 // back/forward entry and the url is identical or it was loaded via
369 // history.replaceState(). 373 // history.replaceState().
370 if (history_commit_type == kHistoryInertCommit && 374 if (history_commit_type == kHistoryInertCommit &&
371 (navigation_type == HistoryNavigationType::kHistoryApi || 375 (navigation_type == HistoryNavigationType::kHistoryApi ||
372 old_item->Url() == history_item_->Url())) { 376 old_item->Url() == history_item_->Url())) {
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 InstallNewDocumentReason::kJavascriptURL, 1094 InstallNewDocumentReason::kJavascriptURL,
1091 kForceSynchronousParsing, KURL()); 1095 kForceSynchronousParsing, KURL());
1092 if (!source.IsNull()) 1096 if (!source.IsNull())
1093 writer_->AppendReplacingData(source); 1097 writer_->AppendReplacingData(source);
1094 EndWriting(); 1098 EndWriting();
1095 } 1099 }
1096 1100
1097 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); 1101 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader);
1098 1102
1099 } // namespace blink 1103 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698