| Index: Source/WebCore/loader/HistoryController.cpp
|
| ===================================================================
|
| --- Source/WebCore/loader/HistoryController.cpp (revision 127219)
|
| +++ Source/WebCore/loader/HistoryController.cpp (working copy)
|
| @@ -163,7 +163,7 @@
|
| Document* document = m_frame->document();
|
| ASSERT(document);
|
|
|
| - if (item->isCurrentDocument(document)) {
|
| + if (item->isCurrentDocument(document) && document->attached()) {
|
| LOG(Loading, "WebCoreLoading %s: saving form state to %p", m_frame->tree()->uniqueName().string().utf8().data(), item);
|
| item->setDocumentState(document->formElementsState());
|
| }
|
| @@ -179,6 +179,22 @@
|
| }
|
| }
|
|
|
| +static inline bool isAssociatedToRequestedHistoryItem(const HistoryItem* current, Frame* frame, const HistoryItem* requested)
|
| +{
|
| + if (requested == current)
|
| + return true;
|
| + if (requested)
|
| + return false;
|
| + while ((frame = frame->tree()->parent())) {
|
| + requested = frame->loader()->requestedHistoryItem();
|
| + if (!requested)
|
| + continue;
|
| + if (requested->isAncestorOf(current))
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| void HistoryController::restoreDocumentState()
|
| {
|
| Document* doc = m_frame->document();
|
| @@ -201,7 +217,7 @@
|
|
|
| if (!itemToRestore)
|
| return;
|
| - if (m_frame->loader()->requestedHistoryItem() == m_currentItem.get() && !m_frame->loader()->documentLoader()->isClientRedirect()) {
|
| + if (isAssociatedToRequestedHistoryItem(itemToRestore, m_frame, m_frame->loader()->requestedHistoryItem()) && !m_frame->loader()->documentLoader()->isClientRedirect()) {
|
| LOG(Loading, "WebCoreLoading %s: restoring form state from %p", m_frame->tree()->uniqueName().string().utf8().data(), itemToRestore);
|
| doc->setStateForNewFormElements(itemToRestore->documentState());
|
| }
|
|
|