Module navigation
The Navigation API (HTML): window.navigation over the tab's session history. The browser keeps the entries, their states and every navigation; the engine fires navigate (wj_nav_fire, reading Navigation_pending) before the browser commits a navigation, and the rest (wj_nav_commit) after a same-document commit. Keys and ids are numbers here.
Exposed to: Window. Source: api/navigation.widl.
Odin: import "wren:navigation".
Types
struct NavigationSource
What started that navigation, besides its URL: the element (event.sourceElement: a link, a submitter, a form submitted without one) and, for a POST form submission, the form and its submitter (event.formData). 0: none.
| field | type | |
|---|---|---|
source | u64 | |
form | u64 | |
submitter | u64 |
Functions
Navigation_entries
string Navigation_entries()navigation.entries(): "<current index>\n" then "<key> <id> <same document 0|1> <url>\n" per entry (the same-origin entries around the current one; none for an opaque origin, current index -1).
Odin: navigation.entries.
Host: Navigation_entries :: proc(c: ^Call) -> string
Navigation_serial
i64 Navigation_serial()Changes with every change of the session history (the engine reads the entries again only then).
Odin: navigation.serial.
Host: Navigation_serial :: proc(c: ^Call) -> i64
Navigation_getState
string Navigation_getState(i64 key, i64 id) raisesentry.getState(): the state of the entry key while its id is id; Not_Found when it has none.
Odin: navigation.getState.
Raises: returns an Error (see web).
Host: Navigation_getState :: proc(c: ^Call, key: i64, id: i64) -> (string, Api_Error)
Navigation_updateCurrentEntry
void Navigation_updateCurrentEntry(string state) raisesnavigation.updateCurrentEntry({state}): Data_Clone past history.max_state_bytes, Invalid_State without entries.
Odin: navigation.updateCurrentEntry.
Raises: returns an Error (see web).
Host: Navigation_updateCurrentEntry :: proc(c: ^Call, state: string) -> Api_Error
Navigation_navigate
void Navigation_navigate(string url, optional string state, i32 history = 0) raisesnavigation.navigate(url, {state, history}) (history: 0 auto, 1 push, 2 replace): Syntax for an invalid URL, Not_Supported for a push to a javascript: URL, Data_Clone for a state too big. navigate fires inside the call.
Odin: navigation.navigate.
Raises: returns an Error (see web).
Host: Navigation_navigate :: proc(c: ^Call, url: string, state: Maybe(string), history: i32) -> Api_Error
Navigation_reload
void Navigation_reload(optional string state) raisesnavigation.reload({state}): without a state the entry keeps its own.
Odin: navigation.reload.
Raises: returns an Error (see web).
Host: Navigation_reload :: proc(c: ^Call, state: Maybe(string)) -> Api_Error
Navigation_traverseTo
void Navigation_traverseTo(i64 key) raisesnavigation.traverseTo(key), back(), forward(): Invalid_State when no entry has this key. From a task of its own.
Odin: navigation.traverseTo.
Raises: returns an Error (see web).
Host: Navigation_traverseTo :: proc(c: ^Call, key: i64) -> Api_Error
Navigation_pending
string Navigation_pending() raisesThe navigation whose navigate event is being fired: "<type> <flags> <key> <id> <index> <url>" (type: 0 push, 1 replace, 2 reload, 3 traverse; flags: 1 same document, 2 user initiated, 4 hash change, 8 can intercept, 16 cancelable, 32 has a state). Not_Found outside the firing.
Odin: navigation.pending.
Raises: returns an Error (see web).
Host: Navigation_pending :: proc(c: ^Call) -> (string, Api_Error)
Navigation_pendingState
string Navigation_pendingState() raisesdestination.getState() of that navigation: Not_Found when it has none.
Odin: navigation.pendingState.
Raises: returns an Error (see web).
Host: Navigation_pendingState :: proc(c: ^Call) -> (string, Api_Error)
Navigation_pendingSource
NavigationSource Navigation_pendingSource()Odin: navigation.pendingSource.
Host: Navigation_pendingSource :: proc(c: ^Call) -> Api_NavigationSource
Navigation_activation
string Navigation_activation()navigation.activation: "<type> <from key>" (type as Navigation_pending's; from key 0: null, the entry of the document this one replaced when it is among navigation.entries()); "" when the document was not reached by a navigation the browser measured (activation null).
Odin: navigation.activation.
Host: Navigation_activation :: proc(c: ^Call) -> string
Navigation_scroll
void Navigation_scroll(i32 type)The scroll of an intercepted navigation of type (as Navigation_pending's), once its handlers are done or at
event.scroll(): a traversal puts the entry's scroll positions back, anything else goes to the fragment or the top.
Odin: navigation.scroll.
Host: Navigation_scroll :: proc(c: ^Call, type: i32)