diff --git a/interfaces/kits/ani/webview/ets/@ohos.web.webview.ets b/interfaces/kits/ani/webview/ets/@ohos.web.webview.ets index 63fd68044f48aa1897e7c94742d11e4628d3a63d..60fb2b60dae9a33bca0c0214d94de20438090a12 100644 --- a/interfaces/kits/ani/webview/ets/@ohos.web.webview.ets +++ b/interfaces/kits/ani/webview/ets/@ohos.web.webview.ets @@ -783,6 +783,7 @@ export default namespace webview { native resumeAllMedia(): void; native setAudioMuted(mute: boolean): void; native getMediaPlaybackState(): MediaPlaybackState; + native avoidVisibleViewportBottom(avoidHeight: int): void; native innerCompleteWindowNew(parentNwebId:int): void; innerGetThisVar(): long { return this.nativePtr; diff --git a/interfaces/kits/ani/webview/native/webviewcontroller/webview_controller.cpp b/interfaces/kits/ani/webview/native/webviewcontroller/webview_controller.cpp index 796cda47149f7d8f80f13d07e3c0747bc87abdb8..5c84eed456d4527a9313efab0023535eaa2ae890 100644 --- a/interfaces/kits/ani/webview/native/webviewcontroller/webview_controller.cpp +++ b/interfaces/kits/ani/webview/native/webviewcontroller/webview_controller.cpp @@ -1303,6 +1303,16 @@ int WebviewController::GetMediaPlaybackState() return nweb_ptr->GetMediaPlaybackState(); } +ErrCode WebviewController::AvoidVisibleViewportBottom(int32_t avoidHeight) +{ + auto nweb_ptr = NWebHelper::Instance().GetNWeb(nwebId_); + if (!nweb_ptr) { + return INIT_ERROR; + } + nweb_ptr->AvoidVisibleViewportBottom(avoidHeight); + return NWebError::NO_ERROR; +} + int WebviewController::GetSecurityLevel() { auto nweb_ptr = NWebHelper::Instance().GetNWeb(nwebId_); diff --git a/interfaces/kits/ani/webview/native/webviewcontroller/webview_controller.h b/interfaces/kits/ani/webview/native/webviewcontroller/webview_controller.h index a7880f1f8d27ab2506412dddd122f6dd82ce03d3..021389b4ca137dcebd7375d2df0383ace290cdf3 100644 --- a/interfaces/kits/ani/webview/native/webviewcontroller/webview_controller.h +++ b/interfaces/kits/ani/webview/native/webviewcontroller/webview_controller.h @@ -303,6 +303,8 @@ public: int GetMediaPlaybackState(); + ErrCode AvoidVisibleViewportBottom(int32_t avoidHeight); + void EnableIntelligentTrackingPrevention(bool enable); bool IsIntelligentTrackingPreventionEnabled() const; diff --git a/interfaces/kits/ani/webview/src/webviewcontroller/ani_webview_controller.cpp b/interfaces/kits/ani/webview/src/webviewcontroller/ani_webview_controller.cpp index cbb6307391b8f70c5643c14e943b396d55ca0d93..3b8252ab6dcb4c042d8862ee0e2f8ec339c9f71a 100644 --- a/interfaces/kits/ani/webview/src/webviewcontroller/ani_webview_controller.cpp +++ b/interfaces/kits/ani/webview/src/webviewcontroller/ani_webview_controller.cpp @@ -3770,6 +3770,25 @@ void OnCreateNativeMediaPlayer(ani_env* env, ani_object object, ani_fn_object ca controller->OnCreateNativeMediaPlayer(g_vm, callback); } +static void AvoidVisibleViewportBottom(ani_env* env, ani_object object, ani_int avoidHeight) +{ + if (env == nullptr) { + WVLOG_E("env is nullptr"); + return; + } + auto* controller = reinterpret_cast(AniParseUtils::Unwrap(env, object)); + if (!controller || !controller->IsInit()) { + AniBusinessError::ThrowErrorByErrCode(env, INIT_ERROR); + return; + } + + ErrCode ret = controller->AvoidVisibleViewportBottom(avoidHeight); + if (ret != NO_ERROR) { + AniBusinessError::ThrowErrorByErrCode(env, ret); + } + return; +} + bool ParseJsLengthDoubleToInt(ani_env* env, ani_ref ref, int32_t& outValue) { if (!env) { @@ -6105,6 +6124,8 @@ ani_status StsWebviewControllerInit(ani_env *env) ani_native_function { "resumeAllMedia", nullptr, reinterpret_cast(ResumeAllMedia) }, ani_native_function { "setAudioMuted", nullptr, reinterpret_cast(SetAudioMuted) }, ani_native_function { "getMediaPlaybackState", nullptr, reinterpret_cast(GetMediaPlaybackState) }, + ani_native_function { "avoidVisibleViewportBottom", nullptr, + reinterpret_cast(AvoidVisibleViewportBottom) }, ani_native_function { "webPageSnapshot", nullptr, reinterpret_cast(WebPageSnapshot) }, ani_native_function { "innerCompleteWindowNew", nullptr, reinterpret_cast(InnerCompleteWindowNew) }, ani_native_function { "setWebSchemeHandler", nullptr, reinterpret_cast(SetWebSchemeHandler) },