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

Side by Side Diff: third_party/WebKit/Source/core/frame/History.cpp

Issue 2710983003: Move HistoryItem handling to DocumentLoader (Closed)
Patch Set: Experiment to fix DCHECKing tests Created 3 years, 8 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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 SerializedScriptValue* History::state() { 71 SerializedScriptValue* History::state() {
72 m_lastStateObjectRequested = stateInternal(); 72 m_lastStateObjectRequested = stateInternal();
73 return m_lastStateObjectRequested.get(); 73 return m_lastStateObjectRequested.get();
74 } 74 }
75 75
76 SerializedScriptValue* History::stateInternal() const { 76 SerializedScriptValue* History::stateInternal() const {
77 if (!frame()) 77 if (!frame())
78 return 0; 78 return 0;
79 79
80 if (HistoryItem* historyItem = frame()->loader().currentItem()) 80 if (HistoryItem* historyItem =
81 frame()->loader().documentLoader()->historyItem()) {
yhirano 2017/03/29 09:38:13 Can |frame()->loader().documentLoader()| be null?
Nate Chapin 2017/03/29 18:23:06 I *think* it can't. FrameLoader::documentLoader()
81 return historyItem->stateObject(); 82 return historyItem->stateObject();
83 }
82 84
83 return 0; 85 return 0;
84 } 86 }
85 87
86 void History::setScrollRestoration(const String& value) { 88 void History::setScrollRestoration(const String& value) {
87 DCHECK(value == "manual" || value == "auto"); 89 DCHECK(value == "manual" || value == "auto");
88 if (!frame() || !frame()->loader().client()) 90 if (!frame() || !frame()->loader().client())
89 return; 91 return;
90 92
91 HistoryScrollRestorationType scrollRestoration = 93 HistoryScrollRestorationType scrollRestoration =
92 value == "manual" ? ScrollRestorationManual : ScrollRestorationAuto; 94 value == "manual" ? ScrollRestorationManual : ScrollRestorationAuto;
93 if (scrollRestoration == scrollRestorationInternal()) 95 if (scrollRestoration == scrollRestorationInternal())
94 return; 96 return;
95 97
96 if (HistoryItem* historyItem = frame()->loader().currentItem()) { 98 if (HistoryItem* historyItem =
99 frame()->loader().documentLoader()->historyItem()) {
97 historyItem->setScrollRestorationType(scrollRestoration); 100 historyItem->setScrollRestorationType(scrollRestoration);
98 frame()->loader().client()->didUpdateCurrentHistoryItem(); 101 frame()->loader().client()->didUpdateCurrentHistoryItem();
99 } 102 }
100 } 103 }
101 104
102 String History::scrollRestoration() { 105 String History::scrollRestoration() {
103 return scrollRestorationInternal() == ScrollRestorationManual ? "manual" 106 return scrollRestorationInternal() == ScrollRestorationManual ? "manual"
104 : "auto"; 107 : "auto";
105 } 108 }
106 109
107 HistoryScrollRestorationType History::scrollRestorationInternal() const { 110 HistoryScrollRestorationType History::scrollRestorationInternal() const {
108 if (frame()) { 111 HistoryItem* historyItem =
109 if (HistoryItem* historyItem = frame()->loader().currentItem()) 112 frame() ? frame()->loader().documentLoader()->historyItem() : nullptr;
110 return historyItem->scrollRestorationType(); 113 return historyItem ? historyItem->scrollRestorationType()
111 } 114 : ScrollRestorationAuto;
112
113 return ScrollRestorationAuto;
114 } 115 }
115 116
116 bool History::stateChanged() const { 117 bool History::stateChanged() const {
117 return m_lastStateObjectRequested != stateInternal(); 118 return m_lastStateObjectRequested != stateInternal();
118 } 119 }
119 120
120 bool History::isSameAsCurrentState(SerializedScriptValue* state) const { 121 bool History::isSameAsCurrentState(SerializedScriptValue* state) const {
121 return state == stateInternal(); 122 return state == stateInternal();
122 } 123 }
123 124
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 frame()->document()->url().elidedString() + "'."); 226 frame()->document()->url().elidedString() + "'.");
226 return; 227 return;
227 } 228 }
228 229
229 frame()->loader().updateForSameDocumentNavigation( 230 frame()->loader().updateForSameDocumentNavigation(
230 fullURL, SameDocumentNavigationHistoryApi, std::move(data), 231 fullURL, SameDocumentNavigationHistoryApi, std::move(data),
231 restorationType, type, frame()->document()); 232 restorationType, type, frame()->document());
232 } 233 }
233 234
234 } // namespace blink 235 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698