Author: [email protected]
Date: Thu Jun 11 17:50:39 2009
New Revision: 5547

Modified:
    branches/crawlability/user/src/com/google/gwt/user/client/History.java
     
branches/crawlability/user/src/com/google/gwt/user/client/impl/HistoryImpl.java
     
branches/crawlability/user/src/com/google/gwt/user/client/ui/Hyperlink.java

Log:
Changes to history and hyperlink necessary for crawling. (Note: draft  
version, the special token(s) may change)



Modified:  
branches/crawlability/user/src/com/google/gwt/user/client/History.java
==============================================================================
--- branches/crawlability/user/src/com/google/gwt/user/client/History.java      
 
(original)
+++ branches/crawlability/user/src/com/google/gwt/user/client/History.java      
 
Thu Jun 11 17:50:39 2009
@@ -138,7 +138,7 @@
    public static String getToken() {
      return impl != null ? HistoryImpl.getToken() : "";
    }
-
+
    /**
     * Adds a new browser history entry. In hosted mode, the 'back'  
and 'forward'
     * actions are accessible via the standard Alt-Left and Alt-Right  
keystrokes.

Modified:  
branches/crawlability/user/src/com/google/gwt/user/client/impl/HistoryImpl.java
==============================================================================
---  
branches/crawlability/user/src/com/google/gwt/user/client/impl/HistoryImpl.java 
 
(original)
+++  
branches/crawlability/user/src/com/google/gwt/user/client/impl/HistoryImpl.java 
 
Thu Jun 11 17:50:39 2009
@@ -27,24 +27,23 @@

  /**
   * Native implementation associated with
- * {...@link com.google.gwt.user.client.History}.
- * User classes should not use this class directly.
+ * {...@link com.google.gwt.user.client.History}. User classes should not use  
this
+ * class directly.
   *
   * <p>
   * This base version uses the HTML5 standard window.onhashchange event to
   * determine when the URL hash identifier changes.
   * </p>
   */
-public class HistoryImpl implements HasValueChangeHandlers<String>,
-    HasHandlers {
+public class HistoryImpl implements HasValueChangeHandlers<String>,  
HasHandlers {

    public static native String getToken() /*-{
-    return $wnd.__gwt_historyToken || "";
-  }-*/;
+     return $wnd.__gwt_historyToken || "";
+   }-*/;

    protected static native void setToken(String token) /*-{
-    $wnd.__gwt_historyToken = token;
-  }-*/;
+     $wnd.__gwt_historyToken = token;
+   }-*/;

    private HandlerManager handlers = new HandlerManager(null);

@@ -67,6 +66,9 @@
     * Fires the {...@link ValueChangeEvent} to all handlers with the given  
tokens.
     */
    public void fireHistoryChangedImpl(String newToken) {
+    if ((newToken.length() > 0) && (newToken.charAt(0) == '!')) {
+      newToken = newToken.substring(1);
+    }
      ValueChangeEvent.fire(this, newToken);
    }

@@ -75,28 +77,28 @@
    }

    public native boolean init() /*-{
-    var token = '';
-
-    // Get the initial token from the url's hash component.
-    var hash = $wnd.location.hash;
-    if (hash.length > 0) {
-      token =  
[email protected]::decodeFragment(Ljava/lang/String;)(hash.substring(1));
-    }
+     var token = '';

-     
@com.google.gwt.user.client.impl.HistoryImpl::setToken(Ljava/lang/String;)(token);
-
-    var historyImpl = this;
-    $wnd.onhashchange = function() {
-      var token = '', hash = $wnd.location.hash;
-      if (hash.length > 0) {
-        token =  
[email protected]::decodeFragment(Ljava/lang/String;)(hash.substring(1));
-      }
+     // Get the initial token from the url's hash component.
+     var hash = $wnd.location.hash;
+     if (hash.length > 0) {
+       token =  
[email protected]::decodeFragment(Ljava/lang/String;)(hash.substring(1));
+     }
+
+      
@com.google.gwt.user.client.impl.HistoryImpl::setToken(Ljava/lang/String;)(token);
+
+     var historyImpl = this;
+     $wnd.onhashchange = function() {
+       var token = '', hash = $wnd.location.hash;
+       if (hash.length > 0) {
+         token =  
[email protected]::decodeFragment(Ljava/lang/String;)(hash.substring(1));
+       }

-       
[email protected]::newItemOnEvent(Ljava/lang/String;)(token);
-    };
+        
[email protected]::newItemOnEvent(Ljava/lang/String;)(token);
+     };

-    return true;
-  }-*/;
+     return true;
+   }-*/;

    public final void newItem(String historyToken, boolean issueEvent) {
      historyToken = (historyToken == null) ? "" : historyToken;
@@ -119,22 +121,22 @@
    }

    protected native String decodeFragment(String encodedFragment) /*-{
-    // decodeURI() does *not* decode the '#' character.
-    return decodeURI(encodedFragment.replace("%23", "#"));
-  }-*/;
+     // decodeURI() does *not* decode the '#' character.
+     return decodeURI(encodedFragment.replace("%23", "#"));
+   }-*/;

    protected native String encodeFragment(String fragment) /*-{
-    // encodeURI() does *not* encode the '#' character.
-    return encodeURI(fragment).replace("#", "%23");
-  }-*/;
+     // encodeURI() does *not* encode the '#' character.
+     return encodeURI(fragment).replace("#", "%23");
+   }-*/;

    /**
     * The standard updateHash implementation assigns to location.hash()  
with an
     * encoded history token.
     */
    protected native void nativeUpdate(String historyToken) /*-{
-    $wnd.location.hash =  
[email protected]::encodeFragment(Ljava/lang/String;)(historyToken);
-  }-*/;
+     $wnd.location.hash =  
[email protected]::encodeFragment(Ljava/lang/String;)(historyToken);
+   }-*/;

    protected void nativeUpdateOnEvent(String historyToken) {
      // Do nothing, the hash is already updated.

Modified:  
branches/crawlability/user/src/com/google/gwt/user/client/ui/Hyperlink.java
==============================================================================
---  
branches/crawlability/user/src/com/google/gwt/user/client/ui/Hyperlink.java     
 
(original)
+++  
branches/crawlability/user/src/com/google/gwt/user/client/ui/Hyperlink.java     
 
Thu Jun 11 17:50:39 2009
@@ -189,8 +189,8 @@
    public void setTargetHistoryToken(String targetHistoryToken) {
      assert targetHistoryToken != null
        : "targetHistoryToken must not be null, consider using Anchor  
instead";
-    this.targetHistoryToken = targetHistoryToken;
-    DOM.setElementProperty(anchorElem, "href", "#" + targetHistoryToken);
+    this.targetHistoryToken = "!" + targetHistoryToken;
+    DOM.setElementProperty(anchorElem, "href", "#!" + targetHistoryToken);
    }

    public void setText(String text) {

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to