OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
8 * Copyright (C) 2011 Google Inc. All rights reserved. | 8 * Copyright (C) 2011 Google Inc. All rights reserved. |
9 * | 9 * |
10 * Redistribution and use in source and binary forms, with or without | 10 * Redistribution and use in source and binary forms, with or without |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 if (Document* doc = m_frame->document()) { | 166 if (Document* doc = m_frame->document()) { |
167 // FIXME: HTML5 doesn't tell us to set the state to complete when aborti
ng, but we do anyway to match legacy behavior. | 167 // FIXME: HTML5 doesn't tell us to set the state to complete when aborti
ng, but we do anyway to match legacy behavior. |
168 // http://www.w3.org/Bugs/Public/show_bug.cgi?id=10537 | 168 // http://www.w3.org/Bugs/Public/show_bug.cgi?id=10537 |
169 doc->setReadyState(Document::Complete); | 169 doc->setReadyState(Document::Complete); |
170 } | 170 } |
171 | 171 |
172 // FIXME: This will cancel redirection timer, which really needs to be resta
rted when restoring the frame from b/f cache. | 172 // FIXME: This will cancel redirection timer, which really needs to be resta
rted when restoring the frame from b/f cache. |
173 m_frame->navigationScheduler().cancel(); | 173 m_frame->navigationScheduler().cancel(); |
174 } | 174 } |
175 | 175 |
176 void FrameLoader::markDocumentStateDirty() | |
177 { | |
178 Document* document = m_frame->document(); | |
179 document->setHistoryItemDocumentStateDirty(true); | |
180 m_client->didUpdateCurrentHistoryItem(); | |
181 } | |
182 | |
183 void FrameLoader::saveDocumentState() | |
184 { | |
185 Document* document = m_frame->document(); | |
186 if (!m_currentItem || !document->historyItemDocumentStateDirty()) | |
187 return; | |
188 | |
189 if (m_currentItem->isCurrentDocument(document) && document->isActive()) | |
190 m_currentItem->setDocumentState(document->formElementsState()); | |
191 | |
192 document->setHistoryItemDocumentStateDirty(false); | |
193 } | |
194 | |
195 void FrameLoader::saveScrollState() | 176 void FrameLoader::saveScrollState() |
196 { | 177 { |
197 if (!m_currentItem || !m_frame->view()) | 178 if (!m_currentItem || !m_frame->view()) |
198 return; | 179 return; |
199 | 180 |
200 // Shouldn't clobber anything if we might still restore later. | 181 // Shouldn't clobber anything if we might still restore later. |
201 if (needsHistoryItemRestore(m_loadType) && !m_frame->view()->wasScrolledByUs
er()) | 182 if (needsHistoryItemRestore(m_loadType) && !m_frame->view()->wasScrolledByUs
er()) |
202 return; | 183 return; |
203 | 184 |
204 m_currentItem->setScrollPoint(m_frame->view()->scrollPosition()); | 185 m_currentItem->setScrollPoint(m_frame->view()->scrollPosition()); |
205 if (m_frame->isMainFrame() && !m_frame->page()->inspectorController().device
EmulationEnabled()) | 186 if (m_frame->isMainFrame() && !m_frame->page()->inspectorController().device
EmulationEnabled()) |
206 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor()); | 187 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor()); |
207 | 188 |
208 m_client->didUpdateCurrentHistoryItem(); | 189 m_client->didUpdateCurrentHistoryItem(); |
209 } | 190 } |
210 | 191 |
211 void FrameLoader::clearScrollPositionAndViewState() | 192 void FrameLoader::clearScrollPositionAndViewState() |
212 { | 193 { |
213 ASSERT(m_frame->isMainFrame()); | 194 ASSERT(m_frame->isMainFrame()); |
214 if (!m_currentItem) | 195 if (!m_currentItem) |
215 return; | 196 return; |
216 m_currentItem->clearScrollPoint(); | 197 m_currentItem->clearScrollPoint(); |
217 m_currentItem->setPageScaleFactor(0); | 198 m_currentItem->setPageScaleFactor(0); |
218 } | 199 } |
219 | 200 |
220 bool FrameLoader::closeURL() | 201 bool FrameLoader::closeURL() |
221 { | 202 { |
222 saveDocumentState(); | |
223 saveScrollState(); | 203 saveScrollState(); |
224 | 204 |
225 // Should only send the pagehide event here if the current document exists. | 205 // Should only send the pagehide event here if the current document exists. |
226 if (m_frame->document()) | 206 if (m_frame->document()) |
227 m_frame->document()->dispatchUnloadEvents(); | 207 m_frame->document()->dispatchUnloadEvents(); |
228 stopLoading(); | 208 stopLoading(); |
229 | 209 |
230 if (Page* page = m_frame->page()) | 210 if (Page* page = m_frame->page()) |
231 page->undoStack().didUnloadFrame(*m_frame); | 211 page->undoStack().didUnloadFrame(*m_frame); |
232 return true; | 212 return true; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 255 |
276 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy
pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject) | 256 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy
pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject) |
277 { | 257 { |
278 if (m_provisionalItem) | 258 if (m_provisionalItem) |
279 m_currentItem = m_provisionalItem.release(); | 259 m_currentItem = m_provisionalItem.release(); |
280 if (!m_currentItem || historyCommitType == StandardCommit) | 260 if (!m_currentItem || historyCommitType == StandardCommit) |
281 m_currentItem = HistoryItem::create(); | 261 m_currentItem = HistoryItem::create(); |
282 else if (!isPushOrReplaceState && m_documentLoader->url() != m_currentItem->
url()) | 262 else if (!isPushOrReplaceState && m_documentLoader->url() != m_currentItem->
url()) |
283 m_currentItem->generateNewSequenceNumbers(); | 263 m_currentItem->generateNewSequenceNumbers(); |
284 m_currentItem->setURL(m_documentLoader->urlForHistory()); | 264 m_currentItem->setURL(m_documentLoader->urlForHistory()); |
| 265 m_currentItem->setDocumentState(m_frame->document()->formElementsState()); |
285 m_currentItem->setTarget(m_frame->tree().uniqueName()); | 266 m_currentItem->setTarget(m_frame->tree().uniqueName()); |
286 if (isPushOrReplaceState) | 267 if (isPushOrReplaceState) |
287 m_currentItem->setStateObject(stateObject); | 268 m_currentItem->setStateObject(stateObject); |
288 m_currentItem->setReferrer(Referrer(m_documentLoader->request().httpReferrer
(), m_documentLoader->request().referrerPolicy())); | 269 m_currentItem->setReferrer(Referrer(m_documentLoader->request().httpReferrer
(), m_documentLoader->request().referrerPolicy())); |
289 m_currentItem->setFormInfoFromRequest(isPushOrReplaceState ? ResourceRequest
() : m_documentLoader->request()); | 270 m_currentItem->setFormInfoFromRequest(isPushOrReplaceState ? ResourceRequest
() : m_documentLoader->request()); |
290 } | 271 } |
291 | 272 |
292 static HistoryCommitType loadTypeToCommitType(FrameLoadType type, bool isValidHi
storyURL) | 273 static HistoryCommitType loadTypeToCommitType(FrameLoadType type, bool isValidHi
storyURL) |
293 { | 274 { |
294 switch (type) { | 275 switch (type) { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 // If we have a state object, we cannot also be a new navigation. | 532 // If we have a state object, we cannot also be a new navigation. |
552 ASSERT(!stateObject || updateBackForwardList == DoNotUpdateBackForwardList); | 533 ASSERT(!stateObject || updateBackForwardList == DoNotUpdateBackForwardList); |
553 | 534 |
554 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. | 535 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. |
555 if (m_provisionalDocumentLoader) { | 536 if (m_provisionalDocumentLoader) { |
556 m_provisionalDocumentLoader->stopLoading(); | 537 m_provisionalDocumentLoader->stopLoading(); |
557 if (m_provisionalDocumentLoader) | 538 if (m_provisionalDocumentLoader) |
558 m_provisionalDocumentLoader->detachFromFrame(); | 539 m_provisionalDocumentLoader->detachFromFrame(); |
559 m_provisionalDocumentLoader = nullptr; | 540 m_provisionalDocumentLoader = nullptr; |
560 } | 541 } |
561 saveDocumentState(); | |
562 saveScrollState(); | 542 saveScrollState(); |
563 | 543 |
564 KURL oldURL = m_frame->document()->url(); | 544 KURL oldURL = m_frame->document()->url(); |
565 // If we were in the autoscroll/panScroll mode we want to stop it before fol
lowing the link to the anchor | 545 // If we were in the autoscroll/panScroll mode we want to stop it before fol
lowing the link to the anchor |
566 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); | 546 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme
ntIdentifier() != oldURL.fragmentIdentifier(); |
567 if (hashChange) { | 547 if (hashChange) { |
568 m_frame->eventHandler().stopAutoscroll(); | 548 m_frame->eventHandler().stopAutoscroll(); |
569 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url); | 549 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url); |
570 } | 550 } |
571 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); | 551 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 { | 1397 { |
1418 SandboxFlags flags = m_forcedSandboxFlags; | 1398 SandboxFlags flags = m_forcedSandboxFlags; |
1419 if (LocalFrame* parentFrame = m_frame->tree().parent()) | 1399 if (LocalFrame* parentFrame = m_frame->tree().parent()) |
1420 flags |= parentFrame->document()->sandboxFlags(); | 1400 flags |= parentFrame->document()->sandboxFlags(); |
1421 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) | 1401 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) |
1422 flags |= ownerElement->sandboxFlags(); | 1402 flags |= ownerElement->sandboxFlags(); |
1423 return flags; | 1403 return flags; |
1424 } | 1404 } |
1425 | 1405 |
1426 } // namespace WebCore | 1406 } // namespace WebCore |
OLD | NEW |