!35707 0611代码质量加固

Merge pull request !35707 from yangziyong/0611zc
This commit is contained in:
openharmony_ci 2024-06-15 08:54:09 +00:00 committed by Gitee
commit 725a05c9bd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 26 additions and 5 deletions

View File

@ -1243,7 +1243,7 @@ void JSParagraphStyleSpan::ParseJsWordBreak(const JSRef<JSObject>& obj, SpanPara
JSRef<JSVal> args = obj->GetProperty("wordBreak");
int32_t index = WORD_BREAK_TYPES_DEFAULT;
if (args->IsNumber()) {
index = args->ToNumber<int32_t>();
index = static_cast<uint32_t>(args->ToNumber<int32_t>());
}
if (index < 0 || index >= WORD_BREAK_TYPES.size()) {
index = 0;

View File

@ -461,6 +461,9 @@ RefPtr<SpanBase> JSSpanString::ParseJsCustomSpan(int32_t start, int32_t length,
if (paramObj->IsUndefined()) {
return nullptr;
}
if (!paramObj->IsObject()) {
return nullptr;
}
auto styleStringValue = JSRef<JSObject>::Cast(JSRef<JSObject>::Cast(paramObj)->GetProperty("styledValue"));
if (styleStringValue->IsUndefined()) {
return nullptr;
@ -582,6 +585,9 @@ void JSMutableSpanString::Constructor(const JSCallbackInfo& args)
spanString->BindWithSpans(spanBases);
}
} else {
if (!args[0]->IsObject()) {
return;
}
auto* base = JSRef<JSObject>::Cast(args[0])->Unwrap<AceType>();
auto* imageAttachment = AceType::DynamicCast<JSImageAttachment>(base);
if (imageAttachment) {
@ -748,6 +754,9 @@ void JSMutableSpanString::ReplaceSpan(const JSCallbackInfo& info)
if (type == SpanType::CustomSpan && !VerifyCustomSpanParameters(start, length)) {
return;
}
if (!styleValueObj->IsObject()) {
return;
}
auto spanBase = ParseJsSpanBaseWithoutSpecialSpan(start, length, type, JSRef<JSObject>::Cast(styleValueObj), info);
if (!spanBase) {
JSException::Throw(ERROR_CODE_PARAM_INVALID, "%s", "Input parameter check failed.");
@ -789,6 +798,9 @@ void JSMutableSpanString::AddSpan(const JSCallbackInfo& info)
if (type == SpanType::CustomSpan && !VerifyCustomSpanParameters(start, length)) {
return;
}
if (!styleValueObj->IsObject()) {
return;
}
auto spanBase = ParseJsSpanBaseWithoutSpecialSpan(start, length, type, JSRef<JSObject>::Cast(styleValueObj), info);
if (!spanBase) {
JSException::Throw(ERROR_CODE_PARAM_INVALID, "%s", "Input parameter check failed.");

View File

@ -241,7 +241,7 @@ void EventManager::RecordHitEmptyMessage(
windowId = NG::WindowSceneHelper::GetWindowIdForWindowScene(frameNode);
#endif
if (windowId == 0) {
windowId = container->GetWindowId();
windowId = static_cast<int32_t>(container->GetWindowId());
}
hitEmptyMessage->Put("windowId", static_cast<int32_t>(windowId));
auto pipelineContext = container->GetPipelineContext();
@ -1367,7 +1367,7 @@ bool EventManager::IsSystemKeyboardShortcut(const std::string& value, uint8_t ke
}
const std::set<char> forbidValue{'X', 'Y', 'Z', 'A', 'C', 'V'};
char c = std::toupper(value.front());
auto c = std::toupper(value.front());
if (forbidValue.count(c) == 0) {
return false;
}

View File

@ -22,14 +22,17 @@
namespace OHOS::Ace {
std::map<int32_t, std::shared_ptr<std::vector<uint8_t>>> ShareData::shareDataMap_;
std::mutex ShareData::shareDataMapMutex_;
void ShareData::InsertBuffer(int32_t bufferId, std::shared_ptr<std::vector<uint8_t>> dataArray)
{
std::unique_lock<std::mutex> lock(shareDataMapMutex_);
shareDataMap_[bufferId] = dataArray;
}
std::shared_ptr<std::vector<uint8_t>> ShareData::GetShareBufferById(int32_t id)
{
std::unique_lock<std::mutex> lock(shareDataMapMutex_);
auto data = ShareData::shareDataMap_.find(id);
if (data != ShareData::shareDataMap_.end()) {
return data->second;
@ -39,6 +42,7 @@ std::shared_ptr<std::vector<uint8_t>> ShareData::GetShareBufferById(int32_t id)
void ShareData::ReleaseShareBufferById(int32_t id)
{
std::unique_lock<std::mutex> lock(shareDataMapMutex_);
auto data = ShareData::shareDataMap_.find(id);
if (data != ShareData::shareDataMap_.end()) {
ShareData::shareDataMap_.erase(data);

View File

@ -17,6 +17,7 @@
#define FRAMEWORKS_CORE_COMMON_SHARE_DATA_SHARE_DATA_H
#include <map>
#include <mutex>
#include "base/memory/ace_type.h"
@ -36,6 +37,7 @@ public:
private:
static std::map<int32_t, std::shared_ptr<std::vector<uint8_t>>> shareDataMap_;
static std::mutex shareDataMapMutex_;
};
} // namespace OHOS::Ace

View File

@ -2121,7 +2121,7 @@ void DragEventActuator::ShowPreviewBadgeAnimation(
CHECK_NULL_VOID(frameNode);
auto dragPreviewOptions = frameNode->GetDragPreviewOption();
auto badgeNumber = dragPreviewOptions.GetCustomerBadgeNumber();
auto childSize = badgeNumber.has_value() ? badgeNumber.value()
int32_t childSize = badgeNumber.has_value() ? badgeNumber.value()
: static_cast<int32_t>(manager->GetGatherNodeChildrenInfo().size()) + 1;
auto textNode = CreateBadgeTextNode(frameNode, childSize, PIXELMAP_DRAG_SCALE_MULTIPLE, true);
CHECK_NULL_VOID(textNode);

View File

@ -1712,7 +1712,7 @@ void DragDropManager::UpdateGatherNodeAttr(const RefPtr<OverlayManager>& overlay
if (cnt > 1) {
props[cnt - SECOND_GATHER_PIXEL_MAP] = { SECOND_PIXELMAP_ANGLE, SECOND_PIXELMAP_OPACITY };
}
for (uint32_t i = 0; i < cnt; ++i) {
for (int32_t i = 0; i < cnt; ++i) {
auto imageNode = gatherNodeChildrenInfo[i].imageNode.Upgrade();
CHECK_NULL_VOID(imageNode);
auto imageContext = imageNode->GetRenderContext();

View File

@ -57,6 +57,9 @@ void FormRendererDispatcherProxy::DispatchPointerEvent(
HILOG_ERROR("Serialized gesture size is not valid!");
} else {
auto buffer = static_cast<const char*>(reply.ReadRawData(size));
if (buffer == nullptr) {
return;
}
serializedGesture.data = std::vector<char>(buffer, buffer + size);
}