diff --git a/ohos_nweb/src/cef_delegate/nweb_render_handler.cc b/ohos_nweb/src/cef_delegate/nweb_render_handler.cc index 14e543c1fd697545605719f2cf9f4d3e234b7ff3..568c20017370befc73ef52c2ed7098f658dc945e 100755 --- a/ohos_nweb/src/cef_delegate/nweb_render_handler.cc +++ b/ohos_nweb/src/cef_delegate/nweb_render_handler.cc @@ -124,8 +124,9 @@ void NWebRenderHandler::GetViewRect(CefRefPtr browser, rect.width = width_; rect.height = height_; } else { - rect.width = width_ / screen_info_.display_ratio; - rect.height = height_ / screen_info_.display_ratio; + // Surface greater than Web Compoment in case show black line. + rect.width = std::ceil(width_ / screen_info_.display_ratio); + rect.height = std::ceil(height_ / screen_info_.display_ratio); } if (rect.width <= 0) { diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index b38953a4b1c46deed9b05d6f575d51d489bfe676..f140a95868b6e34af450229d49a8baa63d836fc2 100755 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -263,12 +263,6 @@ bool NWebImpl::SetVirtualDeviceRatio() { return true; } -uint32_t NWebImpl::NormalizeVirtualDeviceRatio(uint32_t length) { - float ratio = - static_cast(length / device_pixel_ratio_) * device_pixel_ratio_; - return std::ceil(ratio); -} - bool NWebImpl::InitWebEngine(const NWebCreateInfo& create_info) { if (output_handler_ == nullptr) { WVLOG_E("fail to init web engine, NWeb output handler is not ready"); @@ -323,8 +317,6 @@ bool NWebImpl::InitWebEngine(const NWebCreateInfo& create_info) { uint32_t width, height; output_handler_->GetWindowInfo(width, height); - width = NormalizeVirtualDeviceRatio(width); - height = NormalizeVirtualDeviceRatio(height); nweb_delegate_->Resize(width, height); nweb_delegate_->RegisterRenderCb(render_update_cb); @@ -373,8 +365,6 @@ void NWebImpl::Resize(uint32_t width, uint32_t height) { if (input_handler_ == nullptr || output_handler_ == nullptr) { return; } - width = NormalizeVirtualDeviceRatio(width); - height = NormalizeVirtualDeviceRatio(height); if (width > kSurfaceMaxWidth || height > kSurfaceMaxHeight) { return; } diff --git a/ohos_nweb/src/nweb_impl.h b/ohos_nweb/src/nweb_impl.h index 19ebbd1bea0e69078e34c8e41d4915fa33dad208..b35c493ece5d124b38b2cc280e82c0f471ee4c15 100755 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -215,7 +215,6 @@ class NWebImpl : public NWeb { void InitWebEngineArgs(const NWebInitArgs& init_args); bool InitWebEngine(const NWebCreateInfo& create_info); bool SetVirtualDeviceRatio(); - uint32_t NormalizeVirtualDeviceRatio(uint32_t length); void StopCameraSession() const; void RestartCameraSession() const;