From f54c8d3bc61ff3243f254448b3fc4a5ec555ce4d Mon Sep 17 00:00:00 2001 From: kangchongtao Date: Tue, 29 Mar 2022 13:28:56 +0800 Subject: [PATCH] =?UTF-8?q?0324=E5=86=85=E6=BA=90=E5=AE=A1=E8=A7=86?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kangchongtao Change-Id: If3caec9090a14a75e6fd8f141e04fb20d78e7d4c Signed-off-by: kangchongtao --- adapter/ohos/entrance/ace_container.cpp | 34 +++++++++---------- .../inspector/js_inspector_manager.cpp | 3 ++ build/BUILD.gn | 2 +- frameworks/base/i18n/localization.cpp | 2 +- frameworks/base/resource/ace_res_config.cpp | 6 ++-- .../base/subwindow/subwindow_manager.cpp | 2 +- .../accessibility_node_manager.cpp | 2 +- .../bridge/common/dom/dom_list_item.cpp | 4 +-- .../bridge/common/dom/dom_picker_base.cpp | 6 ++-- .../bridge/common/dom/dom_picker_base.h | 2 +- frameworks/bridge/common/dom/dom_progress.cpp | 2 +- .../common/dom/input/dom_checkbox_util.cpp | 6 ++-- frameworks/bridge/common/utils/utils.cpp | 4 +-- .../functions/js_on_area_change_function.cpp | 6 ++-- .../quickjs/modules/qjs_module_manager.cpp | 10 +++--- .../quickjs/modules/qjs_router_module.cpp | 6 ++-- .../engine/v8/v8_bindings.h | 2 +- .../engine/v8/v8_bindings.inl | 30 ++++++++-------- .../jsview/js_textinput.h | 2 +- frameworks/core/common/register/hdc_jdwp.cpp | 6 ++-- .../flutter_render_custom_paint.cpp | 4 +-- .../flutter_render_offscreen_canvas.cpp | 4 +-- .../rosen_render_custom_paint.cpp | 4 +-- .../rosen_render_offscreen_canvas.cpp | 2 +- .../components/font/constants_converter.cpp | 5 +-- .../core/components/form/sub_container.cpp | 10 +++--- .../core/components/svg/parse/svg_dom.h | 4 +-- .../test/unittest/mock/transform_mock.cpp | 4 +-- .../transition/transition_element_test.cpp | 34 +------------------ .../inspector/inspector_composed_element.cpp | 16 ++++----- frameworks/core/image/image_provider.cpp | 1 - frameworks/core/pipeline/base/measurable.h | 6 ++-- .../kits/plugincomponent/js_plugin_util.cpp | 8 +++-- 33 files changed, 106 insertions(+), 133 deletions(-) diff --git a/adapter/ohos/entrance/ace_container.cpp b/adapter/ohos/entrance/ace_container.cpp index c54ce71d..6488a97e 100644 --- a/adapter/ohos/entrance/ace_container.cpp +++ b/adapter/ohos/entrance/ace_container.cpp @@ -133,26 +133,24 @@ void AceContainer::Destroy() { ContainerScope scope(instanceId_); if (pipelineContext_ && taskExecutor_) { - if (taskExecutor_) { - // 1. Destroy Pipeline on UI thread. - RefPtr context; - context.Swap(pipelineContext_); - taskExecutor_->PostTask([context]() { context->Destroy(); }, TaskExecutor::TaskType::UI); + // 1. Destroy Pipeline on UI thread. + RefPtr context; + context.Swap(pipelineContext_); + taskExecutor_->PostTask([context]() { context->Destroy(); }, TaskExecutor::TaskType::UI); - if (isSubContainer_) { - // SubAcecontainer just return. - return; - } - // 2. Destroy Frontend on JS thread. - RefPtr frontend; - frontend_.Swap(frontend); - taskExecutor_->PostTask( - [frontend]() { - frontend->UpdateState(Frontend::State::ON_DESTROY); - frontend->Destroy(); - }, - TaskExecutor::TaskType::JS); + if (isSubContainer_) { + // SubAcecontainer just return. + return; } + // 2. Destroy Frontend on JS thread. + RefPtr frontend; + frontend_.Swap(frontend); + taskExecutor_->PostTask( + [frontend]() { + frontend->UpdateState(Frontend::State::ON_DESTROY); + frontend->Destroy(); + }, + TaskExecutor::TaskType::JS); } resRegister_.Reset(); assetManager_.Reset(); diff --git a/adapter/preview/inspector/js_inspector_manager.cpp b/adapter/preview/inspector/js_inspector_manager.cpp index 1b24fe6a..03bbb77f 100644 --- a/adapter/preview/inspector/js_inspector_manager.cpp +++ b/adapter/preview/inspector/js_inspector_manager.cpp @@ -294,6 +294,9 @@ const WeakPtr& JsInspectorManager::GetRootElement() return nullptr; } auto InspectorComponentElement = GetInspectorElementById(child.front()->GetNodeId()); + if (!InspectorComponentElement) { + return nullptr; + } return InspectorComponentElement->GetElementParent(); } diff --git a/build/BUILD.gn b/build/BUILD.gn index 6bf41d90..650cd24e 100644 --- a/build/BUILD.gn +++ b/build/BUILD.gn @@ -155,7 +155,7 @@ foreach(item, ace_platforms) { } } -# Config for reduceing eh_frame section on android platform to save rom size. +# Config for reduceing eh_frame section on aosp platform to save rom size. config("reduce_eh_frame_config") { if (!use_mingw_win && !use_mac) { cflags = [ diff --git a/frameworks/base/i18n/localization.cpp b/frameworks/base/i18n/localization.cpp index 0dcc03d2..3b6da486 100644 --- a/frameworks/base/i18n/localization.cpp +++ b/frameworks/base/i18n/localization.cpp @@ -572,7 +572,7 @@ LunarDate Localization::GetLunarDate(Date date) // 0 means January, 1 means February, so month + 1 dateRet.month = static_cast(lunarMonth) + 1; dateRet.day = static_cast(lunarDate); - dateRet.isLeapMonth = isLeapMonth == 0 ? false : true; + dateRet.isLeapMonth = !(isLeapMonth == 0); return dateRet; } diff --git a/frameworks/base/resource/ace_res_config.cpp b/frameworks/base/resource/ace_res_config.cpp index 5862dafd..a869d673 100644 --- a/frameworks/base/resource/ace_res_config.cpp +++ b/frameworks/base/resource/ace_res_config.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -628,7 +628,7 @@ bool MatchResConfig(const AceResConfig& desired, const AceResConfig& supported) !IsResolutionMatch(desired, supported)); } -bool DeclaritiveMatchResConfig(const AceResConfig& desired, const AceResConfig& supported) +bool DeclarativeMatchResConfig(const AceResConfig& desired, const AceResConfig& supported) { return !(!IsOrientationMatch(desired, supported) || !IsDeviceTypeMatch(desired, supported)); } @@ -875,7 +875,7 @@ void AceResConfig::MatchAndSortDeclarativeResConfigs(const std::set int32_t candidateConfigSize = static_cast(matchedLocaleConfigs.size()); std::vector matchedResConfigs; for (auto i = 0; i < candidateConfigSize; i++) { - if (!DeclaritiveMatchResConfig(deviceResConfig, matchedLocaleConfigs[i])) { + if (!DeclarativeMatchResConfig(deviceResConfig, matchedLocaleConfigs[i])) { continue; } else { matchedResConfigs.emplace_back(matchedLocaleConfigs[i]); diff --git a/frameworks/base/subwindow/subwindow_manager.cpp b/frameworks/base/subwindow/subwindow_manager.cpp index 4fe9316f..243249b7 100644 --- a/frameworks/base/subwindow/subwindow_manager.cpp +++ b/frameworks/base/subwindow/subwindow_manager.cpp @@ -94,7 +94,7 @@ int32_t SubwindowManager::GetParentContainerId(int32_t containerId) void SubwindowManager::AddSubwindow(int32_t instanceId, RefPtr subwindow) { if (!subwindow) { - LOGE("Add subwindow failed, the subwndow is null."); + LOGE("Add subwindow failed, the subwindow is null."); return; } LOGI("Add subwindow into map, instanceId is %{public}d, subwindow id is %{public}d.", instanceId, diff --git a/frameworks/bridge/common/accessibility/accessibility_node_manager.cpp b/frameworks/bridge/common/accessibility/accessibility_node_manager.cpp index 481e3408..15619669 100644 --- a/frameworks/bridge/common/accessibility/accessibility_node_manager.cpp +++ b/frameworks/bridge/common/accessibility/accessibility_node_manager.cpp @@ -734,7 +734,7 @@ bool AccessibilityNodeManager::GetDefaultAttrsByType( void AccessibilityNodeManager::DumpTree(int32_t depth, NodeId nodeID) { if (!DumpLog::GetInstance().GetDumpFile()) { - LOGE("AccessibilityNodeManager::GetDumpFile fail:%p", &(DumpLog::GetInstance())); + LOGE("AccessibilityNodeManager::GetDumpFile fail"); return; } diff --git a/frameworks/bridge/common/dom/dom_list_item.cpp b/frameworks/bridge/common/dom/dom_list_item.cpp index 33160341..d35477e5 100644 --- a/frameworks/bridge/common/dom/dom_list_item.cpp +++ b/frameworks/bridge/common/dom/dom_list_item.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -348,7 +348,7 @@ void DOMListItem::ResetInitializedStyle() if (style.IsValid() && style.padding.IsEffective()) { return; } - // Add theme padding to item when not set customised padding. + // Add theme padding to item when not set customized padding. double additionalPadding = itemTheme->GetItemPaddingInPercent(); boxComponent_->SetPadding(Edge(), Edge(Dimension(additionalPadding, DimensionUnit::PERCENT))); } diff --git a/frameworks/bridge/common/dom/dom_picker_base.cpp b/frameworks/bridge/common/dom/dom_picker_base.cpp index de72da61..fc518045 100644 --- a/frameworks/bridge/common/dom/dom_picker_base.cpp +++ b/frameworks/bridge/common/dom/dom_picker_base.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -307,7 +307,7 @@ bool DOMPickerBase::SetOptionStyleOperators(const std::pair& style) +bool DOMPickerBase::SetTextBackgroundColor(const std::pair& style) { if (style.first != DOM_BACKGROUND_COLOR) { return false; @@ -385,7 +385,7 @@ bool DOMPickerBase::SetTextStyleOperators(const std::pair& style); - bool SetTextBackgoundColor(const std::pair& style); + bool SetTextBackgroundColor(const std::pair& style); bool SetColumnHeight(const std::pair& style); bool hasValue_ = true; diff --git a/frameworks/bridge/common/dom/dom_progress.cpp b/frameworks/bridge/common/dom/dom_progress.cpp index 52908f63..e464382a 100644 --- a/frameworks/bridge/common/dom/dom_progress.cpp +++ b/frameworks/bridge/common/dom/dom_progress.cpp @@ -291,7 +291,7 @@ void DOMProgress::InitProgressIfNeed() { auto theme = GetTheme(); if (type_ == ProgressType::CIRCLE) { - // Width_ and height_ in circluar progress are usually the same with diameter in loading progress component. + // Width_ and height_ in circular progress are usually the same with diameter in loading progress component. // If width_ and height_ are different, choose smaller one as diameter. if (!loadingProgressChild_) { loadingProgressChild_ = AceType::MakeRefPtr(); diff --git a/frameworks/bridge/common/dom/input/dom_checkbox_util.cpp b/frameworks/bridge/common/dom/input/dom_checkbox_util.cpp index 75a19cff..67317108 100644 --- a/frameworks/bridge/common/dom/input/dom_checkbox_util.cpp +++ b/frameworks/bridge/common/dom/input/dom_checkbox_util.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -53,11 +53,11 @@ RefPtr DOMCheckboxUtil::CreateComponentAndSetChildAttr( component->SetHorizontalPadding(Dimension(0)); component->SetHotZoneVerticalPadding(Dimension(0)); } - if (LessOrEqual(node.GetWidth().Value(), 0.0)) { + if (LessOrEqual(node.GetWidth().Value(), 0.0) && boxComponent) { node.SetWidth(theme->GetWidth()); boxComponent->SetWidth(theme->GetWidth().Value(), theme->GetWidth().Unit()); } - if (LessOrEqual(node.GetHeight().Value(), 0.0)) { + if (LessOrEqual(node.GetHeight().Value(), 0.0) && boxComponent) { node.SetHeight(theme->GetHeight()); boxComponent->SetHeight(theme->GetHeight().Value(), theme->GetHeight().Unit()); } diff --git a/frameworks/bridge/common/utils/utils.cpp b/frameworks/bridge/common/utils/utils.cpp index 5d5ea947..f8a96a1b 100644 --- a/frameworks/bridge/common/utils/utils.cpp +++ b/frameworks/bridge/common/utils/utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -441,7 +441,7 @@ std::optional ParseRadialGradientSize(const std::string& value) return std::nullopt; } -// ObjectPosiotion +// ObjectPosition ImageObjectPosition ParseImageObjectPosition(const std::string& value) { ImageObjectPosition imageObjectPosition; diff --git a/frameworks/bridge/declarative_frontend/engine/functions/js_on_area_change_function.cpp b/frameworks/bridge/declarative_frontend/engine/functions/js_on_area_change_function.cpp index 1faae803..326656d7 100644 --- a/frameworks/bridge/declarative_frontend/engine/functions/js_on_area_change_function.cpp +++ b/frameworks/bridge/declarative_frontend/engine/functions/js_on_area_change_function.cpp @@ -21,7 +21,7 @@ namespace OHOS::Ace::Framework { namespace { -JSRef CreareAreaObject(const Rect& rect, const Offset& origin) +JSRef CreateAreaObject(const Rect& rect, const Offset& origin) { JSRef objectTemplate = JSRef::New(); JSRef area = objectTemplate->NewInstance(); @@ -47,8 +47,8 @@ JSRef CreareAreaObject(const Rect& rect, const Offset& origin) void JsOnAreaChangeFunction::Execute( const Rect& oldRect, const Offset& oldOrigin, const Rect& rect, const Offset& origin) { - auto oldArea = CreareAreaObject(oldRect, oldOrigin); - auto area = CreareAreaObject(rect, origin); + auto oldArea = CreateAreaObject(oldRect, oldOrigin); + auto area = CreateAreaObject(rect, origin); JSRef params[2]; params[0] = oldArea; params[1] = area; diff --git a/frameworks/bridge/declarative_frontend/engine/quickjs/modules/qjs_module_manager.cpp b/frameworks/bridge/declarative_frontend/engine/quickjs/modules/qjs_module_manager.cpp index e7cc8fa6..e13d9285 100644 --- a/frameworks/bridge/declarative_frontend/engine/quickjs/modules/qjs_module_manager.cpp +++ b/frameworks/bridge/declarative_frontend/engine/quickjs/modules/qjs_module_manager.cpp @@ -39,7 +39,7 @@ JSValue AppGetInfo(JSContext* ctx, JSValue value, int32_t argc, JSValueConst* ar { auto* instance = static_cast(JS_GetContextOpaque(ctx)); if (instance == nullptr) { - LOGE("Can not cast Context to QJSDelcarativeEngineInstance object."); + LOGE("Can not cast Context to QJSDeclarativeEngineInstance object."); return JS_NULL; } auto delegate = instance->GetDelegate(); @@ -63,7 +63,7 @@ JSValue AppTerminate(JSContext* ctx, JSValue value, int32_t argc, JSValueConst* { auto* instance = static_cast(JS_GetContextOpaque(ctx)); if (instance == nullptr) { - LOGE("Can not cast Context to QJSDelcarativeEngineInstance object."); + LOGE("Can not cast Context to QJSDeclarativeEngineInstance object."); return JS_NULL; } auto delegate = instance->GetDelegate(); @@ -157,7 +157,7 @@ JSValue AppSetImageCacheCount(JSContext* ctx, JSValue value, int32_t argc, JSVal { auto* instance = static_cast(JS_GetContextOpaque(ctx)); if (instance == nullptr) { - LOGE("Can not cast Context to QJSDelcarativeEngineInstance object."); + LOGE("Can not cast Context to QJSDeclarativeEngineInstance object."); return JS_NULL; } auto delegate = instance->GetDelegate(); @@ -193,7 +193,7 @@ JSValue AppSetImageRawDataCacheSize(JSContext* ctx, JSValue value, int32_t argc, { auto* instance = static_cast(JS_GetContextOpaque(ctx)); if (instance == nullptr) { - LOGE("Can not cast Context to QJSDelcarativeEngineInstance object."); + LOGE("Can not cast Context to QJSDeclarativeEngineInstance object."); return JS_NULL; } auto delegate = instance->GetDelegate(); @@ -229,7 +229,7 @@ JSValue AppSetImageFileCacheSize(JSContext* ctx, JSValue value, int32_t argc, JS { auto* instance = static_cast(JS_GetContextOpaque(ctx)); if (instance == nullptr) { - LOGE("Can not cast Context to QJSDelcarativeEngineInstance object."); + LOGE("Can not cast Context to QJSDeclarativeEngineInstance object."); return JS_NULL; } auto delegate = instance->GetDelegate(); diff --git a/frameworks/bridge/declarative_frontend/engine/quickjs/modules/qjs_router_module.cpp b/frameworks/bridge/declarative_frontend/engine/quickjs/modules/qjs_router_module.cpp index 5afe1239..4a85d568 100644 --- a/frameworks/bridge/declarative_frontend/engine/quickjs/modules/qjs_router_module.cpp +++ b/frameworks/bridge/declarative_frontend/engine/quickjs/modules/qjs_router_module.cpp @@ -190,7 +190,7 @@ JSValue PageGetParams(JSContext* ctx, JSValueConst value, int32_t argc, JSValueC { auto* instance = static_cast(JS_GetContextOpaque(ctx)); if (instance == nullptr) { - LOGE("Can not cast Context to QJSDelcarativeEngineInstance object."); + LOGE("Can not cast Context to QJSDeclarativeEngineInstance object."); return JS_NULL; } std::string paramsStr = instance->GetDelegate()->GetParams(); @@ -207,7 +207,7 @@ JSValue PostponePageTransition(JSContext* ctx, JSValueConst value, int32_t argc, { auto* instance = static_cast(JS_GetContextOpaque(ctx)); if (instance == nullptr) { - LOGE("Can not cast Context to QJSDelcarativeEngineInstance object."); + LOGE("Can not cast Context to QJSDeclarativeEngineInstance object."); return JS_NULL; } instance->GetDelegate()->PostponePageTransition(); @@ -218,7 +218,7 @@ JSValue LaunchPageTransition(JSContext* ctx, JSValueConst value, int32_t argc, J { auto* instance = static_cast(JS_GetContextOpaque(ctx)); if (instance == nullptr) { - LOGE("Can not cast Context to QJSDelcarativeEngineInstance object."); + LOGE("Can not cast Context to QJSDeclarativeEngineInstance object."); return JS_NULL; } instance->GetDelegate()->LaunchPageTransition(); diff --git a/frameworks/bridge/declarative_frontend/engine/v8/v8_bindings.h b/frameworks/bridge/declarative_frontend/engine/v8/v8_bindings.h index 1330b4c8..9d48281b 100644 --- a/frameworks/bridge/declarative_frontend/engine/v8/v8_bindings.h +++ b/frameworks/bridge/declarative_frontend/engine/v8/v8_bindings.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2000 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/frameworks/bridge/declarative_frontend/engine/v8/v8_bindings.inl b/frameworks/bridge/declarative_frontend/engine/v8/v8_bindings.inl index c6fab259..ff2c298e 100644 --- a/frameworks/bridge/declarative_frontend/engine/v8/v8_bindings.inl +++ b/frameworks/bridge/declarative_frontend/engine/v8/v8_bindings.inl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -103,8 +103,8 @@ void V8Class::Method(const char* name, R (Base::*func)(Args...), int id) { v8::Isolate* isolate = V8DeclarativeEngineInstance::GetV8Isolate(); std::lock_guard lock(mutex_); - auto& funtionTemplate = functionTemplates_[isolate]; - funtionTemplate.Get(isolate)->PrototypeTemplate()->Set(isolate, name, + auto& functionTemplate = functionTemplates_[isolate]; + functionTemplate.Get(isolate)->PrototypeTemplate()->Set(isolate, name, v8::FunctionTemplate::New(isolate, MethodCallback, v8::Integer::New(isolate, id))); } @@ -114,8 +114,8 @@ void V8Class::CustomMethod(const char* name, MemberFunctionCallback callba { v8::Isolate* isolate = V8DeclarativeEngineInstance::GetV8Isolate(); std::lock_guard lock(mutex_); - auto& funtionTemplate = functionTemplates_[isolate]; - funtionTemplate.Get(isolate)->PrototypeTemplate()->Set(isolate, name, + auto& functionTemplate = functionTemplates_[isolate]; + functionTemplate.Get(isolate)->PrototypeTemplate()->Set(isolate, name, v8::FunctionTemplate::New(isolate, InternalMemberFunctionCallback&>, v8::Integer::New(isolate, id))); @@ -126,8 +126,8 @@ void V8Class::CustomMethod(const char* name, FunctionCallback callback) { v8::Isolate* isolate = V8DeclarativeEngineInstance::GetV8Isolate(); std::lock_guard lock(mutex_); - auto& funtionTemplate = functionTemplates_[isolate]; - funtionTemplate.Get(isolate)->PrototypeTemplate()->Set( + auto& functionTemplate = functionTemplates_[isolate]; + functionTemplate.Get(isolate)->PrototypeTemplate()->Set( isolate, name, v8::FunctionTemplate::New(isolate, callback)); } @@ -137,8 +137,8 @@ void V8Class::CustomMethod(const char* name, JSMemberFunctionCallback call { v8::Isolate* isolate = V8DeclarativeEngineInstance::GetV8Isolate(); std::lock_guard lock(mutex_); - auto& funtionTemplate = functionTemplates_[isolate]; - funtionTemplate.Get(isolate)->PrototypeTemplate()->Set(isolate, name, + auto& functionTemplate = functionTemplates_[isolate]; + functionTemplate.Get(isolate)->PrototypeTemplate()->Set(isolate, name, v8::FunctionTemplate::New( isolate, InternalMemberFunctionCallback, v8::Integer::New(isolate, id))); } @@ -150,9 +150,9 @@ void V8Class::CustomProperty(const char* name, MemberFunctionGetCallback c { v8::Isolate* isolate = V8DeclarativeEngineInstance::GetV8Isolate(); std::lock_guard lock(mutex_); - auto& funtionTemplate = functionTemplates_[isolate]; + auto& functionTemplate = functionTemplates_[isolate]; - funtionTemplate.Get(isolate)->PrototypeTemplate()->SetAccessorProperty( + functionTemplate.Get(isolate)->PrototypeTemplate()->SetAccessorProperty( v8::Local::Cast(V8ValueConvertor::toV8Value(name)), v8::FunctionTemplate::New(isolate, InternalMemberFunctionCallback&>, @@ -167,8 +167,8 @@ void V8Class::CustomProperty(const char* name, FunctionGetCallback getter, Fu { v8::Isolate* isolate = V8DeclarativeEngineInstance::GetV8Isolate(); std::lock_guard lock(mutex_); - auto& funtionTemplate = functionTemplates_[isolate]; - funtionTemplate.Get(isolate)->PrototypeTemplate()->SetAccessorProperty( + auto& functionTemplate = functionTemplates_[isolate]; + functionTemplate.Get(isolate)->PrototypeTemplate()->SetAccessorProperty( v8::Local::Cast(V8ValueConvertor::toV8Value(name)), v8::FunctionTemplate::New(isolate, getter), v8::FunctionTemplate::New(isolate, setter)); @@ -181,8 +181,8 @@ void V8Class::CustomProperty(const char* name, JSMemberFunctionCallback ca { v8::Isolate* isolate = V8DeclarativeEngineInstance::GetV8Isolate(); std::lock_guard lock(mutex_); - auto& funtionTemplate = functionTemplates_[isolate]; - funtionTemplate.Get(isolate)->PrototypeTemplate()->SetAccessorProperty( + auto& functionTemplate = functionTemplates_[isolate]; + functionTemplate.Get(isolate)->PrototypeTemplate()->SetAccessorProperty( v8::Local::Cast(V8ValueConvertor::toV8Value(name)), v8::FunctionTemplate::New( isolate, InternalMemberFunctionCallback, v8::Integer::New(isolate, getterId)), diff --git a/frameworks/bridge/declarative_frontend/jsview/js_textinput.h b/frameworks/bridge/declarative_frontend/jsview/js_textinput.h index 8146bd4a..d1e7aa0d 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_textinput.h +++ b/frameworks/bridge/declarative_frontend/jsview/js_textinput.h @@ -72,5 +72,5 @@ private: ACE_DISALLOW_COPY_AND_MOVE(JSTextInputController); }; -} // namespace OHOS::Ace::Fremawork +} // namespace OHOS::Ace::Framework #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_TEXTINPUT_H \ No newline at end of file diff --git a/frameworks/core/common/register/hdc_jdwp.cpp b/frameworks/core/common/register/hdc_jdwp.cpp index 49a15f55..0a224aeb 100644 --- a/frameworks/core/common/register/hdc_jdwp.cpp +++ b/frameworks/core/common/register/hdc_jdwp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -113,7 +113,7 @@ void HdcJdwpSimulator::ConnectJdwp(uv_connect_t *connection, int status) LOGE("ConnectJdwp new info fail."); return; } - if (memset_s(info, pkgSize, 0, pkgSize) != 0) { + if (memset_s(info, pkgSize, 0, pkgSize) != EOK) { delete[] info; info = nullptr; return; @@ -124,7 +124,7 @@ void HdcJdwpSimulator::ConnectJdwp(uv_connect_t *connection, int status) LOGI("ConnectJdwp send pid:%{public}d, pkgName:%{public}s, msglen:%{public}d, ", jsMsg->pid, pkgName.c_str(), jsMsg->msgLen); bool retFail = false; - if (memcpy_s(info + sizeof(JsMsgHeader), pkgName.size(), &pkgName[0], pkgName.size()) != 0) { + if (memcpy_s(info + sizeof(JsMsgHeader), pkgName.size(), &pkgName[0], pkgName.size()) != EOK) { LOGE("ConnectJdwp memcpy_s fail :%{public}s.", pkgName.c_str()); retFail = true; } 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 2da53603..e5c93075 100644 --- a/frameworks/core/components/custom_paint/flutter_render_custom_paint.cpp +++ b/frameworks/core/components/custom_paint/flutter_render_custom_paint.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -284,8 +284,8 @@ void FlutterRenderCustomPaint::TransferFromImageBitmap(const RefPtr imageData = offscreenCanvas->GetImageData(0, 0, offscreenCanvas->GetWidth(), offscreenCanvas->GetHeight()); - ImageData* imageDataPtr = imageData.get(); if (imageData != nullptr) { + ImageData* imageDataPtr = imageData.get(); PutImageData(Offset(0, 0), *imageDataPtr); } } 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 a76e3ae6..1b1e53a7 100644 --- a/frameworks/core/components/custom_paint/flutter_render_offscreen_canvas.cpp +++ b/frameworks/core/components/custom_paint/flutter_render_offscreen_canvas.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -74,7 +74,7 @@ std::string GetMimeType(const std::string& args) } // Quality need between 0.0 and 1.0 for MimeType jpeg and webp -double GetQuality(const std::string args, const double quality) +double GetQuality(const std::string& args, const double quality) { std::string type = args; auto mimeType = GetMimeType(type); 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 91a8bf72..0c01c3b2 100644 --- a/frameworks/core/components/custom_paint/rosen_render_custom_paint.cpp +++ b/frameworks/core/components/custom_paint/rosen_render_custom_paint.cpp @@ -1554,11 +1554,11 @@ void RosenRenderCustomPaint::Mesh(SkBitmap& bitmap, int column, int row, flags |= SkVertices::kHasColors_BuilderFlag; } SkVertices::Builder builder(SkVertices::kTriangles_VertexMode, vertCounts, indexCount, flags); - if (memcpy_s(builder.positions(), vertCounts * sizeof(SkPoint), vertices, vertCounts * sizeof(SkPoint)) != 0) { + if (memcpy_s(builder.positions(), vertCounts * sizeof(SkPoint), vertices, vertCounts * sizeof(SkPoint)) != EOK) { return; } if (colors) { - if (memcpy_s(builder.colors(), vertCounts * sizeof(SkColor), colors, vertCounts * sizeof(SkColor)) != 0) { + if (memcpy_s(builder.colors(), vertCounts * sizeof(SkColor), colors, vertCounts * sizeof(SkColor)) != EOK) { return; } } 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 1ce84667..eb7c6c2f 100644 --- a/frameworks/core/components/custom_paint/rosen_render_offscreen_canvas.cpp +++ b/frameworks/core/components/custom_paint/rosen_render_offscreen_canvas.cpp @@ -73,7 +73,7 @@ std::string GetMimeType(const std::string& args) } // Quality need between 0.0 and 1.0 for MimeType jpeg and webp -double GetQuality(const std::string args, const double quality) +double GetQuality(const std::string& args, const double quality) { std::string type = args; auto mimeType = GetMimeType(type); diff --git a/frameworks/core/components/font/constants_converter.cpp b/frameworks/core/components/font/constants_converter.cpp index b608ac5a..e989c6be 100644 --- a/frameworks/core/components/font/constants_converter.cpp +++ b/frameworks/core/components/font/constants_converter.cpp @@ -209,8 +209,9 @@ void ConvertTxtStyle(const TextStyle& textStyle, const WeakPtr& txtStyle.word_spacing = textStyle.GetWordSpacing().Value(); } } - - txtStyle.letter_spacing = pipelineContext->NormalizeToPx(textStyle.GetLetterSpacing()); + if (pipelineContext) { + txtStyle.letter_spacing = pipelineContext->NormalizeToPx(textStyle.GetLetterSpacing()); + } txtStyle.text_baseline = ConvertTxtTextBaseline(textStyle.GetTextBaseline()); txtStyle.decoration = ConvertTxtTextDecoration(textStyle.GetTextDecoration()); txtStyle.decoration_color = ConvertSkColor(textStyle.GetTextDecorationColor()); diff --git a/frameworks/core/components/form/sub_container.cpp b/frameworks/core/components/form/sub_container.cpp index bd16da63..78bf0e7d 100644 --- a/frameworks/core/components/form/sub_container.cpp +++ b/frameworks/core/components/form/sub_container.cpp @@ -83,22 +83,22 @@ void SubContainer::Destroy() void SubContainer::UpdateRootElmentSize() { auto formComponet = AceType::DynamicCast(formComponent_); - Dimension rootWidht = 0.0_vp; + Dimension rootWidth = 0.0_vp; Dimension rootHeight = 0.0_vp; if (formComponet) { - rootWidht = formComponet->GetWidth(); + rootWidth = formComponet->GetWidth(); rootHeight = formComponet->GetHeight(); } - if (rootWidht_ == rootWidht && rootHeight == rootHeight) { + if (rootWidht_ == rootWidth && rootHeight_ == rootHeight) { LOGE("size not changed, should not change"); return; } - surfaceWidth_ = outSidePipelineContext_.Upgrade()->NormalizeToPx(rootWidht); + surfaceWidth_ = outSidePipelineContext_.Upgrade()->NormalizeToPx(rootWidth); surfaceHeight_ = outSidePipelineContext_.Upgrade()->NormalizeToPx(rootHeight); if (pipelineContext_) { - pipelineContext_->SetRootSize(density_, rootWidht.Value(), rootHeight.Value()); + pipelineContext_->SetRootSize(density_, rootWidth.Value(), rootHeight.Value()); } } diff --git a/frameworks/core/components/svg/parse/svg_dom.h b/frameworks/core/components/svg/parse/svg_dom.h index 76499214..0ff391d4 100644 --- a/frameworks/core/components/svg/parse/svg_dom.h +++ b/frameworks/core/components/svg/parse/svg_dom.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -39,7 +39,7 @@ struct SvgRadius { bool IsValid() const { - return topLeft.IsValid() || topLeft.IsValid() || topLeft.IsValid() || topLeft.IsValid(); + return topLeft.IsValid() || topRight.IsValid() || bottomLeft.IsValid() || bottomRight.IsValid(); } }; diff --git a/frameworks/core/components/test/unittest/mock/transform_mock.cpp b/frameworks/core/components/test/unittest/mock/transform_mock.cpp index f7373507..9fdf8cd0 100644 --- a/frameworks/core/components/test/unittest/mock/transform_mock.cpp +++ b/frameworks/core/components/test/unittest/mock/transform_mock.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -53,7 +53,7 @@ void RenderTransform::Translate(const Dimension& x, const Dimension& y) void RenderTransform::Scale(float value) { - LOGD("TransformMock Scale. scale: %{public}f, this:%p", value, this); + LOGD("TransformMock Scale. scale: %{public}f", value); auto mock = AceType::DynamicCast(this); if (mock) { mock->MockScale(value); diff --git a/frameworks/core/components/test/unittest/transition/transition_element_test.cpp b/frameworks/core/components/test/unittest/transition/transition_element_test.cpp index a7b60edf..3599b61b 100644 --- a/frameworks/core/components/test/unittest/transition/transition_element_test.cpp +++ b/frameworks/core/components/test/unittest/transition/transition_element_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -857,8 +857,6 @@ protected: * @tc.name: PushPageTest001 * @tc.desc: test scale animation in tween. * @tc.type: FUNC - * @tc.require: AR000DAIGV - * @tc.author: zhouzebin */ HWTEST_F(TransitionElementTest, PushPageTest001, TestSize.Level1) { @@ -897,10 +895,6 @@ HWTEST_F(TransitionElementTest, PushPageTest001, TestSize.Level1) GetTransitionGroupFromTransition(transitionB_); GetTransitionGroupFromTransition(transitionA_); EXPECT_NE(transitionA_.pageTransitionElement_, transitionB_.pageTransitionElement_); - LOGD("transition in: content display render %{public}p, transform render %{public}p", - &(*transitionB_.displayRenderContent_.Upgrade()), &(*transitionB_.transformRenderContent_.Upgrade())); - LOGD("transition out: content display render %{public}p, transform render %{public}p", - &(*transitionA_.displayRenderContent_.Upgrade()), &(*transitionA_.transformRenderContent_.Upgrade())); EXPECT_TRUE(transitionB_.displayRenderContent_.Upgrade()->GetHidden()); EXPECT_EQ(VisibleType::VISIBLE, transitionA_.displayRenderContent_.Upgrade()->GetVisibleType()); @@ -923,8 +917,6 @@ HWTEST_F(TransitionElementTest, PushPageTest001, TestSize.Level1) * @tc.name: PushPageTest002 * @tc.desc: test translate animation in tween. * @tc.type: FUNC - * @tc.require: AR000DQ1VJ - * @tc.author: jiangdayuan */ HWTEST_F(TransitionElementTest, PushPageTest002, TestSize.Level1) { @@ -961,8 +953,6 @@ HWTEST_F(TransitionElementTest, PushPageTest002, TestSize.Level1) * @tc.name: TransitionUIStandardTest001 * @tc.desc: test ui standard for transition * @tc.type: FUNC - * @tc.require: AR000DBTLT - * @tc.author: zhouzebin */ HWTEST_F(TransitionElementTest, TransitionUIStandardTest001, TestSize.Level1) { @@ -1017,8 +1007,6 @@ HWTEST_F(TransitionElementTest, TransitionUIStandardTest001, TestSize.Level1) * @tc.name: TransitionUIStandardTest002 * @tc.desc: test phone push transition * @tc.type: FUNC - * @tc.require: AR000DQ1VF - * @tc.author: zhouzebin */ HWTEST_F(TransitionElementTest, TransitionUIStandardTest002, TestSize.Level1) { @@ -1070,8 +1058,6 @@ HWTEST_F(TransitionElementTest, TransitionUIStandardTest002, TestSize.Level1) * @tc.name: TransitionUIStandardTest003 * @tc.desc: test watch push transition * @tc.type: FUNC - * @tc.require: AR000DQ1VG - * @tc.author: jiangdayuan */ HWTEST_F(TransitionElementTest, TransitionUIStandardTest003, TestSize.Level1) { @@ -1123,8 +1109,6 @@ HWTEST_F(TransitionElementTest, TransitionUIStandardTest003, TestSize.Level1) * @tc.name: TransitionUIStandardTest004 * @tc.desc: test watch pop transition * @tc.type: FUNC - * @tc.require: AR000DR6DE - * @tc.author: jiangdayuan */ HWTEST_F(TransitionElementTest, TransitionUIStandardTest004, TestSize.Level1) { @@ -1148,8 +1132,6 @@ HWTEST_F(TransitionElementTest, TransitionUIStandardTest004, TestSize.Level1) * @tc.name: TransitionUIStandardTest005 * @tc.desc: test phone pop transition * @tc.type: FUNC - * @tc.require: AR000DQ1VE - * @tc.author: jiangdayuan */ HWTEST_F(TransitionElementTest, TransitionUIStandardTest005, TestSize.Level1) { @@ -1174,8 +1156,6 @@ HWTEST_F(TransitionElementTest, TransitionUIStandardTest005, TestSize.Level1) * @tc.name: OneShotTransitionTest001 * @tc.desc: test tv push transition with shared element with custom page transition parameters. * @tc.type: FUNC - * @tc.require: AR000DR6TF - * @tc.author: zhouzebin */ HWTEST_F(TransitionElementTest, OneShotTransitionTest001, TestSize.Level1) { @@ -1221,8 +1201,6 @@ HWTEST_F(TransitionElementTest, OneShotTransitionTest001, TestSize.Level1) * @tc.name: OneShotTransitionTest002 * @tc.desc: test phone pop transition with shared element with default page transition parameters. * @tc.type: FUNC - * @tc.require: AR000DQ2TV - * @tc.author: zhouzebin */ HWTEST_F(TransitionElementTest, OneShotTransitionTest002, TestSize.Level1) { @@ -1250,8 +1228,6 @@ HWTEST_F(TransitionElementTest, OneShotTransitionTest002, TestSize.Level1) * @tc.name: OneShotTransitionTest003 * @tc.desc: test watch pop transition with shared element with default page transition parameters. * @tc.type: FUNC - * @tc.require: AR000DQ203 - * @tc.author: zhouzebin */ HWTEST_F(TransitionElementTest, OneShotTransitionTest003, TestSize.Level1) { @@ -1279,8 +1255,6 @@ HWTEST_F(TransitionElementTest, OneShotTransitionTest003, TestSize.Level1) * @tc.name: PushPageCardTransitionTest001 * @tc.desc: test card container size and offset animation in card push transition. * @tc.type: FUNC - * @tc.require: AR000F3C9H - * @tc.author: chenlien */ HWTEST_F(TransitionElementTest, PushPageCardTransitionTest001, TestSize.Level1) { @@ -1321,8 +1295,6 @@ HWTEST_F(TransitionElementTest, PushPageCardTransitionTest001, TestSize.Level1) * @tc.name: PushPageCardTransitionTest002 * @tc.desc: test Opacity animation in card push transition. * @tc.type: FUNC - * @tc.require: AR000F3C9H - * @tc.author: chenlien */ HWTEST_F(TransitionElementTest, PushPageCardTransitionTest002, TestSize.Level1) { @@ -1363,8 +1335,6 @@ HWTEST_F(TransitionElementTest, PushPageCardTransitionTest002, TestSize.Level1) * @tc.name: PopPageCardTransitionTest001 * @tc.desc: test clip size and offset animation in card pop transition. * @tc.type: FUNC - * @tc.require: AR000F3CA6 - * @tc.author: chenlien */ HWTEST_F(TransitionElementTest, PopPageCardTransitionTest001, TestSize.Level1) { @@ -1398,8 +1368,6 @@ HWTEST_F(TransitionElementTest, PopPageCardTransitionTest001, TestSize.Level1) * @tc.name: PopPageCardTransitionTest002 * @tc.desc: test opacity animation in card pop transition. * @tc.type: FUNC - * @tc.require: AR000F3CA6 - * @tc.author: chenlien */ HWTEST_F(TransitionElementTest, PopPageCardTransitionTest002, TestSize.Level1) { diff --git a/frameworks/core/components_v2/inspector/inspector_composed_element.cpp b/frameworks/core/components_v2/inspector/inspector_composed_element.cpp index f741270a..0cc48a13 100644 --- a/frameworks/core/components_v2/inspector/inspector_composed_element.cpp +++ b/frameworks/core/components_v2/inspector/inspector_composed_element.cpp @@ -869,22 +869,22 @@ std::unique_ptr InspectorComposedElement::GetBackgroundImagePosition( std::unique_ptr InspectorComposedElement::GetAlignmentType(double width, double height) const { auto jsonValue = JsonUtil::Create(false); - if (width == 0) { - if (height == 0) { + if (NearZero(width)) { + if (NearZero(height)) { jsonValue->Put("x", "Alignment.TopStart"); return jsonValue->GetValue("x"); - } else if (height == 50) { + } else if (NearEqual(height, 50.0)) { // Determine whether the vertical element is centered jsonValue->Put("x", "Alignment.Start"); return jsonValue->GetValue("x"); } else { jsonValue->Put("x", "Alignment.BottomStart"); return jsonValue->GetValue("x"); } - } else if (width == 50) { - if (height == 0) { + } else if (NearEqual(width, 50.0)) { // Judge whether the horizontal element is centered + if (NearZero(height)) { jsonValue->Put("x", "Alignment.Top"); return jsonValue->GetValue("x"); - } else if (height == 50) { + } else if (NearEqual(height, 50)) { jsonValue->Put("x", "Alignment.Center"); return jsonValue->GetValue("x"); } else { @@ -892,10 +892,10 @@ std::unique_ptr InspectorComposedElement::GetAlignmentType(double wid return jsonValue->GetValue("x"); } } else { - if (height == 0) { + if (NearZero(height)) { jsonValue->Put("x", "Alignment.TopEnd"); return jsonValue->GetValue("x"); - } else if (height == 50) { + } else if (NearEqual(height, 50.0)) { jsonValue->Put("x", "Alignment.End"); return jsonValue->GetValue("x"); } else { diff --git a/frameworks/core/image/image_provider.cpp b/frameworks/core/image/image_provider.cpp index 0491fe38..f71ee660 100644 --- a/frameworks/core/image/image_provider.cpp +++ b/frameworks/core/image/image_provider.cpp @@ -256,7 +256,6 @@ void ImageProvider::UploadImageToGPUForRender( // If want to dump draw command or gpu disabled, should use CPU image. callback({ image, renderTaskHolder->unrefQueue }); #else - auto rasterizedImage = image->makeRasterImage(); if (!rasterizedImage) { LOGW("Rasterize image failed. callback."); diff --git a/frameworks/core/pipeline/base/measurable.h b/frameworks/core/pipeline/base/measurable.h index 033bbc59..942b4fce 100644 --- a/frameworks/core/pipeline/base/measurable.h +++ b/frameworks/core/pipeline/base/measurable.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef ACE_ANDROID_SRC_FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_MEASURABLE_H -#define ACE_ANDROID_SRC_FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_MEASURABLE_H +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_MEASURABLE_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_MEASURABLE_H #include "base/memory/ace_type.h" #include "frameworks/base/geometry/animatable_dimension.h" @@ -92,4 +92,4 @@ protected: } // namespace OHOS::Ace -#endif // ACE_ANDROID_SRC_FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_MEASURABLE_H \ No newline at end of file +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_MEASURABLE_H \ No newline at end of file diff --git a/interfaces/napi/kits/plugincomponent/js_plugin_util.cpp b/interfaces/napi/kits/plugincomponent/js_plugin_util.cpp index 9078b4fb..588d1428 100644 --- a/interfaces/napi/kits/plugincomponent/js_plugin_util.cpp +++ b/interfaces/napi/kits/plugincomponent/js_plugin_util.cpp @@ -233,7 +233,9 @@ std::string AceUnwrapStringFromJS(napi_env env, napi_value param, const std::str if (buf == nullptr) { return value; } - memset_s(buf, size + 1, 0, size + 1); + if (memset_s(buf, size + 1, 0, size + 1) != EOK) { + return value; + } bool rev = napi_get_value_string_utf8(env, param, buf, size + 1, &size) == napi_ok; if (rev) { @@ -263,7 +265,9 @@ bool AceUnwrapStringFromJS2(napi_env env, napi_value param, std::string& value) if (buf == nullptr) { return false; } - memset_s(buf, (size + 1), 0, (size + 1)); + if (memset_s(buf, (size + 1), 0, (size + 1)) != EOK) { + return false; + } bool rev = napi_get_value_string_utf8(env, param, buf, size + 1, &size) == napi_ok; if (rev) {