WebCore:
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Jun 2006 21:29:31 +0000 (21:29 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Jun 2006 21:29:31 +0000 (21:29 +0000)
2006-06-01  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Darin.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=6309
        multiple problems prevent bookmarking/back button technique for AJAX/DHTML applications from working

        * bindings/js/kjs_window.cpp:
        (KJS::Location::put):
        Handle the case where the hash starts with a "#". Also, don't do anything if the previous and new hashes
        are equal.

        * bridge/BrowserExtension.h:
        * bridge/mac/BrowserExtensionMac.h:
        * bridge/mac/BrowserExtensionMac.mm:
        (WebCore::BrowserExtensionMac::historyURL):
        * bridge/mac/WebCoreFrameBridge.h:
        * bridge/mac/WebCoreFrameBridge.mm:
        New function historyURL which returns the complete URL for a given item in the history.

        * page/Frame.cpp:
        (WebCore::Frame::scheduleLocationChange):
        (WebCore::Frame::scheduleHistoryNavigation):
        If the URL of the new location only differs in the hash, don't schedule the load. Instead, load it
        directly.

        * platform/KURL.cpp:
        * platform/KURL.h:
        Add equalsIgnoringRef which returns whether two URLs are equal, ignoring the ref.

WebKit:

2006-06-01  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Darin.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=6309
        multiple problems prevent bookmarking/back button technique for AJAX/DHTML applications from working

        * Misc/WebNSURLExtras.m:
        (-[NSString _webkit_URLFragment]):
        Don't include the "#" character in the fragment.

        * WebCoreSupport/WebFrameBridge.m:
        (-[WebFrameBridge historyURL:]):
        New function, returns the history URL for a given position in the back/forward list

        * WebView/WebFrame.m:
        (-[WebFrame _loadItem:withLoadType:]):
        Always call scrollToAnchorWithURL, even if there is no fragment. This way we keep the WebCore frame's
        URL up-to-date.

WebKitTools:

2006-06-01  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Darin.

        * DumpRenderTree/DumpRenderTree.m:
        (+[LayoutTestController isSelectorExcludedFromWebScript:]):
        (-[LayoutTestController clearBackForwardList]):
        Add clearBackForwardList function to layoutTestController

LayoutTests:

2006-06-01  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Darin.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=6309
        multiple problems prevent bookmarking/back button technique for AJAX/DHTML applications from working

        * fast/dom/location-hash-expected.txt: Added.
        * fast/dom/location-hash.html: Added.
        Added tests.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14669 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/location-hash-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/location-hash.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/kjs_window.cpp
WebCore/bridge/BrowserExtension.h
WebCore/bridge/mac/BrowserExtensionMac.h
WebCore/bridge/mac/BrowserExtensionMac.mm
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebCore/page/Frame.cpp
WebCore/platform/KURL.cpp
WebCore/platform/KURL.h
WebKit/ChangeLog
WebKit/Misc/WebNSURLExtras.m
WebKit/WebCoreSupport/WebFrameBridge.m
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebView/WebFrame.m
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/DumpRenderTree.m

index 055de77cd1c8553b82a0f786941e9003a9c2a147..1fc3f0be16be73a8f40eb1c2ca86667b7f6598be 100644 (file)
@@ -1,3 +1,14 @@
+2006-06-01  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=6309
+        multiple problems prevent bookmarking/back button technique for AJAX/DHTML applications from working
+        
+        * fast/dom/location-hash-expected.txt: Added.
+        * fast/dom/location-hash.html: Added.
+        Added tests.
+        
 2006-06-01  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Anders.
diff --git a/LayoutTests/fast/dom/location-hash-expected.txt b/LayoutTests/fast/dom/location-hash-expected.txt
new file mode 100644 (file)
index 0000000..47962c5
--- /dev/null
@@ -0,0 +1,21 @@
+This tests that modifying location.hash works as it should
+
+PASS: window.history.length == originalHistoryLength should be true and is.
+PASS: window.location.hash should be and is.
+PASS: window.location.hash should be #foo and is.
+PASS: window.location == originalLocation + '#foo' should be true and is.
+PASS: window.history.length == originalHistoryLength + 1 should be true and is.
+PASS: window.location.hash should be #bar and is.
+PASS: window.location == originalLocation + '#bar' should be true and is.
+PASS: window.history.length == originalHistoryLength + 2 should be true and is.
+PASS: window.location.hash should be #bar and is.
+PASS: window.location == originalLocation + '#bar' should be true and is.
+PASS: window.history.length == originalHistoryLength + 2 should be true and is.
+PASS: window.location.hash should be #foo and is.
+PASS: window.location == originalLocation + '#foo' should be true and is.
+PASS: window.location.hash should be and is.
+PASS: window.location == originalLocation should be true and is.
+PASS: window.location.hash should be #foo and is.
+PASS: window.location == originalLocation + '#foo' should be true and is.
+SUCCESS!
+
diff --git a/LayoutTests/fast/dom/location-hash.html b/LayoutTests/fast/dom/location-hash.html
new file mode 100644 (file)
index 0000000..b26e906
--- /dev/null
@@ -0,0 +1,100 @@
+<html>
+<head>
+<script>
+    function print(message, color) 
+    {
+        var paragraph = document.createElement("div");
+        paragraph.appendChild(document.createTextNode(message));
+        paragraph.style.fontFamily = "monospace";
+        if (color)
+            paragraph.style.color = color;
+            document.getElementById("console").appendChild(paragraph);
+    }
+
+    function shouldBe(a, b)
+    {
+        var evalA = eval(a);
+        if (evalA == b) 
+            print("PASS: " + a + " should be " + b + " and is.", "green");
+        else {
+            print("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".", "red");
+            numErrors ++;
+        }
+    }
+    
+    function step() {
+        switch (state) {
+            case 0:
+            shouldBe('window.history.length == originalHistoryLength', true);
+            shouldBe('window.location.hash', '');
+            window.location.hash = 'foo';
+            shouldBe('window.location.hash', '#foo');
+            shouldBe("window.location == originalLocation + '#foo'", true);
+            shouldBe('window.history.length ==  originalHistoryLength + 1', true);
+            break;
+        case 1:
+            window.location.hash = 'bar';
+            shouldBe('window.location.hash', '#bar');
+            shouldBe("window.location == originalLocation + '#bar'", true);
+            shouldBe('window.history.length == originalHistoryLength + 2', true);
+            break;
+        case 2:
+            window.location.hash = 'bar';
+            shouldBe('window.location.hash', '#bar');
+            shouldBe("window.location == originalLocation + '#bar'", true);
+            shouldBe('window.history.length == originalHistoryLength + 2', true);
+            break;        
+        case 3:
+            window.history.back();
+            shouldBe('window.location.hash', '#foo');
+            shouldBe("window.location == originalLocation + '#foo'", true);
+            break;
+        case 4:
+            window.history.back();
+            shouldBe('window.location.hash', '');
+            shouldBe("window.location == originalLocation", true);
+            break;
+        case 5:
+            window.history.forward();
+            shouldBe('window.location.hash', '#foo');
+            shouldBe("window.location == originalLocation + '#foo'", true);
+            break;
+        case 6:
+            window.location.hash = '';
+            if (numErrors == 0)
+                print("SUCCESS!", "green")
+            else
+                print("FAILURE: one or more tests failed", "red");
+                
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+                
+            return;
+        }
+        
+        state ++;
+        step();
+    }
+        
+    function runTests() {
+        if (window.layoutTestController) {
+            layoutTestController.clearBackForwardList();
+            layoutTestController.dumpAsText();
+            layoutTestController.waitUntilDone();
+        }
+        
+        state = 0;
+        numErrors = 0;
+        originalLocation = window.location.href;
+        originalHistoryLength = window.history.length;
+     
+        step();
+    }
+    </script>
+</head>
+<body onload="runTests();">
+<p>This tests that modifying location.hash works as it should</p>
+<div id="console">
+</div>
+</body>
+</html>
index 4f35bacdb9ddb04bc082c4a9af318068fa621a6d..ac1153ab856f2dc7b80c0e314f71bfe6f5ece4bc 100644 (file)
@@ -1,3 +1,33 @@
+2006-06-01  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=6309
+        multiple problems prevent bookmarking/back button technique for AJAX/DHTML applications from working
+        
+        * bindings/js/kjs_window.cpp:
+        (KJS::Location::put):
+        Handle the case where the hash starts with a "#". Also, don't do anything if the previous and new hashes
+        are equal.
+        
+        * bridge/BrowserExtension.h:
+        * bridge/mac/BrowserExtensionMac.h:
+        * bridge/mac/BrowserExtensionMac.mm:        
+        (WebCore::BrowserExtensionMac::historyURL):
+        * bridge/mac/WebCoreFrameBridge.h:
+        * bridge/mac/WebCoreFrameBridge.mm:
+        New function historyURL which returns the complete URL for a given item in the history.
+        
+        * page/Frame.cpp:
+        (WebCore::Frame::scheduleLocationChange):        
+        (WebCore::Frame::scheduleHistoryNavigation):
+        If the URL of the new location only differs in the hash, don't schedule the load. Instead, load it
+        directly.
+        
+        * platform/KURL.cpp:
+        * platform/KURL.h:
+        Add equalsIgnoringRef which returns whether two URLs are equal, ignoring the ref.
+
 2006-06-01  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Maciej.
index 9bcad9aa38a3df00a39fede01071d182e8a94ca6..449d6cf8b2ff948ea31f165365f937688f510b69 100644 (file)
                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
 /* End PBXBuildFile section */
 
-/* Begin PBXBuildStyle section */
-               DB14676D0A237ECE00C9DD16 /* Development */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = NO;
-                       };
-                       name = Development;
-               };
-               DB14676E0A237ECE00C9DD16 /* Deployment */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = YES;
-                       };
-                       name = Deployment;
-               };
-/* End PBXBuildStyle section */
-
 /* Begin PBXContainerItemProxy section */
                DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
-                       buildSettings = {
-                       };
-                       buildStyles = (
-                               DB14676D0A237ECE00C9DD16 /* Development */,
-                               DB14676E0A237ECE00C9DD16 /* Deployment */,
-                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index b5de9ea08b92007d98ec5baba2ace93c380451d4..665ba6c1c6ca333cd1682284b8e79083b16bd116 100644 (file)
@@ -2107,9 +2107,16 @@ void Location::put(ExecState *exec, const Identifier &p, JSValue *v, int attr)
         url = str;
       break;
     }
-    case Hash:
+    case Hash: {
+      if (str.startsWith("#"))
+        str = str.mid(1);
+
+      if (url.ref() == str)
+          return;
+
       url.setRef(str);
       break;
+    }
     case Host: {
       DeprecatedString host = str.left(str.find(":"));
       DeprecatedString port = str.mid(str.find(":")+1);
index facba20be2d663d63150882332fbe5bfe32a3d77..f077f24cb435a115f2fc8d9b0299662ef16e2011 100644 (file)
@@ -65,7 +65,8 @@ public:
 
     virtual int getHistoryLength() = 0;
     virtual void goBackOrForward(int distance) = 0;
-
+    virtual KURL historyURL(int distance) = 0;
+    
     virtual bool canRunModal() = 0;
     virtual bool canRunModalNow() = 0;
     virtual void runModal() = 0;
index cd23f376ee8966edec34fadaab2b6fb1e34b943f..d7ee23dc24d2f37b65f840676afa076658197178 100644 (file)
@@ -44,6 +44,7 @@ public:
 
     virtual int getHistoryLength();
     virtual void goBackOrForward(int distance);
+    virtual KURL historyURL(int distance);
 
     virtual bool canRunModal();
     virtual bool canRunModalNow();
index 906cc82c72a3bf1e76d70972a51eb4b9f1da7577..20f2efadf1a8477329327339a934b95520c6abb0 100644 (file)
@@ -165,6 +165,14 @@ void BrowserExtensionMac::goBackOrForward(int distance)
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
+KURL BrowserExtensionMac::historyURL(int distance)
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    return KURL([m_frame->bridge() historyURL:distance]);
+    END_BLOCK_OBJC_EXCEPTIONS;
+    return KURL();
+}
+
 bool BrowserExtensionMac::canRunModal()
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
index 54dac175fb37140d18e4c51fceada6833fb0de3f..22acd4fdd515a7cb10ebe3c0d211f0df51a6c433 100644 (file)
@@ -253,7 +253,6 @@ typedef enum {
 - (void)installInFrame:(NSView *)view;
 - (void)removeFromFrame;
 
-- (void)scrollToAnchor:(NSString *)anchor;
 - (void)scrollToAnchorWithURL:(NSURL *)URL;
 
 - (BOOL)scrollOverflowInDirection:(WebScrollDirection)direction granularity:(WebScrollGranularity)granularity;
@@ -617,6 +616,7 @@ typedef enum {
 - (int)historyLength;
 - (void)goBackOrForward:(int)distance;
 - (BOOL)canGoBackOrForward:(int)distance;
+- (NSURL *)historyURL:(int)distance;
 
 - (void)textFieldDidBeginEditing:(DOMHTMLInputElement *)element;
 - (void)textFieldDidEndEditing:(DOMHTMLInputElement *)element;
index 1cf8cbbe455546fcb17195ba27af1216f79f3037..7ccfbca0b77497ac644342194808330de95f3739 100644 (file)
@@ -736,11 +736,6 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
         frameView->setMarginHeight(mh);
 }
 
-- (void)scrollToAnchor:(NSString *)anchor
-{
-    m_frame->gotoAnchor(anchor);
-}
-
 - (BOOL)isSelectionEditable
 {
     return m_frame->selection().isContentEditable();
index f5e253462cbf4d2833894c4a7d01b35847b6c898..f4e15cb54ed3a39589d4519536b51c24d71f6991 100644 (file)
@@ -898,6 +898,15 @@ void Frame::scheduleRedirection(double delay, const DeprecatedString& url, bool
 
 void Frame::scheduleLocationChange(const DeprecatedString& url, const DeprecatedString& referrer, bool lockHistory, bool userGesture)
 {
+    KURL u(url);
+    
+    // If the URL we're going to navigate to is the same as the current one, except for the
+    // fragment part, we don't need to schedule the location change.
+    if (u.hasRef() && equalIgnoringRef(d->m_url, u)) {
+        changeLocation(url, referrer, lockHistory, userGesture);
+        return;
+    }
+        
     // Handle a location change of a page with no document as a special case.
     // This may happen when a frame changes the location of another frame.
     d->m_scheduledRedirection = d->m_doc ? locationChangeScheduled : locationChangeScheduledDuringLoad;
@@ -908,7 +917,7 @@ void Frame::scheduleLocationChange(const DeprecatedString& url, const Deprecated
     if (d->m_scheduledRedirection == locationChangeScheduledDuringLoad) {
         stopLoading(true);   
     }
-    
+
     d->m_delayRedirect = 0;
     d->m_redirectURL = url;
     d->m_redirectReferrer = referrer;
@@ -942,6 +951,17 @@ void Frame::scheduleHistoryNavigation(int steps)
         return;
     }
 
+    // If the URL we're going to navigate to is the same as the current one, except for the
+    // fragment part, we don't need to schedule the navigation.
+    if (d->m_extension) {
+        KURL u = d->m_extension->historyURL(steps);
+        
+        if (equalIgnoringRef(d->m_url, u)) {
+            d->m_extension->goBackOrForward(steps);
+            return;
+        }
+    }
+    
     d->m_scheduledRedirection = historyNavigationScheduled;
     d->m_delayRedirect = 0;
     d->m_redirectURL = DeprecatedString::null;
index 6e16686f39673d26e124628590957079ad10c880..fc50747bdfcc3b0f044b4f18b2e490d1d21cdbe8 100644 (file)
@@ -1200,15 +1200,9 @@ bool operator==(const KURL &a, const KURL &b)
     return a.urlString == b.urlString;
 }
 
-bool urlcmp(const DeprecatedString &a, const DeprecatedString &b, bool ignoreTrailingSlash, bool ignoreRef)
+bool equalIgnoringRef(const KURL& a, const KURL& b) const;
 {
-    if (ignoreRef) {
-        KURL aURL(a);
-        KURL bURL(b);
-        if (aURL.m_isValid && bURL.m_isValid)
-            return aURL.urlString.left(aURL.queryEndPos) == bURL.urlString.left(bURL.queryEndPos);
-    }
-    return a == b;
+    return a.urlString.left(a.queryEndPos) == b.urlString.left(b.queryEndPos);
 }
 
 DeprecatedString KURL::encode_string(const DeprecatedString& notEncodedString)
index d79251ae5d8f658dff3902ae8db8cc2dcd83d22f..337c337bfc6e3c0bb96183ba9f619b851ba19960 100644 (file)
@@ -110,8 +110,7 @@ private:
     int queryEndPos;
     int fragmentEndPos;
     
-    // True if both URLs are the same.
-    friend bool urlcmp(const DeprecatedString &URLA, const DeprecatedString &URLB, bool ignoreTrailingSlash, bool ignoreRef);
+    friend bool equalIgnoringRef(const KURL& a, const KURL& b);
 };
 
 #endif
index 022cdbdc02b04edbdcf838bdeb975e3d1389a898..2057b1f2c763f5d85f0118afc2e98db1db830a13 100644 (file)
@@ -1,3 +1,23 @@
+2006-06-01  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=6309
+        multiple problems prevent bookmarking/back button technique for AJAX/DHTML applications from working
+
+        * Misc/WebNSURLExtras.m:
+        (-[NSString _webkit_URLFragment]):
+        Don't include the "#" character in the fragment.
+        
+        * WebCoreSupport/WebFrameBridge.m:
+        (-[WebFrameBridge historyURL:]):
+        New function, returns the history URL for a given position in the back/forward list
+        
+        * WebView/WebFrame.m:
+        (-[WebFrame _loadItem:withLoadType:]):
+        Always call scrollToAnchorWithURL, even if there is no fragment. This way we keep the WebCore frame's
+        URL up-to-date.
+
 2006-06-01  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Anders.
index 696046ebcfb9f100e56e233a571d5a380c1f2de9..70b2a30cffb53b6cd528cc4b5d8f8565c3ee6fba 100644 (file)
@@ -1087,7 +1087,7 @@ static BOOL allCharactersInIDNScriptWhiteList(const UChar *buffer, int32_t lengt
     fragmentRange = [self rangeOfString:@"#" options:NSLiteralSearch];
     if (fragmentRange.location == NSNotFound)
         return nil;
-    return [self substringFromIndex:fragmentRange.location];
+    return [self substringFromIndex:fragmentRange.location + 1];
 }
 
 @end
index 9a5d6ce21623419c34b23db715ff968bc765e697..abaa7ce3b938905655761af426d8e31f3037de95 100644 (file)
@@ -1239,6 +1239,28 @@ static BOOL loggedObjectCacheSize = NO;
     }
 }
 
+- (NSURL*)historyURL:(int)distance
+{
+    WebView *webView = [self webView];
+    WebBackForwardList *list = [webView backForwardList];
+    WebHistoryItem *item = [list itemAtIndex:distance];
+    if (!item) {
+        if (distance > 0) {
+            int forwardListCount = [list forwardListCount];
+            if (forwardListCount > 0)
+                item = [list itemAtIndex:forwardListCount];
+        } else {
+            int backListCount = [list forwardListCount];
+            if (backListCount > 0)
+                item = [list itemAtIndex:-backListCount];
+        }
+    }
+    if (item)
+        return [item URL];
+    
+    return nil;
+}
+
 static id <WebFormDelegate> formDelegate(WebFrameBridge *self)
 {
     ASSERT(self->_frame != nil);
index 37d1dedc649085a118be4d84ebfb796b51203397..22e07976b661e1af8a9a7eef7c99acc5f89dfd37 100644 (file)
                ED7F6D8B0980683500C235ED /* WebNSDataExtrasPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 /* End PBXBuildFile section */
 
-/* Begin PBXBuildStyle section */
-               BC5D261E0A2E3FC000102DF0 /* Development */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = NO;
-                       };
-                       name = Development;
-               };
-               BC5D261F0A2E3FC000102DF0 /* Deployment */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = YES;
-                       };
-                       name = Deployment;
-               };
-/* End PBXBuildStyle section */
-
 /* Begin PBXFileReference section */
                1C68F640095B5FC100C2984E /* webInspector */ = {isa = PBXFileReference; lastKnownFileType = folder; name = webInspector; path = WebInspector/webInspector; sourceTree = SOURCE_ROOT; };
                1C68F65C095B5FC100C2984E /* WebInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebInspector.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
-                       buildSettings = {
-                       };
-                       buildStyles = (
-                               BC5D261E0A2E3FC000102DF0 /* Development */,
-                               BC5D261F0A2E3FC000102DF0 /* Deployment */,
-                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index be92a3c4d8eedd52af2ee7f6a230efe23b790cbe..1e85337276c9680c9aebf6e8de4b4c9bc0bac8e1 100644 (file)
@@ -1334,10 +1334,9 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
         [self _saveScrollPositionAndViewStateToItem:[_private currentItem]];
         // FIXME: form state might want to be saved here too
 
-        // FIXME: Perhaps we can use scrollToAnchorWithURL here instead and remove the older scrollToAnchor:?
-        NSString *anchor = [[item URLString] _webkit_URLFragment];
-        if (anchor)
-            [[_private->dataSource _bridge] scrollToAnchor: anchor];
+        // We always call scrollToAnchorWithURL here, even if the URL doesn't have an
+        // anchor fragment. This is so we'll keep the WebCore Frame's URL up-to-date.
+        [[_private->dataSource _bridge] scrollToAnchorWithURL:[item URL]];
     
         // must do this maintenance here, since we don't go through a real page reload
         [_private setCurrentItem:item];
index 1504de14692ff72aa1a3bc1e91d0a766a516cb8f..4a4685dfa86e302293eef9a5d025f572239fe79a 100644 (file)
@@ -1,3 +1,12 @@
+2006-06-01  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Darin.
+
+        * DumpRenderTree/DumpRenderTree.m:
+        (+[LayoutTestController isSelectorExcludedFromWebScript:]):
+        (-[LayoutTestController clearBackForwardList]):
+        Add clearBackForwardList function to layoutTestController
+        
 2006-06-01  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Darin.
index 48ce7f43fd037c69042a28093758543c29935347..5feb9bafcdfbd84165ab37706315c2cc95b8f3d3 100644 (file)
@@ -597,7 +597,8 @@ static void dump(void)
             || aSelector == @selector(dumpSelectionRect)
             || aSelector == @selector(display)
             || aSelector == @selector(testRepaint)
-            || aSelector == @selector(repaintSweepHorizontally))
+            || aSelector == @selector(repaintSweepHorizontally)
+            || aSelector == @selector(clearBackForwardList))
         return NO;
     return YES;
 }
@@ -611,6 +612,21 @@ static void dump(void)
     return nil;
 }
 
+- (void)clearBackForwardList
+{
+    WebBackForwardList *backForwardList = [[frame webView] backForwardList];
+    WebHistoryItem *item = [[backForwardList currentItem] retain];
+
+    // We clear the history by setting the back/forward list's capacity to 0
+    // then restoring it back and adding back the current item.
+    int capacity = [backForwardList capacity];
+    [backForwardList setCapacity:0];
+    [backForwardList setCapacity:capacity];
+    [backForwardList addItem:item];
+    [backForwardList goToItem:item];
+    [item release];
+}
+
 - (void)waitUntilDone 
 {
     waitToDump = YES;