diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_blank_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_blank_bridge.cpp index 03b3cefda74a2b0fe575628fb20763e985b64d95..cb688e9f743245fa051b558351d1f27f36d75953 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_blank_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_blank_bridge.cpp @@ -51,19 +51,21 @@ ArkUINativeModuleValue BlankBridge::SetBlankHeight(ArkUIRuntimeCallInfo* runtime Local valueArg = runtimeCallInfo->GetCallArgRef(1); auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value()); CalcDimension height; + RefPtr heightResObj; std::string calcStr; - if (!ArkTSUtils::ParseJsDimensionVpNG(vm, valueArg, height)) { + if (!ArkTSUtils::ParseJsDimensionVpNG(vm, valueArg, height, heightResObj)) { GetArkUINodeModifiers()->getCommonModifier()->resetHeight(nativeNode); } else { if (LessNotEqual(height.Value(), 0.0)) { height.SetValue(0.0); } + auto heightRawResObj = AceType::RawPtr(heightResObj); if (height.Unit() == DimensionUnit::CALC) { - GetArkUINodeModifiers()->getCommonModifier()->setHeight( - nativeNode, height.Value(), static_cast(height.Unit()), height.CalcValue().c_str()); + GetArkUINodeModifiers()->getCommonModifier()->setHeight(nativeNode, height.Value(), + static_cast(height.Unit()), height.CalcValue().c_str(), heightRawResObj); } else { GetArkUINodeModifiers()->getCommonModifier()->setHeight( - nativeNode, height.Value(), static_cast(height.Unit()), calcStr.c_str()); + nativeNode, height.Value(), static_cast(height.Unit()), calcStr.c_str(), heightRawResObj); } } if (!ArkTSUtils::ParseJsDimensionVp(vm, valueArg, height)) { diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp index 8df58bcc0c7c04d6b05e7c3e9fd6a09c010ed9b1..f936ffded8f77cfe5d823d9cbf373cd6ae138d7a 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp @@ -248,7 +248,8 @@ bool ParseCalcDimensions(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t offset, } ParseResult ParseCalcDimensionsNG(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t offset, uint32_t count, - std::vector>& results, const CalcDimension& defValue) + std::vector>& results, std::vector>& edgesResObj, + const CalcDimension& defValue) { auto end = offset + count; auto argsNumber = runtimeCallInfo->GetArgsNumber(); @@ -260,9 +261,10 @@ ParseResult ParseCalcDimensionsNG(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_ for (uint32_t index = offset; index < end; index++) { auto arg = runtimeCallInfo->GetCallArgRef(index); std::optional optCalcDimension; + RefPtr resObj; CalcDimension dimension(defValue); // Parse string, '10abc' return false - if (ArkTSUtils::ParseJsDimensionVpNG(vm, arg, dimension, true)) { + if (ArkTSUtils::ParseJsDimensionVpNG(vm, arg, dimension, resObj, true)) { optCalcDimension = dimension; res = ParseResult::DIMENSION_SUCCESS; } else if (ArkTSUtils::ParseJsLengthMetrics(vm, arg, dimension)) { @@ -270,6 +272,9 @@ ParseResult ParseCalcDimensionsNG(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_ res = ParseResult::LENGTHMETRICS_SUCCESS; } results.push_back(optCalcDimension); + if (SystemProperties::ConfigChangePerform()) { + edgesResObj.push_back(resObj); + } } return res; } @@ -987,13 +992,6 @@ void ParseOuterBorderColor(ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* vm, st PushOuterBorderColorVector(bottomColor, values); } -void ParseOuterBorderColor(ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* vm, std::vector& values, - int32_t argsIndex, bool needLocalized = false) -{ - std::vector> resObj; - ParseOuterBorderColor(runtimeCallInfo, vm, values, argsIndex, resObj, needLocalized); -} - bool ParseLocalizedBorderRadius(const EcmaVM* vm, const Local& value, CalcDimension& result) { if (ArkTSUtils::ParseJsLengthMetrics(vm, value, result)) { @@ -1011,9 +1009,14 @@ void ParseOuterBorder(EcmaVM* vm, const Local& args, std::optional resObj; ArkTSUtils::ParseOuterBorder(vm, args, optionalDimension, resObj); if (SystemProperties::ConfigChangePerform()) { - if (resObj) { - resObjs.push_back(resObj); - } else { + resObjs.push_back(resObj); + } +} + +void ParseNullptrResObj(std::vector>& resObjs, int32_t index) +{ + if (SystemProperties::ConfigChangePerform()) { + for (uint32_t i = 0; i < index; i++) { resObjs.push_back(nullptr); } } @@ -1048,10 +1051,7 @@ void ParseOuterBorderRadius(ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* vm, s PushOuterBorderDimensionVector(topEndOptional, values); PushOuterBorderDimensionVector(bottomStartOptional, values); PushOuterBorderDimensionVector(bottomEndOptional, values); - if (SystemProperties::ConfigChangePerform()) { - std::vector> vectorResObj(4, nullptr); - resObjs = vectorResObj; - } + ParseNullptrResObj(resObjs, NUM_4); return; } } @@ -1072,13 +1072,6 @@ void ParseOuterBorderRadius(ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* vm, s PushOuterBorderDimensionVector(bottomRightOptional, values); } -void ParseOuterBorderRadius(ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* vm, std::vector& values, - int32_t argsIndex, bool needLocalized = false) -{ - std::vector> resObj; - ParseOuterBorderRadius(runtimeCallInfo, vm, values, argsIndex, resObj, needLocalized); -} - void PushOuterBorderStyleVector(const std::optional& value, std::vector &options) { options.push_back(static_cast(value.has_value())); @@ -1121,8 +1114,18 @@ void ParseOuterBorderStyle( PushOuterBorderStyleVector(styleBottom, values); } +void ParseOuterBorderForDashParams(EcmaVM* vm, const Local& args, + std::optional& optionalDimension, std::vector>& resObjs) +{ + RefPtr resObj; + ArkTSUtils::ParseOuterBorderForDashParams(vm, args, optionalDimension, resObj); + if (SystemProperties::ConfigChangePerform()) { + resObjs.push_back(resObj); + } +} + void ParseOuterBorderDashParam(ArkUIRuntimeCallInfo *runtimeCallInfo, EcmaVM *vm, std::vector &values, - int32_t argsIndex) + int32_t argsIndex, std::vector>& resObjs) { Local leftArgs = runtimeCallInfo->GetCallArgRef(argsIndex); Local rightArgs = runtimeCallInfo->GetCallArgRef(argsIndex + NUM_1); @@ -1133,10 +1136,10 @@ void ParseOuterBorderDashParam(ArkUIRuntimeCallInfo *runtimeCallInfo, EcmaVM *vm std::optional topDim; std::optional bottomDim; - ArkTSUtils::ParseOuterBorderForDashParams(vm, leftArgs, leftDim); - ArkTSUtils::ParseOuterBorderForDashParams(vm, rightArgs, rightDim); - ArkTSUtils::ParseOuterBorderForDashParams(vm, topArgs, topDim); - ArkTSUtils::ParseOuterBorderForDashParams(vm, bottomArgs, bottomDim); + ParseOuterBorderForDashParams(vm, leftArgs, leftDim, resObjs); + ParseOuterBorderForDashParams(vm, rightArgs, rightDim, resObjs); + ParseOuterBorderForDashParams(vm, topArgs, topDim, resObjs); + ParseOuterBorderForDashParams(vm, bottomArgs, bottomDim, resObjs); PushOuterBorderDimensionVector(leftDim, values); PushOuterBorderDimensionVector(rightDim, values); @@ -1427,7 +1430,8 @@ void ParseDynamicBrightnessOption(ArkUIRuntimeCallInfo* runtimeCallInfo, EcmaVM* } bool ParseCalcDimension(const EcmaVM* vm, - ArkUINodeHandle node, const Local& value, CalcDimension& result, bool isWidth) + ArkUINodeHandle node, const Local& value, CalcDimension& result, bool isWidth, + RefPtr& resourceObject) { CHECK_NULL_RETURN(vm, false); bool undefined = value->IsUndefined(); @@ -1436,11 +1440,11 @@ bool ParseCalcDimension(const EcmaVM* vm, return true; } if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TEN)) { - if (!ArkTSUtils::ParseJsDimensionVpNG(vm, value, result)) { + if (!ArkTSUtils::ParseJsDimensionVpNG(vm, value, result, resourceObject)) { GetArkUINodeModifiers()->getCommonModifier()->clearWidthOrHeight(node, isWidth); return false; } - } else if (!ArkTSUtils::ParseJsDimensionVp(vm, value, result)) { + } else if (!ArkTSUtils::ParseJsDimensionVp(vm, value, result, resourceObject)) { return false; } @@ -1448,12 +1452,13 @@ bool ParseCalcDimension(const EcmaVM* vm, result.SetValue(0.0); } std::string calc = result.CalcValue(); + auto RawResObj = AceType::RawPtr(resourceObject); if (isWidth) { GetArkUINodeModifiers()->getCommonModifier()->setWidth( - node, result.Value(), static_cast(result.Unit()), calc.c_str()); + node, result.Value(), static_cast(result.Unit()), calc.c_str(), RawResObj); } else { GetArkUINodeModifiers()->getCommonModifier()->setHeight( - node, result.Value(), static_cast(result.Unit()), calc.c_str()); + node, result.Value(), static_cast(result.Unit()), calc.c_str(), RawResObj); } return true; } @@ -1618,20 +1623,25 @@ ArkUINativeModuleValue CommonBridge::ResetBackgroundColor(ArkUIRuntimeCallInfo * } void SetBorderWidthArray(const EcmaVM* vm, const Local& args, ArkUI_Float32 values[], - int units[], int index) + int units[], int index, std::vector>& resObj) { CalcDimension borderDimension; + RefPtr borderDimensionResObj; if (!args->IsUndefined()) { - if (ArkTSUtils::ParseAllBorder(vm, args, borderDimension)) { + if (ArkTSUtils::ParseAllBorder(vm, args, borderDimension, borderDimensionResObj)) { values[index] = borderDimension.Value(); units[index] = static_cast(borderDimension.Unit()); } else { values[index] = 0; units[index] = static_cast(DimensionUnit::VP); } + if (SystemProperties::ConfigChangePerform()) { + resObj.push_back(borderDimensionResObj); + } } else { values[index] = -1; units[index] = static_cast(DimensionUnit::INVALID); + ParseNullptrResObj(resObj, NUM_1); } } @@ -1653,6 +1663,13 @@ void SetBorderWidthArrayByDimen(CalcDimension& borderDimension, ArkUI_Float32 va units[index] = static_cast(borderDimension.Unit()); } +void ParseBorderWidthLengthMetrics(EcmaVM* vm, Local arg, CalcDimension& dimension, bool& isLengthMetrics) +{ + if (arg->IsObject(vm)) { + isLengthMetrics |= ParseLocalizedBorderWidth(vm, arg, dimension); + } +} + ArkUINativeModuleValue CommonBridge::SetBorderWidth(ArkUIRuntimeCallInfo* runtimeCallInfo) { EcmaVM* vm = runtimeCallInfo->GetVM(); @@ -1674,21 +1691,14 @@ ArkUINativeModuleValue CommonBridge::SetBorderWidth(ArkUIRuntimeCallInfo* runtim CalcDimension left; bool isLengthMetrics = false; - if (topArgs->IsObject(vm)) { - isLengthMetrics |= ParseLocalizedBorderWidth(vm, topArgs, top); - } - if (rightArgs->IsObject(vm)) { - isLengthMetrics |= ParseLocalizedBorderWidth(vm, rightArgs, right); - } - if (bottomArgs->IsObject(vm)) { - isLengthMetrics |= ParseLocalizedBorderWidth(vm, bottomArgs, bottom); - } - if (leftArgs->IsObject(vm)) { - isLengthMetrics |= ParseLocalizedBorderWidth(vm, leftArgs, left); - } + ParseBorderWidthLengthMetrics(vm, topArgs, top, isLengthMetrics); + ParseBorderWidthLengthMetrics(vm, rightArgs, right, isLengthMetrics); + ParseBorderWidthLengthMetrics(vm, bottomArgs, bottom, isLengthMetrics); + ParseBorderWidthLengthMetrics(vm, leftArgs, left, isLengthMetrics); uint32_t size = SIZE_OF_FOUR; ArkUI_Float32 values[size]; + std::vector> resObj; int units[size]; if (isLengthMetrics) { @@ -1697,14 +1707,16 @@ ArkUINativeModuleValue CommonBridge::SetBorderWidth(ArkUIRuntimeCallInfo* runtim SetBorderWidthArrayByDimen(isRightToLeft ? left : right, values, units, NUM_1); SetBorderWidthArrayByDimen(bottom, values, units, NUM_2); SetBorderWidthArrayByDimen(isRightToLeft ? right : left, values, units, NUM_3); + ParseNullptrResObj(resObj, NUM_4); } else { - SetBorderWidthArray(vm, topArgs, values, units, NUM_0); - SetBorderWidthArray(vm, rightArgs, values, units, NUM_1); - SetBorderWidthArray(vm, bottomArgs, values, units, NUM_2); - SetBorderWidthArray(vm, leftArgs, values, units, NUM_3); + SetBorderWidthArray(vm, topArgs, values, units, NUM_0, resObj); + SetBorderWidthArray(vm, rightArgs, values, units, NUM_1, resObj); + SetBorderWidthArray(vm, bottomArgs, values, units, NUM_2, resObj); + SetBorderWidthArray(vm, leftArgs, values, units, NUM_3, resObj); } - GetArkUINodeModifiers()->getCommonModifier()->setBorderWidth(nativeNode, values, units, size); + auto rawPtr = static_cast(&resObj); + GetArkUINodeModifiers()->getCommonModifier()->setBorderWidth(nativeNode, values, units, size, rawPtr); return panda::JSValueRef::Undefined(vm); } @@ -1739,6 +1751,7 @@ void CommonBridge::ParseOuterBorderWidth(ArkUIRuntimeCallInfo* runtimeCallInfo, ArkTSUtils::ParseOuterBorderForDashParams(vm, endArgs, endDim); ArkTSUtils::ParseOuterBorderForDashParams(vm, topArgs, topDim); ArkTSUtils::ParseOuterBorderForDashParams(vm, bottomArgs, bottomDim); + ParseNullptrResObj(resObjs, NUM_2); } else { ParseOuterBorder(vm, topArgs, topDim, resObjs); ParseOuterBorder(vm, bottomArgs, bottomDim, resObjs); @@ -1821,6 +1834,23 @@ bool SetBackShadowForShadowStyle(const ArkUINodeHandle nativeNode, const EcmaVM return false; } +void SetBorderRadiusArray(const EcmaVM* vm, const Local& args, CalcDimension& result, + std::vector>& resObjs) +{ + RefPtr resObj; + ArkTSUtils::ParseAllBorder(vm, args, result, resObj); + if (SystemProperties::ConfigChangePerform()) { + resObjs.push_back(resObj); + } +} + +void ParseBorderRadiusLengthMetrics(EcmaVM* vm, Local arg, CalcDimension& dimension, bool& isLengthMetrics) +{ + if (arg->IsObject(vm)) { + isLengthMetrics |= ParseLocalizedBorderRadius(vm, arg, dimension); + } +} + ArkUINativeModuleValue CommonBridge::SetBorderRadius(ArkUIRuntimeCallInfo *runtimeCallInfo) { EcmaVM *vm = runtimeCallInfo->GetVM(); @@ -1840,24 +1870,19 @@ ArkUINativeModuleValue CommonBridge::SetBorderRadius(ArkUIRuntimeCallInfo *runti CalcDimension topRight; CalcDimension bottomLeft; CalcDimension bottomRight; + std::vector> resObj; bool isLengthMetrics = false; - if (topLeftArgs->IsObject(vm)) { - isLengthMetrics |= ParseLocalizedBorderRadius(vm, topLeftArgs, topLeft); - } - if (topRightArgs->IsObject(vm)) { - isLengthMetrics |= ParseLocalizedBorderRadius(vm, topRightArgs, topRight); - } - if (bottomLeftArgs->IsObject(vm)) { - isLengthMetrics |= ParseLocalizedBorderRadius(vm, bottomLeftArgs, bottomLeft); - } - if (bottomRightArgs->IsObject(vm)) { - isLengthMetrics |= ParseLocalizedBorderRadius(vm, bottomRightArgs, bottomRight); - } + ParseBorderRadiusLengthMetrics(vm, topLeftArgs, topLeft, isLengthMetrics); + ParseBorderRadiusLengthMetrics(vm, topRightArgs, topRight, isLengthMetrics); + ParseBorderRadiusLengthMetrics(vm, bottomLeftArgs, bottomLeft, isLengthMetrics); + ParseBorderRadiusLengthMetrics(vm, bottomRightArgs, bottomRight, isLengthMetrics); if (!isLengthMetrics) { - ArkTSUtils::ParseAllBorder(vm, topLeftArgs, topLeft); - ArkTSUtils::ParseAllBorder(vm, topRightArgs, topRight); - ArkTSUtils::ParseAllBorder(vm, bottomLeftArgs, bottomLeft); - ArkTSUtils::ParseAllBorder(vm, bottomRightArgs, bottomRight); + SetBorderRadiusArray(vm, topLeftArgs, topLeft, resObj); + SetBorderRadiusArray(vm, topRightArgs, topRight, resObj); + SetBorderRadiusArray(vm, bottomLeftArgs, bottomLeft, resObj); + SetBorderRadiusArray(vm, bottomRightArgs, bottomRight, resObj); + } else { + ParseNullptrResObj(resObj, NUM_4); } ArkUI_Float32 values[SIZE_OF_FOUR]; int units[SIZE_OF_FOUR]; @@ -1866,7 +1891,8 @@ ArkUINativeModuleValue CommonBridge::SetBorderRadius(ArkUIRuntimeCallInfo *runti ParseMirrorDimen(values, units, NUM_1, isMirror ? topLeft : topRight); ParseMirrorDimen(values, units, NUM_2, isMirror ? bottomRight : bottomLeft); ParseMirrorDimen(values, units, NUM_3, isMirror ? bottomLeft : bottomRight); - GetArkUINodeModifiers()->getCommonModifier()->setBorderRadius(nativeNode, values, units, SIZE_OF_FOUR); + auto rawPtr = static_cast(&resObj); + GetArkUINodeModifiers()->getCommonModifier()->setBorderRadius(nativeNode, values, units, SIZE_OF_FOUR, rawPtr); return panda::JSValueRef::Undefined(vm); } @@ -1902,8 +1928,9 @@ ArkUINativeModuleValue CommonBridge::SetWidth(ArkUIRuntimeCallInfo* runtimeCallI auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); Local jsValue = runtimeCallInfo->GetCallArgRef(NUM_1); CalcDimension width; + RefPtr widthResObj; std::string calcStr; - if (!ArkTSUtils::ParseJsDimensionVpNG(vm, jsValue, width)) { + if (!ArkTSUtils::ParseJsDimensionVpNG(vm, jsValue, width, widthResObj)) { GetArkUINodeModifiers()->getCommonModifier()->resetWidth(nativeNode); if (jsValue->IsObject(vm)) { auto obj = jsValue->ToObject(vm); @@ -1924,12 +1951,13 @@ ArkUINativeModuleValue CommonBridge::SetWidth(ArkUIRuntimeCallInfo* runtimeCallI width.SetValue(0.0); } + auto widthRawResObj = AceType::RawPtr(widthResObj); if (width.Unit() == DimensionUnit::CALC) { GetArkUINodeModifiers()->getCommonModifier()->setWidth( - nativeNode, 0, static_cast(width.Unit()), width.CalcValue().c_str()); + nativeNode, 0, static_cast(width.Unit()), width.CalcValue().c_str(), widthRawResObj); } else { GetArkUINodeModifiers()->getCommonModifier()->setWidth( - nativeNode, width.Value(), static_cast(width.Unit()), calcStr.c_str()); + nativeNode, width.Value(), static_cast(width.Unit()), calcStr.c_str(), widthRawResObj); } } ViewAbstractModel::GetInstance()->UpdateLayoutPolicyProperty(LayoutCalPolicy::NO_MATCH, true); @@ -1954,8 +1982,9 @@ ArkUINativeModuleValue CommonBridge::SetHeight(ArkUIRuntimeCallInfo* runtimeCall auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); Local jsValue = runtimeCallInfo->GetCallArgRef(NUM_1); CalcDimension height; + RefPtr heightResObj; std::string calcStr; - if (!ArkTSUtils::ParseJsDimensionVpNG(vm, jsValue, height)) { + if (!ArkTSUtils::ParseJsDimensionVpNG(vm, jsValue, height, heightResObj)) { GetArkUINodeModifiers()->getCommonModifier()->resetHeight(nativeNode); if (jsValue->IsObject(vm)) { auto obj = jsValue->ToObject(vm); @@ -1975,12 +2004,13 @@ ArkUINativeModuleValue CommonBridge::SetHeight(ArkUIRuntimeCallInfo* runtimeCall } height.SetValue(0.0); } + auto heightRawResObj = AceType::RawPtr(heightResObj); if (height.Unit() == DimensionUnit::CALC) { - GetArkUINodeModifiers()->getCommonModifier()->setHeight( - nativeNode, height.Value(), static_cast(height.Unit()), height.CalcValue().c_str()); + GetArkUINodeModifiers()->getCommonModifier()->setHeight(nativeNode, height.Value(), + static_cast(height.Unit()), height.CalcValue().c_str(), heightRawResObj); } else { GetArkUINodeModifiers()->getCommonModifier()->setHeight( - nativeNode, height.Value(), static_cast(height.Unit()), calcStr.c_str()); + nativeNode, height.Value(), static_cast(height.Unit()), calcStr.c_str(), heightRawResObj); } } ViewAbstractModel::GetInstance()->UpdateLayoutPolicyProperty(LayoutCalPolicy::NO_MATCH, false); @@ -2006,19 +2036,24 @@ ArkUINativeModuleValue CommonBridge::SetPosition(ArkUIRuntimeCallInfo* runtimeCa bool useEdges = runtimeCallInfo->GetCallArgRef(NUM_1)->ToBoolean(vm)->Value(); std::vector options; std::vector> edges; + std::vector> edgesResObj; if (useEdges) { - ParseResult res = ParseCalcDimensionsNG(runtimeCallInfo, NUM_2, NUM_4, edges, CalcDimension(0.0)); + ParseResult res = ParseCalcDimensionsNG(runtimeCallInfo, NUM_2, NUM_4, edges, edgesResObj, CalcDimension(0.0)); if (res == ParseResult::LENGTHMETRICS_SUCCESS && AceApplicationInfo::GetInstance().IsRightToLeft()) { // Swap left and right std::swap(edges[NUM_1], edges[NUM_3]); } PushDimensionsToVector(options, edges); - GetArkUINodeModifiers()->getCommonModifier()->setPositionEdges(nativeNode, useEdges, options.data()); + auto edgesRawPtr = static_cast(&edgesResObj); + GetArkUINodeModifiers()->getCommonModifier()->setPositionEdges( + nativeNode, useEdges, options.data(), edgesRawPtr); } else { - ParseCalcDimensionsNG(runtimeCallInfo, NUM_2, NUM_2, edges, CalcDimension(0.0)); + ParseCalcDimensionsNG(runtimeCallInfo, NUM_2, NUM_2, edges, edgesResObj, CalcDimension(0.0)); PushDimensionsToVector(options, edges); - GetArkUINodeModifiers()->getCommonModifier()->setPositionEdges(nativeNode, useEdges, options.data()); + auto edgesRawPtr = static_cast(&edgesResObj); + GetArkUINodeModifiers()->getCommonModifier()->setPositionEdges( + nativeNode, useEdges, options.data(), edgesRawPtr); } return panda::JSValueRef::Undefined(vm); } @@ -2133,30 +2168,35 @@ ArkUINativeModuleValue CommonBridge::SetBorderColor(ArkUIRuntimeCallInfo *runtim Local isLocalizedArg = runtimeCallInfo->GetCallArgRef(NUM_5); auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); auto isLocalized = (isLocalizedArg->IsBoolean()) ? isLocalizedArg->ToBoolean(vm)->Value() : false; + std::vector> resObj; Color topColor; Color rightColor; Color bottomColor; Color leftColor; - if (!ArkTSUtils::ParseJsColorAlpha(vm, topArg, topColor)) { + if (!ArkTSUtils::ParseJsColorAlpha(vm, topArg, topColor, resObj)) { topColor.SetValue(COLOR_ALPHA_VALUE); } - if (!ArkTSUtils::ParseJsColorAlpha(vm, rightArg, rightColor)) { + if (!ArkTSUtils::ParseJsColorAlpha(vm, rightArg, rightColor, resObj)) { rightColor.SetValue(COLOR_ALPHA_VALUE); } - if (!ArkTSUtils::ParseJsColorAlpha(vm, bottomArg, bottomColor)) { + if (!ArkTSUtils::ParseJsColorAlpha(vm, bottomArg, bottomColor, resObj)) { bottomColor.SetValue(COLOR_ALPHA_VALUE); } - if (!ArkTSUtils::ParseJsColorAlpha(vm, leftArg, leftColor)) { + if (!ArkTSUtils::ParseJsColorAlpha(vm, leftArg, leftColor, resObj)) { leftColor.SetValue(COLOR_ALPHA_VALUE); } auto isRightToLeft = AceApplicationInfo::GetInstance().IsRightToLeft(); + if (SystemProperties::ConfigChangePerform() && isRightToLeft && isLocalized) { + std::swap(resObj[1], resObj[3]); + } + auto rawPtr = static_cast(&resObj); GetArkUINodeModifiers()->getCommonModifier()->setBorderColor(nativeNode, topColor.GetValue(), (isRightToLeft && isLocalized) ? leftColor.GetValue() : rightColor.GetValue(), bottomColor.GetValue(), - (isRightToLeft && isLocalized) ? rightColor.GetValue() : leftColor.GetValue()); + (isRightToLeft && isLocalized) ? rightColor.GetValue() : leftColor.GetValue(), rawPtr); return panda::JSValueRef::Undefined(vm); } @@ -3302,15 +3342,17 @@ ArkUINativeModuleValue CommonBridge::SetBorder(ArkUIRuntimeCallInfo* runtimeCall auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); std::vector options; - ParseOuterBorderWidth(runtimeCallInfo, vm, options); // Border Width args start index from 1 - ParseOuterBorderRadius(runtimeCallInfo, vm, options, NUM_9); // Border Radius args start index + std::vector> resObj; + ParseOuterBorderWidth(runtimeCallInfo, vm, options, resObj); // Border Width args start index from 1 + ParseOuterBorderRadius(runtimeCallInfo, vm, options, NUM_9, resObj); // Border Radius args start index std::vector colorAndStyleOptions; - ParseOuterBorderColor(runtimeCallInfo, vm, colorAndStyleOptions, NUM_5); // Border Color args start index + ParseOuterBorderColor(runtimeCallInfo, vm, colorAndStyleOptions, NUM_5, resObj); // Border Color args start index ParseOuterBorderStyle(runtimeCallInfo, vm, colorAndStyleOptions, NUM_13); // Border Style args start index + auto rawPtr = static_cast(&resObj); GetArkUINodeModifiers()->getCommonModifier()->setBorder(nativeNode, options.data(), options.size(), - colorAndStyleOptions.data(), colorAndStyleOptions.size(), false, false, false); + colorAndStyleOptions.data(), colorAndStyleOptions.size(), false, false, false, rawPtr); return panda::JSValueRef::Undefined(vm); } @@ -3323,11 +3365,12 @@ ArkUINativeModuleValue CommonBridge::SetLocalizedBorder(ArkUIRuntimeCallInfo* ru auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); std::vector options; - ParseOuterBorderWidth(runtimeCallInfo, vm, options, true); // Border Width args start index from 1 - ParseOuterBorderRadius(runtimeCallInfo, vm, options, NUM_9, true); // Border Radius args start index + std::vector> resObj; + ParseOuterBorderWidth(runtimeCallInfo, vm, options, resObj, true); // Border Width args start index from 1 + ParseOuterBorderRadius(runtimeCallInfo, vm, options, NUM_9, resObj, true); // Border Radius args start index std::vector colorAndStyleOptions; - ParseOuterBorderColor(runtimeCallInfo, vm, colorAndStyleOptions, NUM_5, true); // Border Color args start index + ParseOuterBorderColor(runtimeCallInfo, vm, colorAndStyleOptions, NUM_5, resObj, true); // Border Color args start index ParseOuterBorderStyle(runtimeCallInfo, vm, colorAndStyleOptions, NUM_13); // Border Style args start index int32_t isLocalizedBorderWidth = 0; @@ -3335,9 +3378,10 @@ ArkUINativeModuleValue CommonBridge::SetLocalizedBorder(ArkUIRuntimeCallInfo* ru int32_t isLocalizedBorderRadius = 0; ParseLocalizedBorder(runtimeCallInfo, isLocalizedBorderWidth, isLocalizedBorderColor, isLocalizedBorderRadius); + auto rawPtr = static_cast(&resObj); GetArkUINodeModifiers()->getCommonModifier()->setBorder(nativeNode, options.data(), options.size(), colorAndStyleOptions.data(), colorAndStyleOptions.size(), isLocalizedBorderWidth, isLocalizedBorderColor, - isLocalizedBorderRadius); + isLocalizedBorderRadius, rawPtr); return panda::JSValueRef::Undefined(vm); } @@ -3378,7 +3422,8 @@ ArkUINativeModuleValue CommonBridge::SetBorderWithDashParams(ArkUIRuntimeCallInf auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); std::vector dashOptions; - ParseOuterBorderDashParam(runtimeCallInfo, vm, dashOptions, 17); // Border DashGap args start index from 17 + std::vector> resObj; + ParseOuterBorderDashParam(runtimeCallInfo, vm, dashOptions, 17, resObj); // Border DashGap args start index from 17 Local startDashGap = runtimeCallInfo->GetCallArgRef(36); // Border DashGap args start index from 36 Local endDashGap = runtimeCallInfo->GetCallArgRef(37); // Border DashGap args end index from 37 std::optional startDashGapDim; @@ -3388,7 +3433,7 @@ ArkUINativeModuleValue CommonBridge::SetBorderWithDashParams(ArkUIRuntimeCallInf ArkTSUtils::PushOuterBorderDimensionVector(startDashGapDim, dashOptions); ArkTSUtils::PushOuterBorderDimensionVector(endDashGapDim, dashOptions); - ParseOuterBorderDashParam(runtimeCallInfo, vm, dashOptions, 21); // Border DashWidth args start index from 21 + ParseOuterBorderDashParam(runtimeCallInfo, vm, dashOptions, 21, resObj); // Border DashWidth args start index from 21 Local startDashWidth = runtimeCallInfo->GetCallArgRef(38); // Border DashWidth args start index from 38 Local endDashWidth = runtimeCallInfo->GetCallArgRef(39); // Border DashWidth args end index from 39 std::optional startDashWidthDim; @@ -3398,8 +3443,9 @@ ArkUINativeModuleValue CommonBridge::SetBorderWithDashParams(ArkUIRuntimeCallInf ArkTSUtils::PushOuterBorderDimensionVector(startDashWidthDim, dashOptions); ArkTSUtils::PushOuterBorderDimensionVector(endDashWidthDim, dashOptions); + auto rawPtr = static_cast(&resObj); GetArkUINodeModifiers()->getCommonModifier()->setBorderDashParams(nativeNode, dashOptions.data(), - dashOptions.size()); + dashOptions.size(), rawPtr); return panda::JSValueRef::Undefined(vm); } @@ -4865,19 +4911,22 @@ ArkUINativeModuleValue CommonBridge::SetOffset(ArkUIRuntimeCallInfo* runtimeCall bool useEdges = runtimeCallInfo->GetCallArgRef(NUM_1)->ToBoolean(vm)->Value(); std::vector options; std::vector> edges; + std::vector> edgesResObj; if (useEdges) { - ParseResult res = ParseCalcDimensionsNG(runtimeCallInfo, NUM_2, NUM_4, edges, CalcDimension(0.0)); + ParseResult res = ParseCalcDimensionsNG(runtimeCallInfo, NUM_2, NUM_4, edges, edgesResObj, CalcDimension(0.0)); if (res == ParseResult::LENGTHMETRICS_SUCCESS && AceApplicationInfo::GetInstance().IsRightToLeft()) { // Swap left and right std::swap(edges[NUM_1], edges[NUM_3]); } PushDimensionsToVector(options, edges); - GetArkUINodeModifiers()->getCommonModifier()->setOffsetEdges(nativeNode, useEdges, options.data()); + auto edgesRawPtr = static_cast(&edgesResObj); + GetArkUINodeModifiers()->getCommonModifier()->setOffsetEdges(nativeNode, useEdges, options.data(), edgesRawPtr); } else { - ParseCalcDimensionsNG(runtimeCallInfo, NUM_2, NUM_2, edges, CalcDimension(0.0)); + ParseCalcDimensionsNG(runtimeCallInfo, NUM_2, NUM_2, edges, edgesResObj, CalcDimension(0.0)); PushDimensionsToVector(options, edges); - GetArkUINodeModifiers()->getCommonModifier()->setOffsetEdges(nativeNode, useEdges, options.data()); + auto edgesRawPtr = static_cast(&edgesResObj); + GetArkUINodeModifiers()->getCommonModifier()->setOffsetEdges(nativeNode, useEdges, options.data(), edgesRawPtr); } return panda::JSValueRef::Undefined(vm); } @@ -4893,9 +4942,11 @@ ArkUINativeModuleValue CommonBridge::ResetOffset(ArkUIRuntimeCallInfo *runtimeCa return panda::JSValueRef::Undefined(vm); } -void ParsePadding(const EcmaVM* vm, const Local& value, CalcDimension& dimen, ArkUISizeType& result) +void ParsePadding(const EcmaVM* vm, const Local& value, CalcDimension& dimen, ArkUISizeType& result, + std::vector>& resObjs) { - if (ArkTSUtils::ParseJsDimensionVp(vm, value, dimen)) { + RefPtr resObj; + if (ArkTSUtils::ParseJsDimensionVp(vm, value, dimen, resObj)) { if (LessOrEqual(dimen.Value(), 0.0)) { dimen.SetValue(0.0); dimen.SetUnit(DimensionUnit::VP); @@ -4907,6 +4958,9 @@ void ParsePadding(const EcmaVM* vm, const Local& value, CalcDimensio result.value = dimen.Value(); } } + if (SystemProperties::ConfigChangePerform()) { + resObjs.push_back(resObj); + } } bool ParseLocalizedPadding(const EcmaVM* vm, const Local& value, CalcDimension& dimen, @@ -4948,6 +5002,7 @@ ArkUINativeModuleValue CommonBridge::SetPadding(ArkUIRuntimeCallInfo *runtimeCal CalcDimension rightDimen(0, DimensionUnit::VP); CalcDimension bottomDimen(0, DimensionUnit::VP); CalcDimension leftDimen(0, DimensionUnit::VP); + std::vector> resObj; bool isLengthMetrics = false; if (secondArg->IsObject(vm)) { @@ -4969,15 +5024,17 @@ ArkUINativeModuleValue CommonBridge::SetPadding(ArkUIRuntimeCallInfo *runtimeCal &top, isRightToLeft ? &left : &right, &bottom, - isRightToLeft ? &right : &left); + isRightToLeft ? &right : &left, + nullptr); return panda::JSValueRef::Undefined(vm); } - ParsePadding(vm, secondArg, topDimen, top); - ParsePadding(vm, thirdArg, rightDimen, right); - ParsePadding(vm, forthArg, bottomDimen, bottom); - ParsePadding(vm, fifthArg, leftDimen, left); - GetArkUINodeModifiers()->getCommonModifier()->setPadding(nativeNode, &top, &right, &bottom, &left); + ParsePadding(vm, secondArg, topDimen, top, resObj); + ParsePadding(vm, thirdArg, rightDimen, right, resObj); + ParsePadding(vm, forthArg, bottomDimen, bottom, resObj); + ParsePadding(vm, fifthArg, leftDimen, left, resObj); + auto rawPtr = static_cast(&resObj); + GetArkUINodeModifiers()->getCommonModifier()->setPadding(nativeNode, &top, &right, &bottom, &left, rawPtr); return panda::JSValueRef::Undefined(vm); } @@ -5006,9 +5063,11 @@ bool ParseLocalizedMargin(const EcmaVM* vm, const Local& value, Calc return false; } -void ParseMargin(const EcmaVM* vm, const Local& value, CalcDimension& dimen, ArkUISizeType& result) +void ParseMargin(const EcmaVM* vm, const Local& value, CalcDimension& dimen, ArkUISizeType& result, + std::vector>& resObjs) { - if (ArkTSUtils::ParseJsDimensionVp(vm, value, dimen)) { + RefPtr resObj; + if (ArkTSUtils::ParseJsDimensionVp(vm, value, dimen, resObj)) { result.unit = static_cast(dimen.Unit()); if (dimen.CalcValue() != "") { result.string = dimen.CalcValue().c_str(); @@ -5016,6 +5075,17 @@ void ParseMargin(const EcmaVM* vm, const Local& value, CalcDimension result.value = dimen.Value(); } } + if (SystemProperties::ConfigChangePerform()) { + resObjs.push_back(resObj); + } +} + +void ParseMarginLengthMetrics(EcmaVM* vm, Local arg, CalcDimension& dimension, ArkUISizeType& sizeType, + bool& isLengthMetrics) +{ + if (arg->IsObject(vm)) { + isLengthMetrics |= ParseLocalizedMargin(vm, arg, dimension, sizeType); + } } ArkUINativeModuleValue CommonBridge::SetMargin(ArkUIRuntimeCallInfo *runtimeCallInfo) @@ -5036,34 +5106,30 @@ ArkUINativeModuleValue CommonBridge::SetMargin(ArkUIRuntimeCallInfo *runtimeCall CalcDimension rightDimen(0, DimensionUnit::VP); CalcDimension bottomDimen(0, DimensionUnit::VP); CalcDimension leftDimen(0, DimensionUnit::VP); + std::vector> resObj; bool isLengthMetrics = false; - if (secondArg->IsObject(vm)) { - isLengthMetrics |= ParseLocalizedMargin(vm, secondArg, topDimen, top); - } - if (thirdArg->IsObject(vm)) { - isLengthMetrics |= ParseLocalizedMargin(vm, thirdArg, rightDimen, right); - } - if (forthArg->IsObject(vm)) { - isLengthMetrics |= ParseLocalizedMargin(vm, forthArg, bottomDimen, bottom); - } - if (fifthArg->IsObject(vm)) { - isLengthMetrics |= ParseLocalizedMargin(vm, fifthArg, leftDimen, left); - } + ParseMarginLengthMetrics(vm, secondArg, topDimen, top, isLengthMetrics); + ParseMarginLengthMetrics(vm, thirdArg, rightDimen, right, isLengthMetrics); + ParseMarginLengthMetrics(vm, forthArg, bottomDimen, bottom, isLengthMetrics); + ParseMarginLengthMetrics(vm, fifthArg, leftDimen, left, isLengthMetrics); if (isLengthMetrics) { auto isRightToLeft = AceApplicationInfo::GetInstance().IsRightToLeft(); GetArkUINodeModifiers()->getCommonModifier()->setMargin(nativeNode, &top, isRightToLeft ? &left : &right, &bottom, - isRightToLeft ? &right : &left); + isRightToLeft ? &right : &left, + nullptr); + ParseNullptrResObj(resObj, NUM_4); return panda::JSValueRef::Undefined(vm); } - ParseMargin(vm, secondArg, topDimen, top); - ParseMargin(vm, thirdArg, rightDimen, right); - ParseMargin(vm, forthArg, bottomDimen, bottom); - ParseMargin(vm, fifthArg, leftDimen, left); - GetArkUINodeModifiers()->getCommonModifier()->setMargin(nativeNode, &top, &right, &bottom, &left); + ParseMargin(vm, secondArg, topDimen, top, resObj); + ParseMargin(vm, thirdArg, rightDimen, right, resObj); + ParseMargin(vm, forthArg, bottomDimen, bottom, resObj); + ParseMargin(vm, fifthArg, leftDimen, left, resObj); + auto rawPtr = static_cast(&resObj); + GetArkUINodeModifiers()->getCommonModifier()->setMargin(nativeNode, &top, &right, &bottom, &left, rawPtr); return panda::JSValueRef::Undefined(vm); } @@ -5096,6 +5162,7 @@ ArkUINativeModuleValue CommonBridge::SetSafeAreaPadding(ArkUIRuntimeCallInfo* ru CalcDimension bottomDimen(0, DimensionUnit::VP); CalcDimension startDimen(0, DimensionUnit::VP); bool isLengthMetrics = false; + std::vector> resObj; if (secondArg->IsObject(vm)) { isLengthMetrics |= ParseLocalizedPadding(vm, secondArg, topDimen, top); } @@ -5109,17 +5176,21 @@ ArkUINativeModuleValue CommonBridge::SetSafeAreaPadding(ArkUIRuntimeCallInfo* ru isLengthMetrics |= ParseLocalizedPadding(vm, fifthArg, startDimen, start); } if (!isLengthMetrics) { - ParsePadding(vm, secondArg, topDimen, top); - ParsePadding(vm, thirdArg, endDimen, end); - ParsePadding(vm, forthArg, bottomDimen, bottom); - ParsePadding(vm, fifthArg, startDimen, start); + ParsePadding(vm, secondArg, topDimen, top, resObj); + ParsePadding(vm, thirdArg, endDimen, end, resObj); + ParsePadding(vm, forthArg, bottomDimen, bottom, resObj); + ParsePadding(vm, fifthArg, startDimen, start, resObj); + } else { + ParseNullptrResObj(resObj, NUM_4); } struct ArkUIPaddingType localizedPadding; localizedPadding.top = top; localizedPadding.end = end; localizedPadding.bottom = bottom; localizedPadding.start = start; - GetArkUINodeModifiers()->getCommonModifier()->setSafeAreaPadding(nativeNode, &localizedPadding, isLengthMetrics); + auto rawPtr = static_cast(&resObj); + GetArkUINodeModifiers()->getCommonModifier()->setSafeAreaPadding(nativeNode, &localizedPadding, isLengthMetrics, + rawPtr); return panda::JSValueRef::Undefined(vm); } @@ -5143,16 +5214,21 @@ ArkUINativeModuleValue CommonBridge::SetMarkAnchor(ArkUIRuntimeCallInfo* runtime auto nativeNode = nodePtr(nativeNodeArg->ToNativePointer(vm)->Value()); CalcDimension x(0.0, DimensionUnit::VP); CalcDimension y(0.0, DimensionUnit::VP); + RefPtr xResObj; + RefPtr yResObj; bool useLengthMetrics = ArkTSUtils::ParseJsLengthMetrics(vm, xArg, x); useLengthMetrics = ArkTSUtils::ParseJsLengthMetrics(vm, yArg, y) || useLengthMetrics; if (useLengthMetrics && AceApplicationInfo::GetInstance().IsRightToLeft()) { x.SetValue(-x.Value()); } - bool hasX = useLengthMetrics || ArkTSUtils::ParseJsDimensionNG(vm, xArg, x, DimensionUnit::VP); - bool hasY = useLengthMetrics || ArkTSUtils::ParseJsDimensionNG(vm, yArg, y, DimensionUnit::VP); + bool hasX = useLengthMetrics || ArkTSUtils::ParseJsDimensionNG(vm, xArg, x, DimensionUnit::VP, xResObj); + bool hasY = useLengthMetrics || ArkTSUtils::ParseJsDimensionNG(vm, yArg, y, DimensionUnit::VP, yResObj); if (useLengthMetrics || hasX || hasY) { + auto xRawPtr = AceType::RawPtr(xResObj); + auto yRawPtr = AceType::RawPtr(yResObj); GetArkUINodeModifiers()->getCommonModifier()->setMarkAnchor( - nativeNode, x.Value(), static_cast(x.Unit()), y.Value(), static_cast(y.Unit())); + nativeNode, x.Value(), static_cast(x.Unit()), y.Value(), static_cast(y.Unit()), + xRawPtr, yRawPtr); } else { GetArkUINodeModifiers()->getCommonModifier()->resetMarkAnchor(nativeNode); } @@ -5368,51 +5444,59 @@ ArkUINativeModuleValue CommonBridge::SetConstraintSize(ArkUIRuntimeCallInfo* run struct ArkUISizeType minHeightValue = {0.0, 0}; struct ArkUISizeType maxHeightValue = {0.0, 0}; + RefPtr minWidthResObj; + RefPtr maxWidthResObj; + RefPtr minHeightResObj; + RefPtr maxHeightResObj; bool version10OrLarger = Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TEN); - if (ArkTSUtils::ParseJsDimensionVp(vm, secondArg, minWidth, false)) { + if (ArkTSUtils::ParseJsDimensionVp(vm, secondArg, minWidth, minWidthResObj, false)) { if (minWidth.CalcValue() != "") { minWidthValue.string = minWidth.CalcValue().c_str(); } else { minWidthValue.value = minWidth.Value(); minWidthValue.unit = static_cast(minWidth.Unit()); } - GetArkUINodeModifiers()->getCommonModifier()->setMinWidth(nativeNode, &minWidthValue); + auto minWidthRawResPtr = AceType::RawPtr(minWidthResObj); + GetArkUINodeModifiers()->getCommonModifier()->setMinWidth(nativeNode, &minWidthValue, minWidthRawResPtr); } else if (version10OrLarger) { GetArkUINodeModifiers()->getCommonModifier()->resetMinWidth(nativeNode); } - if (ArkTSUtils::ParseJsDimensionVp(vm, thirdArg, maxWidth, false)) { + if (ArkTSUtils::ParseJsDimensionVp(vm, thirdArg, maxWidth, maxWidthResObj, false)) { if (maxWidth.CalcValue() != "") { maxWidthValue.string = maxWidth.CalcValue().c_str(); } else { maxWidthValue.value = maxWidth.Value(); maxWidthValue.unit = static_cast(maxWidth.Unit()); } - GetArkUINodeModifiers()->getCommonModifier()->setMaxWidth(nativeNode, &maxWidthValue); + auto maxWidthRawResPtr = AceType::RawPtr(maxWidthResObj); + GetArkUINodeModifiers()->getCommonModifier()->setMaxWidth(nativeNode, &maxWidthValue, maxWidthRawResPtr); } else if (version10OrLarger) { GetArkUINodeModifiers()->getCommonModifier()->resetMaxWidth(nativeNode); } - if (ArkTSUtils::ParseJsDimensionVp(vm, forthArg, minHeight, false)) { + if (ArkTSUtils::ParseJsDimensionVp(vm, forthArg, minHeight, minHeightResObj, false)) { if (minHeight.CalcValue() != "") { minHeightValue.string = minHeight.CalcValue().c_str(); } else { minHeightValue.value = minHeight.Value(); minHeightValue.unit = static_cast(minHeight.Unit()); } - GetArkUINodeModifiers()->getCommonModifier()->setMinHeight(nativeNode, &minHeightValue); + auto minHeightRawResPtr = AceType::RawPtr(minHeightResObj); + GetArkUINodeModifiers()->getCommonModifier()->setMinHeight(nativeNode, &minHeightValue, minHeightRawResPtr); } else if (version10OrLarger) { GetArkUINodeModifiers()->getCommonModifier()->resetMinHeight(nativeNode); } - if (ArkTSUtils::ParseJsDimensionVp(vm, fifthArg, maxHeight, false)) { + if (ArkTSUtils::ParseJsDimensionVp(vm, fifthArg, maxHeight, maxHeightResObj, false)) { if (maxHeight.CalcValue() != "") { maxHeightValue.string = maxHeight.CalcValue().c_str(); } else { maxHeightValue.value = maxHeight.Value(); maxHeightValue.unit = static_cast(maxHeight.Unit()); } - GetArkUINodeModifiers()->getCommonModifier()->setMaxHeight(nativeNode, &maxHeightValue); + auto maxHeightRawResPtr = AceType::RawPtr(maxHeightResObj); + GetArkUINodeModifiers()->getCommonModifier()->setMaxHeight(nativeNode, &maxHeightValue, maxHeightRawResPtr); } else if (version10OrLarger) { GetArkUINodeModifiers()->getCommonModifier()->resetMaxHeight(nativeNode); } @@ -5512,8 +5596,10 @@ ArkUINativeModuleValue CommonBridge::SetSize(ArkUIRuntimeCallInfo* runtimeCallIn auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); CalcDimension wVal(0.0, DimensionUnit::VP); CalcDimension hVal(0.0, DimensionUnit::VP); - ParseCalcDimension(vm, nativeNode, secondArg, wVal, true); - ParseCalcDimension(vm, nativeNode, thirdArg, hVal, false); + RefPtr widthResObj; + RefPtr heightResObj; + ParseCalcDimension(vm, nativeNode, secondArg, wVal, true, widthResObj); + ParseCalcDimension(vm, nativeNode, thirdArg, hVal, false, heightResObj); return panda::JSValueRef::Undefined(vm); } diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_search_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_search_bridge.cpp index d606b5b10031bd9fc3c01af3f9f0a22871ff0933..14545bc10567cf9a89f28428f45a8eeea85fc9d3 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_search_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_search_bridge.cpp @@ -751,10 +751,10 @@ ArkUINativeModuleValue SearchBridge::SetSearchHeight(ArkUIRuntimeCallInfo* runti } if (height.Unit() == DimensionUnit::CALC) { GetArkUINodeModifiers()->getCommonModifier()->setHeight( - nativeNode, height.Value(), static_cast(height.Unit()), height.CalcValue().c_str()); + nativeNode, height.Value(), static_cast(height.Unit()), height.CalcValue().c_str(), nullptr); } else { GetArkUINodeModifiers()->getCommonModifier()->setHeight( - nativeNode, height.Value(), static_cast(height.Unit()), calcStr.c_str()); + nativeNode, height.Value(), static_cast(height.Unit()), calcStr.c_str(), nullptr); } GetArkUINodeModifiers()->getSearchModifier()->setSearchHeight( nativeNode, height.Value(), static_cast(height.Unit())); diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.cpp index 365a386fc7a49e5bb8a5e4c4b40530104bc33c8b..caf0286e39dc5bfaf9e59a918ed06a6da8393e45 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.cpp @@ -940,7 +940,7 @@ bool ArkTSUtils::ParseAllBorder(const EcmaVM* vm, const Local& args, bool ArkTSUtils::ParseAllBorder(const EcmaVM* vm, const Local& args, CalcDimension& result, RefPtr& resourceObject) { - if (ParseJsDimensionVp(vm, args, result)) { + if (ParseJsDimensionVp(vm, args, result, resourceObject)) { if (result.IsNegative()) { result.Reset(); } @@ -1803,6 +1803,13 @@ void ArkTSUtils::ParseOuterBorder(EcmaVM* vm, const Local& args, void ArkTSUtils::ParseOuterBorderForDashParams( EcmaVM* vm, const Local& args, std::optional& optionalDimension) +{ + RefPtr resObj; + ParseOuterBorderForDashParams(vm, args, optionalDimension, resObj); +} + +void ArkTSUtils::ParseOuterBorderForDashParams(EcmaVM* vm, const Local& args, + std::optional& optionalDimension, RefPtr& resObj) { CalcDimension valueDim; if (!args->IsUndefined()) { @@ -1811,7 +1818,7 @@ void ArkTSUtils::ParseOuterBorderForDashParams( valueDim.Reset(); } optionalDimension = valueDim; - } else if (ArkTSUtils::ParseJsDimensionVpNG(vm, args, valueDim, false)) { + } else if (ArkTSUtils::ParseJsDimensionVpNG(vm, args, valueDim, resObj, false)) { if (valueDim.IsNegative() || valueDim.Unit() == DimensionUnit::PERCENT) { valueDim.Reset(); } diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h index 159b8a1b28575698b075793ca882e749b137de55..c1ee94ec205ecab907c4787c0024bfa9045a80db 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h @@ -170,6 +170,8 @@ public: std::optional& optionalDimension, RefPtr& resObj); static void ParseOuterBorderForDashParams(EcmaVM* vm, const Local& args, std::optional& optionalDimension); + static void ParseOuterBorderForDashParams(EcmaVM* vm, const Local& args, + std::optional& optionalDimension, RefPtr& resObj); static void PushOuterBorderDimensionVector(const std::optional& valueDim, std::vector& values, std::vector& units); static void ParseJsAngle(const EcmaVM* vm, const Local& value, std::optional& angle); diff --git a/frameworks/core/components_ng/base/view_abstract.cpp b/frameworks/core/components_ng/base/view_abstract.cpp index 2413462fcf283ffa8f4baa960c4ade8d11f8f60f..1e44645abc009fb57bb65c7b9d52febf9b946e8a 100644 --- a/frameworks/core/components_ng/base/view_abstract.cpp +++ b/frameworks/core/components_ng/base/view_abstract.cpp @@ -1085,6 +1085,165 @@ void ViewAbstract::SetDisplayIndex(int32_t value) ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, DisplayIndex, value); } +void ViewAbstract::CheckLocalizedPadding(PaddingProperty& value, const TextDirection& direction) +{ + PaddingProperty padding = value; + if (padding.start.has_value()) { + value.start = padding.start; + if (direction == TextDirection::RTL) { + value.right = padding.start; + } else { + value.left = padding.start; + } + } + if (padding.end.has_value()) { + value.end = padding.end; + if (direction == TextDirection::RTL) { + value.left = padding.end; + } else { + value.right = padding.end; + } + } + if (padding.top.has_value()) { + value.top = padding.top; + } + if (padding.bottom.has_value()) { + value.bottom = padding.bottom; + } + if (value.left.has_value() && !value.right.has_value()) { + value.right = std::optional(CalcLength(0)); + } + if (!value.left.has_value() && value.right.has_value()) { + value.left = std::optional(CalcLength(0)); + } +} + +void ViewAbstract::CheckLocalizedMargin(MarginProperty& value, const TextDirection& direction) +{ + MarginProperty margin = value; + if (margin.start.has_value()) { + value.start = margin.start; + if (direction == TextDirection::RTL) { + value.right = margin.start; + } else { + value.left = margin.start; + } + } + if (margin.end.has_value()) { + value.end = margin.end; + if (direction == TextDirection::RTL) { + value.left = margin.end; + } else { + value.right = margin.end; + } + } + if (margin.top.has_value()) { + value.top = margin.top; + } + if (margin.bottom.has_value()) { + value.bottom = margin.bottom; + } + if (value.left.has_value() && !value.right.has_value()) { + value.right = std::optional(CalcLength(0)); + } + if (!value.left.has_value() && value.right.has_value()) { + value.left = std::optional(CalcLength(0)); + } +} + +void ViewAbstract::CheckLocalizedSafeAreaPadding(PaddingProperty& value, const TextDirection& direction) +{ + PaddingProperty safeAreaPadding = value; + if (safeAreaPadding.start.has_value()) { + value.start = safeAreaPadding.start; + if (direction == TextDirection::RTL) { + value.right = safeAreaPadding.start; + } else { + value.left = safeAreaPadding.start; + } + } + if (safeAreaPadding.end.has_value()) { + value.end = safeAreaPadding.end; + if (direction == TextDirection::RTL) { + value.left = safeAreaPadding.end; + } else { + value.right = safeAreaPadding.end; + } + } + if (safeAreaPadding.top.has_value()) { + value.top = safeAreaPadding.top; + } + if (safeAreaPadding.bottom.has_value()) { + value.bottom = safeAreaPadding.bottom; + } + if (value.left.has_value() && !value.right.has_value()) { + value.right = std::optional(CalcLength(0)); + } + if (!value.left.has_value() && value.right.has_value()) { + value.left = std::optional(CalcLength(0)); + } +} + +void ViewAbstract::CheckPositionLocalizedEdges(EdgesParam& value, TextDirection layoutDirection) +{ + EdgesParam edges = value; + if (!edges.start.has_value() && !edges.end.has_value()) { + return; + } + if (edges.top.has_value()) { + value.SetTop(edges.top.value_or(Dimension(0.0))); + } + if (edges.bottom.has_value()) { + value.SetBottom(edges.bottom.value_or(Dimension(0.0))); + } + if (edges.start.has_value()) { + value.start = edges.start.value(); + if (layoutDirection == TextDirection::RTL) { + value.SetRight(edges.start.value_or(Dimension(0.0))); + } else { + value.SetLeft(edges.start.value_or(Dimension(0.0))); + } + } + if (edges.end.has_value()) { + value.end = edges.end.value(); + if (layoutDirection == TextDirection::RTL) { + value.SetLeft(edges.end.value_or(Dimension(0.0))); + } else { + value.SetRight(edges.end.value_or(Dimension(0.0))); + } + } +} + +void ViewAbstract::CheckOffsetLocalizedEdges(EdgesParam& value, TextDirection layoutDirection) +{ + EdgesParam edges = value; + if (!edges.start.has_value() && !edges.end.has_value()) { + return; + } + if (edges.top.has_value()) { + value.SetTop(edges.top.value_or(Dimension(0.0))); + } + if (edges.bottom.has_value()) { + value.SetBottom(edges.bottom.value_or(Dimension(0.0))); + } + if (edges.start.has_value()) { + value.start = edges.start.value(); + if (layoutDirection == TextDirection::RTL) { + value.SetRight(edges.start.value_or(Dimension(0.0))); + } else { + value.SetLeft(edges.start.value_or(Dimension(0.0))); + } + } + if (edges.end.has_value()) { + value.end = edges.end.value(); + if (layoutDirection == TextDirection::RTL) { + value.SetLeft(edges.end.value_or(Dimension(0.0))); + } else { + value.SetRight(edges.end.value_or(Dimension(0.0))); + } + } +} + void ViewAbstract::SetPadding(const CalcLength& value) { if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) { @@ -1111,6 +1270,10 @@ void ViewAbstract::SetPadding(const PaddingProperty& value) CHECK_NULL_VOID(frameNode); PaddingProperty &padding = const_cast(value); padding.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedPadding(padding, layoutDirection); ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Padding, padding, frameNode); if (frameNode->GetTag() == V2::TEXTAREA_ETS_TAG || frameNode->GetTag() ==V2::TEXTINPUT_ETS_TAG) { ACE_UPDATE_NODE_PAINT_PROPERTY(TextFieldPaintProperty, PaddingByUser, padding, frameNode); @@ -1191,6 +1354,10 @@ void ViewAbstract::SetSafeAreaPadding(const PaddingProperty& value) CHECK_NULL_VOID(frameNode); PaddingProperty &padding = const_cast(value); padding.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedSafeAreaPadding(padding, layoutDirection); ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaPadding, padding, frameNode); frameNode->MarkModifyDone(); frameNode->MarkDirtyNode(PROPERTY_UPDATE_LAYOUT | PROPERTY_UPDATE_MEASURE); @@ -1219,6 +1386,25 @@ void ViewAbstract::SetSafeAreaPadding(FrameNode* frameNode, const CalcLength& va void ViewAbstract::SetSafeAreaPadding(FrameNode* frameNode, const PaddingProperty& value) { CHECK_NULL_VOID(frameNode); + if (SystemProperties::ConfigChangePerform()) { + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + RefPtr resObj = AceType::MakeRefPtr("", "", -1); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + PaddingProperty &padding = const_cast(value); + padding.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedSafeAreaPadding(padding, layoutDirection); + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaPadding, padding, frameNode); + frameNode->MarkModifyDone(); + frameNode->MarkDirtyNode(PROPERTY_UPDATE_LAYOUT | PROPERTY_UPDATE_MEASURE); + }; + pattern->AddResObj("safeAreaPadding", resObj, std::move(updateFunc)); + } ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaPadding, value, frameNode); } @@ -1254,6 +1440,10 @@ void ViewAbstract::SetMargin(const MarginProperty& value) CHECK_NULL_VOID(frameNode); MarginProperty &margin = const_cast(value); margin.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedMargin(margin, layoutDirection); ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Margin, margin, frameNode); auto pattern = frameNode->GetPattern(); CHECK_NULL_VOID(pattern); @@ -1331,6 +1521,10 @@ void ViewAbstract::SetBorderRadius(const BorderRadiusProperty& value) CHECK_NULL_VOID(frameNode); BorderRadiusProperty &borderRadius = const_cast(value); borderRadius.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedBorderRadiuses(borderRadius, layoutDirection); ACE_UPDATE_NODE_RENDER_CONTEXT(BorderRadius, borderRadius, frameNode); auto pattern = frameNode->GetPattern(); CHECK_NULL_VOID(pattern); @@ -1399,6 +1593,10 @@ void ViewAbstract::SetBorderColor(const BorderColorProperty& value) CHECK_NULL_VOID(frameNode); BorderColorProperty &borderColor = const_cast(value); borderColor.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedOuterBorderColor(borderColor, layoutDirection); ACE_UPDATE_NODE_RENDER_CONTEXT(BorderColor, borderColor, frameNode); auto pattern = frameNode->GetPattern(); CHECK_NULL_VOID(pattern); @@ -1472,6 +1670,10 @@ void ViewAbstract::SetBorderWidth(const BorderWidthProperty& value) CHECK_NULL_VOID(frameNode); BorderWidthProperty &borderWidth = const_cast(value); borderWidth.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedEdgeWidths(borderWidth, layoutDirection); ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, borderWidth, frameNode); ACE_UPDATE_NODE_RENDER_CONTEXT(BorderWidth, borderWidth, frameNode); auto pattern = frameNode->GetPattern(); @@ -1586,6 +1788,10 @@ void ViewAbstract::SetDashGap(const BorderWidthProperty& value) CHECK_NULL_VOID(frameNode); BorderWidthProperty &dashGap = const_cast(value); dashGap.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedEdgeWidths(dashGap, layoutDirection); ACE_UPDATE_NODE_RENDER_CONTEXT(DashGap, dashGap, frameNode); }; pattern->AddResObj("border.dashGap", resObj, std::move(updateFunc)); @@ -1595,6 +1801,24 @@ void ViewAbstract::SetDashGap(const BorderWidthProperty& value) void ViewAbstract::SetDashGap(FrameNode *frameNode, const BorderWidthProperty& value) { + CHECK_NULL_VOID(frameNode); + if (SystemProperties::ConfigChangePerform()) { + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + RefPtr resObj = AceType::MakeRefPtr("", "", -1); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + BorderWidthProperty &dashGap = const_cast(value); + dashGap.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedEdgeWidths(dashGap, layoutDirection); + ACE_UPDATE_NODE_RENDER_CONTEXT(DashGap, dashGap, frameNode); + }; + pattern->AddResObj("border.dashGap", resObj, std::move(updateFunc)); + } ACE_UPDATE_NODE_RENDER_CONTEXT(DashGap, value, frameNode); } @@ -1633,6 +1857,10 @@ void ViewAbstract::SetDashWidth(const BorderWidthProperty& value) CHECK_NULL_VOID(frameNode); BorderWidthProperty &dashWidth = const_cast(value); dashWidth.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedEdgeWidths(dashWidth, layoutDirection); ACE_UPDATE_NODE_RENDER_CONTEXT(DashWidth, dashWidth, frameNode); }; pattern->AddResObj("border.dashWidth", resObj, std::move(updateFunc)); @@ -1642,6 +1870,24 @@ void ViewAbstract::SetDashWidth(const BorderWidthProperty& value) void ViewAbstract::SetDashWidth(FrameNode *frameNode, const BorderWidthProperty& value) { + CHECK_NULL_VOID(frameNode); + if (SystemProperties::ConfigChangePerform()) { + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + RefPtr resObj = AceType::MakeRefPtr("", "", -1); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + BorderWidthProperty &dashWidth = const_cast(value); + dashWidth.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedEdgeWidths(dashWidth, layoutDirection); + ACE_UPDATE_NODE_RENDER_CONTEXT(DashWidth, dashWidth, frameNode); + }; + pattern->AddResObj("border.dashWidth", resObj, std::move(updateFunc)); + } ACE_UPDATE_NODE_RENDER_CONTEXT(DashWidth, value, frameNode); } @@ -3032,6 +3278,10 @@ void ViewAbstract::SetPositionEdges(const EdgesParam& value) CHECK_NULL_VOID(frameNode); EdgesParam &edges = const_cast(value); edges.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckPositionLocalizedEdges(edges, layoutDirection); auto parentNode = frameNode->GetAncestorNodeOfFrame(false); CHECK_NULL_VOID(parentNode); if (parentNode->GetTag() == V2::COLUMN_ETS_TAG || parentNode->GetTag() == V2::ROW_ETS_TAG || @@ -3173,6 +3423,10 @@ void ViewAbstract::SetOffsetEdges(const EdgesParam& value) CHECK_NULL_VOID(frameNode); EdgesParam &edges = const_cast(value); edges.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckOffsetLocalizedEdges(edges, layoutDirection); auto parentNode = frameNode->GetAncestorNodeOfFrame(false); CHECK_NULL_VOID(parentNode); if (parentNode->GetTag() == V2::COLUMN_ETS_TAG || parentNode->GetTag() == V2::ROW_ETS_TAG || @@ -5569,6 +5823,24 @@ void ViewAbstract::SetAttractionEffect(const AttractionEffect& effect) void ViewAbstract::SetBorderRadius(FrameNode *frameNode, const BorderRadiusProperty& value) { + CHECK_NULL_VOID(frameNode); + if (SystemProperties::ConfigChangePerform()) { + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + RefPtr resObj = AceType::MakeRefPtr("", "", -1); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + BorderRadiusProperty &borderRadius = const_cast(value); + borderRadius.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedBorderRadiuses(borderRadius, layoutDirection); + ACE_UPDATE_NODE_RENDER_CONTEXT(BorderRadius, borderRadius, frameNode); + }; + pattern->AddResObj("borderRadius", resObj, std::move(updateFunc)); + } ACE_UPDATE_NODE_RENDER_CONTEXT(BorderRadius, value, frameNode); } @@ -5582,6 +5854,26 @@ void ViewAbstract::SetBorderRadius(FrameNode* frameNode, const Dimension& value) void ViewAbstract::SetBorderWidth(FrameNode* frameNode, const BorderWidthProperty& value) { + CHECK_NULL_VOID(frameNode); + if (SystemProperties::ConfigChangePerform()) { + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + RefPtr resObj = AceType::MakeRefPtr("", "", -1); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + BorderWidthProperty &borderWidth = const_cast(value); + borderWidth.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedEdgeWidths(borderWidth, layoutDirection); + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, borderWidth, frameNode); + ACE_UPDATE_NODE_RENDER_CONTEXT(BorderWidth, borderWidth, frameNode); + frameNode->MarkDirtyNode(PROPERTY_UPDATE_LAYOUT | PROPERTY_UPDATE_MEASURE); + }; + pattern->AddResObj("borderWidth", resObj, std::move(updateFunc)); + } ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, value, frameNode); ACE_UPDATE_NODE_RENDER_CONTEXT(BorderWidth, value, frameNode); } @@ -5601,6 +5893,25 @@ void ViewAbstract::SetBorderWidth(FrameNode* frameNode, const Dimension& value) void ViewAbstract::SetBorderColor(FrameNode* frameNode, const BorderColorProperty& value) { + CHECK_NULL_VOID(frameNode); + if (SystemProperties::ConfigChangePerform()) { + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + RefPtr resObj = AceType::MakeRefPtr("", "", -1); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + BorderColorProperty &borderColor = const_cast(value); + borderColor.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedOuterBorderColor(borderColor, layoutDirection); + ACE_UPDATE_NODE_RENDER_CONTEXT(BorderColor, borderColor, frameNode); + frameNode->MarkModifyDone(); + }; + pattern->AddResObj("borderColor", resObj, std::move(updateFunc)); + } ACE_UPDATE_NODE_RENDER_CONTEXT(BorderColor, value, frameNode); } @@ -5625,6 +5936,49 @@ void ViewAbstract::SetWidth(FrameNode* frameNode, const CalcLength& width) layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height)); } +void ViewAbstract::SetWidth(FrameNode* frameNode, const RefPtr& resObj) +{ + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string widthString = pattern->GetResCacheMapByKey("width"); + CalcDimension value; + if (widthString.empty()) { + ResourceParseUtils::ParseResDimensionVpNG(resObj, value); + pattern->AddResCache("width", value.ToString()); + } else { + value = StringUtils::StringToCalcDimension(widthString); + } + CalcLength width; + if (value.Unit() == DimensionUnit::CALC) { + width = NG::CalcLength(value.CalcValue()); + } else { + width = NG::CalcLength(value); + } + if (LessNotEqual(value.Value(), 0.0)) { + ClearWidthOrHeight(AceType::RawPtr(frameNode), true); + return; + } + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + // get previously user defined ideal height + std::optional height = std::nullopt; + auto&& layoutConstraint = layoutProperty->GetCalcLayoutConstraint(); + if (layoutConstraint && layoutConstraint->selfIdealSize) { + height = layoutConstraint->selfIdealSize->Height(); + } + layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height)); + frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); + }; + updateFunc(resObj); + pattern->AddResObj("width", resObj, std::move(updateFunc)); +} + void ViewAbstract::SetHeight(FrameNode* frameNode, const CalcLength& height) { CHECK_NULL_VOID(frameNode); @@ -5638,37 +5992,207 @@ void ViewAbstract::SetHeight(FrameNode* frameNode, const CalcLength& height) layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height)); } -void ViewAbstract::ClearWidthOrHeight(FrameNode* frameNode, bool isWidth) -{ - CHECK_NULL_VOID(frameNode); - auto layoutProperty = frameNode->GetLayoutProperty(); - CHECK_NULL_VOID(layoutProperty); - layoutProperty->ClearUserDefinedIdealSize(isWidth, !isWidth); -} - -void ViewAbstract::SetPosition(FrameNode* frameNode, const OffsetT& value) +void ViewAbstract::SetHeight(FrameNode* frameNode, const RefPtr& resObj) { CHECK_NULL_VOID(frameNode); - CheckIfParentNeedMarkDirty(frameNode); - ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, PositionEdges, frameNode); - ACE_UPDATE_NODE_RENDER_CONTEXT(Position, value, frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string heightString = pattern->GetResCacheMapByKey("height"); + CalcDimension value; + if (heightString.empty()) { + ResourceParseUtils::ParseResDimensionVpNG(resObj, value); + pattern->AddResCache("height", value.ToString()); + } else { + value = StringUtils::StringToCalcDimension(heightString); + } + if (LessNotEqual(value.Value(), 0.0)) { + ClearWidthOrHeight(AceType::RawPtr(frameNode), false); + return; + } + CalcLength height; + if (value.Unit() == DimensionUnit::CALC) { + height = NG::CalcLength(value.CalcValue()); + } else { + height = NG::CalcLength(value); + } + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + // get previously user defined ideal width + std::optional width = std::nullopt; + auto&& layoutConstraint = layoutProperty->GetCalcLayoutConstraint(); + if (layoutConstraint && layoutConstraint->selfIdealSize) { + width = layoutConstraint->selfIdealSize->Width(); + } + layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height)); + frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); + }; + updateFunc(resObj); + pattern->AddResObj("height", resObj, std::move(updateFunc)); } -void ViewAbstract::SetPositionEdges(FrameNode* frameNode, const EdgesParam& value) +void ViewAbstract::ClearWidthOrHeight(FrameNode* frameNode, bool isWidth) { CHECK_NULL_VOID(frameNode); - CheckIfParentNeedMarkDirty(frameNode); - ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Position, frameNode); - ACE_UPDATE_NODE_RENDER_CONTEXT(PositionEdges, value, frameNode); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + layoutProperty->ClearUserDefinedIdealSize(isWidth, !isWidth); } -void ViewAbstract::ResetPosition(FrameNode* frameNode) +void ViewAbstract::SetPositionX(FrameNode* frameNode, OffsetT& value, const RefPtr& xresObj) { - ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Position, frameNode); - ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, PositionEdges, frameNode); CHECK_NULL_VOID(frameNode); - auto parentNode = frameNode->GetAncestorNodeOfFrame(false); - CHECK_NULL_VOID(parentNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + if (!xresObj) { + return; + } + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string xString = pattern->GetResCacheMapByKey("position.x"); + OffsetT &offset = const_cast &>(value); + CalcDimension x; + if (xString.empty()) { + ResourceParseUtils::ParseResDimensionVpNG(resObj, x); + pattern->AddResCache("position.x", x.ToString()); + } else { + x = StringUtils::StringToCalcDimension(xString); + } + const auto& renderContext = frameNode->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + auto position = renderContext->GetPositionValue({}); + offset.SetY(position.GetY()); + offset.SetX(x); + auto parentNode = frameNode->GetAncestorNodeOfFrame(false); + CHECK_NULL_VOID(parentNode); + if (parentNode->GetTag() == V2::COLUMN_ETS_TAG || parentNode->GetTag() == V2::ROW_ETS_TAG || + parentNode->GetTag() == V2::FLEX_ETS_TAG) { + auto renderContext = frameNode->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + if (!renderContext->HasPositionEdges() && !renderContext->HasPosition()) { + parentNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF); + } + } + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, PositionEdges, frameNode); + ACE_UPDATE_NODE_RENDER_CONTEXT(Position, offset, frameNode); + }; + pattern->AddResObj("position.x", xresObj, std::move(updateFunc)); +} + +void ViewAbstract::SetPositionY(FrameNode* frameNode, OffsetT& value, const RefPtr& yresObj) +{ + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + if (!yresObj) { + return; + } + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string yString = pattern->GetResCacheMapByKey("position.y"); + OffsetT &offset = const_cast &>(value); + CalcDimension y; + if (yString.empty()) { + ResourceParseUtils::ParseResDimensionVpNG(resObj, y); + pattern->AddResCache("position.y", y.ToString()); + } else { + y = StringUtils::StringToCalcDimension(yString); + } + const auto& renderContext = frameNode->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + auto position = renderContext->GetPositionValue({}); + offset.SetX(position.GetX()); + offset.SetY(y); + auto parentNode = frameNode->GetAncestorNodeOfFrame(false); + CHECK_NULL_VOID(parentNode); + if (parentNode->GetTag() == V2::COLUMN_ETS_TAG || parentNode->GetTag() == V2::ROW_ETS_TAG || + parentNode->GetTag() == V2::FLEX_ETS_TAG) { + auto renderContext = frameNode->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + if (!renderContext->HasPositionEdges() && !renderContext->HasPosition()) { + parentNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF); + } + } + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, PositionEdges, frameNode); + ACE_UPDATE_NODE_RENDER_CONTEXT(Position, offset, frameNode); + }; + pattern->AddResObj("position.y", yresObj, std::move(updateFunc)); +} + +void ViewAbstract::SetPosition(FrameNode* frameNode, const OffsetT& value) +{ + CHECK_NULL_VOID(frameNode); + CheckIfParentNeedMarkDirty(frameNode); + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, PositionEdges, frameNode); + ACE_UPDATE_NODE_RENDER_CONTEXT(Position, value, frameNode); +} + +void ViewAbstract::SetPosition(FrameNode* frameNode, const Dimension& x, const Dimension& y, + const RefPtr& xresObj, const RefPtr& yresObj) +{ + CHECK_NULL_VOID(frameNode); + OffsetT value = { x, y }; + SetPositionX(frameNode, value, xresObj); + SetPositionY(frameNode, value, yresObj); + CheckIfParentNeedMarkDirty(frameNode); + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, PositionEdges, frameNode); + ACE_UPDATE_NODE_RENDER_CONTEXT(Position, value, frameNode); +} + +void ViewAbstract::SetPositionEdges(FrameNode* frameNode, const EdgesParam& value) +{ + CHECK_NULL_VOID(frameNode); + CheckIfParentNeedMarkDirty(frameNode); + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Position, frameNode); + ACE_UPDATE_NODE_RENDER_CONTEXT(PositionEdges, value, frameNode); + if (!SystemProperties::ConfigChangePerform()) { + return; + } + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + RefPtr resObj = AceType::MakeRefPtr("", "", -1); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + EdgesParam &edges = const_cast(value); + edges.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckPositionLocalizedEdges(edges, layoutDirection); + auto parentNode = frameNode->GetAncestorNodeOfFrame(false); + CHECK_NULL_VOID(parentNode); + if (parentNode->GetTag() == V2::COLUMN_ETS_TAG || parentNode->GetTag() == V2::ROW_ETS_TAG || + parentNode->GetTag() == V2::FLEX_ETS_TAG) { + auto renderContext = frameNode->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + if (!renderContext->HasPositionEdges() && !renderContext->HasPosition()) { + parentNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF); + } + } + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Position, frameNode); + ACE_UPDATE_NODE_RENDER_CONTEXT(PositionEdges, edges, frameNode); + }; + pattern->AddResObj("position.edges", resObj, std::move(updateFunc)); +} + +void ViewAbstract::ResetPosition(FrameNode* frameNode) +{ + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Position, frameNode); + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, PositionEdges, frameNode); + CHECK_NULL_VOID(frameNode); + auto parentNode = frameNode->GetAncestorNodeOfFrame(false); + CHECK_NULL_VOID(parentNode); auto parentPattern = parentNode->GetPattern(); if (parentNode->GetTag() == V2::COLUMN_ETS_TAG || parentNode->GetTag() == V2::ROW_ETS_TAG || @@ -6287,6 +6811,70 @@ void ViewAbstract::SetDisplayIndex(FrameNode* frameNode, int32_t value) ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, DisplayIndex, value, frameNode); } +void ViewAbstract::SetOffsetX(FrameNode* frameNode, OffsetT& value, const RefPtr& xresObj) +{ + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + if (xresObj) { + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string xString = pattern->GetResCacheMapByKey("offset.x"); + OffsetT &offset = const_cast &>(value); + CalcDimension x; + if (xString.empty()) { + ResourceParseUtils::ParseResDimensionVpNG(resObj, x); + pattern->AddResCache("offset.x", x.ToString()); + } else { + x = StringUtils::StringToCalcDimension(xString); + } + const auto& renderContext = frameNode->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + auto offsetValue = renderContext->GetOffsetValue({}); + offset.SetY(offsetValue.GetY()); + offset.SetX(x); + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, OffsetEdges, frameNode); + ACE_UPDATE_NODE_RENDER_CONTEXT(Offset, offset, frameNode); + }; + pattern->AddResObj("offset.x", xresObj, std::move(updateFunc)); + } +} + +void ViewAbstract::SetOffsetY(FrameNode* frameNode, OffsetT& value, const RefPtr& yresObj) +{ + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + if (yresObj) { + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string yString = pattern->GetResCacheMapByKey("offset.y"); + OffsetT &offset = const_cast &>(value); + CalcDimension y; + if (yString.empty()) { + ResourceParseUtils::ParseResDimensionVpNG(resObj, y); + pattern->AddResCache("offset.y", y.ToString()); + } else { + y = StringUtils::StringToCalcDimension(yString); + } + const auto& renderContext = frameNode->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + auto offsetValue = renderContext->GetOffsetValue({}); + offset.SetX(offsetValue.GetX()); + offset.SetY(y); + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, OffsetEdges, frameNode); + ACE_UPDATE_NODE_RENDER_CONTEXT(Offset, offset, frameNode); + }; + pattern->AddResObj("offset.y", yresObj, std::move(updateFunc)); + } +} + void ViewAbstract::SetOffset(FrameNode* frameNode, const OffsetT& value) { CHECK_NULL_VOID(frameNode); @@ -6294,11 +6882,222 @@ void ViewAbstract::SetOffset(FrameNode* frameNode, const OffsetT& val ACE_UPDATE_NODE_RENDER_CONTEXT(Offset, value, frameNode); } +void ViewAbstract::SetOffset(FrameNode* frameNode, const Dimension& x, const Dimension& y, + const RefPtr& xresObj, const RefPtr& yresObj) +{ + CHECK_NULL_VOID(frameNode); + OffsetT value = { x, y }; + SetOffsetX(frameNode, value, xresObj); + SetOffsetY(frameNode, value, yresObj); + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, OffsetEdges, frameNode); + ACE_UPDATE_NODE_RENDER_CONTEXT(Offset, value, frameNode); +} + void ViewAbstract::SetOffsetEdges(FrameNode* frameNode, const EdgesParam& value) { CHECK_NULL_VOID(frameNode); ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Offset, frameNode); ACE_UPDATE_NODE_RENDER_CONTEXT(OffsetEdges, value, frameNode); + if (!SystemProperties::ConfigChangePerform()) { + return; + } + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + RefPtr resObj = AceType::MakeRefPtr("", "", -1); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + EdgesParam &edges = const_cast(value); + edges.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckOffsetLocalizedEdges(edges, layoutDirection); + auto parentNode = frameNode->GetAncestorNodeOfFrame(false); + CHECK_NULL_VOID(parentNode); + if (parentNode->GetTag() == V2::COLUMN_ETS_TAG || parentNode->GetTag() == V2::ROW_ETS_TAG || + parentNode->GetTag() == V2::FLEX_ETS_TAG) { + auto renderContext = frameNode->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + if (!renderContext->HasPositionEdges() && !renderContext->HasPosition()) { + parentNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF); + } + } + ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Offset, frameNode); + ACE_UPDATE_NODE_RENDER_CONTEXT(OffsetEdges, edges, frameNode); + }; + pattern->AddResObj("offset.edges", resObj, std::move(updateFunc)); +} + +void ViewAbstract::MarkAnchorX( + FrameNode* frameNode, const OffsetT& value, const RefPtr& xresObj) +{ + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + if (xresObj) { + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string xString = pattern->GetResCacheMapByKey("markAnchor.x"); + OffsetT &offset = const_cast &>(value); + CalcDimension x; + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + if (xString.empty()) { + ResourceParseUtils::ParseResDimensionVpNG(resObj, x); + pattern->AddResCache("markAnchor.x", x.ToString()); + } else { + x = layoutDirection == TextDirection::RTL ? -StringUtils::StringToCalcDimension(xString) + : StringUtils::StringToCalcDimension(xString); + } + const auto& renderContext = frameNode->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + auto anchor = renderContext->GetAnchorValue({}); + offset.SetY(anchor.GetY()); + offset.SetX(x); + ACE_UPDATE_NODE_RENDER_CONTEXT(Anchor, offset, frameNode); + }; + pattern->AddResObj("markAnchor.x", xresObj, std::move(updateFunc)); + } +} + +void ViewAbstract::MarkAnchorY( + FrameNode* frameNode, const OffsetT& value, const RefPtr& yresObj) +{ + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + if (yresObj) { + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string yString = pattern->GetResCacheMapByKey("markAnchor.y"); + OffsetT &offset = const_cast &>(value); + CalcDimension y; + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + if (yString.empty()) { + ResourceParseUtils::ParseResDimensionVpNG(resObj, y); + pattern->AddResCache("markAnchor.y", y.ToString()); + } else { + y = layoutDirection == TextDirection::RTL ? -StringUtils::StringToCalcDimension(yString) + : StringUtils::StringToCalcDimension(yString); + } + const auto& renderContext = frameNode->GetRenderContext(); + CHECK_NULL_VOID(renderContext); + auto anchor = renderContext->GetAnchorValue({}); + offset.SetX(anchor.GetX()); + offset.SetY(y); + ACE_UPDATE_NODE_RENDER_CONTEXT(Anchor, offset, frameNode); + }; + pattern->AddResObj("markAnchor.y", yresObj, std::move(updateFunc)); + } +} + +void ViewAbstract::CheckLocalizedEdgeWidths(BorderWidthProperty& value, const TextDirection& direction) +{ + BorderWidthProperty borderWidth = value; + if (borderWidth.startDimen.has_value()) { + value.startDimen = borderWidth.startDimen; + if (direction == TextDirection::RTL) { + value.rightDimen = borderWidth.startDimen; + } else { + value.leftDimen = borderWidth.startDimen; + } + } + if (borderWidth.endDimen.has_value()) { + value.endDimen = borderWidth.endDimen; + if (direction == TextDirection::RTL) { + value.leftDimen = borderWidth.endDimen; + } else { + value.rightDimen = borderWidth.endDimen; + } + } + if (borderWidth.topDimen.has_value()) { + value.topDimen = borderWidth.topDimen; + } + if (borderWidth.bottomDimen.has_value()) { + value.bottomDimen = borderWidth.bottomDimen; + } + if (value.leftDimen.has_value() && !value.rightDimen.has_value()) { + value.rightDimen = std::optional(Dimension(0)); + } + if (!value.leftDimen.has_value() && value.rightDimen.has_value()) { + value.leftDimen = std::optional(Dimension(0)); + } + value.multiValued = true; +} + +void ViewAbstract::CheckLocalizedOuterBorderColor(NG::BorderColorProperty& value, const TextDirection& direction) +{ + NG::BorderColorProperty borderColors = value; + borderColors.multiValued = true; + if (borderColors.startColor.has_value()) { + value.startColor = borderColors.startColor; + if (direction == TextDirection::RTL) { + value.rightColor = borderColors.startColor; + } else { + value.leftColor = borderColors.startColor; + } + } + if (borderColors.endColor.has_value()) { + value.endColor = borderColors.endColor; + if (direction == TextDirection::RTL) { + value.leftColor = borderColors.endColor; + } else { + value.rightColor = borderColors.endColor; + } + } + if (borderColors.topColor.has_value()) { + value.topColor = borderColors.topColor; + } + if (borderColors.bottomColor.has_value()) { + value.bottomColor = borderColors.bottomColor; + } +} + +void ViewAbstract::CheckLocalizedBorderRadiuses(BorderRadiusProperty& value, const TextDirection& direction) +{ + BorderRadiusProperty borderRadius = value; + if (borderRadius.radiusTopStart.has_value()) { + value.radiusTopStart = borderRadius.radiusTopStart; + if (direction == TextDirection::RTL) { + value.radiusTopRight = borderRadius.radiusTopStart; + } else { + value.radiusTopLeft = borderRadius.radiusTopStart; + } + } + if (borderRadius.radiusTopEnd.has_value()) { + value.radiusTopEnd = borderRadius.radiusTopEnd; + if (direction == TextDirection::RTL) { + value.radiusTopLeft = borderRadius.radiusTopEnd; + } else { + value.radiusTopRight = borderRadius.radiusTopEnd; + } + } + if (borderRadius.radiusBottomStart.has_value()) { + value.radiusBottomStart = borderRadius.radiusBottomStart; + if (direction == TextDirection::RTL) { + value.radiusBottomRight = borderRadius.radiusBottomStart; + } else { + value.radiusBottomLeft = borderRadius.radiusBottomStart; + } + } + if (borderRadius.radiusBottomEnd.has_value()) { + value.radiusBottomEnd = borderRadius.radiusBottomEnd; + if (direction == TextDirection::RTL) { + value.radiusBottomLeft = borderRadius.radiusBottomEnd; + } else { + value.radiusBottomRight = borderRadius.radiusBottomEnd; + } + } } void ViewAbstract::MarkAnchor(FrameNode* frameNode, const OffsetT& value) @@ -6307,6 +7106,15 @@ void ViewAbstract::MarkAnchor(FrameNode* frameNode, const OffsetT& va ACE_UPDATE_NODE_RENDER_CONTEXT(Anchor, value, frameNode); } +void ViewAbstract::MarkAnchor(FrameNode* frameNode, const OffsetT& value, + const RefPtr& xresObj, const RefPtr& yresObj) +{ + CHECK_NULL_VOID(frameNode); + MarkAnchorX(frameNode, value, xresObj); + MarkAnchorY(frameNode, value, yresObj); + ACE_UPDATE_NODE_RENDER_CONTEXT(Anchor, value, frameNode); +} + void ViewAbstract::SetVisibility(FrameNode* frameNode, VisibleType visible) { CHECK_NULL_VOID(frameNode); @@ -6332,6 +7140,24 @@ void ViewAbstract::SetPadding(FrameNode* frameNode, const CalcLength& value) void ViewAbstract::SetPadding(FrameNode* frameNode, const PaddingProperty& value) { CHECK_NULL_VOID(frameNode); + if (SystemProperties::ConfigChangePerform()) { + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + RefPtr resObj = AceType::MakeRefPtr("", "", -1); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + PaddingProperty& padding = const_cast(value); + padding.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedPadding(padding, layoutDirection); + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Padding, padding, frameNode); + frameNode->MarkDirtyNode(PROPERTY_UPDATE_LAYOUT | PROPERTY_UPDATE_MEASURE); + }; + pattern->AddResObj("padding", resObj, std::move(updateFunc)); + } ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Padding, value, frameNode); } @@ -6346,6 +7172,24 @@ void ViewAbstract::SetMargin(FrameNode* frameNode, const CalcLength& value) void ViewAbstract::SetMargin(FrameNode* frameNode, const PaddingProperty& value) { CHECK_NULL_VOID(frameNode); + if (SystemProperties::ConfigChangePerform()) { + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + RefPtr resObj = AceType::MakeRefPtr("", "", -1); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + MarginProperty &margin = const_cast(value); + margin.ReloadResources(); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto layoutDirection = layoutProperty->GetNonAutoLayoutDirection(); + CheckLocalizedMargin(margin, layoutDirection); + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Margin, margin, frameNode); + frameNode->MarkDirtyNode(PROPERTY_UPDATE_LAYOUT | PROPERTY_UPDATE_MEASURE); + }; + pattern->AddResObj("margin", resObj, std::move(updateFunc)); + } ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Margin, value, frameNode); } @@ -6443,6 +7287,34 @@ void ViewAbstract::SetMinWidth(FrameNode* frameNode, const CalcLength& minWidth) layoutProperty->UpdateCalcMinSize(CalcSize(minWidth, std::nullopt)); } +void ViewAbstract::SetMinWidth(FrameNode* frameNode, const RefPtr& resObj) +{ + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string minWidthString = pattern->GetResCacheMapByKey("constraintSize.minWidth"); + CalcDimension value; + if (minWidthString.empty()) { + ResourceParseUtils::ParseResDimensionVp(resObj, value); + pattern->AddResCache("constraintSize.minWidth", value.ToString()); + } else { + value = StringUtils::StringToCalcDimension(minWidthString); + } + NG::CalcLength width; + width = (value.Unit() == DimensionUnit::CALC) ? NG::CalcLength(value.CalcValue()) : NG::CalcLength(value); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + layoutProperty->UpdateCalcMinSize(CalcSize(width, std::nullopt)); + frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); + }; + pattern->AddResObj("constraintSize.minWidth", resObj, std::move(updateFunc)); +} + void ViewAbstract::SetMaxWidth(FrameNode* frameNode, const CalcLength& maxWidth) { CHECK_NULL_VOID(frameNode); @@ -6451,6 +7323,34 @@ void ViewAbstract::SetMaxWidth(FrameNode* frameNode, const CalcLength& maxWidth) layoutProperty->UpdateCalcMaxSize(CalcSize(maxWidth, std::nullopt)); } +void ViewAbstract::SetMaxWidth(FrameNode* frameNode, const RefPtr& resObj) +{ + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string minWidthString = pattern->GetResCacheMapByKey("constraintSize.maxWidth"); + CalcDimension value; + if (minWidthString.empty()) { + ResourceParseUtils::ParseResDimensionVp(resObj, value); + pattern->AddResCache("constraintSize.maxWidth", value.ToString()); + } else { + value = StringUtils::StringToCalcDimension(minWidthString); + } + NG::CalcLength width; + width = (value.Unit() == DimensionUnit::CALC) ? NG::CalcLength(value.CalcValue()) : NG::CalcLength(value); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + layoutProperty->UpdateCalcMaxSize(CalcSize(width, std::nullopt)); + frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); + }; + pattern->AddResObj("constraintSize.maxWidth", resObj, std::move(updateFunc)); +} + void ViewAbstract::SetMinHeight(FrameNode* frameNode, const CalcLength& minHeight) { CHECK_NULL_VOID(frameNode); @@ -6459,6 +7359,34 @@ void ViewAbstract::SetMinHeight(FrameNode* frameNode, const CalcLength& minHeigh layoutProperty->UpdateCalcMinSize(CalcSize(std::nullopt, minHeight)); } +void ViewAbstract::SetMinHeight(FrameNode* frameNode, const RefPtr& resObj) +{ + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string minWidthString = pattern->GetResCacheMapByKey("constraintSize.minHeight"); + CalcDimension value; + if (minWidthString.empty()) { + ResourceParseUtils::ParseResDimensionVp(resObj, value); + pattern->AddResCache("constraintSize.minHeight", value.ToString()); + } else { + value = StringUtils::StringToCalcDimension(minWidthString); + } + NG::CalcLength height; + height = (value.Unit() == DimensionUnit::CALC) ? NG::CalcLength(value.CalcValue()) : NG::CalcLength(value); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + layoutProperty->UpdateCalcMinSize(CalcSize(std::nullopt, height)); + frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); + }; + pattern->AddResObj("constraintSize.minHeight", resObj, std::move(updateFunc)); +} + void ViewAbstract::SetMaxHeight(FrameNode* frameNode, const CalcLength& maxHeight) { CHECK_NULL_VOID(frameNode); @@ -6467,6 +7395,34 @@ void ViewAbstract::SetMaxHeight(FrameNode* frameNode, const CalcLength& maxHeigh layoutProperty->UpdateCalcMaxSize(CalcSize(std::nullopt, maxHeight)); } +void ViewAbstract::SetMaxHeight(FrameNode* frameNode, const RefPtr& resObj) +{ + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string minWidthString = pattern->GetResCacheMapByKey("constraintSize.maxHeight"); + CalcDimension value; + if (minWidthString.empty()) { + ResourceParseUtils::ParseResDimensionVp(resObj, value); + pattern->AddResCache("constraintSize.maxHeight", value.ToString()); + } else { + value = StringUtils::StringToCalcDimension(minWidthString); + } + NG::CalcLength height; + height = (value.Unit() == DimensionUnit::CALC) ? NG::CalcLength(value.CalcValue()) : NG::CalcLength(value); + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + layoutProperty->UpdateCalcMaxSize(CalcSize(std::nullopt, height)); + frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); + }; + pattern->AddResObj("constraintSize.maxHeight", resObj, std::move(updateFunc)); +} + void ViewAbstract::SetAlignRules(FrameNode* frameNode, const std::map& alignRules) { CHECK_NULL_VOID(frameNode); @@ -8691,6 +9647,17 @@ void ViewAbstract::ClearJSFrameNodeOnWaterFlowScrollIndex(FrameNode* frameNode) eventHub->ClearJSFrameNodeOnWaterFlowScrollIndex(); } +void ViewAbstract::ResetResObj(FrameNode* frameNode, const std::string& key) +{ + if (!SystemProperties::ConfigChangePerform()) { + return; + } + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + pattern->RemoveResObj(key); +} + bool ViewAbstract::CreatePropertyAnimation(FrameNode* frameNode, AnimationPropertyType property, const std::vector& startValue, const std::vector& endValue, const AnimationOption& option) { diff --git a/frameworks/core/components_ng/base/view_abstract.h b/frameworks/core/components_ng/base/view_abstract.h index c6a5922f28b7a253a2465e551d481041a146ebf7..49f0481b397b1b5aa8f80eab7bd0a6671d71c20f 100644 --- a/frameworks/core/components_ng/base/view_abstract.h +++ b/frameworks/core/components_ng/base/view_abstract.h @@ -205,6 +205,15 @@ public: static void SetSphericalEffect(double radio); static void SetPixelStretchEffect(PixStretchEffectOption &option); static void SetLightUpEffect(double radio); + static void CheckLocalizedPadding(PaddingProperty& value, const TextDirection& direction); + static void CheckLocalizedMargin(MarginProperty& value, const TextDirection& direction); + static void CheckLocalizedSafeAreaPadding(PaddingProperty& value, const TextDirection& direction); + static void CheckPositionLocalizedEdges(EdgesParam& value, TextDirection layoutDirection); + static void CheckOffsetLocalizedEdges(EdgesParam& value, TextDirection layoutDirection); + static void CheckLocalizedEdgeWidths(BorderWidthProperty& value, const TextDirection& direction); + static void CheckLocalizedBorderRadiuses(BorderRadiusProperty& value, const TextDirection& direction); + static void CheckLocalizedOuterBorderColor(NG::BorderColorProperty& value, const TextDirection& direction); + static void SetPadding(const CalcLength &value); static void SetPadding(const PaddingProperty &value); static void SetPadding(const RefPtr& resObj); @@ -631,7 +640,9 @@ public: static void SetBackgroundColor(FrameNode* frameNode, const Color& color); static void SetBackgroundColor(FrameNode* frameNode, const Color& color, const RefPtr& resObj); static void SetWidth(FrameNode* frameNode, const CalcLength& width); + static void SetWidth(FrameNode* frameNode, const RefPtr& resObj); static void SetHeight(FrameNode* frameNode, const CalcLength& height); + static void SetHeight(FrameNode* frameNode, const RefPtr& resObj); static void ClearWidthOrHeight(FrameNode* frameNode, bool isWidth); static void SetBorderRadius(FrameNode* frameNode, const BorderRadiusProperty& value); static void SetBorderRadius(FrameNode* frameNode, const Dimension& value); @@ -655,6 +666,10 @@ public: static void SetDashWidth(FrameNode* frameNode, const Dimension& value); static void SetBackShadow(FrameNode* frameNode, const Shadow& shadow); static void SetPosition(FrameNode* frameNode, const OffsetT& value); + static void SetPosition(FrameNode* frameNode, const Dimension& x, const Dimension& y, + const RefPtr& xresObj, const RefPtr& yresObj); + static void SetPositionX(FrameNode* frameNode, OffsetT& value, const RefPtr& xresObj); + static void SetPositionY(FrameNode* frameNode, OffsetT& value, const RefPtr& yresObj); static void SetPositionEdges(FrameNode* frameNode, const EdgesParam& value); static void ResetPosition(FrameNode* frameNode); static void SetTransformMatrix(FrameNode* frameNode, const Matrix4& matrix); @@ -739,8 +754,18 @@ public: static void SetDefaultFocus(FrameNode* frameNode, bool isSet); static void SetDisplayIndex(FrameNode* frameNode, int32_t value); static void SetOffset(FrameNode* frameNode, const OffsetT& value); + static void SetOffset(FrameNode* frameNode, const Dimension& x, const Dimension& y, + const RefPtr& xresObj, const RefPtr& yresObj); + static void SetOffsetX(FrameNode* frameNode, OffsetT& value, const RefPtr& xresObj); + static void SetOffsetY(FrameNode* frameNode, OffsetT& value, const RefPtr& yresObj); static void SetOffsetEdges(FrameNode* frameNode, const EdgesParam& value); static void MarkAnchor(FrameNode* frameNode, const OffsetT& value); + static void MarkAnchor(FrameNode* frameNode, const OffsetT& value, const RefPtr& xresObj, + const RefPtr& yresObj); + static void MarkAnchorX( + FrameNode* frameNode, const OffsetT& value, const RefPtr& xresObj); + static void MarkAnchorY( + FrameNode* frameNode, const OffsetT& value, const RefPtr& yresObj); static void SetVisibility(FrameNode* frameNode, VisibleType visible); static void SetMargin(FrameNode* frameNode, const CalcLength& value); static void SetMargin(FrameNode* frameNode, const PaddingProperty& value); @@ -760,9 +785,13 @@ public: static void ResetMaxSize(FrameNode* frameNode, bool resetWidth); static void ResetMinSize(FrameNode* frameNode, bool resetWidth); static void SetMinWidth(FrameNode* frameNode, const CalcLength& minWidth); + static void SetMinWidth(FrameNode* frameNode, const RefPtr& resObj); static void SetMaxWidth(FrameNode* frameNode, const CalcLength& maxWidth); + static void SetMaxWidth(FrameNode* frameNode, const RefPtr& resObj); static void SetMinHeight(FrameNode* frameNode, const CalcLength& minHeight); + static void SetMinHeight(FrameNode* frameNode, const RefPtr& resObj); static void SetMaxHeight(FrameNode* frameNode, const CalcLength& maxHeight); + static void SetMaxHeight(FrameNode* frameNode, const RefPtr& resObj); static void SetAlignRules(FrameNode* frameNode, const std::map& alignRules); static void SetChainStyle(FrameNode* frameNode, const ChainInfo& chainInfo); static ChainInfo GetChainStyle(FrameNode* frameNode); @@ -972,6 +1001,7 @@ public: bool arrowKeyStepOut); static void SetFocusScopePriority(FrameNode* frameNode, const std::string& focusScopeId, const uint32_t focusPriority); + static void ResetResObj(FrameNode* frameNode, const std::string& key); static void ResetBias(FrameNode* frameNode); static void ResetAlignRules(FrameNode* frameNode); static void ResetResObj(const std::string& key); diff --git a/frameworks/core/interfaces/arkoala/arkoala_api.h b/frameworks/core/interfaces/arkoala/arkoala_api.h index e92ece0107ee259ea0060dde69c711d63efb7cde..14e198b3fd09f5822c565aa9ff7293fd26ce960f 100644 --- a/frameworks/core/interfaces/arkoala/arkoala_api.h +++ b/frameworks/core/interfaces/arkoala/arkoala_api.h @@ -2175,27 +2175,30 @@ struct ArkUICommonModifier { void (*setBackgroundColorWithColorSpace)( ArkUINodeHandle node, ArkUI_Uint32 color, ArkUI_Int32 colorSpace, void* bgColorRawPtr); void (*resetBackgroundColor)(ArkUINodeHandle node); - void (*setWidth)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue); + void (*setWidth)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue, + void* widthResPtr); void (*resetWidth)(ArkUINodeHandle node); - void (*setHeight)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue); + void (*setHeight)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue, + void* heightResPtr); void (*resetHeight)(ArkUINodeHandle node); void (*setBorderRadius)( - ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length); + ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length, void* rawPtr); void (*resetBorderRadius)(ArkUINodeHandle node); void (*setBorderWidth)( - ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length); + ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length, void* rawPtr); void (*resetBorderWidth)(ArkUINodeHandle node); void (*setTransform)(ArkUINodeHandle node, const ArkUI_Float32* matrix, ArkUI_Int32 length); void (*resetTransform)(ArkUINodeHandle node); void (*setTransform3D)(ArkUINodeHandle node, const ArkUI_Float32* matrix, ArkUI_Int32 length); void (*resetTransform3D)(ArkUINodeHandle node); void (*setBorderColor)(ArkUINodeHandle node, ArkUI_Uint32 leftColorInt, ArkUI_Uint32 rightColorInt, - ArkUI_Uint32 topColorInt, ArkUI_Uint32 bottomColorInt); + ArkUI_Uint32 topColorInt, ArkUI_Uint32 bottomColorInt, void* rawPtr); void (*resetBorderColor)(ArkUINodeHandle node); void (*setPosition)( ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue, ArkUI_Int32 yUnit); void (*resetPosition)(ArkUINodeHandle node); - void (*setPositionEdges)(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIStringAndFloat* options); + void (*setPositionEdges)(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIStringAndFloat* options, + void* rawPtr); void (*resetPositionEdges)(ArkUINodeHandle node); void (*setBorderStyle)(ArkUINodeHandle node, const ArkUI_Int32* styles, ArkUI_Int32 length); void (*resetBorderStyle)(ArkUINodeHandle node); @@ -2264,7 +2267,7 @@ struct ArkUICommonModifier { void (*resetBackgroundBlurStyle)(ArkUINodeHandle node); void (*setBorder)(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize, const ArkUI_Uint32* colorAndStyle, ArkUI_Int32 colorAndStyleSize, ArkUI_Bool isLocalizedBorderWidth, - ArkUI_Bool isLocalizedBorderColor, ArkUI_Bool isLocalizedBorderRadius); + ArkUI_Bool isLocalizedBorderColor, ArkUI_Bool isLocalizedBorderRadius, void* rawPtr); void (*resetBorder)(ArkUINodeHandle node); void (*setBackgroundImagePosition)(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* types, ArkUI_Bool isAlign, ArkUI_Int32 size, void* bgImageXRawPtr, void* bgImageYRawPtr); @@ -2333,19 +2336,20 @@ struct ArkUICommonModifier { void (*setDisplayPriority)(ArkUINodeHandle node, ArkUI_Float32 value); void (*resetDisplayPriority)(ArkUINodeHandle node); void (*setOffset)(ArkUINodeHandle node, const ArkUI_Float32* number, const ArkUI_Int32* unit); - void (*setOffsetEdges)(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIStringAndFloat* options); + void (*setOffsetEdges)(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIStringAndFloat* options, void* rawPtr); void (*resetOffset)(ArkUINodeHandle node); void (*setPadding)(ArkUINodeHandle node, const struct ArkUISizeType* top, const struct ArkUISizeType* right, - const struct ArkUISizeType* bottom, const struct ArkUISizeType* left); + const struct ArkUISizeType* bottom, const struct ArkUISizeType* left, void* rawPtr); void (*resetPadding)(ArkUINodeHandle node); void (*setMargin)(ArkUINodeHandle node, const struct ArkUISizeType* top, const struct ArkUISizeType* right, - const struct ArkUISizeType* bottom, const struct ArkUISizeType* left); + const struct ArkUISizeType* bottom, const struct ArkUISizeType* left, void* rawPtr); void (*resetMargin)(ArkUINodeHandle node); void (*setSafeAreaPadding)( - ArkUINodeHandle node, const struct ArkUIPaddingType* safeAreaPadding, ArkUI_Bool isLengthMetrics); + ArkUINodeHandle node, const struct ArkUIPaddingType* safeAreaPadding, ArkUI_Bool isLengthMetrics, void* rawPtr); void (*resetSafeAreaPadding)(ArkUINodeHandle node); void (*setMarkAnchor)( - ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue, ArkUI_Int32 yUnit); + ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue, ArkUI_Int32 yUnit, + void* xRawPtr, void* yRawPtr); void (*resetMarkAnchor)(ArkUINodeHandle node); void (*setVisibility)(ArkUINodeHandle node, ArkUI_Int32 value); void (*resetVisibility)(ArkUINodeHandle node); @@ -2361,13 +2365,13 @@ struct ArkUICommonModifier { void (*resetDirection)(ArkUINodeHandle node); void (*setLayoutWeight)(ArkUINodeHandle node, ArkUI_Int32 layoutWeight); void (*resetLayoutWeight)(ArkUINodeHandle node); - void (*setMinWidth)(ArkUINodeHandle node, const struct ArkUISizeType* minWidth); + void (*setMinWidth)(ArkUINodeHandle node, const struct ArkUISizeType* minWidth, void* minWidthRawResPtr); void (*resetMinWidth)(ArkUINodeHandle node); - void (*setMaxWidth)(ArkUINodeHandle node, const struct ArkUISizeType* maxWidth); + void (*setMaxWidth)(ArkUINodeHandle node, const struct ArkUISizeType* maxWidth, void* maxWidthRawResPtr); void (*resetMaxWidth)(ArkUINodeHandle node); - void (*setMinHeight)(ArkUINodeHandle node, const struct ArkUISizeType* minHeight); + void (*setMinHeight)(ArkUINodeHandle node, const struct ArkUISizeType* minHeight, void* minHeightRawResPtr); void (*resetMinHeight)(ArkUINodeHandle node); - void (*setMaxHeight)(ArkUINodeHandle node, const struct ArkUISizeType* maxHeight); + void (*setMaxHeight)(ArkUINodeHandle node, const struct ArkUISizeType* maxHeight, void* maxHeightRawResPtr); void (*resetMaxHeight)(ArkUINodeHandle node); void (*setSize)(ArkUINodeHandle node, const ArkUI_Float32* number, const ArkUI_Int32* unit, ArkUI_CharPtr* calc); void (*resetSize)(ArkUINodeHandle node); @@ -2646,7 +2650,8 @@ struct ArkUICommonModifier { void (*resetFocusScopePriority)(ArkUINodeHandle node); void (*setPixelRound)(ArkUINodeHandle node, const ArkUI_Int32* values, ArkUI_Int32 length); void (*resetPixelRound)(ArkUINodeHandle node); - void (*setBorderDashParams)(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize); + void (*setBorderDashParams)(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize, + void* rawPtr); void (*getExpandSafeArea)(ArkUINodeHandle node, ArkUI_Uint32 (*values)[2]); void (*setTransition)(ArkUINodeHandle node, ArkUITransitionEffectOption* option); void (*setDragPreview)(ArkUINodeHandle node, ArkUIDragPreview dragPreview); diff --git a/frameworks/core/interfaces/cjui/cjui_api.h b/frameworks/core/interfaces/cjui/cjui_api.h index 360093d4d8dd5e4e689bc25290ab6793cc692807..1f1faaf720b929ebe9998ffef7a249775709592e 100644 --- a/frameworks/core/interfaces/cjui/cjui_api.h +++ b/frameworks/core/interfaces/cjui/cjui_api.h @@ -29,25 +29,28 @@ struct CJUICommonModifier { void (*setBackgroundColorWithColorSpace)( ArkUINodeHandle node, ArkUI_Uint32 color, ArkUI_Int32 colorSpace, void* bgColorRawPtr); void (*resetBackgroundColor)(ArkUINodeHandle node); - void (*setWidth)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue); + void (*setWidth)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue, + void* widthResPtr); void (*resetWidth)(ArkUINodeHandle node); - void (*setHeight)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue); + void (*setHeight)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue, + void* heightResPtr); void (*resetHeight)(ArkUINodeHandle node); void (*setBorderRadius)( - ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length); + ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length, void* rawPtr); void (*resetBorderRadius)(ArkUINodeHandle node); void (*setBorderWidth)( - ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length); + ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length, void* rawPtr); void (*resetBorderWidth)(ArkUINodeHandle node); void (*setTransform)(ArkUINodeHandle node, const ArkUI_Float32* matrix, ArkUI_Int32 length); void (*resetTransform)(ArkUINodeHandle node); void (*setBorderColor)(ArkUINodeHandle node, ArkUI_Uint32 leftColorInt, ArkUI_Uint32 rightColorInt, - ArkUI_Uint32 topColorInt, ArkUI_Uint32 bottomColorInt); + ArkUI_Uint32 topColorInt, ArkUI_Uint32 bottomColorInt, void* rawPtr); void (*resetBorderColor)(ArkUINodeHandle node); void (*setPosition)( ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue, ArkUI_Int32 yUnit); void (*resetPosition)(ArkUINodeHandle node); - void (*setPositionEdges)(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIStringAndFloat* options); + void (*setPositionEdges)(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIStringAndFloat* options, + void* rawPtr); void (*resetPositionEdges)(ArkUINodeHandle node); void (*setBorderStyle)(ArkUINodeHandle node, const ArkUI_Int32* styles, ArkUI_Int32 length); void (*resetBorderStyle)(ArkUINodeHandle node); @@ -115,7 +118,7 @@ struct CJUICommonModifier { void (*resetBackgroundBlurStyle)(ArkUINodeHandle node); void (*setBorder)(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize, const ArkUI_Uint32* colorAndStyle, ArkUI_Int32 colorAndStyleSize, ArkUI_Bool isLocalizedBorderWidth, - ArkUI_Bool isLocalizedBorderColor, ArkUI_Bool isLocalizedBorderRadius); + ArkUI_Bool isLocalizedBorderColor, ArkUI_Bool isLocalizedBorderRadius, void* rawPtr); void (*resetBorder)(ArkUINodeHandle node); void (*setBackgroundImagePosition)(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* types, ArkUI_Bool isAlign, ArkUI_Int32 size, void* bgImageXRawPtr, void* bgImageYRawPtr); @@ -174,16 +177,17 @@ struct CJUICommonModifier { void (*setDisplayPriority)(ArkUINodeHandle node, ArkUI_Float32 value); void (*resetDisplayPriority)(ArkUINodeHandle node); void (*setOffset)(ArkUINodeHandle node, const ArkUI_Float32* number, const ArkUI_Int32* unit); - void (*setOffsetEdges)(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIStringAndFloat* options); + void (*setOffsetEdges)(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIStringAndFloat* options, void* rawPtr); void (*resetOffset)(ArkUINodeHandle node); void (*setPadding)(ArkUINodeHandle node, const struct ArkUISizeType* top, const struct ArkUISizeType* right, - const struct ArkUISizeType* bottom, const struct ArkUISizeType* left); + const struct ArkUISizeType* bottom, const struct ArkUISizeType* left, void* rawPtr); void (*resetPadding)(ArkUINodeHandle node); void (*setMargin)(ArkUINodeHandle node, const struct ArkUISizeType* top, const struct ArkUISizeType* right, - const struct ArkUISizeType* bottom, const struct ArkUISizeType* left); + const struct ArkUISizeType* bottom, const struct ArkUISizeType* left, void* rawPtr); void (*resetMargin)(ArkUINodeHandle node); void (*setMarkAnchor)( - ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue, ArkUI_Int32 yUnit); + ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue, ArkUI_Int32 yUnit, + void* xRawPtr, void* yRawPtr); void (*resetMarkAnchor)(ArkUINodeHandle node); void (*setVisibility)(ArkUINodeHandle node, ArkUI_Int32 value); void (*resetVisibility)(ArkUINodeHandle node); @@ -199,13 +203,13 @@ struct CJUICommonModifier { void (*resetDirection)(ArkUINodeHandle node); void (*setLayoutWeight)(ArkUINodeHandle node, ArkUI_Int32 layoutWeight); void (*resetLayoutWeight)(ArkUINodeHandle node); - void (*setMinWidth)(ArkUINodeHandle node, const struct ArkUISizeType* minWidth); + void (*setMinWidth)(ArkUINodeHandle node, const struct ArkUISizeType* minWidth, void* minWidthRawResPtr); void (*resetMinWidth)(ArkUINodeHandle node); - void (*setMaxWidth)(ArkUINodeHandle node, const struct ArkUISizeType* maxWidth); + void (*setMaxWidth)(ArkUINodeHandle node, const struct ArkUISizeType* maxWidth, void* maxWidthRawResPtr); void (*resetMaxWidth)(ArkUINodeHandle node); - void (*setMinHeight)(ArkUINodeHandle node, const struct ArkUISizeType* minHeight); + void (*setMinHeight)(ArkUINodeHandle node, const struct ArkUISizeType* minHeight, void* minHeightRawResPtr); void (*resetMinHeight)(ArkUINodeHandle node); - void (*setMaxHeight)(ArkUINodeHandle node, const struct ArkUISizeType* maxHeight); + void (*setMaxHeight)(ArkUINodeHandle node, const struct ArkUISizeType* maxHeight, void* maxHeightRawResPtr); void (*resetMaxHeight)(ArkUINodeHandle node); void (*setSize)(ArkUINodeHandle node, const ArkUI_Float32* number, const ArkUI_Int32* unit, ArkUI_CharPtr* calc); void (*resetSize)(ArkUINodeHandle node); @@ -471,7 +475,8 @@ struct CJUICommonModifier { void (*resetFocusScopePriority)(ArkUINodeHandle node); void (*setPixelRound)(ArkUINodeHandle node, const ArkUI_Int32* values, ArkUI_Int32 length); void (*resetPixelRound)(ArkUINodeHandle node); - void (*setBorderDashParams)(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize); + void (*setBorderDashParams)(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize, + void* rawPtr); void (*getExpandSafeArea)(ArkUINodeHandle node, ArkUI_Uint32 (*values)[2]); void (*setTransition)(ArkUINodeHandle node, ArkUITransitionEffectOption* option); void (*setDragPreview)(ArkUINodeHandle node, ArkUIDragPreview dragPreview); diff --git a/frameworks/core/interfaces/native/node/node_common_modifier.cpp b/frameworks/core/interfaces/native/node/node_common_modifier.cpp index 2886725bae08712088947a733d5184fbce98efa9..dbfed0b95d946966c8c4183ef4f43acbafdcced7 100644 --- a/frameworks/core/interfaces/native/node/node_common_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_common_modifier.cpp @@ -955,15 +955,22 @@ void ResetBackgroundColor(ArkUINodeHandle node) ViewAbstract::SetBackgroundColor(frameNode, Color(Color::TRANSPARENT)); } -void SetWidth(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue) +void SetWidth(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue, void* widthResPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - auto unitEnum = static_cast(unit); - if (unitEnum == DimensionUnit::CALC) { - ViewAbstract::SetWidth(frameNode, CalcLength(CalcLength(std::string(calcValue)))); + ViewAbstract::ResetResObj(frameNode, "width"); + if (SystemProperties::ConfigChangePerform() && widthResPtr) { + auto* width = reinterpret_cast(widthResPtr); + auto widthResObj = AceType::Claim(width); + ViewAbstract::SetWidth(frameNode, widthResObj); } else { - ViewAbstract::SetWidth(frameNode, CalcLength(value, unitEnum)); + auto unitEnum = static_cast(unit); + if (unitEnum == DimensionUnit::CALC) { + ViewAbstract::SetWidth(frameNode, CalcLength(CalcLength(std::string(calcValue)))); + } else { + ViewAbstract::SetWidth(frameNode, CalcLength(value, unitEnum)); + } } } @@ -971,25 +978,74 @@ void ResetWidth(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "width"); ViewAbstract::ClearWidthOrHeight(frameNode, true); } -void SetHeight(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue) + +void SetHeight(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue, void* heightResPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - auto unitEnum = static_cast(unit); - if (unitEnum == DimensionUnit::CALC) { - ViewAbstract::SetHeight(frameNode, CalcLength(CalcLength(std::string(calcValue)))); + ViewAbstract::ResetResObj(frameNode, "height"); + if (SystemProperties::ConfigChangePerform() && heightResPtr) { + auto* height = reinterpret_cast(heightResPtr); + auto heightResObj = AceType::Claim(height); + ViewAbstract::SetHeight(frameNode, heightResObj); } else { - ViewAbstract::SetHeight(frameNode, CalcLength(value, unitEnum)); + auto unitEnum = static_cast(unit); + if (unitEnum == DimensionUnit::CALC) { + ViewAbstract::SetHeight(frameNode, CalcLength(CalcLength(std::string(calcValue)))); + } else { + ViewAbstract::SetHeight(frameNode, CalcLength(value, unitEnum)); + } } } void ResetHeight(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "height"); ViewAbstract::ClearWidthOrHeight(frameNode, false); } + +void ParseAllBorderRadiusesResObj(NG::BorderRadiusProperty& borderRadius, const RefPtr& topLeftResObj, + const RefPtr& topRightResObj, const RefPtr& bottomLeftResObj, + const RefPtr& bottomRightResObj) +{ + borderRadius.resMap_.clear(); + if (topLeftResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderRadiusProperty& borderRadius) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVp(resObj, result); + borderRadius.radiusTopLeft = result; + }; + borderRadius.AddResource("borderRadius.topLeft", topLeftResObj, std::move(updateFunc)); + } + if (topRightResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderRadiusProperty& borderRadius) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVp(resObj, result); + borderRadius.radiusTopRight = result; + }; + borderRadius.AddResource("borderRadius.topRight", topRightResObj, std::move(updateFunc)); + } + if (bottomLeftResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderRadiusProperty& borderRadius) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVp(resObj, result); + borderRadius.radiusBottomLeft = result; + }; + borderRadius.AddResource("borderRadius.bottomLeft", bottomLeftResObj, std::move(updateFunc)); + } + if (bottomRightResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderRadiusProperty& borderRadius) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVp(resObj, result); + borderRadius.radiusBottomRight = result; + }; + borderRadius.AddResource("borderRadius.bottomRight", bottomRightResObj, std::move(updateFunc)); + } +} /** * @param values radius values * value[0] : radius value for TopLeft,value[1] : radius value for TopRight @@ -998,10 +1054,12 @@ void ResetHeight(ArkUINodeHandle node) * units[0]: radius unit for TopLeft, units[1] : radius unit for TopRight * units[2]: radius unit for BottomLeft, units[3] : radius unit for TopRight */ -void SetBorderRadius(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length) +void SetBorderRadius( + ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length, void* rawPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "borderRadius"); if (length != DEFAULT_LENGTH) { return; } @@ -1011,6 +1069,10 @@ void SetBorderRadius(ArkUINodeHandle node, const ArkUI_Float32* values, const Ar borderRadius.radiusBottomLeft = Dimension(values[NUM_2], static_cast(units[NUM_2])); borderRadius.radiusBottomRight = Dimension(values[NUM_3], static_cast(units[NUM_3])); borderRadius.multiValued = true; + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ParseAllBorderRadiusesResObj(borderRadius, objs[NUM_0], objs[NUM_1], objs[NUM_2], objs[NUM_3]); + } ViewAbstract::SetBorderRadius(frameNode, borderRadius); } @@ -1018,10 +1080,115 @@ void ResetBorderRadius(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "borderRadius"); OHOS::Ace::CalcDimension reset; ViewAbstract::SetBorderRadius(frameNode, reset); } +void ParseEdgeWidthsResObjFunc(NG::BorderWidthProperty& borderWidth, RefPtr topResObj, + RefPtr rightResObj, RefPtr bottomResObj, RefPtr leftResObj) +{ + borderWidth.resMap_.clear(); + if (leftResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderWidthProperty& borderWidth) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVp(resObj, result); + borderWidth.leftDimen = result; + }; + borderWidth.AddResource("borderWidth.left", leftResObj, std::move(updateFunc)); + } + if (rightResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderWidthProperty& borderWidth) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVp(resObj, result); + borderWidth.rightDimen = result; + }; + borderWidth.AddResource("borderWidth.right", rightResObj, std::move(updateFunc)); + } + if (topResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderWidthProperty& borderWidth) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVp(resObj, result); + borderWidth.topDimen = result; + }; + borderWidth.AddResource("borderWidth.top", topResObj, std::move(updateFunc)); + } + if (bottomResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderWidthProperty& borderWidth) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVp(resObj, result); + borderWidth.bottomDimen = result; + }; + borderWidth.AddResource("borderWidth.bottom", bottomResObj, std::move(updateFunc)); + } +} + +void CheckDimensionUnit(CalcDimension& checkDimension, bool notPercent, bool notNegative) +{ + if (notPercent && checkDimension.Unit() == DimensionUnit::PERCENT) { + checkDimension.Reset(); + return; + } + if (notNegative && checkDimension.IsNegative()) { + checkDimension.Reset(); + return; + } +} + +void ParseEdgeWidthsForDashParamsResObj(NG::BorderWidthProperty& borderWidth, RefPtr topResObj, + RefPtr rightResObj, RefPtr bottomResObj, RefPtr leftResObj) +{ + borderWidth.resMap_.clear(); + if (leftResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderWidthProperty& borderWidth) { + CalcDimension result; + if (ResourceParseUtils::ParseResDimensionVp(resObj, result)) { + CheckDimensionUnit(result, true, false); + borderWidth.leftDimen = result; + } else { + borderWidth.leftDimen = static_cast(-1); + } + }; + borderWidth.AddResource("borderWidth.left", leftResObj, std::move(updateFunc)); + } + if (rightResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderWidthProperty& borderWidth) { + CalcDimension result; + if (ResourceParseUtils::ParseResDimensionVp(resObj, result)) { + CheckDimensionUnit(result, true, false); + borderWidth.rightDimen = result; + } else { + borderWidth.rightDimen = static_cast(-1); + } + }; + borderWidth.AddResource("borderWidth.right", rightResObj, std::move(updateFunc)); + } + if (topResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderWidthProperty& borderWidth) { + CalcDimension result; + if (ResourceParseUtils::ParseResDimensionVp(resObj, result)) { + CheckDimensionUnit(result, true, false); + borderWidth.topDimen = result; + } else { + borderWidth.topDimen = static_cast(-1); + } + }; + borderWidth.AddResource("borderWidth.top", topResObj, std::move(updateFunc)); + } + if (bottomResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderWidthProperty& borderWidth) { + CalcDimension result; + if (ResourceParseUtils::ParseResDimensionVp(resObj, result)) { + CheckDimensionUnit(result, true, false); + borderWidth.bottomDimen = result; + } else { + borderWidth.bottomDimen = static_cast(-1); + } + }; + borderWidth.AddResource("borderWidth.bottom", bottomResObj, std::move(updateFunc)); + } +} + /** * @param values radius values, -1 means no this border width * value[0] : BorderWidth value for left,value[1] : BorderWidth value for right @@ -1030,10 +1197,12 @@ void ResetBorderRadius(ArkUINodeHandle node) * units[0]: BorderWidth unit for left, units[1] : BorderWidth unit for right * units[2]: BorderWidth unit for top, units[3] : BorderWidth unit for bottom */ -void SetBorderWidth(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length) +void SetBorderWidth(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length, + void* rawPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "borderWidth"); if (length != DEFAULT_LENGTH) { return; } @@ -1065,6 +1234,10 @@ void SetBorderWidth(ArkUINodeHandle node, const ArkUI_Float32* values, const Ark borderWidth.topDimen = topDimen; borderWidth.bottomDimen = bottomDimen; borderWidth.multiValued = true; + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ParseEdgeWidthsResObjFunc(borderWidth, objs[NUM_0], objs[NUM_1], objs[NUM_2], objs[NUM_3]); + } ViewAbstract::SetBorderWidth(frameNode, borderWidth); } @@ -1072,6 +1245,7 @@ void ResetBorderWidth(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "borderWidth"); OHOS::Ace::Dimension borderWidth; ViewAbstract::SetBorderWidth(frameNode, borderWidth); } @@ -1128,18 +1302,61 @@ void ResetTransform3D(ArkUINodeHandle node) NG::ViewAbstract::SetTransform3DMatrix(frameNode, Matrix4::CreateIdentity()); } +void ParseBorderColor(NG::BorderColorProperty& borderColors, RefPtr topResObj, + RefPtr rightResObj, RefPtr bottomResObj, RefPtr leftResObj) +{ + borderColors.resMap_.clear(); + if (topResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderColorProperty& borderColors) { + Color result; + ResourceParseUtils::ParseResColor(resObj, result); + borderColors.topColor = result; + }; + borderColors.AddResource("borderColor.top", topResObj, std::move(updateFunc)); + } + if (rightResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderColorProperty& borderColors) { + Color result; + ResourceParseUtils::ParseResColor(resObj, result); + borderColors.rightColor = result; + }; + borderColors.AddResource("borderColor.right", rightResObj, std::move(updateFunc)); + } + if (bottomResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderColorProperty& borderColors) { + Color result; + ResourceParseUtils::ParseResColor(resObj, result); + borderColors.bottomColor = result; + }; + borderColors.AddResource("borderColor.bottom", bottomResObj, std::move(updateFunc)); + } + if (leftResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderColorProperty& borderColors) { + Color result; + ResourceParseUtils::ParseResColor(resObj, result); + borderColors.leftColor = result; + }; + borderColors.AddResource("borderColor.left", leftResObj, std::move(updateFunc)); + } +} + void SetBorderColor( - ArkUINodeHandle node, uint32_t topColorInt, uint32_t rightColorInt, uint32_t bottomColorInt, uint32_t leftColorInt) + ArkUINodeHandle node, uint32_t topColorInt, uint32_t rightColorInt, uint32_t bottomColorInt, uint32_t leftColorInt, + void* rawPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "borderColor"); NG::BorderColorProperty borderColors; borderColors.topColor = Color(topColorInt); borderColors.rightColor = Color(rightColorInt); borderColors.bottomColor = Color(bottomColorInt); borderColors.leftColor = Color(leftColorInt); borderColors.multiValued = true; - + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ParseBorderColor(borderColors, objs[NUM_0], objs[NUM_1], objs[NUM_2], objs[NUM_3]); + } ViewAbstract::SetBorderColor(frameNode, borderColors); } @@ -1147,6 +1364,7 @@ void ResetBorderColor(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "borderColor"); ViewAbstract::SetBorderColor(frameNode, Color::BLACK); } @@ -1169,6 +1387,9 @@ void ResetPosition(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "position.edges"); + ViewAbstract::ResetResObj(frameNode, "position.x"); + ViewAbstract::ResetResObj(frameNode, "position.y"); ViewAbstract::ResetPosition(frameNode); } @@ -1202,15 +1423,60 @@ bool ParseEdges(OHOS::Ace::EdgesParam& edges, const ArkUIStringAndFloat* options return result; } -void SetPositionEdges(ArkUINodeHandle node, const int32_t useEdges, const ArkUIStringAndFloat* options) +void ParseLocationPropsEdgesResObj(OHOS::Ace::EdgesParam& edges, RefPtr topResObj, + RefPtr leftResObj, RefPtr bottomResObj, RefPtr rightResObj) +{ + edges.resMap_.clear(); + if (topResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, EdgesParam& edges) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVpNG(resObj, result); + edges.SetTop(result); + }; + edges.AddResource("edges.top", topResObj, std::move(updateFunc)); + } + if (leftResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, EdgesParam& edges) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVpNG(resObj, result); + edges.SetLeft(result); + }; + edges.AddResource("edges.left", leftResObj, std::move(updateFunc)); + } + if (bottomResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, EdgesParam& edges) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVpNG(resObj, result); + edges.SetBottom(result); + }; + edges.AddResource("edges.bottom", bottomResObj, std::move(updateFunc)); + } + if (rightResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, EdgesParam& edges) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVpNG(resObj, result); + edges.SetRight(result); + }; + edges.AddResource("edges.right", rightResObj, std::move(updateFunc)); + } +} + +void SetPositionEdges(ArkUINodeHandle node, const int32_t useEdges, const ArkUIStringAndFloat* options, void* rawPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "position.edges"); + ViewAbstract::ResetResObj(frameNode, "position.x"); + ViewAbstract::ResetResObj(frameNode, "position.y"); bool vaild = false; if (useEdges) { OHOS::Ace::EdgesParam edges; if (ParseEdges(edges, options)) { + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ParseLocationPropsEdgesResObj(edges, objs[NUM_0], objs[NUM_1], objs[NUM_2], objs[NUM_3]); + } ViewAbstract::SetPositionEdges(frameNode, edges); } else { ViewAbstract::ResetPosition(frameNode); @@ -1230,7 +1496,12 @@ void SetPositionEdges(ArkUINodeHandle node, const int32_t useEdges, const ArkUIS offset.SetY(y.value()); } if (vaild) { - ViewAbstract::SetPosition(frameNode, offset); + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ViewAbstract::SetPosition(frameNode, x.value(), y.value(), objs[0], objs[1]); + } else { + ViewAbstract::SetPosition(frameNode, offset); + } } else { ViewAbstract::ResetPosition(frameNode); } @@ -1241,6 +1512,9 @@ void ResetPositionEdges(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "position.edges"); + ViewAbstract::ResetResObj(frameNode, "position.x"); + ViewAbstract::ResetResObj(frameNode, "position.y"); if (AceApplicationInfo::GetInstance().GreatOrEqualTargetAPIVersion(PlatformVersion::VERSION_TWELVE)) { ViewAbstract::ResetPosition(); } else { @@ -2216,7 +2490,7 @@ void ResetBackgroundBlurStyle(ArkUINodeHandle node) } void SetBorderWidth(const ArkUI_Float32* values, ArkUI_Int32 valuesSize, int32_t& offset, - NG::BorderWidthProperty& borderWidth, ArkUI_Bool isLocalizedBorderWidth, FrameNode* frameNode) + NG::BorderWidthProperty& borderWidth, ArkUI_Bool isLocalizedBorderWidth, FrameNode* frameNode, void* rawPtr) { if (isLocalizedBorderWidth) { SetOptionalBorder(borderWidth.startDimen, values, valuesSize, offset); @@ -2228,6 +2502,10 @@ void SetBorderWidth(const ArkUI_Float32* values, ArkUI_Int32 valuesSize, int32_t SetOptionalBorder(borderWidth.topDimen, values, valuesSize, offset); SetOptionalBorder(borderWidth.bottomDimen, values, valuesSize, offset); borderWidth.multiValued = true; + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ParseEdgeWidthsResObjFunc(borderWidth, objs[NUM_2], objs[NUM_1], objs[NUM_3], objs[NUM_0]); + } if (borderWidth.leftDimen.has_value() || borderWidth.rightDimen.has_value() || borderWidth.topDimen.has_value() || borderWidth.bottomDimen.has_value() || borderWidth.startDimen.has_value() || borderWidth.endDimen.has_value()) { ViewAbstract::SetBorderWidth(frameNode, borderWidth); @@ -2235,7 +2513,7 @@ void SetBorderWidth(const ArkUI_Float32* values, ArkUI_Int32 valuesSize, int32_t } void SetBorderBorderRadius(const ArkUI_Float32* values, ArkUI_Int32 valuesSize, int32_t& offset, - NG::BorderRadiusProperty& borderRadius, ArkUI_Bool isLocalizedBorderRadius, FrameNode* frameNode) + NG::BorderRadiusProperty& borderRadius, ArkUI_Bool isLocalizedBorderRadius, FrameNode* frameNode, void* rawPtr) { if (isLocalizedBorderRadius) { SetOptionalBorder(borderRadius.radiusTopStart, values, valuesSize, offset); @@ -2250,6 +2528,10 @@ void SetBorderBorderRadius(const ArkUI_Float32* values, ArkUI_Int32 valuesSize, } borderRadius.multiValued = true; + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ParseAllBorderRadiusesResObj(borderRadius, objs[NUM_4], objs[NUM_5], objs[NUM_6], objs[NUM_7]); + } if (borderRadius.radiusTopLeft.has_value() || borderRadius.radiusTopRight.has_value() || borderRadius.radiusBottomLeft.has_value() || borderRadius.radiusBottomRight.has_value() || borderRadius.radiusTopStart.has_value() || borderRadius.radiusTopEnd.has_value() || @@ -2258,6 +2540,44 @@ void SetBorderBorderRadius(const ArkUI_Float32* values, ArkUI_Int32 valuesSize, } } +void ParseLocalizedBorderColor(NG::BorderColorProperty& borderColors, RefPtr topResObj, + RefPtr startResObj, RefPtr bottomResObj, RefPtr endResObj) +{ + borderColors.resMap_.clear(); + if (startResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderColorProperty& borderColors) { + Color result; + ResourceParseUtils::ParseResColor(resObj, result); + borderColors.startColor = result; + }; + borderColors.AddResource("borderColor.start", startResObj, std::move(updateFunc)); + } + if (endResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderColorProperty& borderColors) { + Color result; + ResourceParseUtils::ParseResColor(resObj, result); + borderColors.endColor = result; + }; + borderColors.AddResource("borderColor.end", endResObj, std::move(updateFunc)); + } + if (topResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderColorProperty& borderColors) { + Color result; + ResourceParseUtils::ParseResColor(resObj, result); + borderColors.topColor = result; + }; + borderColors.AddResource("borderColor.top", topResObj, std::move(updateFunc)); + } + if (bottomResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::BorderColorProperty& borderColors) { + Color result; + ResourceParseUtils::ParseResColor(resObj, result); + borderColors.bottomColor = result; + }; + borderColors.AddResource("borderColor.bottom", bottomResObj, std::move(updateFunc)); + } +} + /** * @param src source borderWidth and and BorderRadius value * @param options option value @@ -2286,7 +2606,7 @@ void SetBorderBorderRadius(const ArkUI_Float32* values, ArkUI_Int32 valuesSize, */ void SetBorder(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize, const uint32_t* colorAndStyle, int32_t colorAndStyleSize, ArkUI_Bool isLocalizedBorderWidth, ArkUI_Bool isLocalizedBorderColor, - ArkUI_Bool isLocalizedBorderRadius) + ArkUI_Bool isLocalizedBorderRadius, void* rawPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); @@ -2294,19 +2614,30 @@ void SetBorder(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 va return; } + ViewAbstract::ResetResObj(frameNode, "borderWidth"); + ViewAbstract::ResetResObj(frameNode, "borderRadius"); + ViewAbstract::ResetResObj(frameNode, "borderColor"); int32_t offset = NUM_0; NG::BorderWidthProperty borderWidth; - SetBorderWidth(values, valuesSize, offset, borderWidth, isLocalizedBorderWidth, frameNode); + SetBorderWidth(values, valuesSize, offset, borderWidth, isLocalizedBorderWidth, frameNode, rawPtr); NG::BorderRadiusProperty borderRadius; - SetBorderBorderRadius(values, valuesSize, offset, borderRadius, isLocalizedBorderRadius, frameNode); + SetBorderBorderRadius(values, valuesSize, offset, borderRadius, isLocalizedBorderRadius, frameNode, rawPtr); int32_t colorAndStyleOffset = NUM_0; NG::BorderColorProperty borderColors; if (isLocalizedBorderColor) { SetOptionalBorderColor(borderColors.startColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset); SetOptionalBorderColor(borderColors.endColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset); + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ParseLocalizedBorderColor(borderColors, objs[NUM_10], objs[NUM_8], objs[NUM_11], objs[NUM_9]); + } } else { SetOptionalBorderColor(borderColors.leftColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset); SetOptionalBorderColor(borderColors.rightColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset); + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ParseBorderColor(borderColors, objs[NUM_10], objs[NUM_9], objs[NUM_11], objs[NUM_8]); + } } SetOptionalBorderColor(borderColors.topColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset); SetOptionalBorderColor(borderColors.bottomColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset); @@ -2326,6 +2657,11 @@ void ResetBorder(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "borderWidth"); + ViewAbstract::ResetResObj(frameNode, "borderRadius"); + ViewAbstract::ResetResObj(frameNode, "borderColor"); + ViewAbstract::ResetResObj(frameNode, "border.dashGap"); + ViewAbstract::ResetResObj(frameNode, "border.dashWidth"); CalcDimension borderWidth; ViewAbstract::SetBorderWidth(frameNode, borderWidth); ViewAbstract::SetBorderColor(frameNode, Color::BLACK); @@ -3044,14 +3380,21 @@ void SetOffset(ArkUINodeHandle node, const ArkUI_Float32* number, const ArkUI_In ViewAbstract::SetOffset(frameNode, { xVal, yVal }); } -void SetOffsetEdges(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIStringAndFloat* options) +void SetOffsetEdges(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIStringAndFloat* options, void* rawPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "offset.y"); + ViewAbstract::ResetResObj(frameNode, "offset.x"); + ViewAbstract::ResetResObj(frameNode, "offset.edges"); if (useEdges) { OHOS::Ace::EdgesParam edges; ParseEdges(edges, options); + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ParseLocationPropsEdgesResObj(edges, objs[NUM_0], objs[NUM_1], objs[NUM_2], objs[NUM_3]); + } ViewAbstract::SetOffsetEdges(frameNode, edges); } else { OffsetT offset; @@ -3065,7 +3408,12 @@ void SetOffsetEdges(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIString if (y.has_value()) { offset.SetY(y.value()); } - ViewAbstract::SetOffset(frameNode, offset); + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ViewAbstract::SetOffset(frameNode, x.value(), y.value(), objs[0], objs[1]); + } else { + ViewAbstract::SetOffset(frameNode, offset); + } } } @@ -3089,16 +3437,70 @@ void ResetOffset(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "offset.y"); + ViewAbstract::ResetResObj(frameNode, "offset.x"); + ViewAbstract::ResetResObj(frameNode, "offset.edges"); Dimension xVal(0.0, DimensionUnit::VP); Dimension yVal(0.0, DimensionUnit::VP); ViewAbstract::SetOffset(frameNode, { xVal, yVal }); } +NG::CalcLength ConvertCalcLength(CalcDimension& target) +{ + NG::CalcLength targetLength = (target.Unit() == DimensionUnit::CALC) ? + NG::CalcLength(target.IsNonNegative() ? target.CalcValue() : CalcDimension().CalcValue()) : + NG::CalcLength(target.IsNonNegative() ? target : CalcDimension()); + return targetLength; +} + +void GetEdgePaddingsOrSafeAreaPaddings(NG::PaddingProperty& paddings, RefPtr topResObj, + RefPtr rightResObj, RefPtr bottomResObj, RefPtr leftResObj) +{ + paddings.resMap_.clear(); + if (topResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::PaddingProperty& paddings) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVpNG(resObj, result); + NG::CalcLength resultLength = ConvertCalcLength(result); + paddings.top = resultLength; + }; + paddings.AddResource("top", topResObj, std::move(updateFunc)); + } + if (rightResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::PaddingProperty& paddings) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVpNG(resObj, result); + NG::CalcLength resultLength = ConvertCalcLength(result); + paddings.right = resultLength; + }; + paddings.AddResource("right", rightResObj, std::move(updateFunc)); + } + if (bottomResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::PaddingProperty& paddings) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVpNG(resObj, result); + NG::CalcLength resultLength = ConvertCalcLength(result); + paddings.bottom = resultLength; + }; + paddings.AddResource("bottom", bottomResObj, std::move(updateFunc)); + } + if (leftResObj != nullptr) { + auto&& updateFunc = [](const RefPtr& resObj, NG::PaddingProperty& paddings) { + CalcDimension result; + ResourceParseUtils::ParseResDimensionVpNG(resObj, result); + NG::CalcLength resultLength = ConvertCalcLength(result); + paddings.left = resultLength; + }; + paddings.AddResource("left", leftResObj, std::move(updateFunc)); + } +} + void SetPadding(ArkUINodeHandle node, const struct ArkUISizeType* top, const struct ArkUISizeType* right, - const struct ArkUISizeType* bottom, const struct ArkUISizeType* left) + const struct ArkUISizeType* bottom, const struct ArkUISizeType* left, void* rawPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "padding"); CalcLength topDimen; CalcLength rightDimen; CalcLength bottomDimen; @@ -3128,6 +3530,10 @@ void SetPadding(ArkUINodeHandle node, const struct ArkUISizeType* top, const str paddings.bottom = std::optional(bottomDimen); paddings.left = std::optional(leftDimen); paddings.right = std::optional(rightDimen); + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + GetEdgePaddingsOrSafeAreaPaddings(paddings, objs[NUM_0], objs[NUM_1], objs[NUM_2], objs[NUM_3]); + } ViewAbstract::SetPadding(frameNode, paddings); } @@ -3135,6 +3541,7 @@ void ResetPadding(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "padding"); NG::PaddingProperty paddings; paddings.top = std::optional(CalcLength(0.0, DimensionUnit::VP)); paddings.bottom = std::optional(CalcLength(0.0, DimensionUnit::VP)); @@ -3144,10 +3551,11 @@ void ResetPadding(ArkUINodeHandle node) } void SetSafeAreaPadding( - ArkUINodeHandle node, const struct ArkUIPaddingType* safeAreaPadding, ArkUI_Bool isLengthMetrics) + ArkUINodeHandle node, const struct ArkUIPaddingType* safeAreaPadding, ArkUI_Bool isLengthMetrics, void* rawPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "safeAreaPadding"); CalcLength topDimen; CalcLength endDimen; CalcLength bottomDimen; @@ -3183,6 +3591,10 @@ void SetSafeAreaPadding( paddings.right = std::optional(endDimen); paddings.left = std::optional(startDimen); } + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + GetEdgePaddingsOrSafeAreaPaddings(paddings, objs[NUM_0], objs[NUM_1], objs[NUM_2], objs[NUM_3]); + } ViewAbstract::SetSafeAreaPadding(frameNode, paddings); } @@ -3190,6 +3602,7 @@ void ResetSafeAreaPadding(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "safeAreaPadding"); ViewAbstract::ResetSafeAreaPadding(frameNode); } @@ -3573,10 +3986,11 @@ ArkUI_Int32 GetDisplayPriority(ArkUINodeHandle node) } void SetMargin(ArkUINodeHandle node, const struct ArkUISizeType* top, const struct ArkUISizeType* right, - const struct ArkUISizeType* bottom, const struct ArkUISizeType* left) + const struct ArkUISizeType* bottom, const struct ArkUISizeType* left, void* rawPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "margin"); CalcLength topDimen; CalcLength rightDimen; CalcLength bottomDimen; @@ -3606,6 +4020,10 @@ void SetMargin(ArkUINodeHandle node, const struct ArkUISizeType* top, const stru paddings.bottom = std::optional(bottomDimen); paddings.left = std::optional(leftDimen); paddings.right = std::optional(rightDimen); + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + GetEdgePaddingsOrSafeAreaPaddings(paddings, objs[NUM_0], objs[NUM_1], objs[NUM_2], objs[NUM_3]); + } ViewAbstract::SetMargin(frameNode, paddings); } @@ -3613,18 +4031,42 @@ void ResetMargin(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "margin"); ViewAbstract::SetMargin(frameNode, NG::CalcLength(0.0)); } void SetMarkAnchor( - ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue, ArkUI_Int32 yUnit) + ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue, ArkUI_Int32 yUnit, + void* xRawPtr, void* yRawPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "markAnchor.x"); + ViewAbstract::ResetResObj(frameNode, "markAnchor.y"); Dimension xDimension { xValue, static_cast(xUnit) }; Dimension yDimension { yValue, static_cast(yUnit) }; OffsetT value = { xDimension, yDimension }; - ViewAbstract::MarkAnchor(frameNode, value); + if (SystemProperties::ConfigChangePerform()) { + if (xRawPtr && yRawPtr) { + auto* x = reinterpret_cast(xRawPtr); + auto xResObj = AceType::Claim(x); + auto* y = reinterpret_cast(yRawPtr); + auto yResObj = AceType::Claim(y); + ViewAbstract::MarkAnchor(frameNode, value, xResObj, yResObj); + } else if (xRawPtr) { + auto* x = reinterpret_cast(xRawPtr); + auto xResObj = AceType::Claim(x); + ViewAbstract::MarkAnchor(frameNode, value, xResObj, nullptr); + } else if (yRawPtr) { + auto* y = reinterpret_cast(yRawPtr); + auto yResObj = AceType::Claim(y); + ViewAbstract::MarkAnchor(frameNode, value, nullptr, yResObj); + } else { + ViewAbstract::MarkAnchor(frameNode, value, nullptr, nullptr); + } + } else { + ViewAbstract::MarkAnchor(frameNode, value); + } } ArkUIAnchorType GetMarkAnchor(ArkUINodeHandle node) @@ -3647,6 +4089,8 @@ void ResetMarkAnchor(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "markAnchor.x"); + ViewAbstract::ResetResObj(frameNode, "markAnchor.y"); ViewAbstract::MarkAnchor(frameNode, { Dimension(0.0_vp), Dimension(0.0_vp) }); } @@ -3823,11 +4267,12 @@ ArkUI_Float32 GetLayoutWeight(ArkUINodeHandle node) return ViewAbstract::GetLayoutWeight(frameNode); } -void SetMinWidth(ArkUINodeHandle node, const struct ArkUISizeType* minWidth) +void SetMinWidth(ArkUINodeHandle node, const struct ArkUISizeType* minWidth, void* minWidthRawResPtr) { CHECK_NULL_VOID(minWidth); auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "constraintSize.minWidth"); CalcLength strResult; if (minWidth->string != nullptr) { strResult = CalcLength(minWidth->string); @@ -3836,20 +4281,27 @@ void SetMinWidth(ArkUINodeHandle node, const struct ArkUISizeType* minWidth) CalcDimension result(minWidth->value, static_cast(minWidth->unit)); ViewAbstract::SetMinWidth(frameNode, CalcLength(result)); } + if (SystemProperties::ConfigChangePerform() && minWidthRawResPtr) { + auto* minWidthPtr = reinterpret_cast(minWidthRawResPtr); + auto minWidthResObj = AceType::Claim(minWidthPtr); + ViewAbstract::SetMinWidth(frameNode, minWidthResObj); + } } void ResetMinWidth(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "constraintSize.minWidth"); ViewAbstract::ResetMinSize(frameNode, true); } -void SetMaxWidth(ArkUINodeHandle node, const struct ArkUISizeType* maxWidth) +void SetMaxWidth(ArkUINodeHandle node, const struct ArkUISizeType* maxWidth, void* maxWidthRawResPtr) { CHECK_NULL_VOID(maxWidth); auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "constraintSize.maxWidth"); CalcLength strResult; if (maxWidth->string != nullptr) { strResult = CalcLength(maxWidth->string); @@ -3858,20 +4310,27 @@ void SetMaxWidth(ArkUINodeHandle node, const struct ArkUISizeType* maxWidth) CalcDimension result(maxWidth->value, static_cast(maxWidth->unit)); ViewAbstract::SetMaxWidth(frameNode, CalcLength(result)); } + if (SystemProperties::ConfigChangePerform() && maxWidthRawResPtr) { + auto* maxWidthPtr = reinterpret_cast(maxWidthRawResPtr); + auto maxWidthResObj = AceType::Claim(maxWidthPtr); + ViewAbstract::SetMaxWidth(frameNode, maxWidthResObj); + } } void ResetMaxWidth(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "constraintSize.maxWidth"); ViewAbstract::ResetMaxSize(frameNode, true); } -void SetMinHeight(ArkUINodeHandle node, const struct ArkUISizeType* minHeight) +void SetMinHeight(ArkUINodeHandle node, const struct ArkUISizeType* minHeight, void* minHeightRawResPtr) { CHECK_NULL_VOID(minHeight); auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "constraintSize.minHeight"); CalcLength strResult; if (minHeight->string != nullptr) { strResult = CalcLength(minHeight->string); @@ -3880,20 +4339,27 @@ void SetMinHeight(ArkUINodeHandle node, const struct ArkUISizeType* minHeight) CalcDimension result(minHeight->value, static_cast(minHeight->unit)); ViewAbstract::SetMinHeight(frameNode, CalcLength(result)); } + if (SystemProperties::ConfigChangePerform() && minHeightRawResPtr) { + auto* minHeightPtr = reinterpret_cast(minHeightRawResPtr); + auto minHeightResObj = AceType::Claim(minHeightPtr); + ViewAbstract::SetMinHeight(frameNode, minHeightResObj); + } } void ResetMinHeight(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "constraintSize.minHeight"); ViewAbstract::ResetMinSize(frameNode, false); } -void SetMaxHeight(ArkUINodeHandle node, const struct ArkUISizeType* maxHeight) +void SetMaxHeight(ArkUINodeHandle node, const struct ArkUISizeType* maxHeight, void* maxHeightRawResPtr) { CHECK_NULL_VOID(maxHeight); auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "constraintSize.maxHeight"); CalcLength strResult; if (maxHeight->string != nullptr) { strResult = CalcLength(maxHeight->string); @@ -3902,12 +4368,18 @@ void SetMaxHeight(ArkUINodeHandle node, const struct ArkUISizeType* maxHeight) CalcDimension result(maxHeight->value, static_cast(maxHeight->unit)); ViewAbstract::SetMaxHeight(frameNode, CalcLength(result)); } + if (SystemProperties::ConfigChangePerform() && maxHeightRawResPtr) { + auto* maxHeightPtr = reinterpret_cast(maxHeightRawResPtr); + auto maxHeightResObj = AceType::Claim(maxHeightPtr); + ViewAbstract::SetMaxHeight(frameNode, maxHeightResObj); + } } void ResetMaxHeight(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "constraintSize.maxHeight"); ViewAbstract::ResetMaxSize(frameNode, false); } @@ -3919,6 +4391,8 @@ void SetSize(ArkUINodeHandle node, const ArkUI_Float32* number, const ArkUI_Int3 int heightIndex = 1; auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "width"); + ViewAbstract::ResetResObj(frameNode, "height"); if (*(unit + widthIndex) == static_cast(DimensionUnit::CALC) && *(calc + widthIndex) != nullptr) { ViewAbstract::SetWidth(frameNode, CalcLength(std::string(*(calc + widthIndex)))); } else { @@ -3937,6 +4411,8 @@ void ResetSize(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "width"); + ViewAbstract::ResetResObj(frameNode, "height"); ViewAbstract::SetWidth(frameNode, CalcLength(0.0, DimensionUnit::VP)); ViewAbstract::SetHeight(frameNode, CalcLength(0.0, DimensionUnit::VP)); } @@ -3945,6 +4421,11 @@ void ClearWidthOrHeight(ArkUINodeHandle node, ArkUI_Bool isWidth) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + if (isWidth) { + ViewAbstract::ResetResObj(frameNode, "width"); + } else { + ViewAbstract::ResetResObj(frameNode, "height"); + } ViewAbstract::ClearWidthOrHeight(frameNode, isWidth); } @@ -6178,6 +6659,10 @@ void SetConstraintSize(ArkUINodeHandle node, const ArkUI_Float32* values, const { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "constraintSize.minWidth"); + ViewAbstract::ResetResObj(frameNode, "constraintSize.maxWidth"); + ViewAbstract::ResetResObj(frameNode, "constraintSize.minHeight"); + ViewAbstract::ResetResObj(frameNode, "constraintSize.maxHeight"); ViewAbstract::SetMinWidth(frameNode, CalcLength(values[NUM_0], static_cast(units[NUM_0]))); ViewAbstract::SetMaxWidth(frameNode, CalcLength(values[NUM_1], static_cast(units[NUM_1]))); ViewAbstract::SetMinHeight(frameNode, CalcLength(values[NUM_2], static_cast(units[NUM_2]))); @@ -6188,6 +6673,10 @@ void ResetConstraintSize(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); + ViewAbstract::ResetResObj(frameNode, "constraintSize.minWidth"); + ViewAbstract::ResetResObj(frameNode, "constraintSize.maxWidth"); + ViewAbstract::ResetResObj(frameNode, "constraintSize.minHeight"); + ViewAbstract::ResetResObj(frameNode, "constraintSize.maxHeight"); ViewAbstract::ResetMaxSize(frameNode, true); ViewAbstract::ResetMinSize(frameNode, true); ViewAbstract::ResetMaxSize(frameNode, false); @@ -7425,13 +7914,27 @@ void GetExpandSafeArea(ArkUINodeHandle node, ArkUI_Uint32 (*values)[2]) (*values)[NUM_1] = ViewAbstract::GetSafeAreaExpandEdges(frameNode); } -void SetBorderDashParams(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize) +void SetBorderDashParamsDirection(const ArkUI_Bool isRightToLeft, NG::BorderWidthProperty& property, + const ArkUI_Float32* values, ArkUI_Int32 valuesSize, ArkUI_Int32& offset) +{ + if (isRightToLeft) { + SetOptionalBorder(property.rightDimen, values, valuesSize, offset); + SetOptionalBorder(property.leftDimen, values, valuesSize, offset); + } else { + SetOptionalBorder(property.leftDimen, values, valuesSize, offset); + SetOptionalBorder(property.rightDimen, values, valuesSize, offset); + } +} + +void SetBorderDashParams(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize, void* rawPtr) { auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); if ((values == nullptr) || (valuesSize != NUM_36)) { return; } + ViewAbstract::ResetResObj(frameNode, "border.dashGap"); + ViewAbstract::ResetResObj(frameNode, "border.dashWidth"); auto isRightToLeft = AceApplicationInfo::GetInstance().IsRightToLeft(); int32_t offset = NUM_0; NG::BorderWidthProperty borderDashGap; @@ -7439,14 +7942,12 @@ void SetBorderDashParams(ArkUINodeHandle node, const ArkUI_Float32* values, ArkU SetOptionalBorder(borderDashGap.rightDimen, values, valuesSize, offset); SetOptionalBorder(borderDashGap.topDimen, values, valuesSize, offset); SetOptionalBorder(borderDashGap.bottomDimen, values, valuesSize, offset); - if (isRightToLeft) { - SetOptionalBorder(borderDashGap.rightDimen, values, valuesSize, offset); - SetOptionalBorder(borderDashGap.leftDimen, values, valuesSize, offset); - } else { - SetOptionalBorder(borderDashGap.leftDimen, values, valuesSize, offset); - SetOptionalBorder(borderDashGap.rightDimen, values, valuesSize, offset); - } + SetBorderDashParamsDirection(isRightToLeft, borderDashGap, values, valuesSize, offset); borderDashGap.multiValued = true; + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ParseEdgeWidthsForDashParamsResObj(borderDashGap, objs[NUM_2], objs[NUM_1], objs[NUM_3], objs[NUM_0]); + } if (borderDashGap.leftDimen.has_value() || borderDashGap.rightDimen.has_value() || borderDashGap.topDimen.has_value() || borderDashGap.bottomDimen.has_value()) { ViewAbstract::SetDashGap(frameNode, borderDashGap); @@ -7459,14 +7960,12 @@ void SetBorderDashParams(ArkUINodeHandle node, const ArkUI_Float32* values, ArkU SetOptionalBorder(borderDashWidth.rightDimen, values, valuesSize, offset); SetOptionalBorder(borderDashWidth.topDimen, values, valuesSize, offset); SetOptionalBorder(borderDashWidth.bottomDimen, values, valuesSize, offset); - if (isRightToLeft) { - SetOptionalBorder(borderDashWidth.rightDimen, values, valuesSize, offset); - SetOptionalBorder(borderDashWidth.leftDimen, values, valuesSize, offset); - } else { - SetOptionalBorder(borderDashWidth.leftDimen, values, valuesSize, offset); - SetOptionalBorder(borderDashWidth.rightDimen, values, valuesSize, offset); - } + SetBorderDashParamsDirection(isRightToLeft, borderDashWidth, values, valuesSize, offset); borderDashWidth.multiValued = true; + if (SystemProperties::ConfigChangePerform() && rawPtr) { + auto objs = *(reinterpret_cast>*>(rawPtr)); + ParseEdgeWidthsForDashParamsResObj(borderDashWidth, objs[NUM_6], objs[NUM_5], objs[NUM_7], objs[NUM_4]); + } if (borderDashWidth.leftDimen.has_value() || borderDashWidth.rightDimen.has_value() || borderDashWidth.topDimen.has_value() || borderDashWidth.bottomDimen.has_value()) { ViewAbstract::SetDashWidth(frameNode, borderDashWidth); diff --git a/frameworks/core/interfaces/native/node/node_image_modifier.cpp b/frameworks/core/interfaces/native/node/node_image_modifier.cpp index d992281273dd963c95fcc066431e9a7648930d97..0f1fec79413654293d6ab56f0763cba2dae08c80 100644 --- a/frameworks/core/interfaces/native/node/node_image_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_image_modifier.cpp @@ -660,7 +660,7 @@ void SetImageBorderRadius(ArkUINodeHandle node, const ArkUI_Float32* values, con { auto nodeModifiers = GetArkUINodeModifiers(); CHECK_NULL_VOID(nodeModifiers); - nodeModifiers->getCommonModifier()->setBorderRadius(node, values, units, length); + nodeModifiers->getCommonModifier()->setBorderRadius(node, values, units, length, nullptr); auto* frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); if (!Container::GreatOrEqualAPITargetVersion(PlatformVersion::VERSION_FOURTEEN)) { diff --git a/interfaces/inner_api/ace_kit/include/ui/properties/ng/measure_property.h b/interfaces/inner_api/ace_kit/include/ui/properties/ng/measure_property.h index 4b739e0812514030af25f50039ce87424b4f5c8e..d1cfba807553c5379499e8b6119842eb5e6359fc 100644 --- a/interfaces/inner_api/ace_kit/include/ui/properties/ng/measure_property.h +++ b/interfaces/inner_api/ace_kit/include/ui/properties/ng/measure_property.h @@ -154,6 +154,8 @@ struct PaddingPropertyT { jsonValue->Put("right", right.has_value() ? right->ToString().c_str() : T{}.ToString().c_str()); jsonValue->Put("bottom", bottom.has_value() ? bottom->ToString().c_str() : T{}.ToString().c_str()); jsonValue->Put("left", left.has_value() ? left->ToString().c_str() : T{}.ToString().c_str()); + jsonValue->Put("start", start.has_value() ? start->ToString().c_str() : T{}.ToString().c_str()); + jsonValue->Put("end", end.has_value() ? end->ToString().c_str() : T{}.ToString().c_str()); return jsonValue->ToString(); } diff --git a/interfaces/native/node/style_modifier.cpp b/interfaces/native/node/style_modifier.cpp index a7ffc17eb3780ea2767eb22871a451c8ca60ccee..a3d89ea944f84ab694685cc71ae51b7371c06c91 100644 --- a/interfaces/native/node/style_modifier.cpp +++ b/interfaces/native/node/style_modifier.cpp @@ -830,7 +830,7 @@ int32_t SetWidth(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) auto* fullImpl = GetFullImpl(); // 1 for vp. check in DimensionUnit. fullImpl->getNodeModifiers()->getCommonModifier()->setWidth( - node->uiNodeHandle, item->value[NUM_0].f32, GetDefaultUnit(node, UNIT_VP), nullptr); + node->uiNodeHandle, item->value[NUM_0].f32, GetDefaultUnit(node, UNIT_VP), nullptr, nullptr); return ERROR_CODE_NO_ERROR; } @@ -860,7 +860,7 @@ int32_t SetHeight(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) auto* fullImpl = GetFullImpl(); // 1 for vp. check in DimensionUnit. fullImpl->getNodeModifiers()->getCommonModifier()->setHeight( - node->uiNodeHandle, item->value[NUM_0].f32, GetDefaultUnit(node, UNIT_VP), nullptr); + node->uiNodeHandle, item->value[NUM_0].f32, GetDefaultUnit(node, UNIT_VP), nullptr, nullptr); return ERROR_CODE_NO_ERROR; } @@ -1090,7 +1090,7 @@ int32_t SetPadding(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) node->uiNodeHandle, &top, &right, &bottom, &left, nullptr); } else { fullImpl->getNodeModifiers()->getCommonModifier()->setPadding( - node->uiNodeHandle, &top, &right, &bottom, &left); + node->uiNodeHandle, &top, &right, &bottom, &left, nullptr); } return ERROR_CODE_NO_ERROR; } @@ -1206,7 +1206,8 @@ int32_t SetMargin(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) fullImpl->getNodeModifiers()->getRadioModifier()->setRadioMargin( node->uiNodeHandle, &top, &right, &bottom, &left); } else { - fullImpl->getNodeModifiers()->getCommonModifier()->setMargin(node->uiNodeHandle, &top, &right, &bottom, &left); + fullImpl->getNodeModifiers()->getCommonModifier()->setMargin(node->uiNodeHandle, &top, &right, &bottom, &left, + nullptr); } return ERROR_CODE_NO_ERROR; } @@ -1715,7 +1716,7 @@ int32_t SetBorderWidth(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) node->uiNodeHandle, widthVals, widthUnits, ALLOW_SIZE_4); } else { fullImpl->getNodeModifiers()->getCommonModifier()->setBorderWidth( - node->uiNodeHandle, widthVals, widthUnits, ALLOW_SIZE_4); + node->uiNodeHandle, widthVals, widthUnits, ALLOW_SIZE_4, nullptr); } return ERROR_CODE_NO_ERROR; } @@ -1783,7 +1784,7 @@ int32_t SetBorderRadius(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) node->uiNodeHandle, radiusVals, radiusUnits, ALLOW_SIZE_4); } else { fullImpl->getNodeModifiers()->getCommonModifier()->setBorderRadius( - node->uiNodeHandle, radiusVals, radiusUnits, ALLOW_SIZE_4); + node->uiNodeHandle, radiusVals, radiusUnits, ALLOW_SIZE_4, nullptr); } return ERROR_CODE_NO_ERROR; } @@ -1848,7 +1849,7 @@ int32_t SetBorderWidthPercent(ArkUI_NodeHandle node, const ArkUI_AttributeItem* node->uiNodeHandle, widthVals, widthUnits, ALLOW_SIZE_4); } else { fullImpl->getNodeModifiers()->getCommonModifier()->setBorderWidth( - node->uiNodeHandle, widthVals, widthUnits, ALLOW_SIZE_4); + node->uiNodeHandle, widthVals, widthUnits, ALLOW_SIZE_4, nullptr); } return ERROR_CODE_NO_ERROR; } @@ -1906,7 +1907,7 @@ int32_t SetBorderRadiusPercent(ArkUI_NodeHandle node, const ArkUI_AttributeItem* node->uiNodeHandle, radiusVals, radiusUnits, ALLOW_SIZE_4); } else { fullImpl->getNodeModifiers()->getCommonModifier()->setBorderRadius( - node->uiNodeHandle, radiusVals, radiusUnits, ALLOW_SIZE_4); + node->uiNodeHandle, radiusVals, radiusUnits, ALLOW_SIZE_4, nullptr); } return ERROR_CODE_NO_ERROR; } @@ -1952,7 +1953,7 @@ int32_t SetBorderColor(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) node->uiNodeHandle, colors[NUM_0], colors[NUM_1], colors[NUM_2], colors[NUM_3]); } else { fullImpl->getNodeModifiers()->getCommonModifier()->setBorderColor( - node->uiNodeHandle, colors[NUM_0], colors[NUM_1], colors[NUM_2], colors[NUM_3]); + node->uiNodeHandle, colors[NUM_0], colors[NUM_1], colors[NUM_2], colors[NUM_3], nullptr); } return ERROR_CODE_NO_ERROR; } @@ -3629,7 +3630,7 @@ int32_t SetWidthPercent(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) } auto* fullImpl = GetFullImpl(); fullImpl->getNodeModifiers()->getCommonModifier()->setWidth( - node->uiNodeHandle, item->value[NUM_0].f32, UNIT_PERCENT, nullptr); + node->uiNodeHandle, item->value[NUM_0].f32, UNIT_PERCENT, nullptr, nullptr); return ERROR_CODE_NO_ERROR; } @@ -3656,7 +3657,7 @@ int32_t SetHeightPercent(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) } auto* fullImpl = GetFullImpl(); fullImpl->getNodeModifiers()->getCommonModifier()->setHeight( - node->uiNodeHandle, item->value[NUM_0].f32, UNIT_PERCENT, nullptr); + node->uiNodeHandle, item->value[NUM_0].f32, UNIT_PERCENT, nullptr, nullptr); return ERROR_CODE_NO_ERROR; } @@ -3689,7 +3690,8 @@ int32_t SetPaddingPercent(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item struct ArkUISizeType right = { item->value[rightIndex].f32, UNIT_PERCENT }; struct ArkUISizeType bottom = { item->value[bottomIndex].f32, UNIT_PERCENT }; struct ArkUISizeType left = { item->value[leftIndex].f32, UNIT_PERCENT }; - fullImpl->getNodeModifiers()->getCommonModifier()->setPadding(node->uiNodeHandle, &top, &right, &bottom, &left); + fullImpl->getNodeModifiers()->getCommonModifier()->setPadding(node->uiNodeHandle, &top, &right, &bottom, &left, + nullptr); return ERROR_CODE_NO_ERROR; } @@ -3732,7 +3734,8 @@ int32_t SetMarginPercent(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) fullImpl->getNodeModifiers()->getTextAreaModifier()->setTextAreaMargin( node->uiNodeHandle, &top, &right, &bottom, &left, nullptr); } else { - fullImpl->getNodeModifiers()->getCommonModifier()->setMargin(node->uiNodeHandle, &top, &right, &bottom, &left); + fullImpl->getNodeModifiers()->getCommonModifier()->setMargin(node->uiNodeHandle, &top, &right, &bottom, &left, + nullptr); } return ERROR_CODE_NO_ERROR; } @@ -11169,7 +11172,7 @@ int32_t SetMarkAnchor(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item) CalcDimension yDimension(0, static_cast(unit)); yDimension.SetValue(item->value[NUM_1].f32); fullImpl->getNodeModifiers()->getCommonModifier()->setMarkAnchor(node->uiNodeHandle, xDimension.Value(), - unit, yDimension.Value(), unit); + unit, yDimension.Value(), unit, nullptr, nullptr); return ERROR_CODE_NO_ERROR; } diff --git a/test/unittest/core/base/view_abstract_test_ng.cpp b/test/unittest/core/base/view_abstract_test_ng.cpp index da8475d90083590e7dce58904af42d6cf8920b00..84422409297ac40f42c5d4679aa93d21d6ced4b1 100644 --- a/test/unittest/core/base/view_abstract_test_ng.cpp +++ b/test/unittest/core/base/view_abstract_test_ng.cpp @@ -3518,4 +3518,25 @@ HWTEST_F(ViewAbstractTestNg, ViewAbstractSetClickFocusTest001, TestSize.Level1) ASSERT_NE(focusHub2, nullptr); EXPECT_TRUE(focusHub2->IsFocusable()); } + +/** + * @tc.name: ViewAbstractTestNg0097 + * @tc.desc: test position attribute, use Edges type. + * @tc.type: FUNC + */ +HWTEST_F(ViewAbstractTestNg, ViewAbstractTestNg0097, TestSize.Level1) +{ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + ASSERT_NE(frameNode, nullptr); + std::string bundleName = "com.example.test"; + std::string moduleName = "entry"; + RefPtr resObj = AceType::MakeRefPtr(bundleName, moduleName, 0); + auto&& updateFunc = [](const RefPtr& resObj, EdgesParam& edges) {}; + EdgesParam edgesParam; + edgesParam.AddResource("edges.top", resObj, std::move(updateFunc)); + EXPECT_EQ(edgesParam.resMap_.empty(), false); + ViewAbstract::SetPositionEdges(frameNode, edgesParam); + auto renderContext = frameNode->GetRenderContext(); + EXPECT_EQ(renderContext->HasPositionEdges(), true); +} } // namespace OHOS::Ace::NG \ No newline at end of file