[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

trey trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:58:53 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 9ca0d00f9c294e8e2137eabeceb4c09be6b6d871
Author: trey <trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 11 18:33:12 2002 +0000

    First checkin of making frames work with the back forward list, restoring scroll position and form state.  Fixing:
    
    3014555 Lose frameset context going back/forward
    3078151 History inconsistency after loading frame content
    3089551 REGRESSION: www.bmwusa.com frames don't load in alex-30
    3095878 refresh doesn't preserve frame state
    
    WebCore:
    
            * khtml/khtml_part.cpp:
            (KHTMLPart::requestFrameName):  Call through bridge to get generated frame name.
            * kwq/KWQKHTMLPart.h:
            * kwq/KWQKHTMLPart.mm:
            (KWQKHTMLPart::generateFrameName):  New call that just forwards through the bridge.
            * kwq/WebCoreBridge.h:
    
    WebKit:
    
            * History.subproj/WebBackForwardList.m:
            (-[WebBackForwardList addEntry:]):  Yank code to avoid adding a duplicate entry, to catch the
    	refresh case.  That's dealt with in WebFramePrivate now.
            (-[WebBackForwardList description]):  Enhanced to print more info.
    
            * History.subproj/WebHistoryItem.h:
    	History items now hold an array of subitems to mirror the frame tree.  One item in the tree
    	is designated the target of the navigation.
            * History.subproj/WebHistoryItem.m:
            (-[WebHistoryItem dealloc]):  Release new ivars.
            (-[WebHistoryItem isTargetItem]):
            (-[WebHistoryItem setIsTargetItem:]):
    	New setter and setter.
            (-[WebHistoryItem _recurseToFindTargetItem]):
            (-[WebHistoryItem targetItem]):
    	Search the tree to find the target item.
            (-[WebHistoryItem children]):
            (-[WebHistoryItem addChildItem:]):
            (-[WebHistoryItem childItemWithName:]):
    	Maintain and search new child item list.
            (-[WebHistoryItem description]):
    	Enhanced to print out the tree of items.
            (-[WebHistoryItem dictionaryRepresentation]):
            (-[WebHistoryItem initFromDictionaryRepresentation:]):
    	Save and load the new state.
    
            * WebCoreSupport.subproj/WebBridge.m:
            (-[WebBridge generateFrameName]):  New call from KWQ, just forwards to Frame.
            (-[WebBridge createChildFrameNamed:withURL:renderPart:allowsScrolling:marginWidth:marginHeight:]):
    	Call new frame method dedicated to this case.
            (-[WebBridge saveDocumentState:]):
            (-[WebBridge documentState]):
    	Call frame methods to get the right item to save/restore to/from.
    
            * WebView.subproj/WebController.m:
            (-[WebController _goToItem:withLoadType:]):  Stop any current loading before going to a new item.
            (-[WebController goBack]):
            (-[WebController goForward]):
            (-[WebController goBackOrForwardToItem:]):  Name change of private method (for consistency)
    
            * WebView.subproj/WebDataSourcePrivate.h:
    	ProvisionalItem and PreviousItem are moved back up to WebFrame, where we know more about the
    	state transitions that happen during loading.
            * WebView.subproj/WebDataSourcePrivate.m:
            (-[WebDataSourcePrivate dealloc]): Don't release removed ivars.
            (-[WebDataSource _commitIfReady]): Make the view representations -after- the transition to committed.
    	This allows us to save away the scroll location successfully, since making the view was resetting it.
            * WebView.subproj/WebFrame.h:
            * WebView.subproj/WebFrame.m:
            (-[WebFrame setProvisionalDataSource:]):  Saving the scroll location has moved elsewhere to handle frames.
            (-[WebFrame stopLoading]):  Skip all the work if we're already state=complete.
    
            * WebView.subproj/WebFramePrivate.h:
    	The frame now holds a ref to the current, previous and provisional back-forward items.
            * WebView.subproj/WebFramePrivate.m:
            (-[WebFramePrivate dealloc]):  Release new state.
            (-[WebFramePrivate setProvisionalItem:]):
            (-[WebFramePrivate setPreviousItem:]):
            (-[WebFramePrivate setCurrentItem:]):	New setters (1 line getters were missed by script)
            (-[WebFrame _addBackForwardItemClippedAtTarget:]):  Adds a BF item to the top of the BF list.
            (-[WebFrame _createItem]):  Create a single BF item.
            (-[WebFrame _createItemTreeWithTargetFrame:clippedAtTarget:]):  Create a tree of BF items, which
    	mirror the frame tree.
            (-[WebFrame _immediateChildFrameNamed:]):  New frame search utility (doesn't recurse)
            (-[WebFrame _detachFromParent]):  Save the scroll position when detaching a frame.
            (-[WebFrame _transitionToCommitted]):  Maintain new item ivars.  Save scroll position when
    	appropriate.  Hook up items for child frames to their parent, as they are created.
            (-[WebFrame _setState:]):  Clear previousItem whenever we reach committed.
            (-[WebFrame _isLoadComplete]):  Clear previousItem if we are committed.
            (-[WebFrame _childFramesMatchItem:]):  Does the frame's frame tree match the one held by the item?
            (-[WebFrame _loadItem:fromItem:withLoadType:]):  Only do simple anchor navigation if the frame
    	has no children (fixes oddball corner case with a frame reloading itself).  Set provisional item.
            (-[WebFrame _recursiveGoToItem:fromItem:withLoadType:]):  Heart of returning to an item that had
    	frames.  We either find that the existing content is good, or initiate a load.
            (-[WebFrame _goToItem:withLoadType:]):  Adjust the BF list cursor, and recurse to do the work.
            (-[WebFrame _loadURL:loadType:clientRedirect:triggeringEvent:]):  Only do anchor-style nav if
    	the destination URL has a fragment.  Save scroll position.
            (-[WebFrame _loadURL:intoChild:]):  If returning to an item with frames, possibly replace the
    	new content with the stuff that was there at the time, substituting the URL.
            (-[WebFrame _saveScrollPositionToItem:]):  Don't croak on nil item or view.
            (-[WebFrame _restoreScrollPosition]):  Do croak (ASSERT) on nil item.
            (-[WebFrame _scrollToTop]):  Nit cleanup.
            (-[WebFrame _addFramePathToString:]):  Add a component for our frame to the frame name we're generating.
            (-[WebFrame _generateFrameName]):  Generate a frame name that is repeatable.
            (-[WebFrame _itemForSavingDocState]):  Returns correct item to use for formstate save.
            (-[WebFrame _itemForRestoringDocState]):  Returns correct item to use for formstate restore
    
    WebBrowser:
    
            * BrowserDocument.m:
            (-[BrowserDocument _addItem:toMenu:]):
    	For a back-forward item that's a tree because its for a frameset, use the
    	right item of the tree to generate the menu contents.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2624 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 8caa1ea..89cef97 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,12 @@
+2002-11-11  Trey Matteson  <trey at apple.com>
+
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::requestFrameName):  Call through bridge to get generated frame name.
+        * kwq/KWQKHTMLPart.h:
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::generateFrameName):  New call that just forwards through the bridge.
+        * kwq/WebCoreBridge.h:
+
 2002-11-11  Darin Adler  <darin at apple.com>
 
 	- fixed 3097253 -- text tagged <small> inside <h1> is too small
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 8caa1ea..89cef97 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,12 @@
+2002-11-11  Trey Matteson  <trey at apple.com>
+
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::requestFrameName):  Call through bridge to get generated frame name.
+        * kwq/KWQKHTMLPart.h:
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::generateFrameName):  New call that just forwards through the bridge.
+        * kwq/WebCoreBridge.h:
+
 2002-11-11  Darin Adler  <darin at apple.com>
 
 	- fixed 3097253 -- text tagged <small> inside <h1> is too small
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 8caa1ea..89cef97 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,12 @@
+2002-11-11  Trey Matteson  <trey at apple.com>
+
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::requestFrameName):  Call through bridge to get generated frame name.
+        * kwq/KWQKHTMLPart.h:
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::generateFrameName):  New call that just forwards through the bridge.
+        * kwq/WebCoreBridge.h:
+
 2002-11-11  Darin Adler  <darin at apple.com>
 
 	- fixed 3097253 -- text tagged <small> inside <h1> is too small
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index c01a74f..d3739a4 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -2668,7 +2668,11 @@ unsigned KHTMLPartPrivate::m_frameNameId = 0;
 
 QString KHTMLPart::requestFrameName()
 {
-   return QString::fromLatin1("<!--frame %1-->").arg(d->m_frameNameId++);
+#if APPLE_CHANGES
+    return kwq->generateFrameName();
+#else
+    return QString::fromLatin1("<!--frame %1-->").arg(d->m_frameNameId++);
+#endif
 }
 
 bool KHTMLPart::requestObject( khtml::RenderPart *frame, const QString &url, const QString &serviceType,
diff --git a/WebCore/kwq/KWQKHTMLPart.h b/WebCore/kwq/KWQKHTMLPart.h
index 0c64a7b..bc94070 100644
--- a/WebCore/kwq/KWQKHTMLPart.h
+++ b/WebCore/kwq/KWQKHTMLPart.h
@@ -151,6 +151,8 @@ private:
 
     WebCoreBridge *bridgeForFrameName(const QString &frameName);
 
+    QString generateFrameName();
+
     NSView *nextKeyViewInFrame(DOM::NodeImpl *startingPoint, KWQSelectionDirection);
     static DOM::NodeImpl *nodeForWidget(QWidget *);
     static KWQKHTMLPart *partForNode(DOM::NodeImpl *);
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index efae590..83947b5 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -123,6 +123,11 @@ WebCoreBridge *KWQKHTMLPart::bridgeForFrameName(const QString &frameName)
     return frame;
 }
 
+QString KWQKHTMLPart::generateFrameName()
+{
+    return QString::fromNSString([_bridge generateFrameName]);
+}
+
 void KWQKHTMLPart::openURL(const KURL &url)
 {
     NSURL *cocoaURL = url.getNSURL();
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 886736a..bd4c72f 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -177,6 +177,8 @@ enum FrameBorderStyle {
 - (WebCoreBridge *)mainFrame;
 - (WebCoreBridge *)findFramedNamed:(NSString *)name;
 - (WebCoreBridge *)findOrCreateFramedNamed:(NSString *)name;
+/* Creates a name for an frame unnamed in the HTML.  It should produce repeatable results for loads of the same frameset. */
+- (NSString *)generateFrameName;
 
 - (void)loadURL:(NSURL *)URL reload:(BOOL)reload triggeringEvent:(NSEvent *)event;
 - (void)postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)contentType;
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 2a59498..797f4ea 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,92 @@
+2002-11-11  Trey Matteson  <trey at apple.com>
+
+        * History.subproj/WebBackForwardList.m:
+        (-[WebBackForwardList addEntry:]):  Yank code to avoid adding a duplicate entry, to catch the
+	refresh case.  That's dealt with in WebFramePrivate now.
+        (-[WebBackForwardList description]):  Enhanced to print more info.
+
+        * History.subproj/WebHistoryItem.h:
+	History items now hold an array of subitems to mirror the frame tree.  One item in the tree
+	is designated the target of the navigation.
+        * History.subproj/WebHistoryItem.m:
+        (-[WebHistoryItem dealloc]):  Release new ivars.
+        (-[WebHistoryItem isTargetItem]):
+        (-[WebHistoryItem setIsTargetItem:]):
+	New setter and setter.
+        (-[WebHistoryItem _recurseToFindTargetItem]):
+        (-[WebHistoryItem targetItem]):
+	Search the tree to find the target item.
+        (-[WebHistoryItem children]):
+        (-[WebHistoryItem addChildItem:]):
+        (-[WebHistoryItem childItemWithName:]):
+	Maintain and search new child item list.
+        (-[WebHistoryItem description]):
+	Enhanced to print out the tree of items.
+        (-[WebHistoryItem dictionaryRepresentation]):
+        (-[WebHistoryItem initFromDictionaryRepresentation:]):
+	Save and load the new state.
+
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge generateFrameName]):  New call from KWQ, just forwards to Frame.
+        (-[WebBridge createChildFrameNamed:withURL:renderPart:allowsScrolling:marginWidth:marginHeight:]):
+	Call new frame method dedicated to this case.
+        (-[WebBridge saveDocumentState:]):
+        (-[WebBridge documentState]):
+	Call frame methods to get the right item to save/restore to/from.
+
+        * WebView.subproj/WebController.m:
+        (-[WebController _goToItem:withLoadType:]):  Stop any current loading before going to a new item.
+        (-[WebController goBack]):
+        (-[WebController goForward]):
+        (-[WebController goBackOrForwardToItem:]):  Name change of private method (for consistency)
+
+        * WebView.subproj/WebDataSourcePrivate.h:
+	ProvisionalItem and PreviousItem are moved back up to WebFrame, where we know more about the
+	state transitions that happen during loading.
+        * WebView.subproj/WebDataSourcePrivate.m:
+        (-[WebDataSourcePrivate dealloc]): Don't release removed ivars.
+        (-[WebDataSource _commitIfReady]): Make the view representations -after- the transition to committed.
+	This allows us to save away the scroll location successfully, since making the view was resetting it.
+        * WebView.subproj/WebFrame.h:
+        * WebView.subproj/WebFrame.m:
+        (-[WebFrame setProvisionalDataSource:]):  Saving the scroll location has moved elsewhere to handle frames.
+        (-[WebFrame stopLoading]):  Skip all the work if we're already state=complete.
+
+        * WebView.subproj/WebFramePrivate.h:
+	The frame now holds a ref to the current, previous and provisional back-forward items.
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFramePrivate dealloc]):  Release new state.
+        (-[WebFramePrivate setProvisionalItem:]):
+        (-[WebFramePrivate setPreviousItem:]):
+        (-[WebFramePrivate setCurrentItem:]):	New setters (1 line getters were missed by script)
+        (-[WebFrame _addBackForwardItemClippedAtTarget:]):  Adds a BF item to the top of the BF list.
+        (-[WebFrame _createItem]):  Create a single BF item.
+        (-[WebFrame _createItemTreeWithTargetFrame:clippedAtTarget:]):  Create a tree of BF items, which
+	mirror the frame tree.
+        (-[WebFrame _immediateChildFrameNamed:]):  New frame search utility (doesn't recurse)
+        (-[WebFrame _detachFromParent]):  Save the scroll position when detaching a frame.
+        (-[WebFrame _transitionToCommitted]):  Maintain new item ivars.  Save scroll position when
+	appropriate.  Hook up items for child frames to their parent, as they are created.
+        (-[WebFrame _setState:]):  Clear previousItem whenever we reach committed.
+        (-[WebFrame _isLoadComplete]):  Clear previousItem if we are committed.
+        (-[WebFrame _childFramesMatchItem:]):  Does the frame's frame tree match the one held by the item?
+        (-[WebFrame _loadItem:fromItem:withLoadType:]):  Only do simple anchor navigation if the frame
+	has no children (fixes oddball corner case with a frame reloading itself).  Set provisional item.
+        (-[WebFrame _recursiveGoToItem:fromItem:withLoadType:]):  Heart of returning to an item that had
+	frames.  We either find that the existing content is good, or initiate a load.
+        (-[WebFrame _goToItem:withLoadType:]):  Adjust the BF list cursor, and recurse to do the work.
+        (-[WebFrame _loadURL:loadType:clientRedirect:triggeringEvent:]):  Only do anchor-style nav if
+	the destination URL has a fragment.  Save scroll position.
+        (-[WebFrame _loadURL:intoChild:]):  If returning to an item with frames, possibly replace the
+	new content with the stuff that was there at the time, substituting the URL.
+        (-[WebFrame _saveScrollPositionToItem:]):  Don't croak on nil item or view.
+        (-[WebFrame _restoreScrollPosition]):  Do croak (ASSERT) on nil item.
+        (-[WebFrame _scrollToTop]):  Nit cleanup.
+        (-[WebFrame _addFramePathToString:]):  Add a component for our frame to the frame name we're generating.
+        (-[WebFrame _generateFrameName]):  Generate a frame name that is repeatable.
+        (-[WebFrame _itemForSavingDocState]):  Returns correct item to use for formstate save.
+        (-[WebFrame _itemForRestoringDocState]):  Returns correct item to use for formstate restore
+
 2002-11-11  Maciej Stachowiak  <mjs at apple.com>
 
 	Store path and the fact that we're downloading in the data source,
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 2a59498..797f4ea 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,92 @@
+2002-11-11  Trey Matteson  <trey at apple.com>
+
+        * History.subproj/WebBackForwardList.m:
+        (-[WebBackForwardList addEntry:]):  Yank code to avoid adding a duplicate entry, to catch the
+	refresh case.  That's dealt with in WebFramePrivate now.
+        (-[WebBackForwardList description]):  Enhanced to print more info.
+
+        * History.subproj/WebHistoryItem.h:
+	History items now hold an array of subitems to mirror the frame tree.  One item in the tree
+	is designated the target of the navigation.
+        * History.subproj/WebHistoryItem.m:
+        (-[WebHistoryItem dealloc]):  Release new ivars.
+        (-[WebHistoryItem isTargetItem]):
+        (-[WebHistoryItem setIsTargetItem:]):
+	New setter and setter.
+        (-[WebHistoryItem _recurseToFindTargetItem]):
+        (-[WebHistoryItem targetItem]):
+	Search the tree to find the target item.
+        (-[WebHistoryItem children]):
+        (-[WebHistoryItem addChildItem:]):
+        (-[WebHistoryItem childItemWithName:]):
+	Maintain and search new child item list.
+        (-[WebHistoryItem description]):
+	Enhanced to print out the tree of items.
+        (-[WebHistoryItem dictionaryRepresentation]):
+        (-[WebHistoryItem initFromDictionaryRepresentation:]):
+	Save and load the new state.
+
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge generateFrameName]):  New call from KWQ, just forwards to Frame.
+        (-[WebBridge createChildFrameNamed:withURL:renderPart:allowsScrolling:marginWidth:marginHeight:]):
+	Call new frame method dedicated to this case.
+        (-[WebBridge saveDocumentState:]):
+        (-[WebBridge documentState]):
+	Call frame methods to get the right item to save/restore to/from.
+
+        * WebView.subproj/WebController.m:
+        (-[WebController _goToItem:withLoadType:]):  Stop any current loading before going to a new item.
+        (-[WebController goBack]):
+        (-[WebController goForward]):
+        (-[WebController goBackOrForwardToItem:]):  Name change of private method (for consistency)
+
+        * WebView.subproj/WebDataSourcePrivate.h:
+	ProvisionalItem and PreviousItem are moved back up to WebFrame, where we know more about the
+	state transitions that happen during loading.
+        * WebView.subproj/WebDataSourcePrivate.m:
+        (-[WebDataSourcePrivate dealloc]): Don't release removed ivars.
+        (-[WebDataSource _commitIfReady]): Make the view representations -after- the transition to committed.
+	This allows us to save away the scroll location successfully, since making the view was resetting it.
+        * WebView.subproj/WebFrame.h:
+        * WebView.subproj/WebFrame.m:
+        (-[WebFrame setProvisionalDataSource:]):  Saving the scroll location has moved elsewhere to handle frames.
+        (-[WebFrame stopLoading]):  Skip all the work if we're already state=complete.
+
+        * WebView.subproj/WebFramePrivate.h:
+	The frame now holds a ref to the current, previous and provisional back-forward items.
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFramePrivate dealloc]):  Release new state.
+        (-[WebFramePrivate setProvisionalItem:]):
+        (-[WebFramePrivate setPreviousItem:]):
+        (-[WebFramePrivate setCurrentItem:]):	New setters (1 line getters were missed by script)
+        (-[WebFrame _addBackForwardItemClippedAtTarget:]):  Adds a BF item to the top of the BF list.
+        (-[WebFrame _createItem]):  Create a single BF item.
+        (-[WebFrame _createItemTreeWithTargetFrame:clippedAtTarget:]):  Create a tree of BF items, which
+	mirror the frame tree.
+        (-[WebFrame _immediateChildFrameNamed:]):  New frame search utility (doesn't recurse)
+        (-[WebFrame _detachFromParent]):  Save the scroll position when detaching a frame.
+        (-[WebFrame _transitionToCommitted]):  Maintain new item ivars.  Save scroll position when
+	appropriate.  Hook up items for child frames to their parent, as they are created.
+        (-[WebFrame _setState:]):  Clear previousItem whenever we reach committed.
+        (-[WebFrame _isLoadComplete]):  Clear previousItem if we are committed.
+        (-[WebFrame _childFramesMatchItem:]):  Does the frame's frame tree match the one held by the item?
+        (-[WebFrame _loadItem:fromItem:withLoadType:]):  Only do simple anchor navigation if the frame
+	has no children (fixes oddball corner case with a frame reloading itself).  Set provisional item.
+        (-[WebFrame _recursiveGoToItem:fromItem:withLoadType:]):  Heart of returning to an item that had
+	frames.  We either find that the existing content is good, or initiate a load.
+        (-[WebFrame _goToItem:withLoadType:]):  Adjust the BF list cursor, and recurse to do the work.
+        (-[WebFrame _loadURL:loadType:clientRedirect:triggeringEvent:]):  Only do anchor-style nav if
+	the destination URL has a fragment.  Save scroll position.
+        (-[WebFrame _loadURL:intoChild:]):  If returning to an item with frames, possibly replace the
+	new content with the stuff that was there at the time, substituting the URL.
+        (-[WebFrame _saveScrollPositionToItem:]):  Don't croak on nil item or view.
+        (-[WebFrame _restoreScrollPosition]):  Do croak (ASSERT) on nil item.
+        (-[WebFrame _scrollToTop]):  Nit cleanup.
+        (-[WebFrame _addFramePathToString:]):  Add a component for our frame to the frame name we're generating.
+        (-[WebFrame _generateFrameName]):  Generate a frame name that is repeatable.
+        (-[WebFrame _itemForSavingDocState]):  Returns correct item to use for formstate save.
+        (-[WebFrame _itemForRestoringDocState]):  Returns correct item to use for formstate restore
+
 2002-11-11  Maciej Stachowiak  <mjs at apple.com>
 
 	Store path and the fact that we're downloading in the data source,
diff --git a/WebKit/History.subproj/WebBackForwardList.m b/WebKit/History.subproj/WebBackForwardList.m
index facb43b..e81e980 100644
--- a/WebKit/History.subproj/WebBackForwardList.m
+++ b/WebKit/History.subproj/WebBackForwardList.m
@@ -34,19 +34,6 @@
 
 - (void)addEntry:(WebHistoryItem *)entry;
 {
-    // If the last entry matches this new entry, then replace it rather than adding
-    // a new one, since we are doing a reload.
-    if (_current >= 0) {
-        WebHistoryItem *curr = [_entries objectAtIndex:_current];
-        if ([[curr URL] isEqual:[entry URL]]
-            && [[curr target] isEqual:[entry target]]
-            && [[curr parent] isEqual:[entry parent]])
-        {
-            [_entries replaceObjectAtIndex:_current withObject:entry];
-            return;	// skip clearing the forward list
-        }
-    }
-
     // Toss anything in the forward list
     int currSize = [_entries count];
     if (_current != currSize-1 && _current != -1) {
@@ -170,9 +157,15 @@
         else {
             [result appendString:@"    "]; 
         }   
-        [result appendFormat:@" %d) ", i]; 
-        [result appendString:[[_entries objectAtIndex:i] description]]; 
-        [result appendString:@"\n"]; 
+        [result appendFormat:@"%2d) ", i];
+        int currPos = [result length];
+        [result appendString:[[_entries objectAtIndex:i] description]];
+
+        // shift all the contents over.  a bit slow, but this is for debugging
+        NSRange replRange = {currPos, [result length]-currPos};
+        [result replaceOccurrencesOfString:@"\n" withString:@"\n        " options:0 range:replRange];
+        
+        [result appendString:@"\n"];
     }
 
     [result appendString:@"\n--------------------------------------------\n"];    
diff --git a/WebKit/History.subproj/WebHistoryItem.h b/WebKit/History.subproj/WebHistoryItem.h
index 8b05a50..c73cbf4 100644
--- a/WebKit/History.subproj/WebHistoryItem.h
+++ b/WebKit/History.subproj/WebHistoryItem.h
@@ -20,7 +20,9 @@
     NSPoint _scrollPoint;
     NSString *anchor;
     NSArray *_documentState;
+    NSMutableArray *_subItems;
     BOOL _loadedIcon;
+    BOOL _isTargetItem;
 }
 
 + (WebHistoryItem *)entryWithURL:(NSURL *)URL;
@@ -40,6 +42,7 @@
 - (NSCalendarDate *)lastVisitedDate;
 - (NSPoint)scrollPoint;
 - (NSArray *)documentState;
+- (BOOL)isTargetItem;
 - (NSString *)anchor;
 
 - (void)setURL:(NSURL *)URL;
@@ -51,5 +54,11 @@
 - (void)setScrollPoint:(NSPoint)p;
 - (void)setDocumentState:(NSArray *)state;
 - (void)setAnchor:(NSString *)anchor;
+- (void)setIsTargetItem:(BOOL)flag;
+
+- (NSArray *)children;
+- (void)addChildItem:(WebHistoryItem *)item;
+- (WebHistoryItem *)childItemWithName:(NSString *)name;
+- (WebHistoryItem *)targetItem;
 
 @end
diff --git a/WebKit/History.subproj/WebHistoryItem.m b/WebKit/History.subproj/WebHistoryItem.m
index b029919..e4bda23 100644
--- a/WebKit/History.subproj/WebHistoryItem.m
+++ b/WebKit/History.subproj/WebHistoryItem.m
@@ -11,6 +11,7 @@
 #import <WebFoundation/WebNSDictionaryExtras.h>
 #import <WebFoundation/WebNSURLExtras.h>
 
+
 @implementation WebHistoryItem
 
 - (void)_retainIconInDatabase:(BOOL)retain
@@ -72,6 +73,7 @@
     [_lastVisitedDate release];
     [anchor release];
     [_documentState release];
+    [_subItems release];
     
     [super dealloc];
 }
@@ -221,6 +223,45 @@
     anchor = copy;
 }
 
+- (BOOL)isTargetItem
+{
+    return _isTargetItem;
+}
+
+- (void)setIsTargetItem:(BOOL)flag
+{
+    _isTargetItem = flag;
+}
+
+// Main diff from the public method is that the public method will default to returning
+// the top item if it can't find anything marked as target and has no kids
+- (WebHistoryItem *)_recurseToFindTargetItem
+{
+    if (_isTargetItem) {
+        return self;
+    } else if (!_subItems) {
+        return nil;
+    } else {
+        int i;
+        for (i = [_subItems count]-1; i >= 0; i--) {
+            WebHistoryItem *match = [[_subItems objectAtIndex:i] _recurseToFindTargetItem];
+            if (match) {
+                return match;
+            }
+        }
+        return nil;
+    }
+}
+
+- (WebHistoryItem *)targetItem
+{
+    if (_isTargetItem || !_subItems) {
+        return self;
+    } else {
+        return [self _recurseToFindTargetItem];
+    }
+}
+
 - (BOOL)isEqual:(id)anObject
 {
     if (![anObject isMemberOfClass:[WebHistoryItem class]]) {
@@ -231,9 +272,51 @@
     return _URLString == otherURL || [_URLString isEqualToString:otherURL];
 }
 
+- (NSArray *)children
+{
+    return _subItems;
+}
+
+- (void)addChildItem:(WebHistoryItem *)item
+{
+    if (!_subItems) {
+        _subItems = [[NSMutableArray arrayWithObject:item] retain];
+    } else {
+        [_subItems addObject:item];
+    }
+}
+
+- (WebHistoryItem *)childItemWithName:(NSString *)name
+{
+    int i;
+    for (i = (_subItems ? [_subItems count] : 0)-1; i >= 0; i--) {
+        WebHistoryItem *child = [_subItems objectAtIndex:i];
+        if ([[child target] isEqualToString:name]) {
+            return child;
+        }
+    }
+    return nil;
+}
+
 - (NSString *)description
 {
-    return [NSString stringWithFormat:@"WebHistoryItem %@", _URLString];
+    NSMutableString *result = [NSMutableString stringWithFormat:@"%@ %@ in \"%@\"", [super description], _URLString, _target];
+    if (_isTargetItem) {
+        [result appendString:@" *target*"];
+    }
+    if (_subItems) {
+        int currPos = [result length];
+        int i;
+        for (i = 0; i < (int)[_subItems count]; i++) {
+            WebHistoryItem *child = [_subItems objectAtIndex:i];
+            [result appendString:@"\n"];
+            [result appendString:[child description]];
+        }
+        // shift all the contents over.  A bit slow, but hey, this is for debugging.
+        NSRange replRange = {currPos, [result length]-currPos};
+        [result replaceOccurrencesOfString:@"\n" withString:@"\n    " options:0 range:replRange];
+    }
+    return result;
 }
 
 - (NSDictionary *)dictionaryRepresentation
@@ -253,7 +336,16 @@
         [dict setObject:[NSString stringWithFormat:@"%lf", [_lastVisitedDate timeIntervalSinceReferenceDate]]
                  forKey:@"lastVisitedDate"];
     }
-
+    if (_subItems != nil) {
+        NSMutableArray *childDicts = [NSMutableArray arrayWithCapacity:[_subItems count]];
+        int i;
+        for (i = [_subItems count]; i >= 0; i--) {
+            [childDicts addObject: [[_subItems objectAtIndex:i] dictionaryRepresentation]];
+        }
+        [dict setObject: childDicts forKey: @"children"];
+    }
+    [dict setObject: (_isTargetItem ? @"YES" : @"NO") forKey: @"isTargetItem"];
+    
     return dict;
 }
 
@@ -273,6 +365,18 @@
         [calendarDate release];
     }
     
+    NSArray *childDicts = [dict objectForKey:@"children"];
+    if (childDicts) {
+        _subItems = [[NSMutableArray alloc] initWithCapacity:[childDicts count]];
+        int i;
+        for (i = [childDicts count]; i >= 0; i--) {
+            WebHistoryItem *child = [[WebHistoryItem alloc] initFromDictionaryRepresentation: [childDicts objectAtIndex:i]];
+            [_subItems addObject: child];
+        }
+    }
+    NSString *value = [dict objectForKey:@"isTargetItem"];
+    _isTargetItem = (value != nil) && [value isEqualToString:@"YES"];
+
     return self;
 }
     
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index 59363c0..ad959ff 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -287,6 +287,11 @@
     [frame _postWithURL:URL data:data contentType:contentType];
 }
 
+- (NSString *)generateFrameName
+{
+    return [frame _generateFrameName];
+}
+
 - (WebCoreBridge *)createChildFrameNamed:(NSString *)frameName withURL:(NSURL *)URL
     renderPart:(KHTMLRenderPart *)childRenderPart
     allowsScrolling:(BOOL)allowsScrolling marginWidth:(int)width marginHeight:(int)height
@@ -305,7 +310,7 @@
     // We must avoid loading the document itself as a subframe, like
     // other browsers do, otherwise bugs like Radar 3083732
     if (![[[URL _web_URLByRemovingFragment] absoluteURL] isEqual:[[[frame dataSource] URL] absoluteURL]]) {
-	[newFrame _loadURL:URL loadType:WebFrameLoadTypeInternal clientRedirect:NO triggeringEvent:nil];
+	[frame _loadURL:URL intoChild:newFrame];
     }
 
     return [newFrame _bridge];
@@ -323,22 +328,20 @@
 
 - (void)saveDocumentState: (NSArray *)documentState
 {
-    WebHistoryItem *item = [[frame dataSource] _previousBackForwardItem];
-    // If there wasn't a previous item explicitly set, assume it's the backEntry
-    if (!item) {
-        item = [[[frame controller] backForwardList] backEntry];
+    WebHistoryItem *item = [frame _itemForSavingDocState];
+    LOG(Loading, "%@: saving form state from to 0x%x", [frame name], item);
+    if (item) {
+        [item setDocumentState: documentState];
+        // You might think we could save the scroll state here too, but unfortunately this
+        // often gets called after WebFrame::_transitionToCommitted has restored the scroll
+        // position of the next document.
     }
-
-    [item setDocumentState: documentState];
 }
 
 - (NSArray *)documentState
 {
-    WebHistoryItem *currentItem;
-    
-    currentItem = [[[frame controller] backForwardList] currentEntry];
-    
-    return [currentItem documentState];
+    LOG(Loading, "%@: restoring form state from item 0x%x", [frame name], [frame _itemForRestoringDocState]);
+    return [[frame _itemForRestoringDocState] documentState];
 }
 
 - (NSString *)userAgentForURL:(NSURL *)URL
diff --git a/WebKit/WebView.subproj/WebController.m b/WebKit/WebView.subproj/WebController.m
index 57f6fbf..cd00395 100644
--- a/WebKit/WebView.subproj/WebController.m
+++ b/WebKit/WebView.subproj/WebController.m
@@ -244,29 +244,15 @@ NSString *WebElementFrameKey = @"WebElementFrame";
     return _private->useBackForwardList;
 }
 
-- (void)_goToItem: (WebHistoryItem *)item withFrameLoadType: (WebFrameLoadType)type
+- (void)_goToItem: (WebHistoryItem *)item withLoadType: (WebFrameLoadType)type
 {
     WebFrame *targetFrame;
-    
+
+    // abort any current load if we're going back/forward
+    [[self mainFrame] stopLoading];
     targetFrame = [self _findFrameNamed: [item target]];
-    if (targetFrame == nil){
-        NSLog (@"Target frame not found, using main frame instead, will be fixed soon");
-#if 0
-        int pos = 1;
-        WebHistoryItem *next = item;
-        while (next){
-            NSLog (@"frame name %@, parent %@", [next target], [next parent]);
-            nextFrame = [self _findFrameNamed: [next parent]];
-            next = [[self backForwardList] backEntryAtIndex: pos++];
-            if ([[next target] isEqual: @"_top"]){
-                [[self mainFrame] _goToItem: next withFrameLoadType: WebFrameLoadTypeIntermediateBack];
-                return;
-            }
-        }
-#endif            
-        targetFrame = [self mainFrame];
-    }
-    [targetFrame _goToItem: item withFrameLoadType: type];
+    ASSERT(targetFrame != nil);
+    [targetFrame _goToItem: item withLoadType: type];
 }
 
 - (BOOL)goBack
@@ -274,7 +260,7 @@ NSString *WebElementFrameKey = @"WebElementFrame";
     WebHistoryItem *item = [[self backForwardList] backEntry];
     
     if (item){
-        [self _goToItem: item withFrameLoadType: WebFrameLoadTypeBack];
+        [self _goToItem: item withLoadType: WebFrameLoadTypeBack];
         return YES;
     }
     return NO;
@@ -285,7 +271,7 @@ NSString *WebElementFrameKey = @"WebElementFrame";
     WebHistoryItem *item = [[self backForwardList] forwardEntry];
     
     if (item){
-        [self _goToItem: item withFrameLoadType: WebFrameLoadTypeForward];
+        [self _goToItem: item withLoadType: WebFrameLoadTypeForward];
         return YES;
     }
     return NO;
@@ -293,7 +279,7 @@ NSString *WebElementFrameKey = @"WebElementFrame";
 
 - (BOOL)goBackOrForwardToItem:(WebHistoryItem *)item
 {
-    [self _goToItem: item withFrameLoadType: WebFrameLoadTypeIndexedBackForward];
+    [self _goToItem: item withLoadType: WebFrameLoadTypeIndexedBackForward];
     return YES;
 }
 
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.h b/WebKit/WebView.subproj/WebDataSourcePrivate.h
index 2bd59c9..6528ce0 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.h
@@ -68,10 +68,6 @@
     NSURL *iconURL;
     WebIconLoader *iconLoader;
 
-    // item we are about to go to - used to set position in BFList on commit
-    WebHistoryItem *provisionalBackForwardItem;
-    // item we just left - will receive saved doc state on commit
-    WebHistoryItem *previousBackForwardItem;
     // BF items that reference what we loaded - we must keep their titles up to date
     NSMutableArray *ourBackForwardItems;
 
@@ -114,10 +110,6 @@
 - (void)_setIconURL:(NSURL *)URL withType:(NSString *)iconType;
 - (void)_setOverrideEncoding:(NSString *)overrideEncoding;
 - (NSString *)_overrideEncoding;
-- (void)_setProvisionalBackForwardItem: (WebHistoryItem *)item;
-- (WebHistoryItem *)_provisionalBackForwardItem;
-- (void)_setPreviousBackForwardItem: (WebHistoryItem *)item;
-- (WebHistoryItem *)_previousBackForwardItem;
 - (void)_addBackForwardItem:(WebHistoryItem *)item;
 - (void)_addBackForwardItems:(NSArray *)items;
 - (NSArray *)_backForwardItems;
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.m b/WebKit/WebView.subproj/WebDataSourcePrivate.m
index 2407b27..0cd7dc6 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.m
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.m
@@ -56,8 +56,6 @@
     [iconLoader setDelegate:nil];
     [iconLoader release];
     [iconURL release];
-    [provisionalBackForwardItem release];
-    [previousBackForwardItem release];
     [ourBackForwardItems release];
     [triggeringEvent release];
     [downloadPath release];
@@ -322,32 +320,6 @@
     return _private->isClientRedirect;
 }
 
-- (WebHistoryItem *)_provisionalBackForwardItem
-{
-    return _private->provisionalBackForwardItem;
-}
-
-- (void)_setProvisionalBackForwardItem: (WebHistoryItem *)item
-{
-    if (_private->provisionalBackForwardItem != item) {
-        [_private->provisionalBackForwardItem release];
-        _private->provisionalBackForwardItem = [item retain];
-    }
-}
-
-- (WebHistoryItem *)_previousBackForwardItem
-{
-    return _private->previousBackForwardItem;
-}
-
-- (void)_setPreviousBackForwardItem: (WebHistoryItem *)item
-{
-    if (_private->previousBackForwardItem != item) {
-        [_private->previousBackForwardItem release];
-        _private->previousBackForwardItem = [item retain];
-    }
-}
-
 - (void)_addBackForwardItem:(WebHistoryItem *)item
 {
     if (!item) {
@@ -452,12 +424,11 @@
     if (![self isDownloading] && _private->gotFirstByte && !_private->committed) {
         LOG(Loading, "committed resource = %@", [[self request] URL]);
 	_private->committed = TRUE;
-	[self _makeRepresentation];
         [[self webFrame] _transitionToCommitted];
 	[[self _bridge] dataSourceChanged];
-        // we're done with these after committing
-        [self _setProvisionalBackForwardItem: nil];
-        [self _setPreviousBackForwardItem: nil];
+        // Must do this after dataSourceChanged.  makeRep installs a new view, which blows away
+        // scroll state, which is saved within _transitionToCommitted
+        [self _makeRepresentation];
     }
 }
 
diff --git a/WebKit/WebView.subproj/WebFrame.h b/WebKit/WebView.subproj/WebFrame.h
index 97d76cd..2755227 100644
--- a/WebKit/WebView.subproj/WebFrame.h
+++ b/WebKit/WebView.subproj/WebFrame.h
@@ -132,11 +132,11 @@
 - (WebFrame *)findFrameNamed:(NSString *)name;
 
 /*!
-     @method findOrCreateFramedNamed:
-     @discussion This method calls findFrameNamed but if no frame is found, a new window is opened
-     and the main frame of the new window is named with the given name.
-     @param name The name of the frame to find.
-     @result The frame matching the provided name. Won't be nil.
+    @method findOrCreateFramedNamed:
+    @discussion This method calls findFrameNamed but if no frame is found, a new window is opened
+    and the main frame of the new window is named with the given name.
+    @param name The name of the frame to find.
+    @result The frame matching the provided name. Won't be nil.
 */
 - (WebFrame *)findOrCreateFramedNamed:(NSString *)name;
 
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index f5c6920..7cec8a4 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -120,18 +120,6 @@
     // KDE drop we should fix this dependency.
     ASSERT([self webView] != nil);
 
-    // Record the current scroll position if this frame is associated with the
-    // current entry in the back/forward list.
-    {
-        WebHistoryItem *entry;
-    
-        entry = (WebHistoryItem *)[[[self controller] backForwardList] currentEntry];
-        if ([[[entry URL] _web_URLByRemovingFragment] isEqual: [[[[self dataSource] request] URL] _web_URLByRemovingFragment]]) {
-            NSPoint point = [[[[self webView] documentView] superview] bounds].origin;
-            [entry setScrollPoint: point];
-        }
-    }
-
     if ([self _state] != WebFrameStateComplete) {
         [self stopLoading];
     }
@@ -173,9 +161,11 @@
 
 - (void)stopLoading
 {
-    [_private->provisionalDataSource stopLoading];
-    [_private->dataSource stopLoading];
-    [_private->scheduledLayoutTimer fire];
+    if (_private->state != WebFrameStateComplete) {
+        [_private->provisionalDataSource stopLoading];
+        [_private->dataSource stopLoading];
+        [_private->scheduledLayoutTimer fire];
+    }
     ASSERT(_private->scheduledLayoutTimer == nil);
 }
 
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index d010a20..57d387a 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -22,10 +22,10 @@ typedef enum {
     // This state indicates we are ready to commit to a page,
     // which means the view will transition to use the new data source.
     WebFrameStateCommittedPage,
-    
+
     // This state indicates that it is reasonable to perform a layout.
     WebFrameStateLayoutAcceptable,
-    
+
     WebFrameStateComplete
 } WebFrameState;
 
@@ -59,6 +59,10 @@ typedef enum {
     WebFrame *parent;
     NSMutableArray *children;
     WebPluginController *pluginController;
+    WebHistoryItem *currentItem;	// BF item for our current content
+    WebHistoryItem *provisionalItem;	// BF item for where we're trying to go
+                                        // (only known when navigating to a pre-existing BF item)
+    WebHistoryItem *previousItem;	// BF item for previous content, see _itemForSavingDocState
 }
 
 - (void)setName:(NSString *)name;
@@ -74,6 +78,13 @@ typedef enum {
 - (WebFrameLoadType)loadType;
 - (void)setLoadType:(WebFrameLoadType)loadType;
 
+- (void)setProvisionalItem: (WebHistoryItem *)item;
+- (WebHistoryItem *)provisionalItem;
+- (void)setPreviousItem:(WebHistoryItem *)item;
+- (WebHistoryItem *)previousItem;
+- (void)setCurrentItem:(WebHistoryItem *)item;
+- (WebHistoryItem *)currentItem;
+
 @end
 
 @interface WebFrame (WebPrivate)
@@ -95,12 +106,15 @@ typedef enum {
 - (void)_setProvisionalDataSource:(WebDataSource *)d;
 - (void)_setLoadType: (WebFrameLoadType)loadType;
 - (WebFrameLoadType)_loadType;
-- (void)_goToItem: (WebHistoryItem *)item withFrameLoadType: (WebFrameLoadType)type;
 
--(NSDictionary *)_actionInformationForNavigationType:(WebNavigationType)navigationType event:(NSEvent *)event;
--(BOOL)_continueAfterClickPolicyForEvent:(NSEvent *)event request:(WebResourceRequest *)request;
--(void)_loadURL:(NSURL *)URL loadType:(WebFrameLoadType)loadType clientRedirect:(BOOL)clientRedirect triggeringEvent:(NSEvent *)event;
+- (NSDictionary *)_actionInformationForNavigationType:(WebNavigationType)navigationType event:(NSEvent *)event;
+- (BOOL)_continueAfterClickPolicyForEvent:(NSEvent *)event request:(WebResourceRequest *)request;
+- (void)_goToItem: (WebHistoryItem *)item withLoadType: (WebFrameLoadType)type;
+- (void)_loadURL:(NSURL *)URL loadType:(WebFrameLoadType)loadType clientRedirect:(BOOL)clientRedirect triggeringEvent:(NSEvent *)event;
+- (void)_loadURL:(NSURL *)URL intoChild:(WebFrame *)childFrame;
 - (void)_postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)contentType;
+
+- (void)_saveScrollPositionToItem:(WebHistoryItem *)item;
 - (void)_restoreScrollPosition;
 - (void)_scrollToTop;
 - (void)_textSizeMultiplierChanged;
@@ -111,6 +125,13 @@ typedef enum {
 
 - (void)_addChild:(WebFrame *)child;
 
+- (NSString *)_generateFrameName;
+
 - (WebPluginController *)_pluginController;
 
+- (WebHistoryItem *)_createItemTreeWithTargetFrame:(WebFrame *)targetFrame clippedAtTarget:(BOOL)doClip;
+
+- (WebHistoryItem *)_itemForSavingDocState;
+- (WebHistoryItem *)_itemForRestoringDocState;
+
 @end
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 166fa15..23d100b 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -69,6 +69,10 @@ static const char * const stateNames[] = {
     [scheduledLayoutTimer release];
     [children release];
     [pluginController release];
+
+    [currentItem release];
+    [provisionalItem release];
+    [previousItem release];
     
     [super dealloc];
 }
@@ -117,10 +121,100 @@ static const char * const stateNames[] = {
     loadType = t;
 }
 
+- (WebHistoryItem *)provisionalItem { return provisionalItem; }
+- (void)setProvisionalItem: (WebHistoryItem *)item
+{
+    [item retain];
+    [provisionalItem release];
+    provisionalItem = item;
+}
+
+- (WebHistoryItem *)previousItem { return previousItem; }
+- (void)setPreviousItem:(WebHistoryItem *)item
+{
+    [item retain];
+    [previousItem release];
+    previousItem = item;
+}
+
+- (WebHistoryItem *)currentItem { return currentItem; }
+- (void)setCurrentItem:(WebHistoryItem *)item
+{
+    [item retain];
+    [currentItem release];
+    currentItem = item;
+}
+
 @end
 
 @implementation WebFrame (WebPrivate)
 
+// helper method used in various nav cases below
+- (WebHistoryItem *)_addBackForwardItemClippedAtTarget:(BOOL)doClip
+{
+    WebHistoryItem *bfItem = [[[self controller] mainFrame] _createItemTreeWithTargetFrame:self clippedAtTarget:doClip];
+    [[[self controller] backForwardList] addEntry:bfItem];
+    [bfItem release];
+    return bfItem;
+}
+
+// NB: this returns an object with retain count of 1
+- (WebHistoryItem *)_createItem
+{
+    WebDataSource *dataSrc = [self dataSource];
+    NSURL *url = [[dataSrc request] URL];
+    WebHistoryItem *bfItem = [[WebHistoryItem alloc] initWithURL:url target:[self name] parent:[[self parent] name] title:[dataSrc pageTitle]];
+    [bfItem setAnchor:[url fragment]];
+    [dataSrc _addBackForwardItem:bfItem];
+
+    // Set the item for which we will save document state
+    [_private setPreviousItem:[_private currentItem]];
+    [_private setCurrentItem:bfItem];
+
+    return bfItem;
+}
+
+/*
+    In the case of saving state about a page with frames, we store a tree of items that mirrors the frame tree.  The item that was the target of the user's navigation is designated as the "targetItem".  When this method is called with doClip=YES we're able to create the whole tree except for the target's children, which will be loaded in the future.  That part of the tree will be filled out as the child loads are committed.
+*/
+// NB: this returns an object with retain count of 1
+- (WebHistoryItem *)_createItemTreeWithTargetFrame:(WebFrame *)targetFrame clippedAtTarget:(BOOL)doClip
+{
+    WebHistoryItem *bfItem = [self _createItem];
+
+    [self _saveScrollPositionToItem:[_private previousItem]];
+    if (!(doClip && self == targetFrame)) {
+        // save frame state for items that aren't loading (khtml doesn't save those)
+        [_private->bridge saveDocumentState];
+
+        if (_private->children) {
+            unsigned i;
+            for (i = 0; i < [_private->children count]; i++) {
+                WebFrame *child = [_private->children objectAtIndex:i];
+                WebHistoryItem *childItem = [child _createItemTreeWithTargetFrame:targetFrame clippedAtTarget:doClip];
+                [bfItem addChildItem:childItem];
+                [childItem release];
+            }
+        }
+    }
+    if (self == targetFrame) {
+        [bfItem setIsTargetItem:YES];
+    }
+    return bfItem;
+}
+
+- (WebFrame *)_immediateChildFrameNamed:(NSString *)name
+{
+    int i;
+    for (i = [_private->children count]-1; i >= 0; i--) {
+        WebFrame *frame = [_private->children objectAtIndex:i];
+        if ([[frame name] isEqualToString:name]) {
+            return frame;
+        }
+    }
+    return nil;
+}
+
 - (WebFrame *)_descendantFrameNamed:(NSString *)name
 {
     if ([[self name] isEqualToString: name]){
@@ -153,6 +247,7 @@ static const char * const stateNames[] = {
     _private->bridge = nil;
     
     [self stopLoading];
+    [self _saveScrollPositionToItem:[_private currentItem]];
     [bridge closeURL];
 
     [[self children] makeObjectsPerformSelector:@selector(_detachFromParent)];
@@ -305,12 +400,6 @@ static const char * const stateNames[] = {
 - (void)_transitionToCommitted
 {
     ASSERT([self controller] != nil);
-    NSView <WebDocumentView> *documentView;
-    WebHistoryItem *backForwardItem;
-    WebBackForwardList *backForwardList = [[self controller] backForwardList];
-    WebFrame *parentFrame;
-    
-    documentView = [[self webView] documentView];
 
     // Destroy plug-ins before blowing away the view.
     [_private->pluginController destroyAllPlugins];
@@ -318,7 +407,20 @@ static const char * const stateNames[] = {
     switch ([self _state]) {
     	case WebFrameStateProvisional:
         {
-	    ASSERT(documentView != nil);
+            WebFrameLoadType loadType = [self _loadType];
+            if (loadType == WebFrameLoadTypeForward ||
+                loadType == WebFrameLoadTypeBack ||
+                loadType == WebFrameLoadTypeIndexedBackForward)
+            {
+                // Once committed, we want to use current item for saving DocState, and
+                // the provisional item for restoring state.
+                // Note previousItem must be set before we close the URL, which will
+                // happen when the data source is made non-provisional below
+                [_private setPreviousItem:[_private currentItem]];
+                ASSERT([_private provisionalItem]);
+                [_private setCurrentItem:[_private provisionalItem]];
+                [_private setProvisionalItem:nil];
+            }
 
             // Set the committed data source on the frame.
             [self _setDataSource:_private->provisionalDataSource];
@@ -331,12 +433,13 @@ static const char * const stateNames[] = {
             WebHistoryItem *entry = nil;
             NSString *ptitle = [ds pageTitle];
 
-            if ([[self controller] usesBackForwardList]){
-                switch ([self _loadType]) {
+            if ([[self controller] usesBackForwardList]) {
+                switch (loadType) {
                 case WebFrameLoadTypeForward:
                 case WebFrameLoadTypeBack:
                 case WebFrameLoadTypeIndexedBackForward:
-                    [backForwardList goToEntry: [ds _provisionalBackForwardItem]];
+                    // Must grab the current scroll position before disturbing it
+                    [self _saveScrollPositionToItem:[_private previousItem]];
                     [self _restoreScrollPosition];
                     break;
                     
@@ -351,15 +454,7 @@ static const char * const stateNames[] = {
                         [entry setTitle: ptitle];
 
                     if (![ds _isClientRedirect]) {
-                        // Add item to back/forward list.
-                        parentFrame = [self parent];
-                        backForwardItem = [[WebHistoryItem alloc] initWithURL:[[ds request] URL]
-                                                                       target:[self name]
-                                                                       parent:[parentFrame name]
-                                                                        title:ptitle];
-                        [[[self controller] backForwardList] addEntry: backForwardItem];
-                        [ds _addBackForwardItem:backForwardItem];
-                        [backForwardItem release];
+                        [self _addBackForwardItemClippedAtTarget:YES];
                     } else {
                         // update the URL in the BF list that we made before the redirect
                         [[[[self controller] backForwardList] currentEntry] setURL:[[ds request] URL]];
@@ -367,7 +462,15 @@ static const char * const stateNames[] = {
                     break;
                     
                 case WebFrameLoadTypeInternal:
-                    // Do nothing, this was a frame/iframe non user load.
+                    {  // braces because the silly compiler lets you declare vars everywhere but here?!
+                    // Add an item to the item tree for this frame
+                    WebHistoryItem *item = [self _createItem];
+                    ASSERT([[self parent]->_private currentItem]);
+                    [[[self parent]->_private currentItem] addChildItem:item];
+                    [item release];
+                    }
+                    break;
+
                 case WebFrameLoadTypeReloadAllowingStaleData:
                     break;
                     
@@ -437,6 +540,7 @@ static const char * const stateNames[] = {
         [[sv contentView] setCopiesOnScroll:YES];
         [_private->scheduledLayoutTimer fire];
    	ASSERT(_private->scheduledLayoutTimer == nil);
+        [_private setPreviousItem:nil];
     }
 }
 
@@ -479,6 +583,7 @@ static const char * const stateNames[] = {
             if (![ds isLoading]) {
                 id thisView = [self webView];
                 NSView <WebDocumentView> *thisDocumentView = [thisView documentView];
+                ASSERT(thisDocumentView != nil);
 
                 [self _setState: WebFrameStateComplete];
 
@@ -567,6 +672,9 @@ static const char * const stateNames[] = {
         case WebFrameStateComplete:
         {
             LOG(Loading, "%@:  checking complete, current state WebFrameStateComplete", [self name]);
+            // Even if already complete, we might have set a previous item on a frame that
+            // didn't do any data loading on the past transaction.  Make sure to clear these out.
+            [_private setPreviousItem:nil];
             return;
         }
         
@@ -704,28 +812,46 @@ static const char * const stateNames[] = {
     [_private setProvisionalDataSource:d];
 }
 
-// main funnel for navigating via back/forward
-- (void)_goToItem: (WebHistoryItem *)item withFrameLoadType: (WebFrameLoadType)type
+// helper method that determines whether the subframes described by the item's subitems
+// match our own current frameset
+- (BOOL)_childFramesMatchItem:(WebHistoryItem *)item
+{
+    NSArray *childItems = [item children];
+    int numChildItems = childItems ? [childItems count] : 0;
+    int numChildFrames = _private->children ? [_private->children count] : 0;
+    if (numChildFrames != numChildItems) {
+        return NO;
+    } else {
+        int i;
+        for (i = 0; i < numChildItems; i++) {
+            NSString *itemTargetName = [[childItems objectAtIndex:i] target];
+            //Search recursive here?
+            if (![self _immediateChildFrameNamed:itemTargetName]) {
+                return NO;	// couldn't match the i'th itemTarget
+            }
+        }
+        return YES;		// found matches for all itemTargets
+    }
+}
+
+// loads content into this frame, as specified by item
+- (void)_loadItem:(WebHistoryItem *)item fromItem:(WebHistoryItem *)fromItem withLoadType: (WebFrameLoadType)type
 {
     NSURL *itemURL = [item URL];
     WebResourceRequest *request;
-    NSURL *originalURL = [[[self dataSource] request] URL];
-    WebBackForwardList *backForwardList = [[self controller] backForwardList];
+    NSURL *currentURL = [[[self dataSource] request] URL];
 
     // Are we navigating to an anchor within the page?
-    if ([item anchor] && [[itemURL _web_URLByRemovingFragment] isEqual: [originalURL _web_URLByRemovingFragment]]) {
-        if (type == WebFrameLoadTypeForward)
-            [backForwardList goForward];
-        else if (type == WebFrameLoadTypeBack)
-            [backForwardList goBack];
-        else if (type == WebFrameLoadTypeIndexedBackForward)
-            [backForwardList goToEntry:item];
-        else 
-            [NSException raise:NSInvalidArgumentException format:@"WebFrameLoadType incorrect"];
+    // Note if we have child frames we do a real reload, since the child frames might not
+    // match our current frame structure, or they might not have the right content.  We could
+    // check for all that as an additional optimization.
+    if ([item anchor] &&
+        [[itemURL _web_URLByRemovingFragment] isEqual: [currentURL _web_URLByRemovingFragment]] &&
+        (!_private->children || ![_private->children count]))
+    {
         [[_private->dataSource _bridge] scrollToAnchor: [item anchor]];
         [[[self controller] locationChangeDelegate] locationChangedWithinPageForDataSource:_private->dataSource];
-    }
-    else {
+    } else {
         request = [[WebResourceRequest alloc] initWithURL:itemURL];
     
         // set the request cache policy based on the type of request we have
@@ -759,19 +885,81 @@ static const char * const stateNames[] = {
 
         WebDataSource *newDataSource = [[WebDataSource alloc] initWithRequest:request];
         [request release];
-        [self setProvisionalDataSource: newDataSource];
-        // Remember this item in order to set the position in the BFList later.
-        // Important that this happens after our provDataSrc is set, since setting
-        // provDataSrc results in isLoadComplete, which clears provLink!
-        [newDataSource _setProvisionalBackForwardItem: item];
-        // Set the item for which we will save document state
-        [newDataSource _setPreviousBackForwardItem: [backForwardList currentEntry]];
-        [self _setLoadType: type];
+        [self setProvisionalDataSource:newDataSource];
+        // Remember this item so we can traverse any child items as child frames load
+        [_private setProvisionalItem:item];
+        [self _setLoadType:type];
         [self startLoading];
         [newDataSource release];
     }
 }
 
+// The general idea here is to traverse the frame tree and the item tree in parallel,
+// tracking whether each frame already has the content the item requests.  If there is
+// a match (by URL), we just restore scroll position and recurse.  Otherwise we must
+// reload that frame, and all its kids.
+- (void)_recursiveGoToItem:(WebHistoryItem *)item fromItem:(WebHistoryItem *)fromItem withLoadType:(WebFrameLoadType)type
+{
+    NSURL *itemURL = [item URL];
+    NSURL *currentURL = [[[self dataSource] request] URL];
+
+    // Always reload the target frame of the item we're going to.  This ensures that we will
+    // do -some- load for the transition, which means a proper notification will be posted
+    // to the app.
+    // The exact URL has to match, including fragment.  We want to go through the _load
+    // method, even if to do a within-page navigation.
+    // The current frame tree and the frame tree snapshot in the item have to match.
+    if (![item isTargetItem] &&
+        [itemURL isEqual:currentURL] &&
+        [_private->name isEqualToString:[item target]] &&
+        [self _childFramesMatchItem:item])
+    {
+        // This content is good, so leave it alone and look for children that need reloading
+
+        // Save form state (works from currentItem, since prevItem is nil)
+        ASSERT(![_private previousItem]);
+        [_private->bridge saveDocumentState];
+        [self _saveScrollPositionToItem:[_private currentItem]];
+        
+        [_private setCurrentItem:item];
+
+        // Restore form state (works from currentItem)
+        [_private->bridge restoreDocumentState];
+        // Restore the scroll position (taken in favor of going back to the anchor)
+        [self _restoreScrollPosition];
+        
+        NSArray *childItems = [item children];
+        int numChildItems = childItems ? [childItems count] : 0;
+        int i;
+        for (i = numChildItems - 1; i >= 0; i--) {
+            WebHistoryItem *childItem = [childItems objectAtIndex:i];
+            NSString *childName = [childItem target];
+            WebHistoryItem *fromChildItem = [fromItem childItemWithName:childName];
+            ASSERT(fromChildItem || [fromItem isTargetItem]);
+            WebFrame *childFrame = [self _immediateChildFrameNamed:childName];
+            ASSERT(childFrame);
+            [childFrame _recursiveGoToItem:childItem fromItem:fromChildItem withLoadType:type];
+        }
+    } else {
+        // We need to reload the content
+        [self _loadItem:item fromItem:fromItem withLoadType:type];
+    }
+}
+
+// Main funnel for navigating to a previous location (back/forward, non-search snap-back)
+// This includes recursion to handle loading into framesets properly
+- (void)_goToItem: (WebHistoryItem *)item withLoadType: (WebFrameLoadType)type
+{
+    ASSERT(!_private->parent);
+    WebBackForwardList *backForwardList = [[self controller] backForwardList];
+    WebHistoryItem *currItem = [backForwardList currentEntry];
+    // Set the BF cursor before commit, which lets the user quickly click back/forward again.
+    // - plus, it only makes sense for the top level of the operation through the frametree,
+    // as opposed to happening for some/one of the page commits that might happen soon
+    [backForwardList goToEntry:item];
+    [self _recursiveGoToItem:item fromItem:currItem withLoadType:type];
+}
+
 - (void)_loadRequest:(WebResourceRequest *)request
 {
     WebDataSource *newDataSource = [[WebDataSource alloc] initWithRequest:request];
@@ -871,18 +1059,29 @@ static const char * const stateNames[] = {
 
     // FIXME: This logic doesn't exactly match what KHTML does in openURL, so it's possible
     // this will screw up in some cases involving framesets.
-    if (loadType != WebFrameLoadTypeReload && [[URL _web_URLByRemovingFragment] isEqual:[[_private->bridge URL] _web_URLByRemovingFragment]]) {
-        [_private->bridge openURL:URL];
+    if (loadType != WebFrameLoadTypeReload && [URL fragment] && [[URL _web_URLByRemovingFragment] isEqual:[[_private->bridge URL] _web_URLByRemovingFragment]]) {
+        // Just do anchor navigation within the existing content.  Note we only do this if there is
+        // an anchor in the URL - otherwise this check might prevent us from reloading a document
+        // that has subframes that are different than what we're displaying (in other words, a link
+        // from within a frame is trying to reload the frameset into _top).
+        WebDataSource *dataSrc = [self dataSource];
+
+        // save scroll position before we open URL, which will jump to anchor
+        [self _saveScrollPositionToItem:[_private currentItem]];
 
-        WebDataSource *dataSource = [self dataSource];
-        WebHistoryItem *backForwardItem = [[WebHistoryItem alloc] initWithURL:URL target:[self name] parent:[[self parent] name] title:[dataSource pageTitle]];
-        [backForwardItem setAnchor:[URL fragment]];
-        [[[self controller] backForwardList] addEntry:backForwardItem];
-        [backForwardItem release];
+        // ???Might need to save scroll-state, form-state for all other frames
 
-        [dataSource _setURL:URL];
-        [dataSource _addBackForwardItem:backForwardItem];
-        [[[self controller] locationChangeDelegate] locationChangedWithinPageForDataSource:dataSource];
+        ASSERT(![_private previousItem]);
+        // will save form state to current item, since prevItem not set
+        [_private->bridge openURL:URL];
+        [dataSrc _setURL:URL];
+        // NB: must happen after _setURL, since we add based on the current request
+        [self _addBackForwardItemClippedAtTarget:NO];
+        // This will clear previousItem from the rest of the frame tree tree that didn't
+        // doing any loading.  We need to make a pass on this now, since for anchor nav
+        // we'll not go through a real load and reach Completed state
+        [self _checkLoadComplete];
+        [[[self controller] locationChangeDelegate] locationChangedWithinPageForDataSource:dataSrc];
     } else {
         WebFrameLoadType previousLoadType = [self _loadType];
         WebDataSource *oldDataSource = [[self dataSource] retain];
@@ -898,8 +1097,6 @@ static const char * const stateNames[] = {
             // need to transfer BF items from the dataSource that we're replacing
             WebDataSource *newDataSource = [self provisionalDataSource];
             [newDataSource _setIsClientRedirect:YES];
-            [newDataSource _setProvisionalBackForwardItem:[oldDataSource _provisionalBackForwardItem]];
-            [newDataSource _setPreviousBackForwardItem:[oldDataSource _previousBackForwardItem]];
             [newDataSource _addBackForwardItems:[oldDataSource _backForwardItems]];
         }
         [request release];
@@ -907,6 +1104,43 @@ static const char * const stateNames[] = {
     }
 }
 
+- (void)_loadURL:(NSURL *)URL intoChild:(WebFrame *)childFrame
+{
+    //WebDataSource *dataSrc = [self dataSource];
+    WebHistoryItem *parentItem = [_private currentItem];
+    NSArray *childItems = [parentItem children];
+    WebFrameLoadType loadType = [self _loadType];
+    WebFrameLoadType childLoadType = WebFrameLoadTypeInternal;
+    WebHistoryItem *childItem = nil;
+
+    // If we're moving in the backforward list, we might want to replace the content
+    // of this child frame with whatever was there at that point.
+    if ((loadType == WebFrameLoadTypeForward || 
+        loadType == WebFrameLoadTypeBack ||
+        loadType == WebFrameLoadTypeIndexedBackForward ||
+        loadType == WebFrameLoadTypeReload) && childItems)
+    {
+        childItem = [parentItem childItemWithName:[childFrame name]];
+        if (childItem) {
+            URL = [childItem URL];
+            // These behaviors implied by these loadTypes should apply to the child frames
+            childLoadType = loadType;
+        }
+    }
+            
+    [childFrame _loadURL:URL loadType:childLoadType clientRedirect:NO triggeringEvent:nil];
+    // want this here???
+    if (childItem) {
+        if (loadType != WebFrameLoadTypeReload) {
+            // For back/forward, remember this item so we can traverse any child items as child frames load
+            [childFrame->_private setProvisionalItem:childItem];
+        } else {
+            // For reload, just reinstall the current item, since a new child frame was created but we won't be creating a new BF item
+            [childFrame->_private setCurrentItem:childItem];
+        }
+    }
+}
+
 - (void)_postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)contentType
 {
     // When posting, use the WebResourceHandleFlagLoadFromOrigin load flag.
@@ -922,20 +1156,28 @@ static const char * const stateNames[] = {
     [request release];
 }
 
-- (void)_restoreScrollPosition
+- (void)_saveScrollPositionToItem:(WebHistoryItem *)item
 {
-    WebHistoryItem *entry;
+    if (item) {
+        NSView *clipView = [[[self webView] documentView] superview];
+        // we might already be detached when this is called from detachFromParent, in which
+        // case we don't want to override real data earlier gathered with (0,0)
+        if (clipView) {
+            [item setScrollPoint:[clipView bounds].origin];
+        }
+    }
+}
 
-    entry = (WebHistoryItem *)[[[self controller] backForwardList] currentEntry];
-    [[[self webView] documentView] scrollPoint: [entry scrollPoint]];
+- (void)_restoreScrollPosition
+{
+    WebHistoryItem *entry = [_private currentItem];
+    ASSERT(entry);
+    [[[self webView] documentView] scrollPoint:[entry scrollPoint]];
 }
 
 - (void)_scrollToTop
 {
-    NSPoint origin;
-
-    origin.x = origin.y = 0.0;
-    [[[self webView] documentView] scrollPoint: origin];
+    [[[self webView] documentView] scrollPoint: NSZeroPoint];
 }
 
 - (void)_textSizeMultiplierChanged
@@ -992,4 +1234,57 @@ static const char * const stateNames[] = {
     return _private->pluginController;
 }
 
+- (void)_addFramePathToString:(NSMutableString *)path
+{
+    if ([_private->name hasPrefix:@"<!--framePath "]) {
+        // we have a generated name - take the path from our name
+        NSRange ourPathRange = {14, [_private->name length] - 14 - 3};
+        [path appendString:[_private->name substringWithRange:ourPathRange]];
+    } else {
+        // we have a generated name - just add our simple name to the end
+        if (_private->parent) {
+            [_private->parent _addFramePathToString:path];
+        }
+        [path appendString:@"/"];
+        [path appendString:_private->name];
+    }
+}
+
+// Generate a repeatable name for a child about to be added to us.  The name must be
+// unique within the frame tree.  The string we generate includes a "path" of names
+// from the root frame down to us.  For this path to be unique, each set of siblings must
+// contribute a unique name to the path, which can't collide with any HTML-assigned names.
+// We generate this path component by index in the child list along with an unlikely frame name.
+- (NSString *)_generateFrameName
+{
+    NSMutableString *path = [NSMutableString stringWithCapacity:256];
+    [path insertString:@"<!--framePath " atIndex:0];
+    [self _addFramePathToString:path];
+    // The new child's path component is all but the 1st char and the last 3 chars
+    [path appendFormat:@"/<!--frame%d-->-->", _private->children ? [_private->children count] : 0];
+    return path;
+}
+
+- (WebHistoryItem *)_itemForSavingDocState
+{
+    // For a standard page load, we will have a previous item set, which will be used to
+    // store the form state.  However, in some cases we will have no previous item, and
+    // the current item is the right place to save the state.  One example is when we
+    // detach a bunch of frames because we are navigating from a site with frames to
+    // another site.  Another is when saving the frame state of a frame that is not the
+    // target of the current navigation (if we even decide to save with that granularity).
+
+    // Because of previousItem's "masking" of currentItem for this purpose, it's important
+    // that previousItem be cleared at the end of a page transition.  We leverage the
+    // checkLoadComplete recursion to achieve this goal.
+
+    WebHistoryItem *result = [_private previousItem] ? [_private previousItem] : [_private currentItem];
+    return result;
+}
+
+- (WebHistoryItem *)_itemForRestoringDocState
+{
+    return [_private currentItem];
+}
+
 @end
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index 57f6fbf..cd00395 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -244,29 +244,15 @@ NSString *WebElementFrameKey = @"WebElementFrame";
     return _private->useBackForwardList;
 }
 
-- (void)_goToItem: (WebHistoryItem *)item withFrameLoadType: (WebFrameLoadType)type
+- (void)_goToItem: (WebHistoryItem *)item withLoadType: (WebFrameLoadType)type
 {
     WebFrame *targetFrame;
-    
+
+    // abort any current load if we're going back/forward
+    [[self mainFrame] stopLoading];
     targetFrame = [self _findFrameNamed: [item target]];
-    if (targetFrame == nil){
-        NSLog (@"Target frame not found, using main frame instead, will be fixed soon");
-#if 0
-        int pos = 1;
-        WebHistoryItem *next = item;
-        while (next){
-            NSLog (@"frame name %@, parent %@", [next target], [next parent]);
-            nextFrame = [self _findFrameNamed: [next parent]];
-            next = [[self backForwardList] backEntryAtIndex: pos++];
-            if ([[next target] isEqual: @"_top"]){
-                [[self mainFrame] _goToItem: next withFrameLoadType: WebFrameLoadTypeIntermediateBack];
-                return;
-            }
-        }
-#endif            
-        targetFrame = [self mainFrame];
-    }
-    [targetFrame _goToItem: item withFrameLoadType: type];
+    ASSERT(targetFrame != nil);
+    [targetFrame _goToItem: item withLoadType: type];
 }
 
 - (BOOL)goBack
@@ -274,7 +260,7 @@ NSString *WebElementFrameKey = @"WebElementFrame";
     WebHistoryItem *item = [[self backForwardList] backEntry];
     
     if (item){
-        [self _goToItem: item withFrameLoadType: WebFrameLoadTypeBack];
+        [self _goToItem: item withLoadType: WebFrameLoadTypeBack];
         return YES;
     }
     return NO;
@@ -285,7 +271,7 @@ NSString *WebElementFrameKey = @"WebElementFrame";
     WebHistoryItem *item = [[self backForwardList] forwardEntry];
     
     if (item){
-        [self _goToItem: item withFrameLoadType: WebFrameLoadTypeForward];
+        [self _goToItem: item withLoadType: WebFrameLoadTypeForward];
         return YES;
     }
     return NO;
@@ -293,7 +279,7 @@ NSString *WebElementFrameKey = @"WebElementFrame";
 
 - (BOOL)goBackOrForwardToItem:(WebHistoryItem *)item
 {
-    [self _goToItem: item withFrameLoadType: WebFrameLoadTypeIndexedBackForward];
+    [self _goToItem: item withLoadType: WebFrameLoadTypeIndexedBackForward];
     return YES;
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list