modify resize

Signed-off-by: zhaolinglan <zhaolinglan@huawei.com>
This commit is contained in:
zhaolinglan 2023-09-25 17:29:34 +08:00
parent e2a22864e3
commit 9145554605

View File

@ -114,10 +114,6 @@ int32_t InputMethodPanel::Resize(uint32_t width, uint32_t height)
if (window_ == nullptr) { if (window_ == nullptr) {
return ErrorCode::ERROR_NULL_POINTER; return ErrorCode::ERROR_NULL_POINTER;
} }
if (width > INT32_MAX || height > INT32_MAX) {
IMSA_HILOGE("width or height over maximum");
return ErrorCode::ERROR_BAD_PARAMETERS;
}
if (!IsSizeValid(width, height)) { if (!IsSizeValid(width, height)) {
return ErrorCode::ERROR_BAD_PARAMETERS; return ErrorCode::ERROR_BAD_PARAMETERS;
} }
@ -347,18 +343,23 @@ uint32_t InputMethodPanel::GenerateSequenceId()
bool InputMethodPanel::IsSizeValid(uint32_t width, uint32_t height) bool InputMethodPanel::IsSizeValid(uint32_t width, uint32_t height)
{ {
if (panelType_ != PanelType::SOFT_KEYBOARD || panelFlag_ != PanelFlag::FLG_FIXED) { if (width > INT32_MAX || height > INT32_MAX) {
return true; IMSA_HILOGE("width or height over maximum");
return ErrorCode::ERROR_BAD_PARAMETERS;
} }
auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay(); auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
if (defaultDisplay == nullptr) { if (defaultDisplay == nullptr) {
IMSA_HILOGE("GetDefaultDisplay failed."); IMSA_HILOGE("GetDefaultDisplay failed.");
return ErrorCode::ERROR_NULL_POINTER; return ErrorCode::ERROR_NULL_POINTER;
} }
if (static_cast<int32_t>(width) > defaultDisplay->GetWidth() if (panelType_ == PanelType::SOFT_KEYBOARD && panelFlag_ == PanelFlag::FLG_FIXED
|| static_cast<float>(height) > defaultDisplay->GetHeight() * SCREEN_RATIO) { && static_cast<float>(height) > defaultDisplay->GetHeight() * SCREEN_RATIO) {
IMSA_HILOGE("size invalid, defaultDisplay: width = %{public}d, height = %{public}d; " IMSA_HILOGE("height invalid, defaultDisplay height = %{public}d, target height = %{public}u",
"current size: width = %{public}u, height = %{public}u", defaultDisplay->GetHeight(), height);
return false;
}
if (static_cast<int32_t>(width) > defaultDisplay->GetWidth()) {
IMSA_HILOGE("width invalid, defaultDisplay width = %{public}d, target width = %{public}u",
defaultDisplay->GetWidth(), defaultDisplay->GetHeight(), width, height); defaultDisplay->GetWidth(), defaultDisplay->GetHeight(), width, height);
return false; return false;
} }