!1485 WarningClear:告警消除

Merge pull request !1485 from bixuefeng/warn_clear_0307
This commit is contained in:
openharmony_ci 2022-03-08 07:42:44 +00:00 committed by Gitee
commit 19ec32e3dc
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
72 changed files with 212 additions and 198 deletions

View File

@ -154,7 +154,7 @@ protected:
RefPtr<ClickRecognizer> clickRecognizer_;
RefPtr<Animator> progressController_;
ButtonType type_;
ButtonType type_ = ButtonType::NORMAL;
Size buttonSize_;
Offset offsetDelta_;
double rrectRadius_ = 0.0;

View File

@ -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<int32_t>(currentDate.day);
today_.month.year = static_cast<int32_t>(currentDate.year);
today_.month.month = static_cast<int32_t>(currentDate.month - 1);
}
bool CalendarDataAdapter::ParseData(int32_t indexOfContainer, const std::string& source, CalendarDaysOfMonth& result)
@ -533,7 +533,7 @@ void CalendarDataAdapter::ParseCalendarData(std::queue<ObtainedMonth>&& months)
void CalendarDataAdapter::NotifyDataChanged(const CalendarDaysOfMonth& data, int32_t indexOfContainer)
{
int32_t listenersSize = allListeners_.size();
int32_t listenersSize = static_cast<int32_t>(allListeners_.size());
if (indexOfContainer >= 0 && indexOfContainer < listenersSize) {
auto& listener = allListeners_[indexOfContainer];
listener->OnDataChanged(data);

View File

@ -272,7 +272,7 @@ public:
void NotifySelectedChanged() const
{
int32_t listenersSize = allListeners_.size();
int32_t listenersSize = static_cast<int32_t>(allListeners_.size());
if (indexOfContainer_ >= 0 && indexOfContainer_ < listenersSize) {
auto& listener = allListeners_[indexOfContainer_];
listener->OnSelectedDay(selectedDay_);

View File

@ -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(

View File

@ -56,7 +56,7 @@ void RenderCalendar::Update(const RefPtr<Component>& component)
indexOfContainer_ = calendarMonth->GetIndexOfContainer();
calendarController_ = calendarMonth->GetCalendarController();
dataAdapter_ = calendarController_->GetDataAdapter();
colCount_ = weekNumbers_.size();
colCount_ = static_cast<int32_t>(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<uint32_t>(today.month.year);
dateTime.month = static_cast<uint32_t>(today.month.month);
dateTime.day = static_cast<uint32_t>(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<double>(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<int32_t>(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<int32_t>(calendarDays_.size());
if (oldIndex < 0 || oldIndex >= calendarDaysSize) {
LOGW("lost focus index is out of calendar days array");
return;

View File

@ -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;

View File

@ -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<int32_t>(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<LineInfo>& pointInfo, const MainChart& line, const Rect& paintRect)
{
if (line.GetHeadPointIndex() > 0 && line.GetErasePointNumber() > 0) {
startGradientIndex_ = line.GetHeadPointIndex() + line.GetErasePointNumber() - 1;
startGradientIndex_ = static_cast<size_t>(line.GetHeadPointIndex() + line.GetErasePointNumber() - 1);
endGradientIndex_ = startGradientIndex_ + 1;
if (static_cast<size_t>(startGradientIndex_) >= pointInfo.size()) {
startGradientIndex_ = pointInfo.size() - 1;
@ -516,7 +516,7 @@ void FlutterRenderChart::AddCubicPath(fml::RefPtr<flutter::CanvasPath>& 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<int32_t>(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

View File

@ -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<int32_t>(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<LineInfo>& pointInfo, const MainChart& line, const Rect& paintRect)
{
if (line.GetHeadPointIndex() > 0 && line.GetErasePointNumber() > 0) {
startGradientIndex_ = line.GetHeadPointIndex() + line.GetErasePointNumber() - 1;
startGradientIndex_ = static_cast<size_t>(line.GetHeadPointIndex() + line.GetErasePointNumber() - 1);
endGradientIndex_ = startGradientIndex_ + 1;
if (static_cast<size_t>(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<int32_t>(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

View File

@ -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].

View File

@ -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<uint8_t>(tolower(values[1][i]));
}
return values[1];
}
@ -405,9 +405,9 @@ void FlutterRenderCustomPaint::DrawBitmapMesh(const RefPtr<OffscreenCanvas>& 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();

View File

@ -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<uint8_t>(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;

View File

@ -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<uint8_t>(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<OffscreenCanvas>& 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);

View File

@ -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<uint8_t>(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;

View File

@ -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<int32_t>(segments.size()) - 1; i >= 0; i--) {
const auto& segment = segments[i];
arcData.startColor = segment.GetStartColor();
arcData.endColor = segment.GetEndColor();

View File

@ -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();

View File

@ -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<Dimension>(DIALOG_BUTTON_HEIGHT, 0.0_vp);
theme->titleMaxLines_ = dialogPattern->GetAttr<int32_t>(DIALOG_TITLE_MAX_LINES, 2);
theme->titleMaxLines_ = static_cast<uint32_t>(dialogPattern->GetAttr<int32_t>(DIALOG_TITLE_MAX_LINES, 2));
theme->titleTextStyle_.SetFontSize(
themeStyle->GetAttr<Dimension>(THEME_ATTR_TEXT_SIZE_HEAD_LINE8, 20.0_vp));
theme->titleMinFontSize_ = themeStyle->GetAttr<Dimension>(THEME_ATTR_TEXT_SIZE_HEAD_LINE8, 20.0_vp);

View File

@ -137,7 +137,7 @@ void RenderFlex::OnPaintFinish()
return;
}
auto collectionInfo = refPtr->GetCollectionInfo();
collectionInfo.rows = GetChildren().size();
collectionInfo.rows = static_cast<int32_t>(GetChildren().size());
collectionInfo.columns = 1;
refPtr->SetCollectionInfo(collectionInfo);
Rect itemRect;

View File

@ -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<int32_t>(
mAlpha = static_cast<uint8_t>(
MAX_TRANSPARENCY - (progress_ - RIGHT_ANGLE) * ((MAX_TRANSPARENCY - MIN_TRANSPARENCY) / RIGHT_ANGLE));
} else {
mAlpha =
static_cast<int32_t>(MIN_TRANSPARENCY + progress_ * ((MAX_TRANSPARENCY - MIN_TRANSPARENCY) / RIGHT_ANGLE));
static_cast<uint8_t>(MIN_TRANSPARENCY + progress_ * ((MAX_TRANSPARENCY - MIN_TRANSPARENCY) / RIGHT_ANGLE));
}
SkColor boundaryColor = SkColorSetARGB(mAlpha, red, green, blue);
SkColor glowColor = SkColorSetARGB(MAX_ALPHA, red, green, blue);

View File

@ -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<int32_t>(
mAlpha = static_cast<uint8_t>(
MAX_TRANSPARENCY - (progress_ - RIGHT_ANGLE) * ((MAX_TRANSPARENCY - MIN_TRANSPARENCY) / RIGHT_ANGLE));
} else {
mAlpha =
static_cast<int32_t>(MIN_TRANSPARENCY + progress_ * ((MAX_TRANSPARENCY - MIN_TRANSPARENCY) / RIGHT_ANGLE));
static_cast<uint8_t>(MIN_TRANSPARENCY + progress_ * ((MAX_TRANSPARENCY - MIN_TRANSPARENCY) / RIGHT_ANGLE));
}
SkColor boundaryColor = SkColorSetARGB(mAlpha, red, green, blue);
SkColor glowColor = SkColorSetARGB(MAX_ALPHA, red, green, blue);

View File

@ -289,7 +289,7 @@ void SubContainer::GetNamesOfSharedImage(std::vector<std::string>& 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

View File

@ -331,7 +331,7 @@ Offset RenderGrid::GetChildOffset(const RefPtr<RenderNode>& 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<int32_t>(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>& curve)
{
LOGD("Animate to index: %{public}d.", index);
int32_t size = GetChildren().size();
int32_t size = static_cast<int32_t>(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<RenderNode> RenderGrid::GetChildByIndex(int32_t index) const
{
int32_t size = GetChildren().size();
int32_t size = static_cast<int32_t>(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<int32_t>(GetChildren().size());
relation[KeyDirection::UP] = -1;
relation[KeyDirection::DOWN] = -1;
relation[KeyDirection::LEFT] = gridPos % columnCount_ > 0 ? index - 1 : -1;

View File

@ -90,7 +90,7 @@ void Ace::ImageAnimatorElement::Update()
void ImageAnimatorElement::PerformBuild()
{
int32_t size = images_.size();
int32_t size = static_cast<int32_t>(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<int64_t>(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<Component> 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<BoxComponent>();
@ -186,7 +186,7 @@ void ImageAnimatorElement::UpdatePreLoadImages(const RefPtr<BoxComponent>& box)
LOGE("boxComponent is null.");
return;
}
int32_t size = images_.size();
int32_t size = static_cast<int32_t>(images_.size());
for (int32_t idx = 0; (idx < preDecode_) && (idx < size); idx++) {
auto imageComponent = DynamicCast<ImageComponent>(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<int32_t>(filterImages_.size());
for (int32_t index = 0; index < filterImagesSize; ++index) {
int32_t imageDuration = filterImages_[index].duration;
pictureAnimation_->AddPicture((float)imageDuration / durationTotal_, index);

View File

@ -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<int32_t>(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<int32_t>(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<int32_t>(item->GetKeyCount()) + 1;
if (GetCircleMode()) {
--sectionIndex;
}

View File

@ -134,7 +134,7 @@ uint32_t IndexerItemComponent::AddIndexKey(const std::string& indexKey)
}
keyCount_++;
itemIndex += sectionIndex_;
itemIndex += static_cast<uint32_t>(sectionIndex_);
if (circleMode_) {
itemIndex--;
}
@ -178,7 +178,7 @@ uint32_t IndexerItemComponent::AddIndexKeyForSharp(const std::string& indexKey)
}
keyCount_++;
itemIndex += sectionIndex_;
itemIndex += static_cast<uint32_t>(sectionIndex_);
if (circleMode_) {
itemIndex--;
}

View File

@ -126,7 +126,7 @@ void ListComponent::InsertChild(int32_t position, const RefPtr<Component>& 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<Component>& child
--current;
}
if (current == pos) {
if (current == static_cast<int32_t>(pos)) {
break;
}

View File

@ -160,7 +160,7 @@ bool ListElement::BuildListDataFromChild(int32_t index)
return false;
}
// now just for prebuild more items.
preBuildCount_ = itemComponents_.size();
preBuildCount_ = static_cast<int32_t>(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<int32_t>(itemComponents_.size());
}
void ListElement::RebuildElements(int32_t tailIndex)

View File

@ -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<int32_t>(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<int32_t>(children_.size());
if (nextFocusIndex < 0 || nextFocusIndex >= childrenSize) {
return -1;
} else {

View File

@ -143,7 +143,7 @@ void TitleBarMenuBuilder::MoveMenuItemsToBar(const RefPtr<ComponentGroup>& 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) {

View File

@ -200,7 +200,8 @@ bool NavigationBarBuilder::AddMenu(const RefPtr<ComponentGroup>& container)
}
uint32_t showInBarSize = 0;
bool hasRoom = true;
uint32_t mostShowInBarSize = menuCount_ > 0 ? menuCount_ : theme_->GetMostMenuItemCountInBar();
uint32_t mostShowInBarSize =
menuCount_ > 0 ? static_cast<uint32_t>(menuCount_) : theme_->GetMostMenuItemCountInBar();
bool needAddPadding = false;
menu_ = AceType::MakeRefPtr<MenuComponent>("", "navigationMenu");
auto ctx = context_.Upgrade();

View File

@ -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();

View File

@ -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[];
};

View File

@ -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<RenderPickerColumn>& column) { return sum += column->GetWidthRatio(); });
bool divideEvenly = SystemProperties::GetDeviceType() != DeviceType::PHONE || ratioCount == 0;

View File

@ -34,7 +34,8 @@ Rect RosenRenderPickerBase::GetOptionsRect(const Offset& offset, const RefPtr<Re
// 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();

View File

@ -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<int32_t*>(rawData);
uint32_t* data = reinterpret_cast<uint32_t*>(rawData);
int32_t blockWidth = width / qrCode.getSize();
for (int32_t i = 0; i < width; i++) {
for (int32_t j = 0; j < width; j++) {

View File

@ -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<int32_t*>(rawData);
uint32_t* data = reinterpret_cast<uint32_t*>(rawData);
int32_t blockWidth = width / qrCode.getSize();
for (int32_t i = 0; i < width; i++) {
for (int32_t j = 0; j < width; j++) {

View File

@ -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<uint32_t>(local->tm_year + BASE_YEAR);
dateTime.month = static_cast<uint32_t>(local->tm_mon);
dateTime.day = static_cast<uint32_t>(local->tm_mday);
dateTime.hour = static_cast<uint32_t>(local->tm_hour);
dateTime.minute = static_cast<uint32_t>(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;

View File

@ -86,7 +86,7 @@ protected:
bool isBgColorInit_ = false;
bool isReset_ = false;
RefPtr<Animator> controller_;
bool isContextMenu_;
bool isContextMenu_ = false;
};
} // namespace OHOS::Ace

View File

@ -345,7 +345,7 @@ bool RenderMultiChildScroll::ReachMaxCount() const
void RenderMultiChildScroll::OnPredictLayout(int64_t deadline)
{
int32_t childrenSize = GetChildren().size();
int32_t childrenSize = static_cast<uint32_t>(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<int32_t>(GetChildren().size());
if (currentIndex_ < 0 || currentIndex_ >= childrenSize) {
LOGE("invalid current index: %{public}d", currentIndex_);
return;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -55,7 +55,7 @@ void RenderStepper::Update(const RefPtr<Component>& component)
}
childrenArray_.clear();
needReverse_ = (stepperComponent_->GetTextDirection() == TextDirection::RTL);
totalItemCount_ = stepperComponent_->GetChildren().size();
totalItemCount_ = static_cast<int32_t>(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<int32_t>(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<int32_t>(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<int32_t>(childrenArray_.size());
if (index < 0 || index >= childrenCount) {
LOGE("index is error, index = %{public}d", index);
return;

View File

@ -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<uint32_t>(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);

View File

@ -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<int32_t>(paths_.size());
bool ret = false;
if (firstPart < 0 || firstPart > (pathsSize - 1)) {
ret = false;

View File

@ -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<int32_t>(pointsVector_.size());
if (firstPart < 0 || firstPart > (pathsSize - 1)) {
return false;
}

View File

@ -360,8 +360,8 @@ void RenderSvgBase::PrepareTransformFrameAnimation(const RefPtr<SvgAnimate>& svg
// set indices instead of frames
std::vector<std::string> 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<SvgAnimate>();
@ -531,8 +531,8 @@ void RenderSvgBase::PrepareWeightAnimate(const RefPtr<SvgAnimate>& svgAnimate, s
valueVector = svgAnimate->GetValues();
valueVector.insert(valueVector.begin(), originalValue);
std::vector<std::string> 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);

View File

@ -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<int32_t>(paths_.size());
bool ret = false;
if (firstPart < 0 || firstPart > (pathsSize - 1)) {
ret = false;

View File

@ -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<int32_t>(pointsVector_.size());
if (firstPart < 0 || firstPart > (pathsSize - 1)) {
return false;
}

View File

@ -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>& component)
// Get item count of swiper
const auto& children = swiper->GetChildren();
itemCount_ = children.size();
itemCount_ = static_cast<int32_t>(children.size());
for (const auto& child : children) {
auto multiChild = AceType::DynamicCast<MultiChild>(child);
if (multiChild) {
--itemCount_;
itemCount_ += multiChild->Count();
itemCount_ += static_cast<int32_t>(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<double>(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_);

View File

@ -41,7 +41,7 @@ void RenderTabBar::Update(const RefPtr<Component>& component)
EventReport::SendRenderException(RenderExcepType::RENDER_COMPONENT_ERR);
return;
}
tabsSize_ = tabBar->GetChildren().size();
tabsSize_ = static_cast<int32_t>(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<int32_t>(children.size()) - 1;
} else {
if (children.empty()) {
return;
}
tabsSize_ = children.size();
tabsSize_ = static_cast<int32_t>(children.size());
}
index_ = std::clamp(index_, 0, std::max(0, tabsSize_ - 1));
@ -707,7 +707,7 @@ void RenderTabBar::InitScrollableOffset(TabBarMode mode)
RefPtr<RenderNode> RenderTabBar::GetChildByIndex(int32_t index) const
{
int32_t size = GetChildren().size();
int32_t size = static_cast<int32_t>(GetChildren().size());
if (index < 0 || index >= size) {
return nullptr;
}

View File

@ -36,7 +36,7 @@ void RenderTabContent::Update(const RefPtr<Component>& component)
return;
}
auto tabController = tabContent->GetController();
int32_t count = tabContent->GetChildren().size();
int32_t count = static_cast<int32_t>(tabContent->GetChildren().size());
int32_t tabIndex = tabController ? tabController->GetIndex() : 0;
if (count != contentCount_ && tabIndex >= count && tabController) {
tabController->ValidateIndex(count - 1);

View File

@ -62,7 +62,7 @@ public:
void SetIndex(int32_t index)
{
if (controller_) {
int32_t size = GetChildren().size();
int32_t size = static_cast<int32_t>(GetChildren().size());
if (index < 0 || index >= size) {
index = 0;
}

View File

@ -144,7 +144,7 @@ void TabBarElement::OnFocus()
}
if (controller_) {
int32_t index = controller_->GetIndex();
int32_t size = focusNodes_.size();
int32_t size = static_cast<int32_t>(focusNodes_.size());
if (size > 0) {
size--;
}

View File

@ -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<int32_t>(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<int32_t>(wstring.size());
CharType type = GetCharType(wstring, position);
if (type != CharType::NUMBER && type != CharType::LETTER) {
selection.extentOffset = position + 1;

View File

@ -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<uint32_t>(local->tm_year + BASE_YEAR);
dateTime.month = static_cast<uint32_t>(local->tm_mon);
dateTime.day = static_cast<uint32_t>(local->tm_mday);
TimeOfNow timeOfNow = GetTimeOfNow(hoursWest_);
dateTime.hour = timeOfNow.hour24_;
dateTime.minute = timeOfNow.minute_;
dateTime.second = timeOfNow.second_;
dateTime.second = static_cast<uint32_t>(timeOfNow.second_);
return dateTime;
}

View File

@ -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<int32_t>(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<size_t>(extend) > GetEditingValue().GetWideText().length()) {
extend = GetEditingValue().GetWideText().length();
extend = static_cast<int32_t>(GetEditingValue().GetWideText().length());
}
return GetHandleOffset(extend);
}

View File

@ -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<void(uint64_t, uint64_t)> onTimer_;

View File

@ -29,7 +29,7 @@ void RenderToolBar::Update(const RefPtr<Component>& component)
return;
}
toolBarsSize_ = toolBar->GetChildren().size();
toolBarsSize_ = static_cast<int32_t>(toolBar->GetChildren().size());
}
void RenderToolBar::PerformLayout()

View File

@ -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<int32_t>(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<size_t>(index);
highLightStart = totalWeight - currentStart;
}
data.startDegree = paintData_.startDegree + (1 - currentStart / totalWeight) * paintData_.sweepDegree;

View File

@ -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);

View File

@ -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<size_t>(index);
highLightStart = totalWeight - currentStart;
}
data.startDegree = paintData_.startDegree + (1 - currentStart / totalWeight) * paintData_.sweepDegree;

View File

@ -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<int32_t>(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<double>(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<double>(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<double>(contentNum);
startPosition = isHorizontal ? Offset(0.0, crossSpace / 2) : Offset(crossSpace / 2, 0.0);
betweenPosition = isHorizontal ? Offset(0.0, crossSpace) : Offset(crossSpace, 0.0);
break;

View File

@ -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<int32_t>(GetChildrenList().size());
if (focusIndex < 0 || focusIndex >= size) {
return false;
}

View File

@ -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<double>(totalCount_) / static_cast<double>(currentItemCount) * drawLength;
estimateHeight_ = mainScrollExtent_;
totalCountFlag_ = false;
}

View File

@ -146,7 +146,7 @@ void RenderIndexer::PerformLayout()
void RenderIndexer::UpdateItems()
{
if (nonItemCount_ + items_.size() == GetChildren().size()) {
if (nonItemCount_ + static_cast<int32_t>(items_.size()) == static_cast<int32_t>(GetChildren().size())) {
LOGI("[indexer] no need update Items");
return;
}

View File

@ -225,7 +225,7 @@ void RenderPopupList::CalTouchPoint(const Point& globalPoint, int32_t& selected)
std::unique_ptr<Rect> rect = std::make_unique<Rect>(renderItem->GetGlobalOffset(),
renderItem->GetLayoutSize());
if (rect->IsInRegion(globalPoint)) {
selected = index + startIndex_;
selected = index + static_cast<int32_t>(startIndex_);
renderItem->UpdateBoxSelected();
} else {
renderItem->UpdateBoxNormal();

View File

@ -210,11 +210,11 @@ std::string IndexerComposedElement::GetArrayValue() const
auto render = AceType::DynamicCast<RenderIndexer>(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());
}

View File

@ -117,7 +117,7 @@ std::string Inspector::GetInspectorTree(const RefPtr<PipelineContext>& context)
size_t height = 0;
std::unordered_map<int32_t, std::vector<std::pair<RefPtr<Element>, std::string>>> elementJSONInfoMap;
for (int depth = depthElementMap.size(); depth > 0; depth--) {
for (int depth = static_cast<int32_t>(depthElementMap.size()); depth > 0; depth--) {
const auto& depthElements = depthElementMap[depth];
for (const auto& element : depthElements) {
auto inspectorElement = AceType::DynamicCast<V2::InspectorComposedElement>(element);

View File

@ -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<int32_t>(GetChildrenList().size());
if (focusIndex < 0 || focusIndex >= size) {
return false;
}

View File

@ -115,7 +115,7 @@ void RenderList::Update(const RefPtr<Component>& component)
const auto& divider = component_->GetItemDivider();
listSpace_ = component_->GetSpace();
cachedCount_ = component_->GetCachedCount();
cachedCount_ = static_cast<size_t>(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<size_t>(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<int32_t>(count);
}
accessibilityNode->SetCollectionInfo(collectionInfo);
accessibilityNode->SetScrollableState(true);

View File

@ -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<int16_t>(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<int16_t>(passPointLength);
if (nowCode > lastCode) {
choosePoint_.push_back(passPointVec.front());
if (passPointLength > 1) {

View File

@ -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;
};
/**