新增onNavigationEntryCommitted接口

Signed-off-by: xushawly <xushawly.xu@huawei.com>
Change-Id: I073523e09784c669300845bfbad980bdfc6d8aa8
Signed-off-by: xushawly <xushawly.xu@huawei.com>
This commit is contained in:
xushawly 2023-12-11 14:15:27 +08:00 committed by Lei Gao
parent fe9a612ba5
commit ef2cd6f8f4
2 changed files with 151 additions and 0 deletions

View File

@ -15,6 +15,15 @@
declare type WebviewController = import('../api/@ohos.web.webview').default.WebviewController;
/**
* The callback of load committed.
*
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
type OnNavigationEntryCommittedCallback = (loadCommittedDetails: LoadCommittedDetails) => void;
/**
* Enum type supplied to {@link getMessageLevel} for receiving the console log level of JavaScript.
*
@ -2017,6 +2026,68 @@ declare enum ContextMenuEditStateFlags {
CAN_SELECT_ALL = 1 << 3,
}
/**
* Enum type supplied to {@link navigationType} for the navigation's type.
*
* @enum { number }
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
declare enum NavigationType {
/**
* Unknown type.
*
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
UNKNOWN = 0,
/**
* A new entry was created due to a navigation happened on the main frame.
* Contains all situations that will generate a mainframe navigation entry,
* which means that navigations to a hash on the same document or history.pushState
* also belong to this type.
*
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
MAIN_FRAME_NEW_ENTRY = 1,
/**
* Navigate to an existing entry due to a navigation on the main frame.
* e.g.
* 1. History navigations.
* 2. Reloads (contains loading the same url).
* 3. Same-document navigations(history.replaceState(), location.replace()).
*
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
MAIN_FRAME_EXISTING_ENTRY = 2,
/**
* A navigation happened on subframe which was triggered by user.
*
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
NAVIGATION_TYPE_NEW_SUBFRAME = 4,
/**
* A navigation happened on the subframe automatically.
*
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
NAVIGATION_TYPE_AUTO_SUBFRAME = 5,
}
/**
* Defines the context menu param, related to {@link WebContextMenuParam} method.
*
@ -3526,6 +3597,72 @@ declare interface ScriptItem {
scriptRules: Array<string>;
}
/**
* Defines the load committed details.
*
* @interface LoadCommittedDetails
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
declare interface LoadCommittedDetails {
/**
* Check whether the request is for getting the main frame.
*
* @type { boolean }
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
isMainFrame: boolean;
/**
* Whether the navigation happened without changing document. Examples of
* same document navigations are:
* 1. reference fragment navigations.
* 2. pushState/replaceState.
* 3. same page history navigation
*
* @type { boolean }
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
isSameDocument: boolean;
/**
* True if the committed entry has replaced the existing one. Note that in
* case of subframes, the NavigationEntry and FrameNavigationEntry objects
* don't actually get replaced - they're reused, but with updated attributes.
*
* @type { boolean }
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
didReplaceEntry: boolean;
/**
* The type of the navigation.
*
* @type { NavigationType }
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
navigationType: NavigationType;
/**
* The url to navigate.
*
* @type { string }
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
url: string;
}
/**
* Defines the Web interface.
*
@ -5801,6 +5938,17 @@ declare class WebAttribute extends CommonMethod<WebAttribute> {
*/
onOverScroll(callback: (event: { xOffset: number, yOffset: number }) => void): WebAttribute;
/**
* Called when the load committed.
*
* @param { OnNavigationEntryCommittedCallback } callback Function Triggered when a load committed.
* @returns { WebAttribute }
* @syscap SystemCapability.Web.Webview.Core
* @atomicservice
* @since 11
*/
onNavigationEntryCommitted(callback: OnNavigationEntryCommittedCallback): WebAttribute;
/**
* Injects the JavaScripts before Webview creates the DOM tree, and then the JavaScript snippet will run after the document has been created.
* @param { Array<ScriptItem> } scripts - The array of the JavaScripts to be injected.

View File

@ -469,6 +469,7 @@ multisim
multitask
mutes
narrowband
navigations
nci
ndef
neglects
@ -720,6 +721,8 @@ stroked
subassembies
subassemblies
subcomponents
subframe
subframes
subnode
subpixel
subscrbers