diff --git a/frameworks/bridge/declarative_frontend/jsview/js_gauge.cpp b/frameworks/bridge/declarative_frontend/jsview/js_gauge.cpp index 8b39c96f8d79b298fe201505ec1fc0781db14de2..5b58c0cfa46a52e0b66eabd19d0a441f361c9461 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_gauge.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_gauge.cpp @@ -164,14 +164,8 @@ void JSGauge::SetColors(const JSCallbackInfo& info) return; } JSRef tempColors = jsColor->GetValueAt(i); - double value = 0.0; - if (tempColors->GetValueAt(1)->IsNumber()) { - value = tempColors->GetValueAt(1)->ToNumber(); - } - float weight = 0.0; - if (tempColors->GetValueAt(1)->IsNumber()) { - weight = tempColors->GetValueAt(1)->ToNumber(); - } + double value = tempColors->GetValueAt(1)->ToNumber(); + float weight = tempColors->GetValueAt(1)->ToNumber(); Color selectedColor; if (!ParseJsColor(tempColors->GetValueAt(0), selectedColor)) { selectedColor = ERROR_COLOR; @@ -227,10 +221,7 @@ void JSGauge::SetGradientColors(const JSCallbackInfo& info) } auto tempColors = JSRef::Cast(jsValue); // Get weight - float weight = 0.0; - if (tempColors->GetValueAt(1)->IsNumber()) { - weight = tempColors->GetValueAt(1)->ToNumber(); - } + float weight = tempColors->GetValueAt(1)->ToNumber(); if (NonPositive(weight)) { continue; } diff --git a/frameworks/bridge/declarative_frontend/jsview/js_progress.cpp b/frameworks/bridge/declarative_frontend/jsview/js_progress.cpp index c1fe63adccc6a0e840f8d47e45fe15e7e9928694..bc1ce10db8550d8220b769ee651a7311ea32aaa2 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_progress.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_progress.cpp @@ -79,10 +79,7 @@ void JSProgress::Create(const JSCallbackInfo& info) jsStyle = paramObject->GetProperty("style"); } - auto progressStyle = ProgressStyle::Ring; - if (jsStyle->IsNumber()) { - progressStyle = static_cast(jsStyle->ToNumber()); - } + auto progressStyle = static_cast(jsStyle->ToNumber()); if (progressStyle == ProgressStyle::Eclipse) { g_progressType = ProgressType::MOON; } else if (progressStyle == ProgressStyle::Ring) { @@ -213,7 +210,7 @@ void JSProgress::JsSetProgressStyleOptions(const JSCallbackInfo& info) RefPtr strokeWidthResObj; auto jsStrokeWidth = paramObject->GetProperty(attrsProgressStrokeWidth); if (!CheckLength( - jsStrokeWidth, strokeWidthDimension, V2::PROGRESS_ETS_TAG, attrsProgressStrokeWidth, strokeWidthResObj)) { + jsStrokeWidth, strokeWidthDimension, V2::PROGRESS_ETS_TAG, attrsProgressStrokeWidth, strokeWidthResObj)) { strokeWidthDimension = theme->GetTrackThickness(); } @@ -237,8 +234,7 @@ void JSProgress::JsSetProgressStyleOptions(const JSCallbackInfo& info) CalcDimension scaleWidthDimension; RefPtr scaleWidthResObj; auto jsScaleWidth = paramObject->GetProperty(attrsProgressScaleWidth); - if (!CheckLength( - jsScaleWidth, scaleWidthDimension, V2::PROGRESS_ETS_TAG, attrsProgressScaleWidth, scaleWidthResObj)) { + if (!CheckLength(jsScaleWidth, scaleWidthDimension, V2::PROGRESS_ETS_TAG, attrsProgressScaleWidth, scaleWidthResObj)) { scaleWidthDimension = theme->GetScaleWidth(); }