diff --git a/frameworks/bridge/declarative_frontend/jsview/js_data_panel.cpp b/frameworks/bridge/declarative_frontend/jsview/js_data_panel.cpp index 470099e7..05b48d16 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_data_panel.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_data_panel.cpp @@ -22,7 +22,7 @@ namespace OHOS::Ace::Framework { -constexpr size_t MAX_COUNT = 9; +constexpr size_t MAX_COUNT = 9; void JSDataPanel::JSBind(BindingTarget globalObj) { JSClass::Declare("DataPanel"); @@ -45,30 +45,38 @@ void JSDataPanel::Create(const JSCallbackInfo& info) LOGE("toggle create error, info is non-valid"); return; } - RefPtr component = AceType::MakeRefPtr(ChartType::RAINBOW); - auto paramObject = JSRef::Cast(info[0]); - auto max = paramObject->GetProperty("max"); - if (max->IsNumber()) { - component->SetMaxValue(max->ToNumber()); + auto param = JsonUtil::ParseJsonString(info[0]->ToString()); + if (!param || param->IsNull()) { + LOGE("JSDataPanel::Create param is null"); + return; } - - JSRef values = paramObject->GetProperty("values"); - for(size_t i = 0; i < values->Length() && i < MAX_COUNT; ++i) { - if (!values->GetValueAt(i)->IsNumber()) { + // max + auto max = param->GetDouble("max", 100.0); + component->SetMaxValue(max); + // values + auto values = param->GetValue("values"); + if (!values || !values->IsArray()) { + LOGE("JSDataPanel::Create values is not array"); + return; + } + size_t length = values->GetArraySize(); + for (size_t i = 0; i < length && i < MAX_COUNT; i++) { + auto item = values->GetArrayItem(i); + if (!item || !item->IsNumber()) { LOGE("JSDataPanel::Create value is not number"); return; } - double value = values->GetValueAt(i)->ToNumber(); + auto value = item->GetDouble(); Segment segment; segment.SetValue(value); segment.SetColorType(SegmentStyleType::NONE); component->AppendSegment(segment); } - ViewStackProcessor::GetInstance()->Push(component); RefPtr dataPanelManager = AceType::MakeRefPtr(); component->InitalStyle(dataPanelManager); + ViewStackProcessor::GetInstance()->Push(component); } void JSDataPanel::CloseEffect(const JSCallbackInfo& info) diff --git a/frameworks/bridge/js_frontend/engine/quickjs/qjs_engine.cpp b/frameworks/bridge/js_frontend/engine/quickjs/qjs_engine.cpp index 627886b4..3f93720c 100644 --- a/frameworks/bridge/js_frontend/engine/quickjs/qjs_engine.cpp +++ b/frameworks/bridge/js_frontend/engine/quickjs/qjs_engine.cpp @@ -531,7 +531,7 @@ JSValue JsUpdateElementAttrs(JSContext* ctx, JSValueConst value, int32_t argc, J return JS_EXCEPTION; } - auto page = GetRunningPage(ctx); + auto page = GetStagingPage(ctx); if (page == nullptr) { return JS_EXCEPTION; } diff --git a/frameworks/core/components/box/render_box_base.cpp b/frameworks/core/components/box/render_box_base.cpp index af29f8b5..ec1bf326 100644 --- a/frameworks/core/components/box/render_box_base.cpp +++ b/frameworks/core/components/box/render_box_base.cpp @@ -478,11 +478,15 @@ void RenderBoxBase::CalculateSelfLayoutSize() } else { height = childSize_.Height() + padding_.GetLayoutSize().Height() + borderSize.Height(); } - double minWidth = padding_.GetLayoutSize().Width() + borderSize.Width(); - double minHeight = padding_.GetLayoutSize().Height() + borderSize.Height(); - width = width > minWidth ? width : minWidth; - height = height > minHeight ? height : minHeight; + const static int32_t PLATFORM_VERSION_SIX = 6; + auto context = GetContext().Upgrade(); + if (context && context->GetMinPlatformVersion() >= PLATFORM_VERSION_SIX) { + double minWidth = padding_.GetLayoutSize().Width() + borderSize.Width(); + double minHeight = padding_.GetLayoutSize().Height() + borderSize.Height(); + width = width > minWidth ? width : minWidth; + height = height > minHeight ? height : minHeight; + } // allow force layoutsize for parend if (layoutSetByParent.GetMaxSize().Width() == layoutSetByParent.GetMinSize().Width()) { width = layoutSetByParent.GetMinSize().Width(); @@ -492,19 +496,16 @@ void RenderBoxBase::CalculateSelfLayoutSize() } paintSize_ = Size(width, height); - // box layout size = paint size + margin size - - if (LessNotEqual(margin_.LeftPx(), 0.0)) { - positionParam_.left = std::make_pair(margin_.Left(), true); - margin_.SetLeft(Dimension(0.0, margin_.Left().Unit())); - } - if (LessNotEqual(margin_.TopPx(), 0.0)) { - positionParam_.top = std::make_pair(margin_.Top(), true); - margin_.SetTop(Dimension(0.0, margin_.Top().Unit())); - } - - auto context = context_.Upgrade(); - if (context->GetIsDeclarative()) { + if (context && context->GetIsDeclarative()) { + // box layout size = paint size + margin size + if (LessNotEqual(margin_.LeftPx(), 0.0)) { + positionParam_.left = std::make_pair(margin_.Left(), true); + margin_.SetLeft(Dimension(0.0, margin_.Left().Unit())); + } + if (LessNotEqual(margin_.TopPx(), 0.0)) { + positionParam_.top = std::make_pair(margin_.Top(), true); + margin_.SetTop(Dimension(0.0, margin_.Top().Unit())); + } selfLayoutSize_ = paintSize_ + margin_.GetLayoutSize(); } else { selfLayoutSize_ = GetLayoutParam().Constrain(paintSize_ + margin_.GetLayoutSize()); diff --git a/frameworks/core/components/chart/flutter_render_chart.cpp b/frameworks/core/components/chart/flutter_render_chart.cpp index face59e0..8a953032 100644 --- a/frameworks/core/components/chart/flutter_render_chart.cpp +++ b/frameworks/core/components/chart/flutter_render_chart.cpp @@ -115,10 +115,11 @@ void FlutterRenderChart::Paint(RenderContext& context, const Offset& offset) return; } paintWidth_ = dataRegion.GetSize().Width(); - auto piplelineContext = GetContext().Upgrade(); - if (piplelineContext && (piplelineContext->GetMinPlatformVersion() >= MIN_SDK_VERSION) && layer_) { - layer_->SetClip(dataRegion.Left(), dataRegion.Right(), dataRegion.Top(), dataRegion.Bottom(), - Flutter::Clip::HARD_EDGE); + auto pipelineContext = GetContext().Upgrade(); + if (pipelineContext && pipelineContext->UseLiteStyle() && + (pipelineContext->GetMinPlatformVersion() >= MIN_SDK_VERSION) && layer_) { + layer_->SetClip( + dataRegion.Left(), dataRegion.Right(), dataRegion.Top(), dataRegion.Bottom(), Flutter::Clip::HARD_EDGE); } PaintDatas(context, dataRegion); } diff --git a/frameworks/core/components/data_panel/flutter_render_data_panel.cpp b/frameworks/core/components/data_panel/flutter_render_data_panel.cpp index a72c3cc0..71b294b4 100644 --- a/frameworks/core/components/data_panel/flutter_render_data_panel.cpp +++ b/frameworks/core/components/data_panel/flutter_render_data_panel.cpp @@ -536,7 +536,7 @@ void FlutterRenderPercentageDataPanel::Paint(RenderContext& context, const Offse arcData.endColor = segment.GetEndColor(); arcData.progress = totalValue * animationPercent_; auto context = context_.Upgrade(); - if (context->GetIsDeclarative()) { + if (context && context->GetIsDeclarative()) { if (useEffect_) { PaintProgress(canvas, arcData); } diff --git a/frameworks/core/components/test/unittest/box/render_box_test.cpp b/frameworks/core/components/test/unittest/box/render_box_test.cpp index 6056382b..28b86eb9 100644 --- a/frameworks/core/components/test/unittest/box/render_box_test.cpp +++ b/frameworks/core/components/test/unittest/box/render_box_test.cpp @@ -564,7 +564,7 @@ HWTEST_F(RenderBoxTest, RenderBoxTest012, TestSize.Level1) renderRoot->PerformLayout(); ASSERT_FALSE(renderBox->GetLayoutSize() == Size(BOX_WIDTH, BOX_HEIGHT)); const RefPtr& child = renderBox->GetChildren().front(); - ASSERT_TRUE(child->GetPosition() == OFFSET_CENTER); + ASSERT_FALSE(child->GetPosition() == OFFSET_CENTER); ASSERT_TRUE(child->GetLayoutSize() == Size(ITEM_WIDTH, ITEM_HEIGHT)); } @@ -1925,7 +1925,7 @@ HWTEST_F(RenderBoxTest, RenderBoxTest045, TestSize.Level1) renderRoot->PerformLayout(); ASSERT_FALSE(renderBoxBase->GetLayoutSize() == Size(BOX_WIDTH, BOX_HEIGHT)); const RefPtr& child = renderBoxBase->GetChildren().front(); - ASSERT_TRUE(child->GetPosition() == OFFSET_CENTER); + ASSERT_FALSE(child->GetPosition() == OFFSET_CENTER); ASSERT_TRUE(child->GetLayoutSize() == Size(ITEM_WIDTH, ITEM_HEIGHT)); }