| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // leverage the checkLoadComplete recursion to achieve this goal. | 179 // leverage the checkLoadComplete recursion to achieve this goal. |
| 180 | 180 |
| 181 HistoryItem* item = m_frameLoadComplete ? m_currentItem.get() : m_previousIt
em.get(); | 181 HistoryItem* item = m_frameLoadComplete ? m_currentItem.get() : m_previousIt
em.get(); |
| 182 if (!item) | 182 if (!item) |
| 183 return; | 183 return; |
| 184 | 184 |
| 185 Document* document = m_frame->document(); | 185 Document* document = m_frame->document(); |
| 186 ASSERT(document); | 186 ASSERT(document); |
| 187 | 187 |
| 188 if (item->isCurrentDocument(document) && document->attached()) { | 188 if (item->isCurrentDocument(document) && document->attached()) { |
| 189 LOG(Loading, "WebCoreLoading %s: saving form state to %p", m_frame->tree
()->uniqueName().string().utf8().data(), item); | 189 LOG_INFO(Loading, "WebCoreLoading %s: saving form state to %p", m_frame-
>tree()->uniqueName().string().utf8().data(), item); |
| 190 item->setDocumentState(document->formElementsState()); | 190 item->setDocumentState(document->formElementsState()); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 | 193 |
| 194 // Walk the frame tree, telling all frames to save their form state into their c
urrent | 194 // Walk the frame tree, telling all frames to save their form state into their c
urrent |
| 195 // history item. | 195 // history item. |
| 196 void HistoryController::saveDocumentAndScrollState() | 196 void HistoryController::saveDocumentAndScrollState() |
| 197 { | 197 { |
| 198 for (Frame* frame = m_frame; frame; frame = frame->tree()->traverseNext(m_fr
ame)) { | 198 for (Frame* frame = m_frame; frame; frame = frame->tree()->traverseNext(m_fr
ame)) { |
| 199 frame->loader()->history()->saveDocumentState(); | 199 frame->loader()->history()->saveDocumentState(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 case FrameLoadTypeForward: | 233 case FrameLoadTypeForward: |
| 234 case FrameLoadTypeIndexedBackForward: | 234 case FrameLoadTypeIndexedBackForward: |
| 235 case FrameLoadTypeRedirectWithLockedBackForwardList: | 235 case FrameLoadTypeRedirectWithLockedBackForwardList: |
| 236 case FrameLoadTypeStandard: | 236 case FrameLoadTypeStandard: |
| 237 itemToRestore = m_currentItem.get(); | 237 itemToRestore = m_currentItem.get(); |
| 238 } | 238 } |
| 239 | 239 |
| 240 if (!itemToRestore) | 240 if (!itemToRestore) |
| 241 return; | 241 return; |
| 242 if (isAssociatedToRequestedHistoryItem(itemToRestore, m_frame, m_frame->load
er()->requestedHistoryItem()) && !m_frame->loader()->documentLoader()->isClientR
edirect()) { | 242 if (isAssociatedToRequestedHistoryItem(itemToRestore, m_frame, m_frame->load
er()->requestedHistoryItem()) && !m_frame->loader()->documentLoader()->isClientR
edirect()) { |
| 243 LOG(Loading, "WebCoreLoading %s: restoring form state from %p", m_frame-
>tree()->uniqueName().string().utf8().data(), itemToRestore); | 243 LOG_INFO(Loading, "WebCoreLoading %s: restoring form state from %p", m_f
rame->tree()->uniqueName().string().utf8().data(), itemToRestore); |
| 244 doc->setStateForNewFormElements(itemToRestore->documentState()); | 244 doc->setStateForNewFormElements(itemToRestore->documentState()); |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 void HistoryController::invalidateCurrentItemCachedPage() | 248 void HistoryController::invalidateCurrentItemCachedPage() |
| 249 { | 249 { |
| 250 // When we are pre-commit, the currentItem is where the pageCache data resid
es | 250 // When we are pre-commit, the currentItem is where the pageCache data resid
es |
| 251 CachedPage* cachedPage = pageCache()->get(currentItem()); | 251 CachedPage* cachedPage = pageCache()->get(currentItem()); |
| 252 | 252 |
| 253 // FIXME: This is a grotesque hack to fix <rdar://problem/4059059> Crash in
RenderFlow::detach | 253 // FIXME: This is a grotesque hack to fix <rdar://problem/4059059> Crash in
RenderFlow::detach |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 if (!defer && m_deferredItem) { | 319 if (!defer && m_deferredItem) { |
| 320 goToItem(m_deferredItem.get(), m_deferredFrameLoadType); | 320 goToItem(m_deferredItem.get(), m_deferredFrameLoadType); |
| 321 m_deferredItem = 0; | 321 m_deferredItem = 0; |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 | 324 |
| 325 void HistoryController::updateForBackForwardNavigation() | 325 void HistoryController::updateForBackForwardNavigation() |
| 326 { | 326 { |
| 327 #if !LOG_DISABLED | 327 #if !LOG_DISABLED |
| 328 if (m_frame->loader()->documentLoader()) | 328 if (m_frame->loader()->documentLoader()) |
| 329 LOG(History, "WebCoreHistory: Updating History for back/forward navigati
on in frame %s", m_frame->loader()->documentLoader()->title().string().utf8().da
ta()); | 329 LOG_INFO(History, "WebCoreHistory: Updating History for back/forward nav
igation in frame %s", m_frame->loader()->documentLoader()->title().string().utf8
().data()); |
| 330 #endif | 330 #endif |
| 331 | 331 |
| 332 // Must grab the current scroll position before disturbing it | 332 // Must grab the current scroll position before disturbing it |
| 333 if (!m_frameLoadComplete) | 333 if (!m_frameLoadComplete) |
| 334 saveScrollPositionAndViewStateToItem(m_previousItem.get()); | 334 saveScrollPositionAndViewStateToItem(m_previousItem.get()); |
| 335 | 335 |
| 336 // When traversing history, we may end up redirecting to a different URL | 336 // When traversing history, we may end up redirecting to a different URL |
| 337 // this time (e.g., due to cookies). See http://webkit.org/b/49654. | 337 // this time (e.g., due to cookies). See http://webkit.org/b/49654. |
| 338 updateCurrentItem(); | 338 updateCurrentItem(); |
| 339 } | 339 } |
| 340 | 340 |
| 341 void HistoryController::updateForReload() | 341 void HistoryController::updateForReload() |
| 342 { | 342 { |
| 343 #if !LOG_DISABLED | 343 #if !LOG_DISABLED |
| 344 if (m_frame->loader()->documentLoader()) | 344 if (m_frame->loader()->documentLoader()) |
| 345 LOG(History, "WebCoreHistory: Updating History for reload in frame %s",
m_frame->loader()->documentLoader()->title().string().utf8().data()); | 345 LOG_INFO(History, "WebCoreHistory: Updating History for reload in frame
%s", m_frame->loader()->documentLoader()->title().string().utf8().data()); |
| 346 #endif | 346 #endif |
| 347 | 347 |
| 348 if (m_currentItem) { | 348 if (m_currentItem) { |
| 349 pageCache()->remove(m_currentItem.get()); | 349 pageCache()->remove(m_currentItem.get()); |
| 350 | 350 |
| 351 if (m_frame->loader()->loadType() == FrameLoadTypeReload || m_frame->loa
der()->loadType() == FrameLoadTypeReloadFromOrigin) | 351 if (m_frame->loader()->loadType() == FrameLoadTypeReload || m_frame->loa
der()->loadType() == FrameLoadTypeReloadFromOrigin) |
| 352 saveScrollPositionAndViewStateToItem(m_currentItem.get()); | 352 saveScrollPositionAndViewStateToItem(m_currentItem.get()); |
| 353 } | 353 } |
| 354 | 354 |
| 355 // When reloading the page, we may end up redirecting to a different URL | 355 // When reloading the page, we may end up redirecting to a different URL |
| 356 // this time (e.g., due to cookies). See http://webkit.org/b/4072. | 356 // this time (e.g., due to cookies). See http://webkit.org/b/4072. |
| 357 updateCurrentItem(); | 357 updateCurrentItem(); |
| 358 } | 358 } |
| 359 | 359 |
| 360 // There are 3 things you might think of as "history", all of which are handled
by these functions. | 360 // There are 3 things you might think of as "history", all of which are handled
by these functions. |
| 361 // | 361 // |
| 362 // 1) Back/forward: The m_currentItem is part of this mechanism. | 362 // 1) Back/forward: The m_currentItem is part of this mechanism. |
| 363 // 2) Global history: Handled by the client. | 363 // 2) Global history: Handled by the client. |
| 364 // 3) Visited links: Handled by the PageGroup. | 364 // 3) Visited links: Handled by the PageGroup. |
| 365 | 365 |
| 366 void HistoryController::updateForStandardLoad(HistoryUpdateType updateType) | 366 void HistoryController::updateForStandardLoad(HistoryUpdateType updateType) |
| 367 { | 367 { |
| 368 LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s
", m_frame->loader()->documentLoader()->url().string().ascii().data()); | 368 LOG_INFO(History, "WebCoreHistory: Updating History for Standard Load in fra
me %s", m_frame->loader()->documentLoader()->url().string().ascii().data()); |
| 369 | 369 |
| 370 FrameLoader* frameLoader = m_frame->loader(); | 370 FrameLoader* frameLoader = m_frame->loader(); |
| 371 | 371 |
| 372 Settings* settings = m_frame->settings(); | 372 Settings* settings = m_frame->settings(); |
| 373 bool needPrivacy = !settings || settings->privateBrowsingEnabled(); | 373 bool needPrivacy = !settings || settings->privateBrowsingEnabled(); |
| 374 const KURL& historyURL = frameLoader->documentLoader()->urlForHistory(); | 374 const KURL& historyURL = frameLoader->documentLoader()->urlForHistory(); |
| 375 | 375 |
| 376 if (!frameLoader->documentLoader()->isClientRedirect()) { | 376 if (!frameLoader->documentLoader()->isClientRedirect()) { |
| 377 if (!historyURL.isEmpty()) { | 377 if (!historyURL.isEmpty()) { |
| 378 if (updateType != UpdateAllExceptBackForwardList) | 378 if (updateType != UpdateAllExceptBackForwardList) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 397 | 397 |
| 398 if (!frameLoader->documentLoader()->didCreateGlobalHistoryEntry() && fra
meLoader->documentLoader()->unreachableURL().isEmpty() && !m_frame->document()->
url().isEmpty()) | 398 if (!frameLoader->documentLoader()->didCreateGlobalHistoryEntry() && fra
meLoader->documentLoader()->unreachableURL().isEmpty() && !m_frame->document()->
url().isEmpty()) |
| 399 frameLoader->client()->updateGlobalHistoryRedirectLinks(); | 399 frameLoader->client()->updateGlobalHistoryRedirectLinks(); |
| 400 } | 400 } |
| 401 } | 401 } |
| 402 | 402 |
| 403 void HistoryController::updateForRedirectWithLockedBackForwardList() | 403 void HistoryController::updateForRedirectWithLockedBackForwardList() |
| 404 { | 404 { |
| 405 #if !LOG_DISABLED | 405 #if !LOG_DISABLED |
| 406 if (m_frame->loader()->documentLoader()) | 406 if (m_frame->loader()->documentLoader()) |
| 407 LOG(History, "WebCoreHistory: Updating History for redirect load in fram
e %s", m_frame->loader()->documentLoader()->title().string().utf8().data()); | 407 LOG_INFO(History, "WebCoreHistory: Updating History for redirect load in
frame %s", m_frame->loader()->documentLoader()->title().string().utf8().data())
; |
| 408 #endif | 408 #endif |
| 409 | 409 |
| 410 Settings* settings = m_frame->settings(); | 410 Settings* settings = m_frame->settings(); |
| 411 bool needPrivacy = !settings || settings->privateBrowsingEnabled(); | 411 bool needPrivacy = !settings || settings->privateBrowsingEnabled(); |
| 412 const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory(
); | 412 const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory(
); |
| 413 | 413 |
| 414 if (m_frame->loader()->documentLoader()->isClientRedirect()) { | 414 if (m_frame->loader()->documentLoader()->isClientRedirect()) { |
| 415 if (!m_currentItem && !m_frame->tree()->parent()) { | 415 if (!m_currentItem && !m_frame->tree()->parent()) { |
| 416 if (!historyURL.isEmpty()) { | 416 if (!historyURL.isEmpty()) { |
| 417 updateBackForwardListClippedAtTarget(true); | 417 updateBackForwardListClippedAtTarget(true); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 439 | 439 |
| 440 if (!m_frame->loader()->documentLoader()->didCreateGlobalHistoryEntry()
&& m_frame->loader()->documentLoader()->unreachableURL().isEmpty() && !m_frame->
document()->url().isEmpty()) | 440 if (!m_frame->loader()->documentLoader()->didCreateGlobalHistoryEntry()
&& m_frame->loader()->documentLoader()->unreachableURL().isEmpty() && !m_frame->
document()->url().isEmpty()) |
| 441 m_frame->loader()->client()->updateGlobalHistoryRedirectLinks(); | 441 m_frame->loader()->client()->updateGlobalHistoryRedirectLinks(); |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 | 444 |
| 445 void HistoryController::updateForClientRedirect() | 445 void HistoryController::updateForClientRedirect() |
| 446 { | 446 { |
| 447 #if !LOG_DISABLED | 447 #if !LOG_DISABLED |
| 448 if (m_frame->loader()->documentLoader()) | 448 if (m_frame->loader()->documentLoader()) |
| 449 LOG(History, "WebCoreHistory: Updating History for client redirect in fr
ame %s", m_frame->loader()->documentLoader()->title().string().utf8().data()); | 449 LOG_INFO(History, "WebCoreHistory: Updating History for client redirect
in frame %s", m_frame->loader()->documentLoader()->title().string().utf8().data(
)); |
| 450 #endif | 450 #endif |
| 451 | 451 |
| 452 // Clear out form data so we don't try to restore it into the incoming page.
Must happen after | 452 // Clear out form data so we don't try to restore it into the incoming page.
Must happen after |
| 453 // webcore has closed the URL and saved away the form state. | 453 // webcore has closed the URL and saved away the form state. |
| 454 if (m_currentItem) { | 454 if (m_currentItem) { |
| 455 m_currentItem->clearDocumentState(); | 455 m_currentItem->clearDocumentState(); |
| 456 m_currentItem->clearScrollPoint(); | 456 m_currentItem->clearScrollPoint(); |
| 457 } | 457 } |
| 458 | 458 |
| 459 Settings* settings = m_frame->settings(); | 459 Settings* settings = m_frame->settings(); |
| 460 bool needPrivacy = !settings || settings->privateBrowsingEnabled(); | 460 bool needPrivacy = !settings || settings->privateBrowsingEnabled(); |
| 461 const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory(
); | 461 const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory(
); |
| 462 | 462 |
| 463 if (!historyURL.isEmpty() && !needPrivacy) { | 463 if (!historyURL.isEmpty() && !needPrivacy) { |
| 464 if (Page* page = m_frame->page()) | 464 if (Page* page = m_frame->page()) |
| 465 addVisitedLink(page, historyURL); | 465 addVisitedLink(page, historyURL); |
| 466 } | 466 } |
| 467 } | 467 } |
| 468 | 468 |
| 469 void HistoryController::updateForCommit() | 469 void HistoryController::updateForCommit() |
| 470 { | 470 { |
| 471 FrameLoader* frameLoader = m_frame->loader(); | 471 FrameLoader* frameLoader = m_frame->loader(); |
| 472 #if !LOG_DISABLED | 472 #if !LOG_DISABLED |
| 473 if (frameLoader->documentLoader()) | 473 if (frameLoader->documentLoader()) |
| 474 LOG(History, "WebCoreHistory: Updating History for commit in frame %s",
frameLoader->documentLoader()->title().string().utf8().data()); | 474 LOG_INFO(History, "WebCoreHistory: Updating History for commit in frame
%s", frameLoader->documentLoader()->title().string().utf8().data()); |
| 475 #endif | 475 #endif |
| 476 FrameLoadType type = frameLoader->loadType(); | 476 FrameLoadType type = frameLoader->loadType(); |
| 477 if (isBackForwardLoadType(type) | 477 if (isBackForwardLoadType(type) |
| 478 || isReplaceLoadTypeWithProvisionalItem(type) | 478 || isReplaceLoadTypeWithProvisionalItem(type) |
| 479 || (isReloadTypeWithProvisionalItem(type) && !frameLoader->provisionalDo
cumentLoader()->unreachableURL().isEmpty())) { | 479 || (isReloadTypeWithProvisionalItem(type) && !frameLoader->provisionalDo
cumentLoader()->unreachableURL().isEmpty())) { |
| 480 // Once committed, we want to use current item for saving DocState, and | 480 // Once committed, we want to use current item for saving DocState, and |
| 481 // the provisional item for restoring state. | 481 // the provisional item for restoring state. |
| 482 // Note previousItem must be set before we close the URL, which will | 482 // Note previousItem must be set before we close the URL, which will |
| 483 // happen when the data source is made non-provisional below | 483 // happen when the data source is made non-provisional below |
| 484 m_frameLoadComplete = false; | 484 m_frameLoadComplete = false; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 if (m_frame->loader()->documentLoader()->urlForHistory().isEmpty()) | 823 if (m_frame->loader()->documentLoader()->urlForHistory().isEmpty()) |
| 824 return; | 824 return; |
| 825 | 825 |
| 826 Frame* mainFrame = page->mainFrame(); | 826 Frame* mainFrame = page->mainFrame(); |
| 827 ASSERT(mainFrame); | 827 ASSERT(mainFrame); |
| 828 FrameLoader* frameLoader = mainFrame->loader(); | 828 FrameLoader* frameLoader = mainFrame->loader(); |
| 829 | 829 |
| 830 frameLoader->checkDidPerformFirstNavigation(); | 830 frameLoader->checkDidPerformFirstNavigation(); |
| 831 | 831 |
| 832 RefPtr<HistoryItem> topItem = frameLoader->history()->createItemTree(m_frame
, doClip); | 832 RefPtr<HistoryItem> topItem = frameLoader->history()->createItemTree(m_frame
, doClip); |
| 833 LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame
%s", topItem.get(), m_frame->loader()->documentLoader()->url().string().ascii().
data()); | 833 LOG_INFO(BackForward, "WebCoreBackForward - Adding backforward item %p for f
rame %s", topItem.get(), m_frame->loader()->documentLoader()->url().string().asc
ii().data()); |
| 834 page->backForward()->addItem(topItem.release()); | 834 page->backForward()->addItem(topItem.release()); |
| 835 } | 835 } |
| 836 | 836 |
| 837 void HistoryController::updateCurrentItem() | 837 void HistoryController::updateCurrentItem() |
| 838 { | 838 { |
| 839 if (!m_currentItem) | 839 if (!m_currentItem) |
| 840 return; | 840 return; |
| 841 | 841 |
| 842 DocumentLoader* documentLoader = m_frame->loader()->documentLoader(); | 842 DocumentLoader* documentLoader = m_frame->loader()->documentLoader(); |
| 843 | 843 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 Settings* settings = m_frame->settings(); | 902 Settings* settings = m_frame->settings(); |
| 903 if (!settings || settings->privateBrowsingEnabled()) | 903 if (!settings || settings->privateBrowsingEnabled()) |
| 904 return; | 904 return; |
| 905 | 905 |
| 906 ASSERT(m_frame->page()); | 906 ASSERT(m_frame->page()); |
| 907 addVisitedLink(m_frame->page(), KURL(ParsedURLString, urlString)); | 907 addVisitedLink(m_frame->page(), KURL(ParsedURLString, urlString)); |
| 908 m_frame->loader()->client()->updateGlobalHistory(); | 908 m_frame->loader()->client()->updateGlobalHistory(); |
| 909 } | 909 } |
| 910 | 910 |
| 911 } // namespace WebCore | 911 } // namespace WebCore |
| OLD | NEW |