diff --git a/frameworks/core/components/button/render_button.h b/frameworks/core/components/button/render_button.h index c2fc781c..be21652b 100644 --- a/frameworks/core/components/button/render_button.h +++ b/frameworks/core/components/button/render_button.h @@ -154,7 +154,7 @@ protected: RefPtr clickRecognizer_; RefPtr progressController_; - ButtonType type_; + ButtonType type_ = ButtonType::NORMAL; Size buttonSize_; Offset offsetDelta_; double rrectRadius_ = 0.0; diff --git a/frameworks/core/components/calendar/calendar_data_adapter.cpp b/frameworks/core/components/calendar/calendar_data_adapter.cpp index 89a72d8c..d5efe718 100644 --- a/frameworks/core/components/calendar/calendar_data_adapter.cpp +++ b/frameworks/core/components/calendar/calendar_data_adapter.cpp @@ -63,9 +63,9 @@ CalendarDataAdapter::CalendarDataAdapter( : dataAdapterAction_(dataAdapterAction), pipelineContext_(pipelineContext) { Date currentDate = Date::Current(); - today_.day = currentDate.day; - today_.month.year = currentDate.year; - today_.month.month = currentDate.month - 1; + today_.day = static_cast(currentDate.day); + today_.month.year = static_cast(currentDate.year); + today_.month.month = static_cast(currentDate.month - 1); } bool CalendarDataAdapter::ParseData(int32_t indexOfContainer, const std::string& source, CalendarDaysOfMonth& result) @@ -533,7 +533,7 @@ void CalendarDataAdapter::ParseCalendarData(std::queue&& months) void CalendarDataAdapter::NotifyDataChanged(const CalendarDaysOfMonth& data, int32_t indexOfContainer) { - int32_t listenersSize = allListeners_.size(); + int32_t listenersSize = static_cast(allListeners_.size()); if (indexOfContainer >= 0 && indexOfContainer < listenersSize) { auto& listener = allListeners_[indexOfContainer]; listener->OnDataChanged(data); diff --git a/frameworks/core/components/calendar/calendar_data_adapter.h b/frameworks/core/components/calendar/calendar_data_adapter.h index 2d588700..80fdc798 100644 --- a/frameworks/core/components/calendar/calendar_data_adapter.h +++ b/frameworks/core/components/calendar/calendar_data_adapter.h @@ -272,7 +272,7 @@ public: void NotifySelectedChanged() const { - int32_t listenersSize = allListeners_.size(); + int32_t listenersSize = static_cast(allListeners_.size()); if (indexOfContainer_ >= 0 && indexOfContainer_ < listenersSize) { auto& listener = allListeners_[indexOfContainer_]; listener->OnSelectedDay(selectedDay_); diff --git a/frameworks/core/components/calendar/flutter_render_calendar.cpp b/frameworks/core/components/calendar/flutter_render_calendar.cpp index 0d899d27..98d1acf8 100644 --- a/frameworks/core/components/calendar/flutter_render_calendar.cpp +++ b/frameworks/core/components/calendar/flutter_render_calendar.cpp @@ -616,8 +616,11 @@ void FlutterRenderCalendar::PaintUnderscore(ScopedCanvas& canvas, const Offset& paint.setColor(color); paint.setStyle(SkPaint::Style::kStroke_Style); paint.setStrokeWidth(NormalizeToPx(underscoreWidth)); - skCanvas->drawLine(offset.GetX(), offset.GetY() + NormalizeToPx(underscoreWidth) / 2, - offset.GetX() + NormalizeToPx(underscoreLength), offset.GetY() + NormalizeToPx(underscoreWidth) / 2, paint); + if (skCanvas) { + skCanvas->drawLine(offset.GetX(), offset.GetY() + NormalizeToPx(underscoreWidth) / 2.0, + offset.GetX() + NormalizeToPx(underscoreLength), offset.GetY() + NormalizeToPx(underscoreWidth) / 2.0, + paint); + } } void FlutterRenderCalendar::PaintScheduleMarker(ScopedCanvas& canvas, const Offset& offset, const CalendarDay& day) @@ -636,7 +639,9 @@ void FlutterRenderCalendar::PaintScheduleMarker(ScopedCanvas& canvas, const Offs } paint.setAntiAlias(true); paint.setColor(color); - skCanvas->drawCircle(offset.GetX(), offset.GetY(), NormalizeToPx(scheduleMarkerRadius), paint); + if (skCanvas) { + skCanvas->drawCircle(offset.GetX(), offset.GetY(), NormalizeToPx(scheduleMarkerRadius), paint); + } } void FlutterRenderCalendar::InitWorkStateStyle( diff --git a/frameworks/core/components/calendar/render_calendar.cpp b/frameworks/core/components/calendar/render_calendar.cpp index b242533f..914c86e2 100644 --- a/frameworks/core/components/calendar/render_calendar.cpp +++ b/frameworks/core/components/calendar/render_calendar.cpp @@ -56,7 +56,7 @@ void RenderCalendar::Update(const RefPtr& component) indexOfContainer_ = calendarMonth->GetIndexOfContainer(); calendarController_ = calendarMonth->GetCalendarController(); dataAdapter_ = calendarController_->GetDataAdapter(); - colCount_ = weekNumbers_.size(); + colCount_ = static_cast(weekNumbers_.size()); dataAdapter_->RegisterDataListener(AceType::Claim(this)); type_ = calendarMonth->GetCalendarType(); if (type_ != CalendarType::SIMPLE) { @@ -93,9 +93,9 @@ void RenderCalendar::UpdateAccessibility() } auto today = calendarController_->GetDataAdapter()->GetToday(); DateTime dateTime; - dateTime.year = today.month.year; - dateTime.month = today.month.month; - dateTime.day = today.day; + dateTime.year = static_cast(today.month.year); + dateTime.month = static_cast(today.month.month); + dateTime.day = static_cast(today.day); auto dateText = Localization::GetInstance()->FormatDateTime(dateTime, "yyyyMMdd"); node->SetText(dateText); } @@ -169,7 +169,7 @@ void RenderCalendar::OnDataChanged(const CalendarDaysOfMonth& daysOfMonth) OnStatusChanged(RenderStatus::FOCUS); } // the number of rows will be 5 or 6, and week number height is half of the date number - rowCount_ = colCount_ ? daysOfMonth.days.size() / colCount_ : 0; + rowCount_ = colCount_ ? daysOfMonth.days.size() / static_cast(colCount_) : 0; calendarController_->JumpMonth(); hasRequestFocus_ = false; cardCalendar_ ? MarkNeedLayout() : MarkNeedRender(); @@ -216,7 +216,7 @@ void RenderCalendar::OnSelectedDay(int32_t selected) void RenderCalendar::OnStatusChanged(RenderStatus renderStatus) { - int32_t calendarDaysSize = calendarDays_.size(); + int32_t calendarDaysSize = static_cast(calendarDays_.size()); if (renderStatus == RenderStatus::FOCUS) { int32_t focusedIndex = selectedDayNumber_ + firstDayIndex_ - 1; if (selectedDayNumber_ < 0) { @@ -269,7 +269,7 @@ void RenderCalendar::OnDateSelected(const CalendarDay& date) void RenderCalendar::FocusChanged(int32_t oldIndex, int32_t newIndex) { - int32_t calendarDaysSize = calendarDays_.size(); + int32_t calendarDaysSize = static_cast(calendarDays_.size()); if (oldIndex < 0 || oldIndex >= calendarDaysSize) { LOGW("lost focus index is out of calendar days array"); return; diff --git a/frameworks/core/components/calendar/rosen_render_calendar.cpp b/frameworks/core/components/calendar/rosen_render_calendar.cpp index 6bc7e1ca..d3db76a9 100644 --- a/frameworks/core/components/calendar/rosen_render_calendar.cpp +++ b/frameworks/core/components/calendar/rosen_render_calendar.cpp @@ -437,7 +437,7 @@ void RosenRenderCalendar::DrawTouchedArea(RenderContext& context, Offset offset) double dayNumberStartY = topPadding_ + weekHeight_ + weekAndDayRowSpace_ + NormalizeToPx(dateOffset); double x = textDirection_ == TextDirection::LTR ? column * (dayWidth_ + colSpace_) : (totalWeek - column - 1) * (dayWidth_ + colSpace_); - double y = (touchIndex_ / 7) * (dayHeight_ + dailyRowSpace) + dayNumberStartY; + double y = (touchIndex_ / 7.0) * (dayHeight_ + dailyRowSpace) + dayNumberStartY; Offset circleCenter = Offset(x - (focusedAreaRadius_ * 2 - dayWidth_) / 2 + focusedAreaRadius_, y - NormalizeToPx(1.0_vp) + focusedAreaRadius_); Offset bgCircleStart = offset + circleCenter; diff --git a/frameworks/core/components/chart/flutter_render_chart.cpp b/frameworks/core/components/chart/flutter_render_chart.cpp index 70ceb1b3..32884cc9 100644 --- a/frameworks/core/components/chart/flutter_render_chart.cpp +++ b/frameworks/core/components/chart/flutter_render_chart.cpp @@ -259,7 +259,7 @@ void FlutterRenderChart::PaintDatas(RenderContext& context, const Rect& paintRec paint.paint()->setAntiAlias(true); paint.paint()->setStyle(SkPaint::Style::kStrokeAndFill_Style); - const int32_t barGroupNumber = mainCharts_.size(); + const int32_t barGroupNumber = static_cast(mainCharts_.size()); auto barsAreaNumber = horizontal_.tickNumber; for (int32_t barGroupIndex = 0; barGroupIndex < barGroupNumber; ++barGroupIndex) { auto barGroup = mainCharts_[barGroupIndex]; @@ -273,7 +273,7 @@ void FlutterRenderChart::UpdateLineGradientPoint( const std::vector& pointInfo, const MainChart& line, const Rect& paintRect) { if (line.GetHeadPointIndex() > 0 && line.GetErasePointNumber() > 0) { - startGradientIndex_ = line.GetHeadPointIndex() + line.GetErasePointNumber() - 1; + startGradientIndex_ = static_cast(line.GetHeadPointIndex() + line.GetErasePointNumber() - 1); endGradientIndex_ = startGradientIndex_ + 1; if (static_cast(startGradientIndex_) >= pointInfo.size()) { startGradientIndex_ = pointInfo.size() - 1; @@ -516,7 +516,7 @@ void FlutterRenderChart::AddCubicPath(fml::RefPtr& path, co // and control point B = [(Xi+1 - (Xi+2 - Xi) / 4), (Yi+1 - (Yi+2 - Yi) / 4)] if (index > 0 && index < line.size()) { Offset prev = ConvertDataToPosition( - paintRect, line[(index - 2 < startIndex_ || index < 2) ? startIndex_ : index - 2].GetPointInfo()); + paintRect, line[(index < 2 || index - 2 < startIndex_) ? startIndex_ : index - 2].GetPointInfo()); Offset cur = ConvertDataToPosition(paintRect, line[index - 1].GetPointInfo()); Offset next = ConvertDataToPosition(paintRect, line[index].GetPointInfo()); Offset nextNext = ConvertDataToPosition(paintRect, @@ -608,7 +608,7 @@ void FlutterRenderChart::PaintBar(const ScopedCanvas& canvas, flutter::Paint& pa LOGE("data paint region width:%{public}lf height:%{public}lf", paintRect.Width(), paintRect.Height()); return; } - const int32_t barSize = barGroupData.size(); + const int32_t barSize = static_cast(barGroupData.size()); for (int32_t barIndex = 0; barIndex < barSize; ++barIndex) { const auto point = barGroupData[barIndex].GetPointInfo(); // If the actual number of data exceeds Tick, the extra part will not be laid out diff --git a/frameworks/core/components/chart/rosen_render_chart.cpp b/frameworks/core/components/chart/rosen_render_chart.cpp index 55d27258..5c754e63 100644 --- a/frameworks/core/components/chart/rosen_render_chart.cpp +++ b/frameworks/core/components/chart/rosen_render_chart.cpp @@ -240,7 +240,7 @@ void RosenRenderChart::PaintDatas(RenderContext& context, const Rect& paintRect) paint.setAntiAlias(true); paint.setStyle(SkPaint::Style::kStrokeAndFill_Style); - const int32_t barGroupNumber = mainCharts_.size(); + const int32_t barGroupNumber = static_cast(mainCharts_.size()); auto barsAreaNumber = horizontal_.tickNumber; for (int32_t barGroupIndex = 0; barGroupIndex < barGroupNumber; ++barGroupIndex) { auto barGroup = mainCharts_[barGroupIndex]; @@ -254,7 +254,7 @@ void RosenRenderChart::UpdateLineGradientPoint( const std::vector& pointInfo, const MainChart& line, const Rect& paintRect) { if (line.GetHeadPointIndex() > 0 && line.GetErasePointNumber() > 0) { - startGradientIndex_ = line.GetHeadPointIndex() + line.GetErasePointNumber() - 1; + startGradientIndex_ = static_cast(line.GetHeadPointIndex() + line.GetErasePointNumber() - 1); endGradientIndex_ = startGradientIndex_ + 1; if (static_cast(startGradientIndex_) >= pointInfo.size()) { startGradientIndex_ = pointInfo.size() - 1; @@ -495,7 +495,7 @@ void RosenRenderChart::AddCubicPath(SkPath& path, const Rect& paintRect, // and control point B = [(Xi+1 - (Xi+2 - Xi) / 4), (Yi+1 - (Yi+2 - Yi) / 4)] if (index > 0 && index < line.size()) { Offset prev = ConvertDataToPosition( - paintRect, line[(index - 2 < startIndex_ || index < 2) ? startIndex_ : index - 2].GetPointInfo()); + paintRect, line[(index < 2 || index - 2 < startIndex_) ? startIndex_ : index - 2].GetPointInfo()); Offset cur = ConvertDataToPosition(paintRect, line[index - 1].GetPointInfo()); Offset next = ConvertDataToPosition(paintRect, line[index].GetPointInfo()); Offset nextNext = ConvertDataToPosition(paintRect, @@ -585,7 +585,7 @@ void RosenRenderChart::PaintBar(SkCanvas* canvas, SkPaint& paint, LOGE("data paint region width:%{public}lf height:%{public}lf", paintRect.Width(), paintRect.Height()); return; } - const int32_t barSize = barGroupData.size(); + const int32_t barSize = static_cast(barGroupData.size()); for (int32_t barIndex = 0; barIndex < barSize; ++barIndex) { const auto point = barGroupData[barIndex].GetPointInfo(); // If the actual number of data exceeds Tick, the extra part will not be laid out diff --git a/frameworks/core/components/checkable/render_switch.cpp b/frameworks/core/components/checkable/render_switch.cpp index d6ba18ef..3d751fff 100644 --- a/frameworks/core/components/checkable/render_switch.cpp +++ b/frameworks/core/components/checkable/render_switch.cpp @@ -296,7 +296,7 @@ void RenderSwitch::OnDrag(const Offset& updatePoint) bool moveRight = pointPositionDelta_ > 0.0; bool needChangeStatus = ((needReverse_ == oldChecked_) && moveRight && effectiveMove) || ((needReverse_ != oldChecked_) && !moveRight && effectiveMove); - checked_ = needChangeStatus ^ oldChecked_; + checked_ = needChangeStatus != oldChecked_; // reverse [checked_] status if [needChangeStatus] is true // let A = [needReverse_], B = [oldChecked_], C = [moveRight], D = [excessiveMove], // and [A'] represents the reverse of [A]. diff --git a/frameworks/core/components/custom_paint/flutter_render_custom_paint.cpp b/frameworks/core/components/custom_paint/flutter_render_custom_paint.cpp index 12efc419..2da53603 100644 --- a/frameworks/core/components/custom_paint/flutter_render_custom_paint.cpp +++ b/frameworks/core/components/custom_paint/flutter_render_custom_paint.cpp @@ -73,7 +73,7 @@ std::string GetMimeType(const std::string& args) } else { // Convert to lowercase string. for (size_t i = 0; i < values[1].size(); ++i) { - values[1][i] = tolower(values[1][i]); + values[1][i] = static_cast(tolower(values[1][i])); } return values[1]; } @@ -405,9 +405,9 @@ void FlutterRenderCustomPaint::DrawBitmapMesh(const RefPtr& off skBitmap.allocPixels(imageInfo); skBitmap.setPixels(data); - int32_t size = mesh.size(); + uint32_t size = mesh.size(); float verts[size]; - for (int32_t i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { verts[i] = mesh[i]; } @@ -1174,10 +1174,10 @@ void FlutterRenderCustomPaint::UpdatePaintShader(const Offset& offset, SkPaint& SkDoubleToScalar(gradient.GetEndOffset().GetY() + offset.GetY())); SkPoint pts[2] = { beginPoint, endPoint }; auto gradientColors = gradient.GetColors(); - int32_t colorsSize = gradientColors.size(); + uint32_t colorsSize = gradientColors.size(); SkColor colors[gradientColors.size()]; float pos[gradientColors.size()]; - for (auto i = 0; i < colorsSize; ++i) { + for (uint32_t i = 0; i < colorsSize; ++i) { const auto& gradientColor = gradientColors[i]; colors[i] = gradientColor.GetColor().GetValue(); pos[i] = gradientColor.GetDimension().Value(); diff --git a/frameworks/core/components/custom_paint/flutter_render_offscreen_canvas.cpp b/frameworks/core/components/custom_paint/flutter_render_offscreen_canvas.cpp index 889dc06d..a76e3ae6 100644 --- a/frameworks/core/components/custom_paint/flutter_render_offscreen_canvas.cpp +++ b/frameworks/core/components/custom_paint/flutter_render_offscreen_canvas.cpp @@ -68,7 +68,7 @@ std::string GetMimeType(const std::string& args) { std::string type = args; for (size_t i = 0; i < type.size(); ++i) { - type[i] = tolower(type[i]); + type[i] = static_cast(tolower(type[i])); } return type; } @@ -464,10 +464,10 @@ void FlutterRenderOffscreenCanvas::UpdatePaintShader(SkPaint& paint, const Gradi SkDoubleToScalar(gradient.GetEndOffset().GetY())); SkPoint pts[2] = { beginPoint, endPoint }; auto gradientColors = gradient.GetColors(); - int32_t colorsSize = gradientColors.size(); + uint32_t colorsSize = gradientColors.size(); SkColor colors[gradientColors.size()]; float pos[gradientColors.size()]; - for (auto i = 0; i < colorsSize; ++i) { + for (uint32_t i = 0; i < colorsSize; ++i) { const auto& gradientColor = gradientColors[i]; colors[i] = gradientColor.GetColor().GetValue(); pos[i] = gradientColor.GetDimension().Value(); @@ -1459,7 +1459,7 @@ bool FlutterRenderOffscreenCanvas::GetFilterType(std::string& filterType, std::s bool FlutterRenderOffscreenCanvas::IsPercentStr(std::string& percent) { if (percent.find("%") != std::string::npos) { - int index = percent.find("%"); + size_t index = percent.find("%"); percent = percent.substr(0, index); return true; } @@ -1668,20 +1668,20 @@ void FlutterRenderOffscreenCanvas::SetHueRotateFilter(const std::string& filterP std::string percent = filterParam; float degree = 0.0f; if (percent.find("deg") != std::string::npos) { - int index = percent.find("deg"); + size_t index = percent.find("deg"); percent = percent.substr(0, index); std::istringstream iss(percent); iss >> degree; } if (percent.find("turn") != std::string::npos) { - int index = percent.find("turn"); + size_t index = percent.find("turn"); percent = percent.substr(0, index); std::istringstream iss(percent); iss >> degree; degree = degree * 360; } if (percent.find("rad") != std::string::npos) { - int index = percent.find("rad"); + size_t index = percent.find("rad"); percent = percent.substr(0, index); std::istringstream iss(percent); iss >> degree; diff --git a/frameworks/core/components/custom_paint/rosen_render_custom_paint.cpp b/frameworks/core/components/custom_paint/rosen_render_custom_paint.cpp index 18c9f981..68bc1272 100644 --- a/frameworks/core/components/custom_paint/rosen_render_custom_paint.cpp +++ b/frameworks/core/components/custom_paint/rosen_render_custom_paint.cpp @@ -74,7 +74,7 @@ std::string GetMimeType(const std::string& args) } else { // Convert to lowercase string. for (size_t i = 0; i < values[1].size(); ++i) { - values[1][i] = tolower(values[1][i]); + values[1][i] = static_cast(tolower(values[1][i])); } return values[1]; } @@ -1043,10 +1043,10 @@ void RosenRenderCustomPaint::UpdatePaintShader(const Offset& offset, SkPaint& pa SkDoubleToScalar(gradient.GetEndOffset().GetY() + offset.GetY())); SkPoint pts[2] = { beginPoint, endPoint }; auto gradientColors = gradient.GetColors(); - int32_t colorsSize = gradientColors.size(); + uint32_t colorsSize = gradientColors.size(); SkColor colors[gradientColors.size()]; float pos[gradientColors.size()]; - for (auto i = 0; i < colorsSize; ++i) { + for (uint32_t i = 0; i < colorsSize; ++i) { const auto& gradientColor = gradientColors[i]; colors[i] = gradientColor.GetColor().GetValue(); pos[i] = gradientColor.GetDimension().Value(); @@ -1529,9 +1529,9 @@ void RosenRenderCustomPaint::DrawBitmapMesh(const RefPtr& offsc SkColorType::kBGRA_8888_SkColorType, SkAlphaType::kOpaque_SkAlphaType); skBitmap.allocPixels(imageInfo); skBitmap.setPixels(data); - int32_t size = mesh.size(); + uint32_t size = mesh.size(); float verts[size]; - for (int32_t i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { verts[i] = mesh[i]; } Mesh(skBitmap, column, row, verts, 0, nullptr); diff --git a/frameworks/core/components/custom_paint/rosen_render_offscreen_canvas.cpp b/frameworks/core/components/custom_paint/rosen_render_offscreen_canvas.cpp index d952e127..1ce84667 100644 --- a/frameworks/core/components/custom_paint/rosen_render_offscreen_canvas.cpp +++ b/frameworks/core/components/custom_paint/rosen_render_offscreen_canvas.cpp @@ -67,7 +67,7 @@ std::string GetMimeType(const std::string& args) { std::string type = args; for (size_t i = 0; i < type.size(); ++i) { - type[i] = tolower(type[i]); + type[i] = static_cast(tolower(type[i])); } return type; } @@ -450,10 +450,10 @@ void RosenRenderOffscreenCanvas::UpdatePaintShader(SkPaint& paint, const Gradien SkDoubleToScalar(gradient.GetEndOffset().GetY())); SkPoint pts[2] = { beginPoint, endPoint }; auto gradientColors = gradient.GetColors(); - int32_t colorsSize = gradientColors.size(); + uint32_t colorsSize = gradientColors.size(); SkColor colors[gradientColors.size()]; float pos[gradientColors.size()]; - for (auto i = 0; i < colorsSize; ++i) { + for (uint32_t i = 0; i < colorsSize; ++i) { const auto& gradientColor = gradientColors[i]; colors[i] = gradientColor.GetColor().GetValue(); pos[i] = gradientColor.GetDimension().Value(); @@ -1445,7 +1445,7 @@ bool RosenRenderOffscreenCanvas::GetFilterType(std::string& filterType, std::str bool RosenRenderOffscreenCanvas::IsPercentStr(std::string& percent) { if (percent.find("%") != std::string::npos) { - int index = percent.find("%"); + size_t index = percent.find("%"); percent = percent.substr(0, index); return true; } @@ -1654,20 +1654,20 @@ void RosenRenderOffscreenCanvas::SetHueRotateFilter(const std::string& filterPar std::string percent = filterParam; float degree = 0.0f; if (percent.find("deg") != std::string::npos) { - int index = percent.find("deg"); + size_t index = percent.find("deg"); percent = percent.substr(0, index); std::istringstream iss(percent); iss >> degree; } if (percent.find("turn") != std::string::npos) { - int index = percent.find("turn"); + size_t index = percent.find("turn"); percent = percent.substr(0, index); std::istringstream iss(percent); iss >> degree; degree = degree * 360; } if (percent.find("rad") != std::string::npos) { - int index = percent.find("rad"); + size_t index = percent.find("rad"); percent = percent.substr(0, index); std::istringstream iss(percent); iss >> degree; 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 8d09b6d6..a4579a30 100644 --- a/frameworks/core/components/data_panel/flutter_render_data_panel.cpp +++ b/frameworks/core/components/data_panel/flutter_render_data_panel.cpp @@ -594,9 +594,9 @@ void FlutterRenderPercentageDataPanel::PaintLinearProgress(RenderContext& contex bool isFull = false; auto valueSum = 0.0; PaintBackground(context, offset, totalWidth, height); - for (int i = 0; i < segment.size(); i++) { + for (uint32_t i = 0; i < segment.size(); i++) { if (i == 0 && segment[0].GetValue() == 0.0) { - for (int j = 0; j < segment.size(); j++) { + for (uint32_t j = 0; j < segment.size(); j++) { if (segment[j].GetValue() != 0.0 && i == 0) { i = j; } @@ -665,7 +665,7 @@ void FlutterRenderPercentageDataPanel::Paint(RenderContext& context, const Offse PaintRainbowFilterMask(canvas, factor * animationPercent_, segments, arcData); } totalValue = totalValue * proportions; - for (int i = segments.size() - 1; i >= 0; i--) { + for (int i = static_cast(segments.size()) - 1; i >= 0; i--) { const auto& segment = segments[i]; arcData.startColor = segment.GetStartColor(); arcData.endColor = segment.GetEndColor(); diff --git a/frameworks/core/components/data_panel/rosen_render_data_panel.cpp b/frameworks/core/components/data_panel/rosen_render_data_panel.cpp index 9a971c30..1b99acd6 100644 --- a/frameworks/core/components/data_panel/rosen_render_data_panel.cpp +++ b/frameworks/core/components/data_panel/rosen_render_data_panel.cpp @@ -571,7 +571,7 @@ void RosenRenderPercentageDataPanel::PaintLinearProgress(RenderContext& context, auto height = GetLayoutSize().Height(); auto widthSegment = offset.GetX(); PaintBackground(context, offset, totalWidth, height); - for (int i = 0; i < segment.size(); i++) { + for (uint32_t i = 0; i < segment.size(); i++) { auto segmentWidth = segment[i].GetValue(); if (segmentWidth == 0.0) { continue; @@ -625,7 +625,7 @@ void RosenRenderPercentageDataPanel::Paint(RenderContext& context, const Offset& PaintRainbowFilterMask(canvas, factor * animationPercent_, segments, arcData); } totalValue = totalValue * proportions; - for (int i = segments.size() - 1; i >= 0; i--) { + for (uint32_t i = segments.size() - 1; i >= 0; i--) { const auto& segment = segments[i]; arcData.startColor = segment.GetStartColor(); arcData.endColor = segment.GetEndColor(); diff --git a/frameworks/core/components/dialog/dialog_theme.h b/frameworks/core/components/dialog/dialog_theme.h index 72ade658..fc68bc93 100644 --- a/frameworks/core/components/dialog/dialog_theme.h +++ b/frameworks/core/components/dialog/dialog_theme.h @@ -149,7 +149,7 @@ public: theme->contentAdjustPadding_ = Edge(defaultPadding, 0.0_vp, defaultPadding, 0.0_vp); theme->actionsPadding_ = Edge(defaultPadding, actionsTopPadding, defaultPadding, actionsTopPadding); theme->buttonHeight_ = dialogPattern->GetAttr(DIALOG_BUTTON_HEIGHT, 0.0_vp); - theme->titleMaxLines_ = dialogPattern->GetAttr(DIALOG_TITLE_MAX_LINES, 2); + theme->titleMaxLines_ = static_cast(dialogPattern->GetAttr(DIALOG_TITLE_MAX_LINES, 2)); theme->titleTextStyle_.SetFontSize( themeStyle->GetAttr(THEME_ATTR_TEXT_SIZE_HEAD_LINE8, 20.0_vp)); theme->titleMinFontSize_ = themeStyle->GetAttr(THEME_ATTR_TEXT_SIZE_HEAD_LINE8, 20.0_vp); diff --git a/frameworks/core/components/flex/render_flex.cpp b/frameworks/core/components/flex/render_flex.cpp index 38d618e5..c8e5b4c2 100644 --- a/frameworks/core/components/flex/render_flex.cpp +++ b/frameworks/core/components/flex/render_flex.cpp @@ -137,7 +137,7 @@ void RenderFlex::OnPaintFinish() return; } auto collectionInfo = refPtr->GetCollectionInfo(); - collectionInfo.rows = GetChildren().size(); + collectionInfo.rows = static_cast(GetChildren().size()); collectionInfo.columns = 1; refPtr->SetCollectionInfo(collectionInfo); Rect itemRect; diff --git a/frameworks/core/components/focus_animation/flutter_render_focus_animation.cpp b/frameworks/core/components/focus_animation/flutter_render_focus_animation.cpp index 219d5a6c..e7574090 100644 --- a/frameworks/core/components/focus_animation/flutter_render_focus_animation.cpp +++ b/frameworks/core/components/focus_animation/flutter_render_focus_animation.cpp @@ -124,11 +124,11 @@ void FlutterRenderFocusAnimation::PaintGlow(SkCanvas* skCanvas, SkPaint& paint, uint8_t blue = pathColor_.GetBlue() & 0xFF; uint8_t mAlpha = 0; if (progress_ > RIGHT_ANGLE) { - mAlpha = static_cast( + mAlpha = static_cast( MAX_TRANSPARENCY - (progress_ - RIGHT_ANGLE) * ((MAX_TRANSPARENCY - MIN_TRANSPARENCY) / RIGHT_ANGLE)); } else { mAlpha = - static_cast(MIN_TRANSPARENCY + progress_ * ((MAX_TRANSPARENCY - MIN_TRANSPARENCY) / RIGHT_ANGLE)); + static_cast(MIN_TRANSPARENCY + progress_ * ((MAX_TRANSPARENCY - MIN_TRANSPARENCY) / RIGHT_ANGLE)); } SkColor boundaryColor = SkColorSetARGB(mAlpha, red, green, blue); SkColor glowColor = SkColorSetARGB(MAX_ALPHA, red, green, blue); diff --git a/frameworks/core/components/focus_animation/rosen_render_focus_animation.cpp b/frameworks/core/components/focus_animation/rosen_render_focus_animation.cpp index f05fad1b..aa1dd499 100644 --- a/frameworks/core/components/focus_animation/rosen_render_focus_animation.cpp +++ b/frameworks/core/components/focus_animation/rosen_render_focus_animation.cpp @@ -114,11 +114,11 @@ void RosenRenderFocusAnimation::PaintGlow(SkCanvas* skCanvas, SkPaint& paint, in uint8_t blue = pathColor_.GetBlue() & 0xFF; uint8_t mAlpha = 0; if (progress_ > RIGHT_ANGLE) { - mAlpha = static_cast( + mAlpha = static_cast( MAX_TRANSPARENCY - (progress_ - RIGHT_ANGLE) * ((MAX_TRANSPARENCY - MIN_TRANSPARENCY) / RIGHT_ANGLE)); } else { mAlpha = - static_cast(MIN_TRANSPARENCY + progress_ * ((MAX_TRANSPARENCY - MIN_TRANSPARENCY) / RIGHT_ANGLE)); + static_cast(MIN_TRANSPARENCY + progress_ * ((MAX_TRANSPARENCY - MIN_TRANSPARENCY) / RIGHT_ANGLE)); } SkColor boundaryColor = SkColorSetARGB(mAlpha, red, green, blue); SkColor glowColor = SkColorSetARGB(MAX_ALPHA, red, green, blue); diff --git a/frameworks/core/components/form/sub_container.cpp b/frameworks/core/components/form/sub_container.cpp index f0f611d9..e74592ad 100644 --- a/frameworks/core/components/form/sub_container.cpp +++ b/frameworks/core/components/form/sub_container.cpp @@ -289,7 +289,7 @@ void SubContainer::GetNamesOfSharedImage(std::vector& picNameArray) sharedImageManager = pipelineCtx->GetSharedImageManager(); } auto nameSize = picNameArray.size(); - for (int i = 0; i < nameSize; i++) { + for (uint32_t i = 0; i < nameSize; i++) { // get name of picture auto name = picNameArray[i]; sharedImageManager->AddPictureNamesToReloadMap(std::move(name)); @@ -320,7 +320,7 @@ void SubContainer::UpdateSharedImage( // now it can be assured that all three arrays are of the same size std::string picNameCopy; - for (int i = 0; i < nameArraySize; i++) { + for (uint32_t i = 0; i < nameArraySize; i++) { // get name of picture auto picName = picNameArray[i]; // save a copy of picName and ReleaseStringUTFChars immediately to avoid memory leak diff --git a/frameworks/core/components/grid/render_grid.cpp b/frameworks/core/components/grid/render_grid.cpp index 3eb4b709..546dbb70 100644 --- a/frameworks/core/components/grid/render_grid.cpp +++ b/frameworks/core/components/grid/render_grid.cpp @@ -331,7 +331,7 @@ Offset RenderGrid::GetChildOffset(const RefPtr& child) const void RenderGrid::JumpTo(int32_t index) { LOGD("Jump to index: %{public}d.", index); - int32_t size = GetChildren().size(); + int32_t size = static_cast(GetChildren().size()); if (index < 0 || index >= size) { LOGW("Invalid index: %{public}d.", index); return; @@ -349,7 +349,7 @@ void RenderGrid::JumpTo(int32_t index) void RenderGrid::AnimateTo(int32_t index, float duration, const RefPtr& curve) { LOGD("Animate to index: %{public}d.", index); - int32_t size = GetChildren().size(); + int32_t size = static_cast(GetChildren().size()); if (index < 0 || index >= size) { LOGW("Invalid index: %{public}d.", index); return; @@ -497,7 +497,7 @@ void RenderGrid::MoveChildToViewPort(int32_t index) RefPtr RenderGrid::GetChildByIndex(int32_t index) const { - int32_t size = GetChildren().size(); + int32_t size = static_cast(GetChildren().size()); if (index < 0 || index >= size) { return nullptr; } @@ -646,7 +646,7 @@ void RenderGrid::BuildPositionRelations(int32_t gridPos, int32_t columnSpan, int gridPositions_[gridPos] = index; indexPositions_[index] = gridPos; RelationMap relation; - int32_t size = GetChildren().size(); + int32_t size = static_cast(GetChildren().size()); relation[KeyDirection::UP] = -1; relation[KeyDirection::DOWN] = -1; relation[KeyDirection::LEFT] = gridPos % columnCount_ > 0 ? index - 1 : -1; diff --git a/frameworks/core/components/image/image_animator_element.cpp b/frameworks/core/components/image/image_animator_element.cpp index cfc525bf..dfde571e 100644 --- a/frameworks/core/components/image/image_animator_element.cpp +++ b/frameworks/core/components/image/image_animator_element.cpp @@ -90,7 +90,7 @@ void Ace::ImageAnimatorElement::Update() void ImageAnimatorElement::PerformBuild() { - int32_t size = images_.size(); + int32_t size = static_cast(images_.size()); if (size <= 0) { LOGE("image size is less than 0."); return; @@ -117,7 +117,7 @@ void ImageAnimatorElement::PerformBuild() animator_->ClearInterpolators(); animator_->AddInterpolator(pictureAnimation_); animator_->RemoveRepeatListener(repeatCallbackId_); - repeatCallbackId_ = animator_->AddRepeatListener([weak = WeakClaim(this)]() { + repeatCallbackId_ = static_cast(animator_->AddRepeatListener([weak = WeakClaim(this)]() { auto imageAnimator = weak.Upgrade(); if (!imageAnimator) { return; @@ -127,7 +127,7 @@ void ImageAnimatorElement::PerformBuild() } else { imageAnimator->animator_->SetDuration(imageAnimator->duration_); } - }); + })); animator_->RemoveStopListener(stopCallbackId_); stopCallbackId_ = animator_->AddStopListener([weak = WeakClaim(this)]() { auto imageAnimator = weak.Upgrade(); @@ -154,9 +154,9 @@ void ImageAnimatorElement::PerformBuild() RefPtr ImageAnimatorElement::BuildChild() { - int32_t size = images_.size(); - if (size <= 0) { - LOGE("image size is less than 0."); + uint32_t size = images_.size(); + if (size == 0) { + LOGE("image size is 0."); return nullptr; } auto boxComponent = AceType::MakeRefPtr(); @@ -186,7 +186,7 @@ void ImageAnimatorElement::UpdatePreLoadImages(const RefPtr& box) LOGE("boxComponent is null."); return; } - int32_t size = images_.size(); + int32_t size = static_cast(images_.size()); for (int32_t idx = 0; (idx < preDecode_) && (idx < size); idx++) { auto imageComponent = DynamicCast(box->GetChild()); if (!imageComponent) { @@ -210,7 +210,7 @@ void ImageAnimatorElement::CreatePictureAnimation(int32_t size) pictureAnimation_->ClearListeners(); pictureAnimation_->ClearPictures(); if (durationTotal_ > 0) { - int32_t filterImagesSize = filterImages_.size(); + int32_t filterImagesSize = static_cast(filterImages_.size()); for (int32_t index = 0; index < filterImagesSize; ++index) { int32_t imageDuration = filterImages_[index].duration; pictureAnimation_->AddPicture((float)imageDuration / durationTotal_, index); diff --git a/frameworks/core/components/indexer/indexer_component.cpp b/frameworks/core/components/indexer/indexer_component.cpp index 06971a37..f403c765 100644 --- a/frameworks/core/components/indexer/indexer_component.cpp +++ b/frameworks/core/components/indexer/indexer_component.cpp @@ -232,8 +232,8 @@ void IndexerComponent::BuildCollapseItem() void IndexerComponent::BuildIndexerItems() { - int32_t length = labelLocal_.size(); - if (length <= 0) { + uint32_t length = labelLocal_.size(); + if (length == 0) { LOGE("[indexer] invalid section string"); return; } @@ -256,7 +256,7 @@ void IndexerComponent::BuildIndexerItems() } // add indexer items except '#' isFirstItem_ = true; - for (int32_t i = 0; i < length; ++i) { + for (uint32_t i = 0; i < length; ++i) { std::u16string strItem = labelLocal_[i]; if (!userDefineList_ && strItem == INDEXER_STR_SHARP) { continue; @@ -267,8 +267,8 @@ void IndexerComponent::BuildIndexerItems() if (circleMode_ && multiLanguageEnabled_) { isFirstItem_ = true; // add default alphabet indexer - int32_t count = defaultAlphaLocal_.size(); - for (int32_t i = 0; i < count; ++i) { + uint32_t count = defaultAlphaLocal_.size(); + for (uint32_t i = 0; i < count; ++i) { std::u16string strItem = defaultAlphaLocal_[i]; BuildTextItem(strItem, strItem, 1); } @@ -335,7 +335,7 @@ int32_t IndexerComponent::AddItemIndexKey(const std::string& indexKey, const std AddSectionHead(item, headStyle); } // add index key - itemIndex = item->AddIndexKey(indexKey); + itemIndex = static_cast(item->AddIndexKey(indexKey)); break; } } @@ -372,7 +372,7 @@ int32_t IndexerComponent::AddItemToSharp(const std::string& indexKey, const std: AddSectionHead(itemPtr, headStyle); } // add index key - int32_t itemIndex = itemPtr->AddIndexKey(indexKey); + int32_t itemIndex = static_cast(itemPtr->AddIndexKey(indexKey)); // update section head index UpdateSectionIndex(); @@ -581,7 +581,7 @@ void IndexerComponent::UpdateSectionIndex() } item->SetSectionIndex(sectionIndex); if (item->GetKeyCount() != 0) { - sectionIndex = sectionIndex + item->GetKeyCount() + 1; + sectionIndex = sectionIndex + static_cast(item->GetKeyCount()) + 1; if (GetCircleMode()) { --sectionIndex; } diff --git a/frameworks/core/components/indexer/indexer_item_component.cpp b/frameworks/core/components/indexer/indexer_item_component.cpp index 0579d07d..433b0095 100644 --- a/frameworks/core/components/indexer/indexer_item_component.cpp +++ b/frameworks/core/components/indexer/indexer_item_component.cpp @@ -134,7 +134,7 @@ uint32_t IndexerItemComponent::AddIndexKey(const std::string& indexKey) } keyCount_++; - itemIndex += sectionIndex_; + itemIndex += static_cast(sectionIndex_); if (circleMode_) { itemIndex--; } @@ -178,7 +178,7 @@ uint32_t IndexerItemComponent::AddIndexKeyForSharp(const std::string& indexKey) } keyCount_++; - itemIndex += sectionIndex_; + itemIndex += static_cast(sectionIndex_); if (circleMode_) { itemIndex--; } diff --git a/frameworks/core/components/list/list_component.cpp b/frameworks/core/components/list/list_component.cpp index 7ce8ba81..92e89129 100644 --- a/frameworks/core/components/list/list_component.cpp +++ b/frameworks/core/components/list/list_component.cpp @@ -126,7 +126,7 @@ void ListComponent::InsertChild(int32_t position, const RefPtr& child return; } - uint32_t current = 0; + int32_t current = 0; auto it = children.begin(); while (it != children.end()) { auto listItemComponent = ListItemComponent::GetListItem(*it); @@ -134,7 +134,7 @@ void ListComponent::InsertChild(int32_t position, const RefPtr& child --current; } - if (current == pos) { + if (current == static_cast(pos)) { break; } diff --git a/frameworks/core/components/list/list_element.cpp b/frameworks/core/components/list/list_element.cpp index cfe9b21a..f581a81f 100644 --- a/frameworks/core/components/list/list_element.cpp +++ b/frameworks/core/components/list/list_element.cpp @@ -160,7 +160,7 @@ bool ListElement::BuildListDataFromChild(int32_t index) return false; } // now just for prebuild more items. - preBuildCount_ = itemComponents_.size(); + preBuildCount_ = static_cast(itemComponents_.size()); if (index >= preBuildCount_ - cachedCount_ && requestItemAsync_) { RetrieveListData(0, preBuildCount_ + cachedCount_); } @@ -787,7 +787,7 @@ void ListElement::GetRefreshItems(bool& rebuild, int32_t& tailIndex) if (isJsCard_) { rebuild = true; } - maxCount_ = itemComponents_.size(); + maxCount_ = static_cast(itemComponents_.size()); } void ListElement::RebuildElements(int32_t tailIndex) diff --git a/frameworks/core/components/list/list_item_group_element.cpp b/frameworks/core/components/list/list_item_group_element.cpp index e38c4c11..23958b01 100644 --- a/frameworks/core/components/list/list_item_group_element.cpp +++ b/frameworks/core/components/list/list_item_group_element.cpp @@ -139,7 +139,7 @@ bool ListItemGroupElement::RequestNextFocus(bool vertical, bool reverse, const R --nextFocusIndex; } } else { - int32_t maxSize = children_.size(); + int32_t maxSize = static_cast(children_.size()); while (nextFocusIndex < maxSize) { ret = TraverseFocusNode(nextFocusIndex, false); if (ret) { @@ -155,7 +155,7 @@ bool ListItemGroupElement::RequestNextFocus(bool vertical, bool reverse, const R int32_t ListItemGroupElement::GetNextFocusIndex(bool vertical, bool reverse) { int32_t nextFocusIndex = renderItemGroup_->GetNextFocusIndex(GetItemGroupFocusIndex(), vertical, reverse); - int32_t childrenSize = children_.size(); + int32_t childrenSize = static_cast(children_.size()); if (nextFocusIndex < 0 || nextFocusIndex >= childrenSize) { return -1; } else { diff --git a/frameworks/core/components/navigation_bar/navigation_bar_component.cpp b/frameworks/core/components/navigation_bar/navigation_bar_component.cpp index 8e3b43cd..533297ff 100644 --- a/frameworks/core/components/navigation_bar/navigation_bar_component.cpp +++ b/frameworks/core/components/navigation_bar/navigation_bar_component.cpp @@ -143,7 +143,7 @@ void TitleBarMenuBuilder::MoveMenuItemsToBar(const RefPtr& conta bool needAddPadding = false; for (const auto& menuItem : allMenuItems_) { - hasRoom &= ((showInBarSize < mostShowInBarSize - 1) || + hasRoom = hasRoom && ((showInBarSize < mostShowInBarSize - 1) || (showInBarSize == mostShowInBarSize - 1 && allMenuItems_.size() == mostShowInBarSize) || (showInBarSize < mostShowInBarSize && SystemProperties::GetDeviceType() == DeviceType::TV)); if (menuItem->GetShowInNavigationBar() == ShowInNavigationBar::SHOW && hasRoom) { diff --git a/frameworks/core/components/navigation_bar/navigation_bar_component_v2.cpp b/frameworks/core/components/navigation_bar/navigation_bar_component_v2.cpp index bdd1f803..0dc7ca67 100644 --- a/frameworks/core/components/navigation_bar/navigation_bar_component_v2.cpp +++ b/frameworks/core/components/navigation_bar/navigation_bar_component_v2.cpp @@ -200,7 +200,8 @@ bool NavigationBarBuilder::AddMenu(const RefPtr& container) } uint32_t showInBarSize = 0; bool hasRoom = true; - uint32_t mostShowInBarSize = menuCount_ > 0 ? menuCount_ : theme_->GetMostMenuItemCountInBar(); + uint32_t mostShowInBarSize = + menuCount_ > 0 ? static_cast(menuCount_) : theme_->GetMostMenuItemCountInBar(); bool needAddPadding = false; menu_ = AceType::MakeRefPtr("", "navigationMenu"); auto ctx = context_.Upgrade(); diff --git a/frameworks/core/components/picker/flutter_render_picker_base.cpp b/frameworks/core/components/picker/flutter_render_picker_base.cpp index 848001ab..21033bf2 100644 --- a/frameworks/core/components/picker/flutter_render_picker_base.cpp +++ b/frameworks/core/components/picker/flutter_render_picker_base.cpp @@ -44,7 +44,8 @@ Rect FlutterRenderPickerBase::GetOptionsRect(const Offset& offset, const RefPtr< // Get pickerColumn's relative position. auto parent = pickerColumn->GetParent().Upgrade(); uint32_t depth = 0; - while ((parent) && (AceType::RawPtr(parent) != this) && (++depth < SEARCH_MAX_DEPTH)) { + while ((parent) && (AceType::RawPtr(parent) != this) && (depth < SEARCH_MAX_DEPTH)) { + depth++; top += parent->GetPosition().GetY(); left += parent->GetPosition().GetX(); parent = parent->GetParent().Upgrade(); diff --git a/frameworks/core/components/picker/picker_date_component.h b/frameworks/core/components/picker/picker_date_component.h index a0330e4f..e7d90189 100644 --- a/frameworks/core/components/picker/picker_date_component.h +++ b/frameworks/core/components/picker/picker_date_component.h @@ -23,16 +23,16 @@ namespace OHOS::Ace { class LunarCalculator { public: - static int GetLunarLeapMonth(int lunarYear) + static uint32_t GetLunarLeapMonth(uint32_t lunarYear) { if ((lunarYear - YEAR_START) >= LUNAR_INFO_SIZE) { return 0; } - int leapMonth = LUNAR_INFO[lunarYear - YEAR_START] & 0xf; // use 0xf to get leap month info + uint32_t leapMonth = LUNAR_INFO[lunarYear - YEAR_START] & 0xf; // use 0xf to get leap month info return leapMonth == 0xf ? 0 : leapMonth; } - static int GetLunarLeapDays(int lunarYear) + static uint32_t GetLunarLeapDays(uint32_t lunarYear) { if ((lunarYear - YEAR_START + 1) >= LUNAR_INFO_SIZE) { return 0; @@ -41,12 +41,12 @@ public: : 0; // big month 30 days other 29 } - static int GetLunarYearDays(int lunarYear) + static uint32_t GetLunarYearDays(uint32_t lunarYear) { if ((lunarYear - YEAR_START) >= LUNAR_INFO_SIZE) { return 0; } - int totalDays = 348; // lunar year has (12 * 29 =) 348 days at least + uint32_t totalDays = 348; // lunar year has (12 * 29 =) 348 days at least for (uint32_t i = 0x8000; i > 0x8; i >>= 1) { // get month info from bit of LUNAR_INFO totalDays += ((LUNAR_INFO[lunarYear - YEAR_START] & i) != 0) ? 1 : 0; } @@ -54,7 +54,7 @@ public: return totalDays + GetLunarLeapDays(lunarYear); } - static int GetLunarMonthDays(int lunarYear, int lunarMonth) + static uint32_t GetLunarMonthDays(uint32_t lunarYear, uint32_t lunarMonth) { if ((lunarYear - YEAR_START) >= LUNAR_INFO_SIZE) { return 0; @@ -65,7 +65,7 @@ public: } private: - static constexpr int YEAR_START = 1897; // start year reference with LUNAR_INFO + static constexpr uint32_t YEAR_START = 1897; // start year reference with LUNAR_INFO static constexpr int32_t LUNAR_INFO_SIZE = 207; static const uint16_t LUNAR_INFO[]; }; diff --git a/frameworks/core/components/picker/render_picker_base.cpp b/frameworks/core/components/picker/render_picker_base.cpp index 07793ecd..7e80c389 100644 --- a/frameworks/core/components/picker/render_picker_base.cpp +++ b/frameworks/core/components/picker/render_picker_base.cpp @@ -345,7 +345,7 @@ void RenderPickerBase::LayoutColumns() double totalWidth = columnParent_->GetLayoutSize().Width(); double totalHeight = columnParent_->GetLayoutSize().Height(); - uint32_t ratioCount = std::accumulate(columns_.begin(), columns_.end(), 0, + int32_t ratioCount = std::accumulate(columns_.begin(), columns_.end(), 0, [](uint32_t sum, const RefPtr& column) { return sum += column->GetWidthRatio(); }); bool divideEvenly = SystemProperties::GetDeviceType() != DeviceType::PHONE || ratioCount == 0; diff --git a/frameworks/core/components/picker/rosen_render_picker_base.cpp b/frameworks/core/components/picker/rosen_render_picker_base.cpp index 08efa4a2..ef5bd887 100644 --- a/frameworks/core/components/picker/rosen_render_picker_base.cpp +++ b/frameworks/core/components/picker/rosen_render_picker_base.cpp @@ -34,7 +34,8 @@ Rect RosenRenderPickerBase::GetOptionsRect(const Offset& offset, const RefPtrGetParent().Upgrade(); uint32_t depth = 0; - while ((parent) && (AceType::RawPtr(parent) != this) && (++depth < SEARCH_MAX_DEPTH)) { + while ((parent) && (AceType::RawPtr(parent) != this) && (depth < SEARCH_MAX_DEPTH)) { + depth++; top += parent->GetPosition().GetY(); left += parent->GetPosition().GetX(); parent = parent->GetParent().Upgrade(); diff --git a/frameworks/core/components/qrcode/flutter_render_qrcode.cpp b/frameworks/core/components/qrcode/flutter_render_qrcode.cpp index 0dc0df15..ad4f2041 100644 --- a/frameworks/core/components/qrcode/flutter_render_qrcode.cpp +++ b/frameworks/core/components/qrcode/flutter_render_qrcode.cpp @@ -50,7 +50,7 @@ void FlutterRenderQrcode::DrawQRCode( } if (qrcode_->GetType() == QrcodeType::CIRCLE) { SkRect clipRect = { topLeft.GetX(), topLeft.GetY(), topLeft.GetX() + size, topLeft.GetY() + size }; - auto clipLayer = SkRRect::MakeRectXY(clipRect, size / 2, size / 2); + auto clipLayer = SkRRect::MakeRectXY(clipRect, size / 2.0, size / 2.0); canvas->canvas()->clipRRect(clipLayer, SkClipOp::kIntersect, true); } canvas->canvas()->drawBitmap(ProcessQrcodeData(size, qrCode), topLeft.GetX(), topLeft.GetY()); @@ -82,7 +82,7 @@ SkBitmap FlutterRenderQrcode::ProcessQrcodeData(int32_t width, const qrcodegen:: } skBitmap.allocPixels(imageInfo); void* rawData = skBitmap.getPixels(); - int32_t* data = reinterpret_cast(rawData); + uint32_t* data = reinterpret_cast(rawData); int32_t blockWidth = width / qrCode.getSize(); for (int32_t i = 0; i < width; i++) { for (int32_t j = 0; j < width; j++) { diff --git a/frameworks/core/components/qrcode/rosen_render_qrcode.cpp b/frameworks/core/components/qrcode/rosen_render_qrcode.cpp index 70de2584..2b518509 100644 --- a/frameworks/core/components/qrcode/rosen_render_qrcode.cpp +++ b/frameworks/core/components/qrcode/rosen_render_qrcode.cpp @@ -82,7 +82,7 @@ SkBitmap RosenRenderQrcode::ProcessQrcodeData(int32_t width, const qrcodegen::Qr } skBitmap.allocPixels(imageInfo); void* rawData = skBitmap.getPixels(); - int32_t* data = reinterpret_cast(rawData); + uint32_t* data = reinterpret_cast(rawData); int32_t blockWidth = width / qrCode.getSize(); for (int32_t i = 0; i < width; i++) { for (int32_t j = 0; j < width; j++) { diff --git a/frameworks/core/components/refresh/render_refresh.cpp b/frameworks/core/components/refresh/render_refresh.cpp index f96c6062..c57483b4 100644 --- a/frameworks/core/components/refresh/render_refresh.cpp +++ b/frameworks/core/components/refresh/render_refresh.cpp @@ -541,11 +541,11 @@ std::string RenderRefresh::GetFormatDateTime() // This is for i18n date time DateTime dateTime; - dateTime.year = local->tm_year + BASE_YEAR; - dateTime.month = local->tm_mon; - dateTime.day = local->tm_mday; - dateTime.hour = local->tm_hour; - dateTime.minute = local->tm_min; + dateTime.year = static_cast(local->tm_year + BASE_YEAR); + dateTime.month = static_cast(local->tm_mon); + dateTime.day = static_cast(local->tm_mday); + dateTime.hour = static_cast(local->tm_hour); + dateTime.minute = static_cast(local->tm_min); std::string time = Localization::GetInstance()->FormatDateTime(dateTime, LAST_UPDATE_FORMAT); LOGD("Last update refresh time is %{public}s", time.c_str()); return time; diff --git a/frameworks/core/components/root/render_root.h b/frameworks/core/components/root/render_root.h index 463e7c38..0fe2f524 100644 --- a/frameworks/core/components/root/render_root.h +++ b/frameworks/core/components/root/render_root.h @@ -86,7 +86,7 @@ protected: bool isBgColorInit_ = false; bool isReset_ = false; RefPtr controller_; - bool isContextMenu_; + bool isContextMenu_ = false; }; } // namespace OHOS::Ace diff --git a/frameworks/core/components/scroll/render_multi_child_scroll.cpp b/frameworks/core/components/scroll/render_multi_child_scroll.cpp index 17834872..06508858 100644 --- a/frameworks/core/components/scroll/render_multi_child_scroll.cpp +++ b/frameworks/core/components/scroll/render_multi_child_scroll.cpp @@ -345,7 +345,7 @@ bool RenderMultiChildScroll::ReachMaxCount() const void RenderMultiChildScroll::OnPredictLayout(int64_t deadline) { - int32_t childrenSize = GetChildren().size(); + int32_t childrenSize = static_cast(GetChildren().size()); if (currentIndex_ < 0 || currentIndex_ >= childrenSize || childrenSize == 0) { LOGE("invalid current index: %{public}d, size is: %{public}d", currentIndex_, childrenSize); return; @@ -423,7 +423,7 @@ bool RenderMultiChildScroll::LayoutChild( void RenderMultiChildScroll::LayoutChild() { - int32_t childrenSize = GetChildren().size(); + int32_t childrenSize = static_cast(GetChildren().size()); if (currentIndex_ < 0 || currentIndex_ >= childrenSize) { LOGE("invalid current index: %{public}d", currentIndex_); return; diff --git a/frameworks/core/components/search/render_search.cpp b/frameworks/core/components/search/render_search.cpp index 78f6e6d6..2a3cd75d 100644 --- a/frameworks/core/components/search/render_search.cpp +++ b/frameworks/core/components/search/render_search.cpp @@ -525,8 +525,8 @@ bool RenderSearch::MouseHoverTest(const Point& parentLocalPoint) } bool hoverInSearch = !searchTextRect_.IsInRegion(parentLocalPoint); - if (showCloseIcon_) { - hoverInSearch &= !closeIconHotZoneRect_.IsInRegion(parentLocalPoint); + if (showCloseIcon_ && hoverInSearch) { + hoverInSearch = !closeIconHotZoneRect_.IsInRegion(parentLocalPoint); } if (hoverInSearch) { hoverOrPressRender_ = SearchNodeType::NONE; diff --git a/frameworks/core/components/shape/flutter_render_shape_container.cpp b/frameworks/core/components/shape/flutter_render_shape_container.cpp index 3ffe5a52..e8162150 100644 --- a/frameworks/core/components/shape/flutter_render_shape_container.cpp +++ b/frameworks/core/components/shape/flutter_render_shape_container.cpp @@ -122,9 +122,9 @@ void FlutterRenderShapeContainer::BitmapMesh(RenderContext& context, const Offse skCanvas_->drawBitmap(skOffBitmap_, 0, 0); return; } - int32_t size = mesh_.size(); + uint32_t size = mesh_.size(); float verts[size]; - for (int32_t i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { verts[i] = (float)mesh_[i]; } DrawBitmapMesh(skOffBitmap_, column_, row_, verts, 0, nullptr); diff --git a/frameworks/core/components/shape/rosen_render_shape_container.cpp b/frameworks/core/components/shape/rosen_render_shape_container.cpp index d5707c03..e33c255a 100644 --- a/frameworks/core/components/shape/rosen_render_shape_container.cpp +++ b/frameworks/core/components/shape/rosen_render_shape_container.cpp @@ -136,9 +136,9 @@ void RosenRenderShapeContainer::BitmapMesh(RenderContext& context, const Offset& skCanvas_->drawBitmap(skOffBitmap_, 0, 0); return; } - int32_t size = mesh_.size(); + uint32_t size = mesh_.size(); float verts[size]; - for (int32_t i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { verts[i] = (float)mesh_[i]; } DrawBitmapMesh(skOffBitmap_, column_, row_, verts, 0, nullptr); diff --git a/frameworks/core/components/stepper/render_stepper.cpp b/frameworks/core/components/stepper/render_stepper.cpp index 7e69af55..538a1a7d 100644 --- a/frameworks/core/components/stepper/render_stepper.cpp +++ b/frameworks/core/components/stepper/render_stepper.cpp @@ -55,7 +55,7 @@ void RenderStepper::Update(const RefPtr& component) } childrenArray_.clear(); needReverse_ = (stepperComponent_->GetTextDirection() == TextDirection::RTL); - totalItemCount_ = stepperComponent_->GetChildren().size(); + totalItemCount_ = static_cast(stepperComponent_->GetChildren().size()); // currentIndex_ should be updated only for the first time if (currentIndex_ == -1) { @@ -452,7 +452,7 @@ void RenderStepper::PerformLayout() innerLayout.SetMaxSize(Size(maxSize.Width(), maxSize.Height() - controlPanelHeight_)); double maxWidth = minSize.Width(); double maxHeight = minSize.Height(); - int32_t childrenSize = childrenArray_.size(); + int32_t childrenSize = static_cast(childrenArray_.size()); for (int32_t i = 0; i < childrenSize; i++) { const auto& childItem = childrenArray_[i]; childItem->Layout(innerLayout); @@ -636,7 +636,7 @@ void RenderStepper::FireBackEvent(int32_t currentIndex, int32_t& pendingIndex) void RenderStepper::FireItemEvent(int32_t index, bool isAppear) const { - int32_t childrenCount = childrenArray_.size(); + int32_t childrenCount = static_cast(childrenArray_.size()); if (index < 0 || index >= childrenCount) { LOGW("index is error, index = %{public}d", index); return; @@ -758,7 +758,7 @@ void RenderStepper::InitChildrenArr() void RenderStepper::UpdateItemPosition(double offset, int32_t index) { - int32_t childrenCount = childrenArray_.size(); + int32_t childrenCount = static_cast(childrenArray_.size()); if (index < 0 || index >= childrenCount) { LOGE("index is error, index = %{public}d", index); return; diff --git a/frameworks/core/components/stepper/stepper_theme.h b/frameworks/core/components/stepper/stepper_theme.h index 3703adf6..ff9f0e3b 100644 --- a/frameworks/core/components/stepper/stepper_theme.h +++ b/frameworks/core/components/stepper/stepper_theme.h @@ -53,7 +53,7 @@ public: families.emplace_back("sans-serif"); theme->textStyle_.SetFontFamilies(families); theme->minFontSize_ = themeConstants->GetDimension(THEME_STEPPER_TEXT_FONTSIZE_MIN); - auto maxlines = themeConstants->GetInt(THEME_STEPPER_TEXT_MAX_LINES); + uint32_t maxlines = static_cast(themeConstants->GetInt(THEME_STEPPER_TEXT_MAX_LINES)); theme->textMaxLines_ = maxlines < 0 ? theme->textMaxLines_ : maxlines; theme->defaultPaddingStart_ = themeConstants->GetDimension(THEME_STEPPER_DEFAULT_PADDING_START); theme->defaultPaddingEnd_ = themeConstants->GetDimension(THEME_STEPPER_DEFAULT_PADDING_END); diff --git a/frameworks/core/components/svg/flutter_render_svg_path.cpp b/frameworks/core/components/svg/flutter_render_svg_path.cpp index 63ebdf55..11dc25fe 100644 --- a/frameworks/core/components/svg/flutter_render_svg_path.cpp +++ b/frameworks/core/components/svg/flutter_render_svg_path.cpp @@ -126,7 +126,7 @@ void FlutterRenderSvgPath::GetPath(SkPath& out) SkPath path; SkPath ending; int32_t firstPart = (int)weight_; - int32_t pathsSize = paths_.size(); + int32_t pathsSize = static_cast(paths_.size()); bool ret = false; if (firstPart < 0 || firstPart > (pathsSize - 1)) { ret = false; diff --git a/frameworks/core/components/svg/flutter_render_svg_polygon.cpp b/frameworks/core/components/svg/flutter_render_svg_polygon.cpp index 094c156b..aa01b15b 100644 --- a/frameworks/core/components/svg/flutter_render_svg_polygon.cpp +++ b/frameworks/core/components/svg/flutter_render_svg_polygon.cpp @@ -174,7 +174,7 @@ bool FlutterRenderSvgPolygon::GetPath(SkPath* out) return GetPathWithoutAnimate(out); } else { int32_t firstPart = (int)weight_; - int32_t pathsSize = pointsVector_.size(); + int32_t pathsSize = static_cast(pointsVector_.size()); if (firstPart < 0 || firstPart > (pathsSize - 1)) { return false; } diff --git a/frameworks/core/components/svg/render_svg_base.cpp b/frameworks/core/components/svg/render_svg_base.cpp index a7ee3386..902c6605 100644 --- a/frameworks/core/components/svg/render_svg_base.cpp +++ b/frameworks/core/components/svg/render_svg_base.cpp @@ -360,8 +360,8 @@ void RenderSvgBase::PrepareTransformFrameAnimation(const RefPtr& svg // set indices instead of frames std::vector indices; - int32_t size = svgAnimate->GetValues().size(); - for (int32_t i = 0; i < size; i++) { + uint32_t size = svgAnimate->GetValues().size(); + for (uint32_t i = 0; i < size; i++) { indices.emplace_back(std::to_string(i)); } auto instance = AceType::MakeRefPtr(); @@ -531,8 +531,8 @@ void RenderSvgBase::PrepareWeightAnimate(const RefPtr& svgAnimate, s valueVector = svgAnimate->GetValues(); valueVector.insert(valueVector.begin(), originalValue); std::vector newValues; - int32_t size = svgAnimate->GetValues().size(); - for (int32_t i = 0; i < size; i++) { + uint32_t size = svgAnimate->GetValues().size(); + for (uint32_t i = 0; i < size; i++) { newValues.emplace_back(std::to_string(i)); } svgAnimate->SetValues(newValues); diff --git a/frameworks/core/components/svg/rosen_render_svg_path.cpp b/frameworks/core/components/svg/rosen_render_svg_path.cpp index 748bed3b..50fb1807 100644 --- a/frameworks/core/components/svg/rosen_render_svg_path.cpp +++ b/frameworks/core/components/svg/rosen_render_svg_path.cpp @@ -105,7 +105,7 @@ void RosenRenderSvgPath::GetPath(SkPath& out) SkPath path; SkPath ending; int32_t firstPart = (int)weight_; - int32_t pathsSize = paths_.size(); + int32_t pathsSize = static_cast(paths_.size()); bool ret = false; if (firstPart < 0 || firstPart > (pathsSize - 1)) { ret = false; diff --git a/frameworks/core/components/svg/rosen_render_svg_polygon.cpp b/frameworks/core/components/svg/rosen_render_svg_polygon.cpp index 45eaf45e..f9f569f0 100644 --- a/frameworks/core/components/svg/rosen_render_svg_polygon.cpp +++ b/frameworks/core/components/svg/rosen_render_svg_polygon.cpp @@ -153,7 +153,7 @@ bool RosenRenderSvgPolygon::GetPath(SkPath* out) return GetPathWithoutAnimate(out); } else { int32_t firstPart = (int)weight_; - int32_t pathsSize = pointsVector_.size(); + int32_t pathsSize = static_cast(pointsVector_.size()); if (firstPart < 0 || firstPart > (pathsSize - 1)) { return false; } diff --git a/frameworks/core/components/swiper/render_swiper.cpp b/frameworks/core/components/swiper/render_swiper.cpp index dc7be8ca..889d120a 100644 --- a/frameworks/core/components/swiper/render_swiper.cpp +++ b/frameworks/core/components/swiper/render_swiper.cpp @@ -60,6 +60,8 @@ constexpr double SPRING_STIFF = 700.0; constexpr double SPRING_DAMP = 22.0; constexpr double SPRING_DAMP_INC = 5.0; constexpr double DRAG_CALC_STRETCH_STEP = 0.01; +constexpr int32_t DRAG_CALC_STRETCH_STEP_INT = 1; // 100*DRAG_CALC_STRETCH_STEP +constexpr int32_t DRAG_CALC_STRETCH_STEP_MAX = 100; // 100*DRAG_CALC_STRETCH_STEP_INT constexpr double DRAG_OFFSET_START_DP = 4.0; constexpr double DRAG_OFFSET_SWITCH_DP = 14.0; constexpr double DRAG_STRETCH_LONGEST_DP = 80.0; @@ -171,12 +173,12 @@ void RenderSwiper::Update(const RefPtr& component) // Get item count of swiper const auto& children = swiper->GetChildren(); - itemCount_ = children.size(); + itemCount_ = static_cast(children.size()); for (const auto& child : children) { auto multiChild = AceType::DynamicCast(child); if (multiChild) { --itemCount_; - itemCount_ += multiChild->Count(); + itemCount_ += static_cast(multiChild->Count()); } } @@ -2325,12 +2327,13 @@ void RenderSwiper::CalMaxStretch() if (focusStretchMaxTime_ == DRAG_OFFSET_MIN) { double stretch = DRAG_OFFSET_MIN; double maxStretch = DRAG_OFFSET_MIN; - const double step = DRAG_CALC_STRETCH_STEP; - for (double i = step; i <= 1.0; i += step) { - stretch = INDICATOR_FOCUS_HEAD->Move(i) - INDICATOR_FOCUS_TAIL->Move(i); + const int32_t step = DRAG_CALC_STRETCH_STEP_INT; + for (int32_t i = step; i <= DRAG_CALC_STRETCH_STEP_MAX; i += step) { + double actualStep = i * DRAG_CALC_STRETCH_STEP / static_cast(DRAG_CALC_STRETCH_STEP_INT); + stretch = INDICATOR_FOCUS_HEAD->Move(actualStep) - INDICATOR_FOCUS_TAIL->Move(actualStep); if (stretch > maxStretch) { maxStretch = stretch; - focusStretchMaxTime_ = i; + focusStretchMaxTime_ = actualStep; } } LOGD("CalMaxStretch(%{public}lf), time(%{public}lf)", maxStretch, focusStretchMaxTime_); diff --git a/frameworks/core/components/tab_bar/render_tab_bar.cpp b/frameworks/core/components/tab_bar/render_tab_bar.cpp index 3de125a7..f42f29eb 100644 --- a/frameworks/core/components/tab_bar/render_tab_bar.cpp +++ b/frameworks/core/components/tab_bar/render_tab_bar.cpp @@ -41,7 +41,7 @@ void RenderTabBar::Update(const RefPtr& component) EventReport::SendRenderException(RenderExcepType::RENDER_COMPONENT_ERR); return; } - tabsSize_ = tabBar->GetChildren().size(); + tabsSize_ = static_cast(tabBar->GetChildren().size()); auto tabController = tabBar->GetController(); if (tabController) { auto index = tabController->GetIndex(); @@ -85,12 +85,12 @@ void RenderTabBar::PerformLayout() if (children.size() <= 1) { return; } - tabsSize_ = children.size() - 1; + tabsSize_ = static_cast(children.size()) - 1; } else { if (children.empty()) { return; } - tabsSize_ = children.size(); + tabsSize_ = static_cast(children.size()); } index_ = std::clamp(index_, 0, std::max(0, tabsSize_ - 1)); @@ -707,7 +707,7 @@ void RenderTabBar::InitScrollableOffset(TabBarMode mode) RefPtr RenderTabBar::GetChildByIndex(int32_t index) const { - int32_t size = GetChildren().size(); + int32_t size = static_cast(GetChildren().size()); if (index < 0 || index >= size) { return nullptr; } diff --git a/frameworks/core/components/tab_bar/render_tab_content.cpp b/frameworks/core/components/tab_bar/render_tab_content.cpp index 93739a6f..7e3dfa0a 100644 --- a/frameworks/core/components/tab_bar/render_tab_content.cpp +++ b/frameworks/core/components/tab_bar/render_tab_content.cpp @@ -36,7 +36,7 @@ void RenderTabContent::Update(const RefPtr& component) return; } auto tabController = tabContent->GetController(); - int32_t count = tabContent->GetChildren().size(); + int32_t count = static_cast(tabContent->GetChildren().size()); int32_t tabIndex = tabController ? tabController->GetIndex() : 0; if (count != contentCount_ && tabIndex >= count && tabController) { tabController->ValidateIndex(count - 1); diff --git a/frameworks/core/components/tab_bar/tab_bar_component.h b/frameworks/core/components/tab_bar/tab_bar_component.h index 62d49feb..7f2cf16e 100644 --- a/frameworks/core/components/tab_bar/tab_bar_component.h +++ b/frameworks/core/components/tab_bar/tab_bar_component.h @@ -62,7 +62,7 @@ public: void SetIndex(int32_t index) { if (controller_) { - int32_t size = GetChildren().size(); + int32_t size = static_cast(GetChildren().size()); if (index < 0 || index >= size) { index = 0; } diff --git a/frameworks/core/components/tab_bar/tab_bar_element.cpp b/frameworks/core/components/tab_bar/tab_bar_element.cpp index 19c8694a..d23d3074 100644 --- a/frameworks/core/components/tab_bar/tab_bar_element.cpp +++ b/frameworks/core/components/tab_bar/tab_bar_element.cpp @@ -144,7 +144,7 @@ void TabBarElement::OnFocus() } if (controller_) { int32_t index = controller_->GetIndex(); - int32_t size = focusNodes_.size(); + int32_t size = static_cast(focusNodes_.size()); if (size > 0) { size--; } diff --git a/frameworks/core/components/text/text_utils.h b/frameworks/core/components/text/text_utils.h index 910ff0e4..5e364cbb 100644 --- a/frameworks/core/components/text/text_utils.h +++ b/frameworks/core/components/text/text_utils.h @@ -34,7 +34,7 @@ enum class CharType { inline CharType GetCharType(const std::wstring& value, int32_t position) { - if (position < 0 || position >= value.size()) { + if (position < 0 || position >= static_cast(value.size())) { return CharType::NONE; } @@ -52,7 +52,7 @@ inline TextSelection GetRangeOfSameType(const std::string& str, int32_t position { TextSelection selection = TextSelection(position, position); auto wstring = StringUtils::ToWstring(str); - int32_t length = wstring.size(); + int32_t length = static_cast(wstring.size()); CharType type = GetCharType(wstring, position); if (type != CharType::NUMBER && type != CharType::LETTER) { selection.extentOffset = position + 1; diff --git a/frameworks/core/components/text_clock/render_text_clock.cpp b/frameworks/core/components/text_clock/render_text_clock.cpp index cb64867f..a1165433 100644 --- a/frameworks/core/components/text_clock/render_text_clock.cpp +++ b/frameworks/core/components/text_clock/render_text_clock.cpp @@ -123,13 +123,13 @@ DateTime RenderTextClock::GetDateTime() const } // This is for i18n date time DateTime dateTime; - dateTime.year = local->tm_year + BASE_YEAR; - dateTime.month = local->tm_mon; - dateTime.day = local->tm_mday; + dateTime.year = static_cast(local->tm_year + BASE_YEAR); + dateTime.month = static_cast(local->tm_mon); + dateTime.day = static_cast(local->tm_mday); TimeOfNow timeOfNow = GetTimeOfNow(hoursWest_); dateTime.hour = timeOfNow.hour24_; dateTime.minute = timeOfNow.minute_; - dateTime.second = timeOfNow.second_; + dateTime.second = static_cast(timeOfNow.second_); return dateTime; } diff --git a/frameworks/core/components/text_field/render_text_field.cpp b/frameworks/core/components/text_field/render_text_field.cpp index d2f6eefa..2e28d088 100644 --- a/frameworks/core/components/text_field/render_text_field.cpp +++ b/frameworks/core/components/text_field/render_text_field.cpp @@ -972,7 +972,7 @@ void RenderTextField::SetEditingValue(TextEditingValue&& newValue, bool needFire } else { std::regex rw(inputFilter_); if (regex_match(newValue.text.c_str(), rw)) { - inputCallBackStrSize_ = newValue.text.length(); + inputCallBackStrSize_ = static_cast(newValue.text.length()); controller_->SetValue(newValue, needFireChangeEvent); } else { inputCallBackStr_ = newValue.text.substr(inputCallBackStrSize_); @@ -1894,7 +1894,7 @@ Offset RenderTextField::GetPositionForExtend(int32_t extend, bool isSingleHandle extend = 0; } if (static_cast(extend) > GetEditingValue().GetWideText().length()) { - extend = GetEditingValue().GetWideText().length(); + extend = static_cast(GetEditingValue().GetWideText().length()); } return GetHandleOffset(extend); } diff --git a/frameworks/core/components/texttimer/render_texttimer.h b/frameworks/core/components/texttimer/render_texttimer.h index eac5d5e3..df6cac16 100644 --- a/frameworks/core/components/texttimer/render_texttimer.h +++ b/frameworks/core/components/texttimer/render_texttimer.h @@ -57,8 +57,8 @@ public: protected: uint64_t elapsedTime_ = 0; // millisecond. - double inputCount_; - bool isCountDown_; + double inputCount_ = 0.0; + bool isCountDown_ = false; std::string format_; std::function onTimer_; diff --git a/frameworks/core/components/tool_bar/render_tool_bar.cpp b/frameworks/core/components/tool_bar/render_tool_bar.cpp index 478ded50..46c5853d 100644 --- a/frameworks/core/components/tool_bar/render_tool_bar.cpp +++ b/frameworks/core/components/tool_bar/render_tool_bar.cpp @@ -29,7 +29,7 @@ void RenderToolBar::Update(const RefPtr& component) return; } - toolBarsSize_ = toolBar->GetChildren().size(); + toolBarsSize_ = static_cast(toolBar->GetChildren().size()); } void RenderToolBar::PerformLayout() diff --git a/frameworks/core/components/track/flutter_render_arc_track.cpp b/frameworks/core/components/track/flutter_render_arc_track.cpp index bc7a9a19..9bb86734 100644 --- a/frameworks/core/components/track/flutter_render_arc_track.cpp +++ b/frameworks/core/components/track/flutter_render_arc_track.cpp @@ -170,12 +170,12 @@ void FlutterRenderArcTrack::Paint(RenderContext& context, const Offset& offset) double highLightStart = 0.0; size_t highLightIndex = 0; double ratio = leftToRight_ ? GetTotalRatio() : 1 - GetTotalRatio(); - for (int32_t index = colors_.size() - 1; index >= 0; --index) { + for (int32_t index = static_cast(colors_.size()) - 1; index >= 0; --index) { data.color = colors_[index]; data.color.ChangeAlpha(UNSELECT_ALPHA); currentStart += weights_[index]; if (ShouldHighLight(totalWeight - currentStart, weights_[index], ratio * totalWeight)) { - highLightIndex = index; + highLightIndex = static_cast(index); highLightStart = totalWeight - currentStart; } data.startDegree = paintData_.startDegree + (1 - currentStart / totalWeight) * paintData_.sweepDegree; diff --git a/frameworks/core/components/track/flutter_render_circular_track.cpp b/frameworks/core/components/track/flutter_render_circular_track.cpp index 4040ddd6..96bc51a8 100644 --- a/frameworks/core/components/track/flutter_render_circular_track.cpp +++ b/frameworks/core/components/track/flutter_render_circular_track.cpp @@ -83,7 +83,9 @@ void FlutterRenderCircularTrack::Paint(RenderContext& context, const Offset& off } canvas->save(); // change the start point to the top. - canvas.GetSkCanvas()->rotate(-90.0, data.center.GetX(), data.center.GetY()); + if (canvas.GetSkCanvas()) { + canvas.GetSkCanvas()->rotate(-90.0, data.center.GetX(), data.center.GetY()); + } // draw background data.color = GetBackgroundColor(); DrawArc(context, data); diff --git a/frameworks/core/components/track/rosen_render_arc_track.cpp b/frameworks/core/components/track/rosen_render_arc_track.cpp index 4abeaffd..1d45b5f7 100644 --- a/frameworks/core/components/track/rosen_render_arc_track.cpp +++ b/frameworks/core/components/track/rosen_render_arc_track.cpp @@ -173,7 +173,7 @@ void RosenRenderArcTrack::Paint(RenderContext& context, const Offset& offset) data.color.ChangeAlpha(UNSELECT_ALPHA); currentStart += weights_[index]; if (ShouldHighLight(totalWeight - currentStart, weights_[index], ratio * totalWeight)) { - highLightIndex = index; + highLightIndex = static_cast(index); highLightStart = totalWeight - currentStart; } data.startDegree = paintData_.startDegree + (1 - currentStart / totalWeight) * paintData_.sweepDegree; diff --git a/frameworks/core/components/wrap/render_wrap.cpp b/frameworks/core/components/wrap/render_wrap.cpp index 91206fa5..4891e365 100644 --- a/frameworks/core/components/wrap/render_wrap.cpp +++ b/frameworks/core/components/wrap/render_wrap.cpp @@ -245,7 +245,7 @@ Size RenderWrap::GetLeftSize(double crossLength, double mainLeftLength, double c void RenderWrap::LayoutWholeWrap() { - int32_t contentNum = contentList_.size(); + int32_t contentNum = static_cast(contentList_.size()); if (contentNum == 0) { LOGW("no content in wrap"); return; @@ -273,20 +273,21 @@ void RenderWrap::LayoutWholeWrap() } case WrapAlignment::SPACE_BETWEEN: { startPosition = Offset(0.0, 0.0); - double crossSpace = contentNum > 1 ? (crossLengthLimit_ - totalCrossLength_) / (contentNum - 1) : 0.0; + double crossSpace = + contentNum > 1 ? (crossLengthLimit_ - totalCrossLength_) / static_cast(contentNum - 1) : 0.0; betweenPosition = isHorizontal ? Offset(0.0, crossSpace) : Offset(crossSpace, 0.0); break; } case WrapAlignment::SPACE_EVENLY: { double leftSpace = crossLengthLimit_ - totalCrossLength_; - double crossSpace = leftSpace / (contentNum + 1); + double crossSpace = leftSpace / static_cast(contentNum + 1); startPosition = isHorizontal ? Offset(0.0, crossSpace) : Offset(crossSpace, 0.0); betweenPosition = isHorizontal ? Offset(0.0, crossSpace) : Offset(crossSpace, 0.0); break; } case WrapAlignment::SPACE_AROUND: { double leftSpace = crossLengthLimit_ - totalCrossLength_; - double crossSpace = leftSpace / contentNum; + double crossSpace = leftSpace / static_cast(contentNum); startPosition = isHorizontal ? Offset(0.0, crossSpace / 2) : Offset(crossSpace / 2, 0.0); betweenPosition = isHorizontal ? Offset(0.0, crossSpace) : Offset(crossSpace, 0.0); break; diff --git a/frameworks/core/components_v2/grid/grid_element.cpp b/frameworks/core/components_v2/grid/grid_element.cpp index f7dd5c11..bee852a1 100644 --- a/frameworks/core/components_v2/grid/grid_element.cpp +++ b/frameworks/core/components_v2/grid/grid_element.cpp @@ -141,7 +141,7 @@ bool GridElement::RequestNextFocus(bool vertical, bool reverse, const Rect& rect bool ret = false; while (!ret) { int32_t focusIndex = grid->RequestNextFocus(vertical, reverse); - int32_t size = GetChildrenList().size(); + int32_t size = static_cast(GetChildrenList().size()); if (focusIndex < 0 || focusIndex >= size) { return false; } diff --git a/frameworks/core/components_v2/grid/render_grid_scroll.cpp b/frameworks/core/components_v2/grid/render_grid_scroll.cpp index 3fa38eac..7de2ef2d 100644 --- a/frameworks/core/components_v2/grid/render_grid_scroll.cpp +++ b/frameworks/core/components_v2/grid/render_grid_scroll.cpp @@ -1043,7 +1043,7 @@ void RenderGridScroll::CalculateWholeSize(double drawLength) if (currentItemCount != 0) { mainScrollExtent_ = 0.0; // calculate the whole size - mainScrollExtent_ = totalCount_ / currentItemCount * drawLength; + mainScrollExtent_ = static_cast(totalCount_) / static_cast(currentItemCount) * drawLength; estimateHeight_ = mainScrollExtent_; totalCountFlag_ = false; } diff --git a/frameworks/core/components_v2/indexer/render_indexer.cpp b/frameworks/core/components_v2/indexer/render_indexer.cpp index f1bee9bf..c1bcc3e6 100644 --- a/frameworks/core/components_v2/indexer/render_indexer.cpp +++ b/frameworks/core/components_v2/indexer/render_indexer.cpp @@ -146,7 +146,7 @@ void RenderIndexer::PerformLayout() void RenderIndexer::UpdateItems() { - if (nonItemCount_ + items_.size() == GetChildren().size()) { + if (nonItemCount_ + static_cast(items_.size()) == static_cast(GetChildren().size())) { LOGI("[indexer] no need update Items"); return; } diff --git a/frameworks/core/components_v2/indexer/render_popup_list.cpp b/frameworks/core/components_v2/indexer/render_popup_list.cpp index 618ebebd..c328d07e 100644 --- a/frameworks/core/components_v2/indexer/render_popup_list.cpp +++ b/frameworks/core/components_v2/indexer/render_popup_list.cpp @@ -225,7 +225,7 @@ void RenderPopupList::CalTouchPoint(const Point& globalPoint, int32_t& selected) std::unique_ptr rect = std::make_unique(renderItem->GetGlobalOffset(), renderItem->GetLayoutSize()); if (rect->IsInRegion(globalPoint)) { - selected = index + startIndex_; + selected = index + static_cast(startIndex_); renderItem->UpdateBoxSelected(); } else { renderItem->UpdateBoxNormal(); diff --git a/frameworks/core/components_v2/inspector/indexer_composed_element.cpp b/frameworks/core/components_v2/inspector/indexer_composed_element.cpp index e1395189..b0113fef 100644 --- a/frameworks/core/components_v2/inspector/indexer_composed_element.cpp +++ b/frameworks/core/components_v2/inspector/indexer_composed_element.cpp @@ -210,11 +210,11 @@ std::string IndexerComposedElement::GetArrayValue() const auto render = AceType::DynamicCast(node); auto jsonValueArray = JsonUtil::CreateArray(true); auto value = render->GetArrayValue(); - int32_t length = value.size(); + uint32_t length = value.size(); if (length <= 0) { return ""; } - for (int32_t i = 0; i < length; i++) { + for (uint32_t i = 0; i < length; i++) { auto index = std::to_string(i); jsonValueArray->Put(index.c_str(), value[i].c_str()); } diff --git a/frameworks/core/components_v2/inspector/inspector.cpp b/frameworks/core/components_v2/inspector/inspector.cpp index 3f120f81..45845624 100644 --- a/frameworks/core/components_v2/inspector/inspector.cpp +++ b/frameworks/core/components_v2/inspector/inspector.cpp @@ -117,7 +117,7 @@ std::string Inspector::GetInspectorTree(const RefPtr& context) size_t height = 0; std::unordered_map, std::string>>> elementJSONInfoMap; - for (int depth = depthElementMap.size(); depth > 0; depth--) { + for (int depth = static_cast(depthElementMap.size()); depth > 0; depth--) { const auto& depthElements = depthElementMap[depth]; for (const auto& element : depthElements) { auto inspectorElement = AceType::DynamicCast(element); diff --git a/frameworks/core/components_v2/list/list_element.cpp b/frameworks/core/components_v2/list/list_element.cpp index 140077d5..7cc95af2 100644 --- a/frameworks/core/components_v2/list/list_element.cpp +++ b/frameworks/core/components_v2/list/list_element.cpp @@ -103,7 +103,7 @@ bool ListElement::RequestNextFocus(bool vertical, bool reverse, const Rect& rect bool ret = false; while (!ret) { int32_t focusIndex = list->RequestNextFocus(vertical, reverse); - int32_t size = GetChildrenList().size(); + int32_t size = static_cast(GetChildrenList().size()); if (focusIndex < 0 || focusIndex >= size) { return false; } diff --git a/frameworks/core/components_v2/list/render_list.cpp b/frameworks/core/components_v2/list/render_list.cpp index 63273af4..ded05b0c 100644 --- a/frameworks/core/components_v2/list/render_list.cpp +++ b/frameworks/core/components_v2/list/render_list.cpp @@ -115,7 +115,7 @@ void RenderList::Update(const RefPtr& component) const auto& divider = component_->GetItemDivider(); listSpace_ = component_->GetSpace(); - cachedCount_ = component_->GetCachedCount(); + cachedCount_ = static_cast(component_->GetCachedCount()); LOGI("cached count: %{public}zu", cachedCount_); spaceWidth_ = std::max(NormalizePercentToPx(component_->GetSpace(), vertical_), @@ -865,7 +865,7 @@ void RenderList::ApplyPreviousStickyListItem(size_t index, bool needLayout, cons void RenderList::JumpToIndex(int32_t idx, int32_t source) { RemoveAllItems(); - startIndex_ = idx; + startIndex_ = static_cast(idx); currentOffset_ = 0.0; MarkNeedLayout(true); } @@ -1221,7 +1221,7 @@ void RenderList::UpdateAccessibilityAttr() collectionInfo.columns = 1; } else { collectionInfo.rows = 1; - collectionInfo.columns = count; + collectionInfo.columns = static_cast(count); } accessibilityNode->SetCollectionInfo(collectionInfo); accessibilityNode->SetScrollableState(true); diff --git a/frameworks/core/components_v2/pattern_lock/render_pattern_lock.cpp b/frameworks/core/components_v2/pattern_lock/render_pattern_lock.cpp index 8f76f3d3..30099462 100644 --- a/frameworks/core/components_v2/pattern_lock/render_pattern_lock.cpp +++ b/frameworks/core/components_v2/pattern_lock/render_pattern_lock.cpp @@ -242,7 +242,7 @@ bool RenderPatternLock::CheckChoosePoint(int16_t x, int16_t y) const } bool RenderPatternLock::CheckChoosePointIsLastIndex(int16_t x, int16_t y, int16_t index) const { - if (!choosePoint_.empty() && choosePoint_.size() >= index) { + if (!choosePoint_.empty() && static_cast(choosePoint_.size()) >= index) { if (choosePoint_.at(choosePoint_.size() - index).GetColumn() == x && choosePoint_.at(choosePoint_.size() - index).GetRow() == y) { return true; @@ -289,7 +289,7 @@ void RenderPatternLock::AddPassPoint(Offset offset, int16_t x, int16_t y) if (passPointLength == 0) { return; } - passPointCount_ = passPointLength; + passPointCount_ = static_cast(passPointLength); if (nowCode > lastCode) { choosePoint_.push_back(passPointVec.front()); if (passPointLength > 1) { diff --git a/interfaces/native/native_interface_xcomponent.h b/interfaces/native/native_interface_xcomponent.h index 9951176a..f4d53400 100644 --- a/interfaces/native/native_interface_xcomponent.h +++ b/interfaces/native/native_interface_xcomponent.h @@ -70,23 +70,23 @@ const uint32_t OH_MAX_TOUCH_POINTS_NUMBER = 10; struct OH_NativeXComponent_TouchPoint { // Point ID of contact between the finger and the screen. - int32_t id; + int32_t id = 0; // Horizontal distance of the touch point relative to the upper left corner of screen. - float screenX; + float screenX = 0.0; // Vertical distance of the touch point relative to the upper left corner of screen. - float screenY; + float screenY = 0.0; // Horizontal distance of the touch point relative to the upper left corner of touched element. - float x; + float x = 0.0; // Vertical distance of the touch point relative to the upper left corner of touched element. - float y; + float y = 0.0; // Touch type of the touch event. - OH_NativeXComponent_TouchEventType type; + OH_NativeXComponent_TouchEventType type = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN; // Contacted surface size of encircling the user and the touch screen. - double size; + double size = 0.0; // Pressure of finger squeezing the touch screen. - float force; + float force = 0.0; // Timestamp of the touch event. - long long timeStamp; + long long timeStamp = 0; // whether the dot is pressed bool isPressed = false; }; @@ -94,29 +94,29 @@ struct OH_NativeXComponent_TouchPoint { // the active changed point info struct OH_NativeXComponent_TouchEvent { // Point ID of contact between the finger and the screen. - int32_t id; + int32_t id = 0; // Horizontal distance of the touch point relative to the upper left corner of screen. - float screenX; + float screenX = 0.0; // Vertical distance of the touch point relative to the upper left corner of screen. - float screenY; + float screenY = 0.0; // Horizontal distance of the touch point relative to the upper left corner of the element to touch. - float x; + float x = 0.0; // Vertical distance of the touch point relative to the upper left corner of the element to touch. - float y; + float y = 0.0; // Touch type of the touch event. - OH_NativeXComponent_TouchEventType type; + OH_NativeXComponent_TouchEventType type = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN; // Contacted surface size of encircling the user and the touch screen. - double size; + double size = 0.0; // Pressure of finger squeezing the touch screen. - float force; + float force = 0.0; // Device Id. - int64_t deviceId; + int64_t deviceId = 0; // Timestamp of the touch event. - long long timeStamp; + long long timeStamp = 0; // all points on the touch screen. OH_NativeXComponent_TouchPoint touchPoints[OH_MAX_TOUCH_POINTS_NUMBER]; // number of touchPointers - uint32_t numPoints; + uint32_t numPoints = 0; }; /**