!40102 修复cj_frontend backgroundImagePosition 不同单位效果一致问题。

Merge pull request !40102 from yuzhuohao/fix_cj_frontend_backgroundImagePostion
This commit is contained in:
openharmony_ci 2024-08-10 09:59:15 +00:00 committed by Gitee
commit 1dc504c431
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -19,6 +19,7 @@
#include "cj_lambda.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/matrix4/cj_matrix4_ffi.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_pixel_unit_convert_ffi.h"
#include "bridge/common/utils/utils.h"
#include "core/common/container.h"
#include "core/components/theme/theme_manager.h"
@ -592,13 +593,19 @@ void FfiOHOSAceFrameworkViewAbstractSetBackgroundImagePositionXY(double x, int32
DimensionUnit typeX = xDime.Unit();
DimensionUnit typeY = yDime.Unit();
double valueX = xDime.Value();
double valueY = yDime.Value();
double valueX = xDime.ConvertToPx();
double valueY = yDime.ConvertToPx();
if (xDime.Unit() == DimensionUnit::LPX) {
valueX = FfiOHOSAceFrameworkLpx2Px(xDime.Value());
}
if (yDime.Unit() == DimensionUnit::LPX) {
valueY = FfiOHOSAceFrameworkLpx2Px(yDime.Value());
}
if (xDime.Unit() == DimensionUnit::PERCENT) {
valueX = xDime.Value() * FULL_DIMENSION;
valueX = xDime.Value();
}
if (yDime.Unit() == DimensionUnit::PERCENT) {
valueY = yDime.Value() * FULL_DIMENSION;
valueY = yDime.Value();
}
UpdateBackgroundImagePosition(typeX, typeY, valueX, valueY, bgImgPosition);