Changeset 14669 in webkit


Ignore:
Timestamp:
Jun 1, 2006 2:29:31 PM (18 years ago)
Author:
andersca
Message:

WebCore:

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.


Location:
trunk
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r14667 r14669  
     12006-06-01  Anders Carlsson  <acarlsson@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        http://bugzilla.opendarwin.org/show_bug.cgi?id=6309
     6        multiple problems prevent bookmarking/back button technique for AJAX/DHTML applications from working
     7       
     8        * fast/dom/location-hash-expected.txt: Added.
     9        * fast/dom/location-hash.html: Added.
     10        Added tests.
     11       
    1122006-06-01  Maciej Stachowiak  <mjs@apple.com>
    213
  • trunk/WebCore/ChangeLog

    r14668 r14669  
     12006-06-01  Anders Carlsson  <acarlsson@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        http://bugzilla.opendarwin.org/show_bug.cgi?id=6309
     6        multiple problems prevent bookmarking/back button technique for AJAX/DHTML applications from working
     7       
     8        * bindings/js/kjs_window.cpp:
     9        (KJS::Location::put):
     10        Handle the case where the hash starts with a "#". Also, don't do anything if the previous and new hashes
     11        are equal.
     12       
     13        * bridge/BrowserExtension.h:
     14        * bridge/mac/BrowserExtensionMac.h:
     15        * bridge/mac/BrowserExtensionMac.mm:       
     16        (WebCore::BrowserExtensionMac::historyURL):
     17        * bridge/mac/WebCoreFrameBridge.h:
     18        * bridge/mac/WebCoreFrameBridge.mm:
     19        New function historyURL which returns the complete URL for a given item in the history.
     20       
     21        * page/Frame.cpp:
     22        (WebCore::Frame::scheduleLocationChange):       
     23        (WebCore::Frame::scheduleHistoryNavigation):
     24        If the URL of the new location only differs in the hash, don't schedule the load. Instead, load it
     25        directly.
     26       
     27        * platform/KURL.cpp:
     28        * platform/KURL.h:
     29        Add equalsIgnoringRef which returns whether two URLs are equal, ignoring the ref.
     30
    1312006-06-01  Anders Carlsson  <acarlsson@apple.com>
    232
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r14646 r14669  
    15151515                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
    15161516/* End PBXBuildFile section */
    1517 
    1518 /* Begin PBXBuildStyle section */
    1519                 DB14676D0A237ECE00C9DD16 /* Development */ = {
    1520                         isa = PBXBuildStyle;
    1521                         buildSettings = {
    1522                                 COPY_PHASE_STRIP = NO;
    1523                         };
    1524                         name = Development;
    1525                 };
    1526                 DB14676E0A237ECE00C9DD16 /* Deployment */ = {
    1527                         isa = PBXBuildStyle;
    1528                         buildSettings = {
    1529                                 COPY_PHASE_STRIP = YES;
    1530                         };
    1531                         name = Deployment;
    1532                 };
    1533 /* End PBXBuildStyle section */
    15341517
    15351518/* Begin PBXContainerItemProxy section */
     
    61876170                        isa = PBXProject;
    61886171                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
    6189                         buildSettings = {
    6190                         };
    6191                         buildStyles = (
    6192                                 DB14676D0A237ECE00C9DD16 /* Development */,
    6193                                 DB14676E0A237ECE00C9DD16 /* Deployment */,
    6194                         );
    61956172                        hasScannedForEncodings = 1;
    61966173                        knownRegions = (
  • trunk/WebCore/bindings/js/kjs_window.cpp

    r14651 r14669  
    21082108      break;
    21092109    }
    2110     case Hash:
     2110    case Hash: {
     2111      if (str.startsWith("#"))
     2112        str = str.mid(1);
     2113
     2114      if (url.ref() == str)
     2115          return;
     2116
    21112117      url.setRef(str);
    21122118      break;
     2119    }
    21132120    case Host: {
    21142121      DeprecatedString host = str.left(str.find(":"));
  • trunk/WebCore/bridge/BrowserExtension.h

    r14643 r14669  
    6666    virtual int getHistoryLength() = 0;
    6767    virtual void goBackOrForward(int distance) = 0;
    68 
     68    virtual KURL historyURL(int distance) = 0;
     69   
    6970    virtual bool canRunModal() = 0;
    7071    virtual bool canRunModalNow() = 0;
  • trunk/WebCore/bridge/mac/BrowserExtensionMac.h

    r13440 r14669  
    4545    virtual int getHistoryLength();
    4646    virtual void goBackOrForward(int distance);
     47    virtual KURL historyURL(int distance);
    4748
    4849    virtual bool canRunModal();
  • trunk/WebCore/bridge/mac/BrowserExtensionMac.mm

    r14651 r14669  
    166166}
    167167
     168KURL BrowserExtensionMac::historyURL(int distance)
     169{
     170    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     171    return KURL([m_frame->bridge() historyURL:distance]);
     172    END_BLOCK_OBJC_EXCEPTIONS;
     173    return KURL();
     174}
     175
    168176bool BrowserExtensionMac::canRunModal()
    169177{
  • trunk/WebCore/bridge/mac/WebCoreFrameBridge.h

    r14651 r14669  
    254254- (void)removeFromFrame;
    255255
    256 - (void)scrollToAnchor:(NSString *)anchor;
    257256- (void)scrollToAnchorWithURL:(NSURL *)URL;
    258257
     
    618617- (void)goBackOrForward:(int)distance;
    619618- (BOOL)canGoBackOrForward:(int)distance;
     619- (NSURL *)historyURL:(int)distance;
    620620
    621621- (void)textFieldDidBeginEditing:(DOMHTMLInputElement *)element;
  • trunk/WebCore/bridge/mac/WebCoreFrameBridge.mm

    r14643 r14669  
    737737}
    738738
    739 - (void)scrollToAnchor:(NSString *)anchor
    740 {
    741     m_frame->gotoAnchor(anchor);
    742 }
    743 
    744739- (BOOL)isSelectionEditable
    745740{
  • trunk/WebCore/page/Frame.cpp

    r14658 r14669  
    899899void Frame::scheduleLocationChange(const DeprecatedString& url, const DeprecatedString& referrer, bool lockHistory, bool userGesture)
    900900{
     901    KURL u(url);
     902   
     903    // If the URL we're going to navigate to is the same as the current one, except for the
     904    // fragment part, we don't need to schedule the location change.
     905    if (u.hasRef() && equalIgnoringRef(d->m_url, u)) {
     906        changeLocation(url, referrer, lockHistory, userGesture);
     907        return;
     908    }
     909       
    901910    // Handle a location change of a page with no document as a special case.
    902911    // This may happen when a frame changes the location of another frame.
     
    909918        stopLoading(true);   
    910919    }
    911    
     920
    912921    d->m_delayRedirect = 0;
    913922    d->m_redirectURL = url;
     
    943952    }
    944953
     954    // If the URL we're going to navigate to is the same as the current one, except for the
     955    // fragment part, we don't need to schedule the navigation.
     956    if (d->m_extension) {
     957        KURL u = d->m_extension->historyURL(steps);
     958       
     959        if (equalIgnoringRef(d->m_url, u)) {
     960            d->m_extension->goBackOrForward(steps);
     961            return;
     962        }
     963    }
     964   
    945965    d->m_scheduledRedirection = historyNavigationScheduled;
    946966    d->m_delayRedirect = 0;
  • trunk/WebCore/platform/KURL.cpp

    r14320 r14669  
    12011201}
    12021202
    1203 bool urlcmp(const DeprecatedString &a, const DeprecatedString &b, bool ignoreTrailingSlash, bool ignoreRef)
    1204 {
    1205     if (ignoreRef) {
    1206         KURL aURL(a);
    1207         KURL bURL(b);
    1208         if (aURL.m_isValid && bURL.m_isValid)
    1209             return aURL.urlString.left(aURL.queryEndPos) == bURL.urlString.left(bURL.queryEndPos);
    1210     }
    1211     return a == b;
     1203bool equalIgnoringRef(const KURL& a, const KURL& b) const;
     1204{
     1205    return a.urlString.left(a.queryEndPos) == b.urlString.left(b.queryEndPos);
    12121206}
    12131207
  • trunk/WebCore/platform/KURL.h

    r13821 r14669  
    111111    int fragmentEndPos;
    112112   
    113     // True if both URLs are the same.
    114     friend bool urlcmp(const DeprecatedString &URLA, const DeprecatedString &URLB, bool ignoreTrailingSlash, bool ignoreRef);
     113    friend bool equalIgnoringRef(const KURL& a, const KURL& b);
    115114};
    116115
  • trunk/WebKit/ChangeLog

    r14667 r14669  
     12006-06-01  Anders Carlsson  <acarlsson@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        http://bugzilla.opendarwin.org/show_bug.cgi?id=6309
     6        multiple problems prevent bookmarking/back button technique for AJAX/DHTML applications from working
     7
     8        * Misc/WebNSURLExtras.m:
     9        (-[NSString _webkit_URLFragment]):
     10        Don't include the "#" character in the fragment.
     11       
     12        * WebCoreSupport/WebFrameBridge.m:
     13        (-[WebFrameBridge historyURL:]):
     14        New function, returns the history URL for a given position in the back/forward list
     15       
     16        * WebView/WebFrame.m:
     17        (-[WebFrame _loadItem:withLoadType:]):
     18        Always call scrollToAnchorWithURL, even if there is no fragment. This way we keep the WebCore frame's
     19        URL up-to-date.
     20
    1212006-06-01  Maciej Stachowiak  <mjs@apple.com>
    222
  • trunk/WebKit/Misc/WebNSURLExtras.m

    r14021 r14669  
    10881088    if (fragmentRange.location == NSNotFound)
    10891089        return nil;
    1090     return [self substringFromIndex:fragmentRange.location];
     1090    return [self substringFromIndex:fragmentRange.location + 1];
    10911091}
    10921092
  • trunk/WebKit/WebCoreSupport/WebFrameBridge.m

    r14651 r14669  
    12401240}
    12411241
     1242- (NSURL*)historyURL:(int)distance
     1243{
     1244    WebView *webView = [self webView];
     1245    WebBackForwardList *list = [webView backForwardList];
     1246    WebHistoryItem *item = [list itemAtIndex:distance];
     1247    if (!item) {
     1248        if (distance > 0) {
     1249            int forwardListCount = [list forwardListCount];
     1250            if (forwardListCount > 0)
     1251                item = [list itemAtIndex:forwardListCount];
     1252        } else {
     1253            int backListCount = [list forwardListCount];
     1254            if (backListCount > 0)
     1255                item = [list itemAtIndex:-backListCount];
     1256        }
     1257    }
     1258    if (item)
     1259        return [item URL];
     1260   
     1261    return nil;
     1262}
     1263
    12421264static id <WebFormDelegate> formDelegate(WebFrameBridge *self)
    12431265{
  • trunk/WebKit/WebKit.xcodeproj/project.pbxproj

    r14651 r14669  
    281281                ED7F6D8B0980683500C235ED /* WebNSDataExtrasPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    282282/* End PBXBuildFile section */
    283 
    284 /* Begin PBXBuildStyle section */
    285                 BC5D261E0A2E3FC000102DF0 /* Development */ = {
    286                         isa = PBXBuildStyle;
    287                         buildSettings = {
    288                                 COPY_PHASE_STRIP = NO;
    289                         };
    290                         name = Development;
    291                 };
    292                 BC5D261F0A2E3FC000102DF0 /* Deployment */ = {
    293                         isa = PBXBuildStyle;
    294                         buildSettings = {
    295                                 COPY_PHASE_STRIP = YES;
    296                         };
    297                         name = Deployment;
    298                 };
    299 /* End PBXBuildStyle section */
    300283
    301284/* Begin PBXFileReference section */
     
    12571240                        isa = PBXProject;
    12581241                        buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
    1259                         buildSettings = {
    1260                         };
    1261                         buildStyles = (
    1262                                 BC5D261E0A2E3FC000102DF0 /* Development */,
    1263                                 BC5D261F0A2E3FC000102DF0 /* Deployment */,
    1264                         );
    12651242                        hasScannedForEncodings = 1;
    12661243                        knownRegions = (
  • trunk/WebKit/WebView/WebFrame.m

    r14586 r14669  
    13351335        // FIXME: form state might want to be saved here too
    13361336
    1337         // FIXME: Perhaps we can use scrollToAnchorWithURL here instead and remove the older scrollToAnchor:?
    1338         NSString *anchor = [[item URLString] _webkit_URLFragment];
    1339         if (anchor)
    1340             [[_private->dataSource _bridge] scrollToAnchor: anchor];
     1337        // We always call scrollToAnchorWithURL here, even if the URL doesn't have an
     1338        // anchor fragment. This is so we'll keep the WebCore Frame's URL up-to-date.
     1339        [[_private->dataSource _bridge] scrollToAnchorWithURL:[item URL]];
    13411340   
    13421341        // must do this maintenance here, since we don't go through a real page reload
  • trunk/WebKitTools/ChangeLog

    r14665 r14669  
     12006-06-01  Anders Carlsson  <acarlsson@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        * DumpRenderTree/DumpRenderTree.m:
     6        (+[LayoutTestController isSelectorExcludedFromWebScript:]):
     7        (-[LayoutTestController clearBackForwardList]):
     8        Add clearBackForwardList function to layoutTestController
     9       
    1102006-06-01  Anders Carlsson  <acarlsson@apple.com>
    211
  • trunk/WebKitTools/DumpRenderTree/DumpRenderTree.m

    r14665 r14669  
    598598            || aSelector == @selector(display)
    599599            || aSelector == @selector(testRepaint)
    600             || aSelector == @selector(repaintSweepHorizontally))
     600            || aSelector == @selector(repaintSweepHorizontally)
     601            || aSelector == @selector(clearBackForwardList))
    601602        return NO;
    602603    return YES;
     
    610611        return @"setMainFrameIsFirstResponder";
    611612    return nil;
     613}
     614
     615- (void)clearBackForwardList
     616{
     617    WebBackForwardList *backForwardList = [[frame webView] backForwardList];
     618    WebHistoryItem *item = [[backForwardList currentItem] retain];
     619
     620    // We clear the history by setting the back/forward list's capacity to 0
     621    // then restoring it back and adding back the current item.
     622    int capacity = [backForwardList capacity];
     623    [backForwardList setCapacity:0];
     624    [backForwardList setCapacity:capacity];
     625    [backForwardList addItem:item];
     626    [backForwardList goToItem:item];
     627    [item release];
    612628}
    613629
Note: See TracChangeset for help on using the changeset viewer.