Distinguishing between navigation and history.pushState

72 views
Skip to first unread message

Vincent Scheib

unread,
Jul 23, 2012, 1:36:19 PM7/23/12
to Chromium-dev
I'm seeking a way to determine that navigation has occurred and actually changed the document. http://crbug.com/138324

Currently, Fullscreen Controller observes content::NOTIFICATION_NAV_ENTRY_COMMITTED and uses (details)->is_navigation_to_different_page(). However, history.pushState triggers this, too.

The problem is that history.pushState also triggers that notification, and in that situation we do not want to exit full screen.

Any help finding the right logic to detect this appreciated.

Jochen Eisinger

unread,
Jul 23, 2012, 2:17:58 PM7/23/12
to sch...@chromium.org, Chromium-dev
A navigation that changes the frame is always preceded by the start of a provisional load. If you just see a commit but no start, the location is updated (happens for reference fragment navigations and history state changes). See WebNavigationTabObserver::DidCommitProvisionalLoadForFrame

best
-jochen


--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

Darin Fisher

unread,
Jul 23, 2012, 2:57:25 PM7/23/12
to joc...@chromium.org, sch...@chromium.org, Chromium-dev
We should probably add a "IsWithinDocumentNavigation" or "IsSameDocument" method to NavigationEntry to help distinguish these cases.  We probably don't want code to be inferring this condition when WebKit knows it precisely.

-Darin

Michael Nordman

unread,
Jul 23, 2012, 3:09:48 PM7/23/12
to da...@google.com, joc...@chromium.org, sch...@chromium.org, Chromium-dev
On Mon, Jul 23, 2012 at 11:57 AM, Darin Fisher <da...@chromium.org> wrote:
We should probably add a "IsWithinDocumentNavigation" or "IsSameDocument" method to NavigationEntry to help distinguish these cases.  We probably don't want code to be inferring this condition when WebKit knows it precisely.

+1, IsFragmentNavigation()?

Jochen Eisinger

unread,
Jul 23, 2012, 3:13:31 PM7/23/12
to Michael Nordman, da...@google.com, sch...@chromium.org, Chromium-dev
On Mon, Jul 23, 2012 at 9:09 PM, Michael Nordman <mich...@google.com> wrote:



On Mon, Jul 23, 2012 at 11:57 AM, Darin Fisher <da...@chromium.org> wrote:
We should probably add a "IsWithinDocumentNavigation" or "IsSameDocument" method to NavigationEntry to help distinguish these cases.  We probably don't want code to be inferring this condition when WebKit knows it precisely.

+1, IsFragmentNavigation()?

that would be NavigationControllerImpl::IsURLInPageNavigation, no?

The history navigation case is differently, as you can't detect it from just looking at the URL.

-jochen

Michael Nordman

unread,
Jul 23, 2012, 3:36:34 PM7/23/12
to Jochen Eisinger, da...@google.com, sch...@chromium.org, Chromium-dev
I see... i spoke too quickly w/o being familiar enough with these abstractions... it's not clear to me how to best reflect this state between NavigationController and NavigationEntry and NavigationDetails and such... but +1 an accessor that allows a caller to determine after the fact when a navigation is the the result of pushState vs other cases w/o having to monitor for commit w/o a provisional load on their own.

Darin Fisher

unread,
Jul 23, 2012, 7:20:52 PM7/23/12
to Michael Nordman, Jochen Eisinger, sch...@chromium.org, Chromium-dev
WebCore uses terms like "didNavigateWithinPage" and "loadSameDocumentItem" to refer to navigations that are either hash changes or induced via pushState/replaceState or popstate events.

The key thing that makes pushState introduce bugs is that it isn't just about changing the hash fragment.  In fact, in many cases it is now a bug if you just compare URLs sans-reference fragment.  The only code that should be doing that is the code in WebCore that tests to see if it should scroll to an anchor!

-Darin
Reply all
Reply to author
Forward
0 new messages