diff --git a/frameworks/bridge/declarative_frontend/jsview/js_radio.cpp b/frameworks/bridge/declarative_frontend/jsview/js_radio.cpp index f985aa872a942f3f4c463879bd1826a3bb9a7b99..32225fb50d58ea250dfd24b5e9f45fa0752b840f 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_radio.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_radio.cpp @@ -93,7 +93,8 @@ void JSRadio::Create(const JSCallbackInfo& info) void JSRadio::ParseIndicator(const JSCallbackInfo& info, std::optional& indicator, std::function& customBuilderFunc, JSRef& builderObject) { - if (indicator.value() == static_cast(RadioIndicatorType::CUSTOM)) { + if (indicator.value_or(static_cast(RadioIndicatorType::TICK)) == + static_cast(RadioIndicatorType::CUSTOM)) { if (builderObject->IsFunction()) { auto builderFunc = AceType::MakeRefPtr(info.This(), JSRef::Cast(builderObject)); CHECK_NULL_VOID(builderFunc); diff --git a/frameworks/core/components_ng/pattern/button/button_model_ng.cpp b/frameworks/core/components_ng/pattern/button/button_model_ng.cpp index 73ea8a694544f56724594e0a60ceab7b58297593..53aefdf6a6b58b79fbde7a382f9d425c6d3a79c2 100644 --- a/frameworks/core/components_ng/pattern/button/button_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/button/button_model_ng.cpp @@ -513,7 +513,7 @@ void ButtonModelNG::SetControlSize(FrameNode* frameNode, const std::optional>& buttonChildren) { - CreateWithLabel(para.label.value()); + CreateWithLabel(para.label.value_or("")); SetTypeAndStateEffect(para.type, para.stateEffect); SetButtonStyle(para.buttonStyleMode); SetControlSize(para.controlSize); diff --git a/frameworks/core/components_ng/pattern/button/button_pattern.cpp b/frameworks/core/components_ng/pattern/button/button_pattern.cpp index 50b8104c86a1ffde1cfaf77ca660f8f4dad78b39..14e5f440ce9144d8f93b0ce225911dde9c7d3d5f 100644 --- a/frameworks/core/components_ng/pattern/button/button_pattern.cpp +++ b/frameworks/core/components_ng/pattern/button/button_pattern.cpp @@ -1223,6 +1223,7 @@ void ButtonPattern::FireBuilder() RefPtr ButtonPattern::BuildContentModifierNode() { + CHECK_NULL_RETURN(makeFunc_, nullptr); auto host = GetHost(); CHECK_NULL_RETURN(host, nullptr); auto layoutProperty = GetLayoutProperty(); diff --git a/frameworks/core/components_ng/pattern/button/toggle_button_pattern.cpp b/frameworks/core/components_ng/pattern/button/toggle_button_pattern.cpp index 8bc907a0567065721bd235171b5fb7095270cf7c..f594cdc2b3f860f2d815a1c2354d38db35cc2511 100644 --- a/frameworks/core/components_ng/pattern/button/toggle_button_pattern.cpp +++ b/frameworks/core/components_ng/pattern/button/toggle_button_pattern.cpp @@ -299,12 +299,12 @@ void ToggleButtonPattern::SetBlurButtonStyle(RefPtr& textNode, { CHECK_NULL_VOID(toggleTheme_); CHECK_NULL_VOID(renderContext); - if (isCheckedShadow_ && isOn_.value()) { + if (isCheckedShadow_ && isOn_.value_or(false)) { isCheckedShadow_ = false; ShadowStyle shadowStyle = static_cast(toggleTheme_->GetShadowNormal()); renderContext->UpdateBackShadow(Shadow::CreateShadow(shadowStyle)); } - if (isShadow_ && !isOn_.value()) { + if (isShadow_ && !isOn_.value_or(false)) { isShadow_ = false; renderContext->UpdateBackShadow(Shadow::CreateShadow(ShadowStyle::None)); } diff --git a/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp b/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp index 59197a2d696bb93787acd7152eb1c81a92904d2f..6369d68444590efd8e9a95cebc58d724f1191c57 100644 --- a/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp +++ b/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp @@ -901,7 +901,7 @@ RefPtr DialogPattern::CreateButton( // update background color auto renderContext = buttonNode->GetRenderContext(); CHECK_NULL_RETURN(renderContext, nullptr); - renderContext->UpdateBackgroundColor(bgColor.value()); + renderContext->UpdateBackgroundColor(bgColor.value_or(Color::TRANSPARENT)); // set button default height auto layoutProps = buttonNode->GetLayoutProperty(); @@ -1530,7 +1530,7 @@ void DialogPattern::UpdateButtonsPropertyForEachButton(RefPtr buttonF // update background color auto renderContext = buttonFrameNode->GetRenderContext(); CHECK_NULL_VOID(renderContext); - renderContext->UpdateBackgroundColor(bgColor.value()); + renderContext->UpdateBackgroundColor(bgColor.value_or(Color::TRANSPARENT)); auto buttonTextNode = DynamicCast(buttonFrameNode->GetFirstChild()); CHECK_NULL_VOID(buttonTextNode); auto buttonTextLayoutProperty = buttonTextNode->GetLayoutProperty(); diff --git a/frameworks/core/components_ng/pattern/menu/menu_item/menu_item_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/menu/menu_item/menu_item_layout_algorithm.cpp index 1e4a79d286e9caae3ddf0fd62fb016b032ccca4b..a9216f20f2ac1119ef56291a21e896cef5dc58d7 100644 --- a/frameworks/core/components_ng/pattern/menu/menu_item/menu_item_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/menu/menu_item/menu_item_layout_algorithm.cpp @@ -546,8 +546,8 @@ void MenuItemLayoutAlgorithm::MeasureOption(LayoutWrapper* layoutWrapper, const auto optionPattern = optionNode->GetPattern(); CHECK_NULL_VOID(optionPattern); - auto idealSize = CreateIdealSize( - layoutConstraint.value(), Axis::HORIZONTAL, props->GetMeasureType(MeasureType::MATCH_CONTENT), true); + auto idealSize = CreateIdealSize(layoutConstraint.value_or(LayoutConstraintF()), Axis::HORIZONTAL, + props->GetMeasureType(MeasureType::MATCH_CONTENT), true); float maxChildWidth = layoutConstraint->maxSize.Width() - horInterval_ * 2.0f; // measure child auto childConstraint = props->CreateChildConstraint(); diff --git a/frameworks/core/components_ng/pattern/menu/menu_item/menu_item_pattern.cpp b/frameworks/core/components_ng/pattern/menu/menu_item/menu_item_pattern.cpp index be1784d3bd0ecaf9cdf09d8f8bfb44260405910f..13d037566d815981cb848e9512ce2eaea8c6987b 100644 --- a/frameworks/core/components_ng/pattern/menu/menu_item/menu_item_pattern.cpp +++ b/frameworks/core/components_ng/pattern/menu/menu_item/menu_item_pattern.cpp @@ -2915,7 +2915,7 @@ float MenuItemPattern::GetSelectOptionWidth() auto optionPatintProperty = optionNode->GetPaintProperty(); CHECK_NULL_RETURN(optionPatintProperty, MIN_OPTION_WIDTH.ConvertToPx()); auto selectmodifiedwidth = optionPatintProperty->GetSelectModifiedWidth(); - finalWidth = selectmodifiedwidth.value(); + finalWidth = selectmodifiedwidth.value_or(0.0f); } else { finalWidth = defaultWidth; } @@ -2950,7 +2950,7 @@ std::string MenuItemPattern::GetText() CHECK_NULL_RETURN(text_, std::string()); auto textProps = text_->GetLayoutProperty(); CHECK_NULL_RETURN(textProps, std::string()); - return UtfUtils::Str16ToStr8(textProps->GetContentValue()); + return UtfUtils::Str16ToStr8(textProps->GetContentValue(u"")); } std::string MenuItemPattern::InspectorGetFont() diff --git a/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp index 6a59d53558cad9e12902274633e100faf444964f..3bb976e9f7908b5e03847734b125e861e507d01b 100644 --- a/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp @@ -2581,7 +2581,7 @@ void MenuLayoutAlgorithm::UpdateConstraintHeight(LayoutWrapper* layoutWrapper, L if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_ELEVEN)) { if (menuPattern->IsHeightModifiedBySelect()) { auto menuLayoutProps = AceType::DynamicCast(layoutWrapper->GetLayoutProperty()); - auto selectModifiedHeight = menuLayoutProps->GetSelectModifiedHeight().value(); + auto selectModifiedHeight = menuLayoutProps->GetSelectModifiedHeight().value_or(0.0f); if (LessNotEqual(selectModifiedHeight, maxSpaceHeight)) { maxSpaceHeight = selectModifiedHeight; } @@ -2629,7 +2629,7 @@ void MenuLayoutAlgorithm::UpdateConstraintSelectHeight(LayoutWrapper* layoutWrap if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_ELEVEN)) { if (menuPattern->IsHeightModifiedBySelect()) { auto menuLayoutProps = AceType::DynamicCast(layoutWrapper->GetLayoutProperty()); - auto selectModifiedHeight = menuLayoutProps->GetSelectModifiedHeight().value(); + auto selectModifiedHeight = menuLayoutProps->GetSelectModifiedHeight().value_or(0.0f); if (LessNotEqual(selectModifiedHeight, maxSpaceHeight)) { maxSpaceHeight = selectModifiedHeight; } diff --git a/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp b/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp index f5b4ba0e63b825d0e858e1e85ef0eabaf68aa9aa..bd59fe31213dd121629b6d990a2f0db31ce3fe53 100644 --- a/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp +++ b/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp @@ -2488,7 +2488,7 @@ float MenuPattern::GetSelectMenuWidth() if (IsWidthModifiedBySelect()) { auto menuLayoutProperty = GetLayoutProperty(); auto selectmodifiedwidth = menuLayoutProperty->GetSelectMenuModifiedWidth(); - finalWidth = selectmodifiedwidth.value(); + finalWidth = selectmodifiedwidth.value_or(0.0f); } else { finalWidth = defaultWidth; } diff --git a/frameworks/core/components_ng/pattern/menu/multi_menu_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/menu/multi_menu_layout_algorithm.cpp index 317ddecad3232e5236a3d3d4c7a1fc55be231caf..2c4d10b528a2ac374f608cafa9411d9261075172 100644 --- a/frameworks/core/components_ng/pattern/menu/multi_menu_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/menu/multi_menu_layout_algorithm.cpp @@ -49,7 +49,7 @@ struct SelectOverlayRightClickMenuLayoutHelper { } childLayoutProperty->UpdateUserDefinedIdealSize( { CalcLength(1.0, DimensionUnit::PERCENT), CalcLength(0.0, DimensionUnit::AUTO) }); - constrainMinWidth.percentReference.SetWidth(constrainMinWidth.selfIdealSize.Width().value()); + constrainMinWidth.percentReference.SetWidth(constrainMinWidth.selfIdealSize.Width().value_or(0.0f)); auto row = child->GetChildByIndex(0); CHECK_NULL_VOID(row); auto layoutProperty = row->GetLayoutProperty(); @@ -400,7 +400,7 @@ void MultiMenuLayoutAlgorithm::UpdateSelfSize(LayoutWrapper* layoutWrapper, Layo CHECK_NULL_VOID(pattern); float contentHeight = 0.0f; - float contentWidth = childConstraint.selfIdealSize.Width().value(); + float contentWidth = childConstraint.selfIdealSize.Width().value_or(0.0f); for (const auto& child : layoutWrapper->GetAllChildrenWithBuild()) { if (!child) { TAG_LOGW(AceLogTag::ACE_MENU, "child is null in MultiMenu"); diff --git a/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp b/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp index 0f0e3b8f45cca74657d68647b31e3066ef0ef8fb..221489279247c3139dcaefb37f585ac2e52006b8 100644 --- a/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp +++ b/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp @@ -5111,8 +5111,8 @@ void OverlayManager::HandleModalShow(std::function&& c // create modal page auto modalNode = FrameNode::CreateFrameNode(V2::MODAL_PAGE_TAG, ElementRegister::GetInstance()->MakeUniqueId(), - AceType::MakeRefPtr( - targetId, static_cast(modalTransition.value()), std::move(callback))); + AceType::MakeRefPtr(targetId, + static_cast(modalTransition.value_or(ModalTransition::DEFAULT)), std::move(callback))); CHECK_NULL_VOID(modalNode); auto modalPagePattern = modalNode->GetPattern(); CHECK_NULL_VOID(modalPagePattern); @@ -6009,7 +6009,7 @@ SheetStyle OverlayManager::UpdateSheetStyle( { auto layoutProperty = sheetNode->GetLayoutProperty(); CHECK_NULL_RETURN(layoutProperty, sheetStyle); - auto currentStyle = layoutProperty->GetSheetStyleValue(); + auto currentStyle = layoutProperty->GetSheetStyleValue(SheetStyle()); if (isPartialUpdate) { currentStyle.PartialUpdate(sheetStyle); } else { @@ -8938,7 +8938,7 @@ void OverlayManager::FireNavigationLifecycle(const RefPtr& node, int32_t } } else if (node->GetTag() == V2::SHEET_PAGE_TAG) { auto layoutProperty = frameNode->GetLayoutProperty(); - if (layoutProperty && layoutProperty->GetSheetStyleValue().showInPage.value_or(false)) { + if (layoutProperty && layoutProperty->GetSheetStyleValue(SheetStyle()).showInPage.value_or(false)) { return; } } diff --git a/frameworks/core/components_ng/pattern/radio/radio_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/radio/radio_layout_algorithm.cpp index f27e40612f46ae5f56970fd11e28df235a313e53..444fa7a27de573739dfd985bc164070063efd49b 100644 --- a/frameworks/core/components_ng/pattern/radio/radio_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/radio/radio_layout_algorithm.cpp @@ -50,8 +50,8 @@ std::optional RadioLayoutAlgorithm::MeasureContent( // Case 1: Width and height are set in the front end. if (contentConstraint.selfIdealSize.IsValid() && contentConstraint.selfIdealSize.IsNonNegative()) { - auto height = contentConstraint.selfIdealSize.Height().value(); - auto width = contentConstraint.selfIdealSize.Width().value(); + auto height = contentConstraint.selfIdealSize.Height().value_or(0.0f); + auto width = contentConstraint.selfIdealSize.Width().value_or(0.0f); auto length = std::min(width, height); return SizeF(length, length); } diff --git a/frameworks/core/components_ng/pattern/radio/radio_pattern.cpp b/frameworks/core/components_ng/pattern/radio/radio_pattern.cpp index a8aab8a748ea0336cf58be2b77f333e192a5bff7..2166be469b5e7aeea6c7b80cdcb65ec29e1d14ab 100644 --- a/frameworks/core/components_ng/pattern/radio/radio_pattern.cpp +++ b/frameworks/core/components_ng/pattern/radio/radio_pattern.cpp @@ -99,7 +99,7 @@ void RadioPattern::UpdateIndicatorType() CHECK_NULL_VOID(renderContext); renderContext->UpdateTransformScale({ INDICATOR_MAX_SCALE, INDICATOR_MAX_SCALE }); renderContext->UpdateOpacity(1); - if (!radioPaintProperty->GetRadioCheckValue()) { + if (!radioPaintProperty->GetRadioCheckValue(false)) { SetBuilderState(); } } diff --git a/frameworks/core/components_ng/pattern/rating/rating_pattern.cpp b/frameworks/core/components_ng/pattern/rating/rating_pattern.cpp index 9073f2ca8954bbb65de2996e34ac1a96ded3a774..a15ac847e3054d7076c4098871bcc02a31d6a245 100644 --- a/frameworks/core/components_ng/pattern/rating/rating_pattern.cpp +++ b/frameworks/core/components_ng/pattern/rating/rating_pattern.cpp @@ -360,7 +360,7 @@ void RatingPattern::RecalculatedRatingScoreBasedOnEventPoint(double eventPointX, ratingScore = (ratingScore < 0.0) ? 0.0 : ratingScore; const double newDrawScore = fmin(ceil(ratingScore / stepSize) * stepSize, starNum); // step3.2: Determine whether the old and new ratingScores are same or not. - const double oldRatingScore = ratingRenderProperty->GetRatingScoreValue(); + const double oldRatingScore = ratingRenderProperty->GetRatingScoreValue(0.0); const double oldDrawScore = fmin(Round(oldRatingScore / stepSize) * stepSize, static_cast(starNum)); CHECK_NULL_VOID(!NearEqual(newDrawScore, oldDrawScore)); @@ -400,9 +400,9 @@ void RatingPattern::FireChangeEvent() auto ratingRenderProperty = GetPaintProperty(); CHECK_NULL_VOID(ratingRenderProperty); std::stringstream ss; - ss << std::setprecision(2) << ratingRenderProperty->GetRatingScoreValue(); + ss << std::setprecision(2) << ratingRenderProperty->GetRatingScoreValue(0.0); ratingEventHub->FireChangeEvent(ss.str()); - lastRatingScore_ = ratingRenderProperty->GetRatingScoreValue(); + lastRatingScore_ = ratingRenderProperty->GetRatingScoreValue(0.0); if (!Recorder::EventRecorder::Get().IsComponentRecordEnable()) { return; @@ -717,7 +717,7 @@ void RatingPattern::OnBlurEvent() RemoveIsFocusActiveUpdateEvent(); auto ratingRenderProperty = GetPaintProperty(); CHECK_NULL_VOID(ratingRenderProperty); - focusRatingScore_ = ratingRenderProperty->GetRatingScoreValue(); + focusRatingScore_ = ratingRenderProperty->GetRatingScoreValue(0.0); MarkDirtyNode(PROPERTY_UPDATE_RENDER); } diff --git a/frameworks/core/components_ng/pattern/toggle/switch_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/toggle/switch_layout_algorithm.cpp index 4949872037535fef66446e0742773bb15a018c70..3ffb09b13b0f57daf97e2eaab64ab441e3a7723e 100644 --- a/frameworks/core/components_ng/pattern/toggle/switch_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/toggle/switch_layout_algorithm.cpp @@ -46,7 +46,7 @@ std::optional SwitchLayoutAlgorithm::MeasureContent( frameWidth = contentConstraint.selfIdealSize.Width().value(); } else { auto width = (switchTheme->GetWidth() - switchTheme->GetHotZoneHorizontalPadding() * 2).ConvertToPx(); - frameWidth = static_cast(width) - padding.left.value() - padding.right.value(); + frameWidth = static_cast(width) - padding.left.value_or(0.0f) - padding.right.value_or(0.0f); if (frameWidth > contentConstraint.maxSize.Width()) { frameWidth = contentConstraint.maxSize.Width(); } @@ -55,7 +55,7 @@ std::optional SwitchLayoutAlgorithm::MeasureContent( frameHeight = contentConstraint.selfIdealSize.Height().value(); } else { auto height = (switchTheme->GetHeight() - switchTheme->GetHotZoneVerticalPadding() * 2).ConvertToPx(); - frameHeight = static_cast(height) - padding.top.value() - padding.bottom.value(); + frameHeight = static_cast(height) - padding.top.value_or(0.0f) - padding.bottom.value_or(0.0f); if (frameHeight > contentConstraint.maxSize.Height()) { frameHeight = contentConstraint.maxSize.Height(); } diff --git a/frameworks/core/components_ng/pattern/toggle/switch_pattern.cpp b/frameworks/core/components_ng/pattern/toggle/switch_pattern.cpp index 90ad7c9dcf72b1f3b0a39386c58f52347bcf0e56..78113825b07d4a8f8caa9e1b6a007fae1aee15cb 100644 --- a/frameworks/core/components_ng/pattern/toggle/switch_pattern.cpp +++ b/frameworks/core/components_ng/pattern/toggle/switch_pattern.cpp @@ -357,7 +357,7 @@ void SwitchPattern::OnChange() CHECK_NULL_VOID(paintMethod_); auto switchModifier = paintMethod_->GetSwitchModifier(); CHECK_NULL_VOID(switchModifier); - switchModifier->SetIsOn(isOn_.value()); + switchModifier->SetIsOn(isOn_.value_or(false)); switchPaintProperty->UpdateIsOn(isOn_.value_or(false)); UpdateChangeEvent(); host->MarkDirtyNode(PROPERTY_UPDATE_RENDER); @@ -386,7 +386,7 @@ void SwitchPattern::UpdateChangeEvent() const { auto switchEventHub = GetOrCreateEventHub(); CHECK_NULL_VOID(switchEventHub); - switchEventHub->UpdateChangeEvent(isOn_.value()); + switchEventHub->UpdateChangeEvent(isOn_.value_or(false)); } void SwitchPattern::OnClick() @@ -687,11 +687,11 @@ void SwitchPattern::HandleDragEnd() auto mainSize = GetSwitchWidth(); auto contentOffset = GetSwitchContentOffsetX(); if ((direction_ == TextDirection::RTL && - ((isOn_.value() && dragOffsetX_ - contentOffset > mainSize / 2) || - (!isOn_.value() && dragOffsetX_ - contentOffset <= mainSize / 2))) || + ((isOn_.value_or(false) && dragOffsetX_ - contentOffset > mainSize / 2) || + (!isOn_.value_or(false) && dragOffsetX_ - contentOffset <= mainSize / 2))) || (direction_ != TextDirection::RTL && - ((isOn_.value() && dragOffsetX_ - contentOffset < mainSize / 2) || - (!isOn_.value() && dragOffsetX_ - contentOffset >= mainSize / 2)))) { + ((isOn_.value_or(false) && dragOffsetX_ - contentOffset < mainSize / 2) || + (!isOn_.value_or(false) && dragOffsetX_ - contentOffset >= mainSize / 2)))) { OnClick(); } isDragEvent_ = false;