Bug 35547

Summary: Clicking the same named anchor twice in a row fails the second time
Product: WebKit Reporter: Nate Chapin <japhet>
Component: WebCore Misc.Assignee: Nate Chapin <japhet>
Severity: Normal CC: beidson, daniel, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Description Flags
patch kenneth: review+

Description Nate Chapin 2010-03-01 14:45:58 PST
Originally reported at http://crbug.com/31851.

Repro steps:
1. Go to http://en.wikipedia.org/wiki/WebKit
2. Click on "Usage" link in the Contents at the top of the page
3. Scroll back to top of the page
4. Click "Usage" again

Step 4 should result in navigating back to the #Usage anchor, but nothing occurs.

I believe this is a regression due to http://trac.webkit.org/changeset/51644.  We don't scroll to the anchor if there isn't a hash change, which means we don't handle the case where we navigate, scroll, then navigate back to the same fragment.

I have a fix and layout test ready and will upload momentarily.
Comment 1 Nate Chapin 2010-03-01 14:51:56 PST
Created attachment 49755 [details]
Comment 2 Kenneth Rohde Christiansen 2010-03-04 10:02:46 PST
Comment on attachment 49755 [details]

> +    // We need to scrool to the fragment whether or not a hash change occurred, since

I guess that should be "scroll" :-) You should fix that before landing.
Comment 3 Nate Chapin 2010-03-04 16:47:39 PST
(In reply to comment #2)
> (From update of attachment 49755 [details])
> > +    // We need to scrool to the fragment whether or not a hash change occurred, since
> I guess that should be "scroll" :-) You should fix that before landing.

Comment 4 Brady Eidson 2010-03-04 17:13:33 PST
As far as I can tell, this change violates the HTML5 navigation spec:

The section "Navigating to a fragment identifier" invokes "History traversal".  History traversal has the following steps:

6 - If the specified entry has a URL that differs from the current entry's only by its fragment identifier, and the two share the same Document object, then let hash changed be true, and let old URL be the URL of the current entry and new URL be the URL of the specified entry. Otherwise, let hash changed be false.
8 - If hash changed is true, then, if the new URL has a fragment identifier, scroll to the fragment identifier.

Since hashchange is false, there should be no scroll.


All of that said, I think the new behavior is sensible, and it matches previous WebKit, Firefox, and Opera.  But my original change wasn't an accidental change in behavior, it was willfully following the spec.  I didn't realize at the time that it was breaking this fundamental case.

I think the spec needs to be changed to reflect this, but until it is changed, WebKit (and other browser engines) are out of spec.  :)
Comment 5 Brady Eidson 2010-03-04 17:31:50 PST
I brought this to Hixie's attention.  He filed http://www.w3.org/Bugs/Public/show_bug.cgi?id=9193 to fix the spec.

All is well.