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

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:28:47 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit b3bb7300328409eef50a5e2b63b450c95bbac65f
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Aug 1 20:31:33 2002 +0000

    WebKit:
            More back/forward word.  Support for restoring scroll position.
            We still have a big remaining issue.  We don't record the entire
            frame tree in back/forward items.  This means going back or forward
            to a frame will looose the context of the containing frameset,
            see 3014555.
    
            * History.subproj/WebBackForwardList.m:
            (-[WebBackForwardList currentEntry]):
            * History.subproj/WebHistoryItem.h:
            * History.subproj/WebHistoryItem.m:
            (-[WebHistoryItem anchor]):
            (-[WebHistoryItem setAnchor:]):
            * WebCoreSupport.subproj/WebBridge.m:
            (-[WebBridge reportError:]):
            * WebView.subproj/WebController.m:
            (-[WebController _goToItem:withFrameLoadType:]):
            (-[WebController goBack]):
            (-[WebController goForward]):
            * WebView.subproj/WebFrame.m:
            (-[WebFrame setProvisionalDataSource:]):
            * WebView.subproj/WebFramePrivate.h:
            * WebView.subproj/WebFramePrivate.m:
            (-[WebFrame _transitionToCommitted]):
            (-[WebFrame _isLoadComplete]):
            (-[WebFrame _goToItem:withFrameLoadType:]):
            (-[WebFrame _restoreScrollPosition]):
            (-[WebFrame _scrollToTop]):
    
    WebBrowser:
            Removed old obsolete restore scroll position code.
    
            * LocationChangeHandler.m:
            (-[LocationChangeHandler locationChangeStartedForDataSource:]):
    
    WebCore:
            Added method to allow WebKit to direct khtml to
            goto to an anchor point.  Need for back/forward.
    
            * kwq/KWQKHTMLPartImpl.mm:
            (KWQKHTMLPartImpl::urlSelected):
            * kwq/WebCoreBridge.h:
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge gotoAnchor:]):
    
    WebFoundation:
            Convenience method to remove fragment (target anchor)
            from URL.
    
            * Misc.subproj/WebNSURLExtras.h:
            * Misc.subproj/WebNSURLExtras.m:
            (-[NSURL _web_URLWithoutFragment]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1718 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 25ed094..a9e964f 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,14 @@
+2002-08-01  Richard Williamson (Local)  <rjw at apple.com>
+
+        Added method to allow WebKit to direct khtml to
+        goto to an anchor point.  Need for back/forward.
+        
+        * kwq/KWQKHTMLPartImpl.mm:
+        (KWQKHTMLPartImpl::urlSelected):
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge gotoAnchor:]):
+
 2002-08-01  Ken Kocienda  <kocienda at apple.com>
 
 	Tweaked WebCore cache settings. The WebCore cache will now grow
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 25ed094..a9e964f 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,14 @@
+2002-08-01  Richard Williamson (Local)  <rjw at apple.com>
+
+        Added method to allow WebKit to direct khtml to
+        goto to an anchor point.  Need for back/forward.
+        
+        * kwq/KWQKHTMLPartImpl.mm:
+        (KWQKHTMLPartImpl::urlSelected):
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge gotoAnchor:]):
+
 2002-08-01  Ken Kocienda  <kocienda at apple.com>
 
 	Tweaked WebCore cache settings. The WebCore cache will now grow
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 25ed094..a9e964f 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,14 @@
+2002-08-01  Richard Williamson (Local)  <rjw at apple.com>
+
+        Added method to allow WebKit to direct khtml to
+        goto to an anchor point.  Need for back/forward.
+        
+        * kwq/KWQKHTMLPartImpl.mm:
+        (KWQKHTMLPartImpl::urlSelected):
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge gotoAnchor:]):
+
 2002-08-01  Ken Kocienda  <kocienda at apple.com>
 
 	Tweaked WebCore cache settings. The WebCore cache will now grow
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index b29561e..b850863 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -265,6 +265,8 @@ void KWQKHTMLPartImpl::urlSelected( const QString &url, int button, int state, c
     if (refLess.url() == part->m_url.url()){
         part->m_url = clickedURL;
         part->gotoAnchor (clickedURL.ref());
+        // This URL needs to be added to the back/forward list.
+        [bridge addBackForwardItemWithURL: clickedURL.getNSURL() anchor:clickedURL.ref().getNSString()];
         return;
     }
     
diff --git a/WebCore/kwq/KWQKHTMLPartImpl.mm b/WebCore/kwq/KWQKHTMLPartImpl.mm
index b29561e..b850863 100644
--- a/WebCore/kwq/KWQKHTMLPartImpl.mm
+++ b/WebCore/kwq/KWQKHTMLPartImpl.mm
@@ -265,6 +265,8 @@ void KWQKHTMLPartImpl::urlSelected( const QString &url, int button, int state, c
     if (refLess.url() == part->m_url.url()){
         part->m_url = clickedURL;
         part->gotoAnchor (clickedURL.ref());
+        // This URL needs to be added to the back/forward list.
+        [bridge addBackForwardItemWithURL: clickedURL.getNSURL() anchor:clickedURL.ref().getNSString()];
         return;
     }
     
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index a9175a3..797e76e 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -88,6 +88,7 @@ typedef khtml::RenderPart KHTMLRenderPart;
 - (void)removeFromFrame;
 
 - (void)scrollToBaseAnchor;
+- (void)gotoAnchor: (NSString *)anchor;
 
 - (void)createKHTMLViewWithNSView:(NSView *)view
     width:(int)width height:(int)height
@@ -164,6 +165,8 @@ typedef khtml::RenderPart KHTMLRenderPart;
 
 - (BOOL)modifierTrackingEnabled;
 
+- (void)addBackForwardItemWithURL: (NSURL *)url anchor: (NSString *)anchor;
+
 @end
 
 // This interface definition allows those who hold a WebCoreBridge * to call all the methods
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 15b308a..58e28cc 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -132,6 +132,11 @@ using namespace khtml;
     part->impl->gotoBaseAnchor();
 }
 
+- (void)gotoAnchor: (NSString *)a
+{
+    part->gotoAnchor(QString::fromCFString((CFStringRef)a));
+}
+
 - (NSString *)selectedText
 {
     return [[part->selectedText().getNSString() copy] autorelease];
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index a900103..5043b21 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,33 @@
+2002-08-01  Richard Williamson (Local)  <rjw at apple.com>
+
+        More back/forward word.  Support for restoring scroll position.
+        We still have a big remaining issue.  We don't record the entire
+        frame tree in back/forward items.  This means going back or forward
+        to a frame will looose the context of the containing frameset,
+        see 3014555.
+        
+        * History.subproj/WebBackForwardList.m:
+        (-[WebBackForwardList currentEntry]):
+        * History.subproj/WebHistoryItem.h:
+        * History.subproj/WebHistoryItem.m:
+        (-[WebHistoryItem anchor]):
+        (-[WebHistoryItem setAnchor:]):
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge reportError:]):
+        * WebView.subproj/WebController.m:
+        (-[WebController _goToItem:withFrameLoadType:]):
+        (-[WebController goBack]):
+        (-[WebController goForward]):
+        * WebView.subproj/WebFrame.m:
+        (-[WebFrame setProvisionalDataSource:]):
+        * WebView.subproj/WebFramePrivate.h:
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFrame _transitionToCommitted]):
+        (-[WebFrame _isLoadComplete]):
+        (-[WebFrame _goToItem:withFrameLoadType:]):
+        (-[WebFrame _restoreScrollPosition]):
+        (-[WebFrame _scrollToTop]):
+
 2002-08-01  Chris Blumenberg  <cblu at apple.com>
 
 	Fixed:
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index a900103..5043b21 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,33 @@
+2002-08-01  Richard Williamson (Local)  <rjw at apple.com>
+
+        More back/forward word.  Support for restoring scroll position.
+        We still have a big remaining issue.  We don't record the entire
+        frame tree in back/forward items.  This means going back or forward
+        to a frame will looose the context of the containing frameset,
+        see 3014555.
+        
+        * History.subproj/WebBackForwardList.m:
+        (-[WebBackForwardList currentEntry]):
+        * History.subproj/WebHistoryItem.h:
+        * History.subproj/WebHistoryItem.m:
+        (-[WebHistoryItem anchor]):
+        (-[WebHistoryItem setAnchor:]):
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge reportError:]):
+        * WebView.subproj/WebController.m:
+        (-[WebController _goToItem:withFrameLoadType:]):
+        (-[WebController goBack]):
+        (-[WebController goForward]):
+        * WebView.subproj/WebFrame.m:
+        (-[WebFrame setProvisionalDataSource:]):
+        * WebView.subproj/WebFramePrivate.h:
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFrame _transitionToCommitted]):
+        (-[WebFrame _isLoadComplete]):
+        (-[WebFrame _goToItem:withFrameLoadType:]):
+        (-[WebFrame _restoreScrollPosition]):
+        (-[WebFrame _scrollToTop]):
+
 2002-08-01  Chris Blumenberg  <cblu at apple.com>
 
 	Fixed:
diff --git a/WebKit/History.subproj/WebBackForwardList.m b/WebKit/History.subproj/WebBackForwardList.m
index c73ee63..d68a49e 100644
--- a/WebKit/History.subproj/WebBackForwardList.m
+++ b/WebKit/History.subproj/WebBackForwardList.m
@@ -70,6 +70,9 @@
 {
     WebHistoryItem *result;
     
+    if (index < 0 || index >= [uriList count])
+        return  nil;
+        
     result = [uriList entryAtIndex:index];
 
     return result;
diff --git a/WebKit/History.subproj/WebHistoryItem.h b/WebKit/History.subproj/WebHistoryItem.h
index 499987c..e0a8992 100644
--- a/WebKit/History.subproj/WebHistoryItem.h
+++ b/WebKit/History.subproj/WebHistoryItem.h
@@ -14,34 +14,37 @@
     NSImage *_image;
     NSCalendarDate *_lastVisitedDate;
     NSPoint _scrollPoint;
+    NSString *anchor;
 }
 
 +(WebHistoryItem *)entryWithURL:(NSURL *)url;
 
--(id)init;
--(id)initWithURL:(NSURL *)url title:(NSString *)title;
--(id)initWithURL:(NSURL *)url title:(NSString *)title image:(NSImage *)image;
--(id)initWithURL:(NSURL *)url target: (NSString *)target title:(NSString *)title image:(NSImage *)image;
-
--(NSDictionary *)dictionaryRepresentation;
--(id)initFromDictionaryRepresentation:(NSDictionary *)dict;
-
--(NSURL *)url;
--(NSString *)target;
--(NSString *)title;
--(NSString *)displayTitle;
--(NSImage *)image;
--(NSCalendarDate *)lastVisitedDate;
-
--(void)setURL:(NSURL *)url;
--(void)setTarget:(NSString *)target;
--(void)setTitle:(NSString *)title;
--(void)setDisplayTitle:(NSString *)displayTitle;
--(void)setImage:(NSImage *)image;
--(void)setLastVisitedDate:(NSCalendarDate *)date;
--(void)setScrollPoint: (NSPoint)p;
+- (id)init;
+- (id)initWithURL:(NSURL *)url title:(NSString *)title;
+- (id)initWithURL:(NSURL *)url title:(NSString *)title image:(NSImage *)image;
+- (id)initWithURL:(NSURL *)url target: (NSString *)target title:(NSString *)title image:(NSImage *)image;
+
+- (NSDictionary *)dictionaryRepresentation;
+- (id)initFromDictionaryRepresentation:(NSDictionary *)dict;
+
+- (NSURL *)url;
+- (NSString *)target;
+- (NSString *)title;
+- (NSString *)displayTitle;
+- (NSImage *)image;
+- (NSCalendarDate *)lastVisitedDate;
+
+- (void)setURL:(NSURL *)url;
+- (void)setTarget:(NSString *)target;
+- (void)setTitle:(NSString *)title;
+- (void)setDisplayTitle:(NSString *)displayTitle;
+- (void)setImage:(NSImage *)image;
+- (void)setLastVisitedDate:(NSCalendarDate *)date;
+- (void)setScrollPoint: (NSPoint)p;
 - (NSPoint)scrollPoint;
--(unsigned)hash;
--(BOOL)isEqual:(id)anObject;
+- (unsigned)hash;
+- (BOOL)isEqual:(id)anObject;
+- (NSString *)anchor;
+- (void)setAnchor: (NSString *)anchor;
 
 @end
diff --git a/WebKit/History.subproj/WebHistoryItem.m b/WebKit/History.subproj/WebHistoryItem.m
index 2596765..c35a9f7 100644
--- a/WebKit/History.subproj/WebHistoryItem.m
+++ b/WebKit/History.subproj/WebHistoryItem.m
@@ -156,6 +156,19 @@
     return [_url hash];
 }
 
+- (NSString *)anchor
+{
+    return anchor;
+}
+
+- (void)setAnchor: (NSString *)a
+{
+    [a retain];
+    [anchor release];
+    anchor = a;
+}
+
+
 -(BOOL)isEqual:(id)anObject
 {
     BOOL result;
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index 2e5ed4f..5a0d8f3 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -1,20 +1,22 @@
 /*	
     WebBridge.mm
-	Copyright (c) 2002, Apple, Inc. All rights reserved.
+    Copyright (c) 2002, Apple, Inc. All rights reserved.
 */
 
 #import <WebKit/WebBridge.h>
 
-#import <WebKit/WebHTMLRepresentationPrivate.h>
-#import <WebKit/WebHTMLViewPrivate.h>
-#import <WebKit/WebSubresourceClient.h>
+#import <WebKit/WebBackForwardList.h>
 #import <WebKit/WebControllerPrivate.h>
 #import <WebKit/WebDataSourcePrivate.h>
 #import <WebKit/WebFramePrivate.h>
-#import <WebKit/WebViewPrivate.h>
-#import <WebKit/WebLoadProgress.h>
-#import <WebKit/WebKitStatisticsPrivate.h>
+#import <WebKit/WebHistoryItem.h>
+#import <WebKit/WebHTMLRepresentationPrivate.h>
+#import <WebKit/WebHTMLViewPrivate.h>
 #import <WebKit/WebKitDebug.h>
+#import <WebKit/WebKitStatisticsPrivate.h>
+#import <WebKit/WebLoadProgress.h>
+#import <WebKit/WebSubresourceClient.h>
+#import <WebKit/WebViewPrivate.h>
 
 #import <WebFoundation/WebResourceHandle.h>
 
@@ -306,4 +308,14 @@
                         fromDataSource:[self dataSource]];
 }
 
+- (void)addBackForwardItemWithURL: (NSURL *)url anchor: (NSString *)anchor;
+{
+    WebHistoryItem *backForwardItem;
+
+    backForwardItem = [[WebHistoryItem alloc] initWithURL:url target: [frame name] title:[[frame dataSource] pageTitle] image: nil];
+    [backForwardItem setAnchor: anchor];
+    [[[frame controller] backForwardList] addEntry: backForwardItem];
+    [backForwardItem release];
+}
+
 @end
diff --git a/WebKit/WebView.subproj/WebController.m b/WebKit/WebView.subproj/WebController.m
index 4b74b15..9498eb0 100644
--- a/WebKit/WebView.subproj/WebController.m
+++ b/WebKit/WebView.subproj/WebController.m
@@ -308,15 +308,23 @@
     return _private->useBackForwardList;
 }
 
+- (void)_goToItem: (WebHistoryItem *)item withFrameLoadType: (WebFrameLoadType)type
+{
+    WebFrame *targetFrame;
+    targetFrame = [self frameNamed: [item target]];
+    if (targetFrame == nil){
+        NSLog (@"Target frame not found, using main frame instead, will be fixed soon.\n");
+        targetFrame = [self mainFrame];
+    }
+    [targetFrame _goToItem: item withFrameLoadType: type];
+}
 
 - (BOOL)goBack
 {
     WebHistoryItem *item = [[self backForwardList] backEntry];
-    WebFrame *targetFrame;
     
     if (item){
-        targetFrame = [self frameNamed: [item target]];
-        [targetFrame _goToURL: [item url] withFrameLoadType: WebFrameLoadTypeBack];
+        [self _goToItem: item withFrameLoadType: WebFrameLoadTypeBack];
         return YES;
     }
     return NO;
@@ -325,11 +333,9 @@
 - (BOOL)goForward
 {
     WebHistoryItem *item = [[self backForwardList] forwardEntry];
-    WebFrame *targetFrame;
     
     if (item){
-        targetFrame = [self frameNamed: [item target]];
-        [targetFrame _goToURL: [item url] withFrameLoadType: WebFrameLoadTypeForward];
+        [self _goToItem: item withFrameLoadType: WebFrameLoadTypeForward];
         return YES;
     }
     return NO;
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index d2ed8c7..7dacb9b 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -7,16 +7,20 @@
 
 #import <Cocoa/Cocoa.h>
 
-#import <WebKit/WebHTMLRepresentationPrivate.h>
-#import <WebKit/WebHTMLViewPrivate.h>
 #import <WebKit/WebController.h>
+#import <WebKit/WebBackForwardList.h>
 #import <WebKit/WebBridge.h>
 #import <WebKit/WebDataSourcePrivate.h>
 #import <WebKit/WebFramePrivate.h>
-#import <WebKit/WebViewPrivate.h>
-#import <WebKit/WebLocationChangeHandler.h>
+#import <WebKit/WebHistoryItem.h>
+#import <WebKit/WebHTMLRepresentationPrivate.h>
+#import <WebKit/WebHTMLViewPrivate.h>
 #import <WebKit/WebKitStatisticsPrivate.h>
 #import <WebKit/WebKitDebug.h>
+#import <WebKit/WebLocationChangeHandler.h>
+#import <WebKit/WebViewPrivate.h>
+
+#import <WebFoundation/WebNSURLExtras.h>
 
 @implementation WebFrame
 
@@ -124,6 +128,17 @@
     // KDE drop we should fix this dependency.
     WEBKIT_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_URLWithoutFragment] isEqual: [[[self dataSource] inputURL] _web_URLWithoutFragment]]){
+            NSPoint point = [[[[self webView] documentView] superview] bounds].origin;
+            [entry setScrollPoint: point];
+        }
+    }
     if ([self _state] != WebFrameStateComplete){
         [self stopLoading];
     }
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index b77254c..d4f94b1 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -1,7 +1,7 @@
 /*	
         WebFramePrivate.h
 	    
-	    Copyright 2001, Apple, Inc. All rights reserved.
+        Copyright 2001, Apple, Inc. All rights reserved.
 
         Private header file.
 */
@@ -10,7 +10,9 @@
 
 @class WebBridge;
 @class WebFrameBridge;
+ at class WebHistoryItem;
 @class WebView;
+
 @protocol WebDocumentLoading;
 
 typedef enum {
@@ -92,5 +94,7 @@ typedef enum {
 - (void)_setProvisionalDataSource:(WebDataSource *)d;
 - (void)_setLoadType: (WebFrameLoadType)loadType;
 - (WebFrameLoadType)_loadType;
-- (void)_goToURL: (NSURL *)url withFrameLoadType: (WebFrameLoadType)type;
+- (void)_goToItem: (WebHistoryItem *)item withFrameLoadType: (WebFrameLoadType)type;
+- (void)_restoreScrollPosition;
+- (void)_scrollToTop;
 @end
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 5cce6b7..2a8951b 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -23,6 +23,7 @@
 #import <WebKit/WebPreferencesPrivate.h>
 #import <WebKit/WebViewPrivate.h>
 
+#import <WebFoundation/WebNSURLExtras.h>
 #import <WebFoundation/WebFoundation.h>
 
 static const char * const stateNames[6] = {
@@ -260,16 +261,16 @@ static const char * const stateNames[6] = {
                 switch ([self _loadType]) {
                 case WebFrameLoadTypeForward:
                     [backForwardList goForward];
-                    // restore scroll position.
+                    [self _restoreScrollPosition];
                     break;
     
                 case WebFrameLoadTypeBack:
                     [backForwardList goBack];
-                    // restore scroll position.
+                    [self _restoreScrollPosition];
                     break;
                     
                 case WebFrameLoadTypeRefresh:
-                    // restore scroll position.
+                    [self _scrollToTop];
                     break;
     
                 case WebFrameLoadTypeStandard:
@@ -438,6 +439,39 @@ static const char * const stateNames[6] = {
                 // Jump to anchor point, if necessary.
                 [[ds _bridge] scrollToBaseAnchor];
 
+                // If the user had a scroll point scroll to it.  This will override
+                // the anchor point.  After much discussion it was decided by folks
+                // that the user scroll point should override the anchor point.
+                if ([[self controller] useBackForwardList]){
+                    switch ([self _loadType]) {
+                    case WebFrameLoadTypeForward:
+                        [self _restoreScrollPosition];
+                        break;
+        
+                    case WebFrameLoadTypeBack:
+                        [self _restoreScrollPosition];
+                        break;
+                        
+                    case WebFrameLoadTypeRefresh:
+                        [self _scrollToTop];
+                        break;
+        
+                    case WebFrameLoadTypeStandard:
+                    case WebFrameLoadTypeInternal:
+                        // Do nothing.
+                        break;
+                        
+                    // FIXME Remove this check when dummy ds is removed.  An exception should be thrown
+                    // if we're in the WebFrameLoadTypeUninitialized state.
+                    case WebFrameLoadTypeUninitialized:
+                        break;
+                        
+                    default:
+                        [[NSException exceptionWithName:NSGenericException reason:@"invalid load type during commit transition" userInfo: nil] raise];
+                        break;
+                    }
+                }
+
                 [[[self controller] locationChangeHandler] locationChangeDone: [ds mainDocumentError] forDataSource:ds];
  
                 //if ([ds isDocumentHTML])
@@ -625,13 +659,48 @@ static const char * const stateNames[6] = {
 }
 
 
-- (void)_goToURL: (NSURL *)url withFrameLoadType: (WebFrameLoadType)type
+- (void)_goToItem: (WebHistoryItem *)item withFrameLoadType: (WebFrameLoadType)type
 {
-    WebDataSource *dataSource = [[WebDataSource alloc] initWithURL:url];
-    [self setProvisionalDataSource: dataSource];
-    [self _setLoadType: type];
-    [self startLoading];
-    [dataSource release];
+    NSURL *itemURL = [item url];
+    WebDataSource *dataSource;
+    NSURL *inputURL = [[self dataSource] inputURL];
+    
+    if ([item anchor] && [[itemURL _web_URLWithoutFragment] isEqual: [inputURL _web_URLWithoutFragment]]){
+        WebBackForwardList *backForwardList = [[self controller] backForwardList];
+
+        if (type == WebFrameLoadTypeForward)
+            [backForwardList goForward];
+        else if (type == WebFrameLoadTypeBack)
+            [backForwardList goBack];
+        else 
+            [NSException raise:NSInvalidArgumentException format:@"WebFrameLoadType incorrect"];
+        [[_private->dataSource _bridge] gotoAnchor: [item anchor]];
+    }
+    else {
+        dataSource = [[WebDataSource alloc] initWithURL:itemURL];
+        [self setProvisionalDataSource: dataSource];
+        [self _setLoadType: type];
+        [self startLoading];
+        [dataSource release];
+    }
 }
 
+- (void)_restoreScrollPosition
+{
+    WebHistoryItem *entry;
+
+    entry = (WebHistoryItem *)[[[self controller] backForwardList] currentEntry];
+    [[[self webView] documentView] scrollPoint: [entry scrollPoint]];
+}
+
+- (void)_scrollToTop
+{
+    NSPoint origin;
+
+    origin.x = origin.y = 0.0;
+    [[[self webView] documentView] scrollPoint: origin];
+}
+
+
+
 @end
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index 4b74b15..9498eb0 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -308,15 +308,23 @@
     return _private->useBackForwardList;
 }
 
+- (void)_goToItem: (WebHistoryItem *)item withFrameLoadType: (WebFrameLoadType)type
+{
+    WebFrame *targetFrame;
+    targetFrame = [self frameNamed: [item target]];
+    if (targetFrame == nil){
+        NSLog (@"Target frame not found, using main frame instead, will be fixed soon.\n");
+        targetFrame = [self mainFrame];
+    }
+    [targetFrame _goToItem: item withFrameLoadType: type];
+}
 
 - (BOOL)goBack
 {
     WebHistoryItem *item = [[self backForwardList] backEntry];
-    WebFrame *targetFrame;
     
     if (item){
-        targetFrame = [self frameNamed: [item target]];
-        [targetFrame _goToURL: [item url] withFrameLoadType: WebFrameLoadTypeBack];
+        [self _goToItem: item withFrameLoadType: WebFrameLoadTypeBack];
         return YES;
     }
     return NO;
@@ -325,11 +333,9 @@
 - (BOOL)goForward
 {
     WebHistoryItem *item = [[self backForwardList] forwardEntry];
-    WebFrame *targetFrame;
     
     if (item){
-        targetFrame = [self frameNamed: [item target]];
-        [targetFrame _goToURL: [item url] withFrameLoadType: WebFrameLoadTypeForward];
+        [self _goToItem: item withFrameLoadType: WebFrameLoadTypeForward];
         return YES;
     }
     return NO;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list