OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
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 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // that we keep track of the end of a page transition with m_frameLoadComple
te. We | 156 // that we keep track of the end of a page transition with m_frameLoadComple
te. We |
157 // leverage the checkLoadComplete recursion to achieve this goal. | 157 // leverage the checkLoadComplete recursion to achieve this goal. |
158 | 158 |
159 HistoryItem* item = m_frameLoadComplete ? m_currentItem.get() : m_previousIt
em.get(); | 159 HistoryItem* item = m_frameLoadComplete ? m_currentItem.get() : m_previousIt
em.get(); |
160 if (!item) | 160 if (!item) |
161 return; | 161 return; |
162 | 162 |
163 Document* document = m_frame->document(); | 163 Document* document = m_frame->document(); |
164 ASSERT(document); | 164 ASSERT(document); |
165 | 165 |
166 if (item->isCurrentDocument(document)) { | 166 if (item->isCurrentDocument(document) && document->attached()) { |
167 LOG(Loading, "WebCoreLoading %s: saving form state to %p", m_frame->tree
()->uniqueName().string().utf8().data(), item); | 167 LOG(Loading, "WebCoreLoading %s: saving form state to %p", m_frame->tree
()->uniqueName().string().utf8().data(), item); |
168 item->setDocumentState(document->formElementsState()); | 168 item->setDocumentState(document->formElementsState()); |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 // Walk the frame tree, telling all frames to save their form state into their c
urrent | 172 // Walk the frame tree, telling all frames to save their form state into their c
urrent |
173 // history item. | 173 // history item. |
174 void HistoryController::saveDocumentAndScrollState() | 174 void HistoryController::saveDocumentAndScrollState() |
175 { | 175 { |
176 for (Frame* frame = m_frame; frame; frame = frame->tree()->traverseNext(m_fr
ame)) { | 176 for (Frame* frame = m_frame; frame; frame = frame->tree()->traverseNext(m_fr
ame)) { |
177 frame->loader()->history()->saveDocumentState(); | 177 frame->loader()->history()->saveDocumentState(); |
178 frame->loader()->history()->saveScrollPositionAndViewStateToItem(frame->
loader()->history()->currentItem()); | 178 frame->loader()->history()->saveScrollPositionAndViewStateToItem(frame->
loader()->history()->currentItem()); |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
| 182 static inline bool isAssociatedToRequestedHistoryItem(const HistoryItem* current
, Frame* frame, const HistoryItem* requested) |
| 183 { |
| 184 if (requested == current) |
| 185 return true; |
| 186 if (requested) |
| 187 return false; |
| 188 while ((frame = frame->tree()->parent())) { |
| 189 requested = frame->loader()->requestedHistoryItem(); |
| 190 if (!requested) |
| 191 continue; |
| 192 if (requested->isAncestorOf(current)) |
| 193 return true; |
| 194 } |
| 195 return false; |
| 196 } |
| 197 |
182 void HistoryController::restoreDocumentState() | 198 void HistoryController::restoreDocumentState() |
183 { | 199 { |
184 Document* doc = m_frame->document(); | 200 Document* doc = m_frame->document(); |
185 | 201 |
186 HistoryItem* itemToRestore = 0; | 202 HistoryItem* itemToRestore = 0; |
187 | 203 |
188 switch (m_frame->loader()->loadType()) { | 204 switch (m_frame->loader()->loadType()) { |
189 case FrameLoadTypeReload: | 205 case FrameLoadTypeReload: |
190 case FrameLoadTypeReloadFromOrigin: | 206 case FrameLoadTypeReloadFromOrigin: |
191 case FrameLoadTypeSame: | 207 case FrameLoadTypeSame: |
192 case FrameLoadTypeReplace: | 208 case FrameLoadTypeReplace: |
193 break; | 209 break; |
194 case FrameLoadTypeBack: | 210 case FrameLoadTypeBack: |
195 case FrameLoadTypeForward: | 211 case FrameLoadTypeForward: |
196 case FrameLoadTypeIndexedBackForward: | 212 case FrameLoadTypeIndexedBackForward: |
197 case FrameLoadTypeRedirectWithLockedBackForwardList: | 213 case FrameLoadTypeRedirectWithLockedBackForwardList: |
198 case FrameLoadTypeStandard: | 214 case FrameLoadTypeStandard: |
199 itemToRestore = m_currentItem.get(); | 215 itemToRestore = m_currentItem.get(); |
200 } | 216 } |
201 | 217 |
202 if (!itemToRestore) | 218 if (!itemToRestore) |
203 return; | 219 return; |
204 if (m_frame->loader()->requestedHistoryItem() == m_currentItem.get() && !m_f
rame->loader()->documentLoader()->isClientRedirect()) { | 220 if (isAssociatedToRequestedHistoryItem(itemToRestore, m_frame, m_frame->load
er()->requestedHistoryItem()) && !m_frame->loader()->documentLoader()->isClientR
edirect()) { |
205 LOG(Loading, "WebCoreLoading %s: restoring form state from %p", m_frame-
>tree()->uniqueName().string().utf8().data(), itemToRestore); | 221 LOG(Loading, "WebCoreLoading %s: restoring form state from %p", m_frame-
>tree()->uniqueName().string().utf8().data(), itemToRestore); |
206 doc->setStateForNewFormElements(itemToRestore->documentState()); | 222 doc->setStateForNewFormElements(itemToRestore->documentState()); |
207 } | 223 } |
208 } | 224 } |
209 | 225 |
210 void HistoryController::invalidateCurrentItemCachedPage() | 226 void HistoryController::invalidateCurrentItemCachedPage() |
211 { | 227 { |
212 // When we are pre-commit, the currentItem is where the pageCache data resid
es | 228 // When we are pre-commit, the currentItem is where the pageCache data resid
es |
213 CachedPage* cachedPage = pageCache()->get(currentItem()); | 229 CachedPage* cachedPage = pageCache()->get(currentItem()); |
214 | 230 |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 Settings* settings = m_frame->settings(); | 880 Settings* settings = m_frame->settings(); |
865 if (!settings || settings->privateBrowsingEnabled()) | 881 if (!settings || settings->privateBrowsingEnabled()) |
866 return; | 882 return; |
867 | 883 |
868 ASSERT(m_frame->page()); | 884 ASSERT(m_frame->page()); |
869 addVisitedLink(m_frame->page(), KURL(ParsedURLString, urlString)); | 885 addVisitedLink(m_frame->page(), KURL(ParsedURLString, urlString)); |
870 m_frame->loader()->client()->updateGlobalHistory(); | 886 m_frame->loader()->client()->updateGlobalHistory(); |
871 } | 887 } |
872 | 888 |
873 } // namespace WebCore | 889 } // namespace WebCore |
OLD | NEW |