mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-30 02:32:28 +00:00
!48780 安全编码检查问题修改
Merge pull request !48780 from ChenYC009/security_fix
This commit is contained in:
commit
cf074d85fb
@ -133,11 +133,9 @@ void ClipboardImpl::SetPixelMapData(const RefPtr<PixelMap>& pixmap, CopyOptions
|
|||||||
|
|
||||||
void ClipboardImpl::GetData(const std::function<void(const std::string&)>& callback, bool syncMode)
|
void ClipboardImpl::GetData(const std::function<void(const std::string&)>& callback, bool syncMode)
|
||||||
{
|
{
|
||||||
|
CHECK_NULL_VOID(callback);
|
||||||
#ifdef SYSTEM_CLIPBOARD_SUPPORTED
|
#ifdef SYSTEM_CLIPBOARD_SUPPORTED
|
||||||
if (!taskExecutor_ || !callback) {
|
CHECK_NULL_VOID(taskExecutor_);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (syncMode) {
|
if (syncMode) {
|
||||||
GetDataSync(callback);
|
GetDataSync(callback);
|
||||||
} else {
|
} else {
|
||||||
|
@ -99,6 +99,7 @@ void DOMSpan::OnChildNodeAdded(const RefPtr<DOMNode>& child, int32_t slot)
|
|||||||
// Get current span's styles to compare with its parent span.
|
// Get current span's styles to compare with its parent span.
|
||||||
TextStyle currentSpanStyle = spanComponent->GetTextStyle();
|
TextStyle currentSpanStyle = spanComponent->GetTextStyle();
|
||||||
auto domSpan = AceType::DynamicCast<DOMSpan>(child);
|
auto domSpan = AceType::DynamicCast<DOMSpan>(child);
|
||||||
|
CHECK_NULL_VOID(domSpan);
|
||||||
CheckAndSetCurrentSpanStyle(domSpan, currentSpanStyle, parentSpanStyle);
|
CheckAndSetCurrentSpanStyle(domSpan, currentSpanStyle, parentSpanStyle);
|
||||||
domSpan->SetTextStyle(currentSpanStyle);
|
domSpan->SetTextStyle(currentSpanStyle);
|
||||||
spanComponent->SetTextStyle(currentSpanStyle);
|
spanComponent->SetTextStyle(currentSpanStyle);
|
||||||
|
@ -35,6 +35,7 @@ void DOMTextFieldUtil::InitDefaultValue(const RefPtr<BoxComponent>& boxComponent
|
|||||||
const RefPtr<TextFieldComponent>& component, const RefPtr<TextFieldTheme>& theme)
|
const RefPtr<TextFieldComponent>& component, const RefPtr<TextFieldTheme>& theme)
|
||||||
{
|
{
|
||||||
if (!boxComponent || !component || !theme) {
|
if (!boxComponent || !component || !theme) {
|
||||||
|
LOGW("RefPtr of InitDefaultValue is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ namespace OHOS::Ace::NG {
|
|||||||
void HyperlinkModelNG::Create(const std::string& address, const std::string& content)
|
void HyperlinkModelNG::Create(const std::string& address, const std::string& content)
|
||||||
{
|
{
|
||||||
auto* stack = ViewStackProcessor::GetInstance();
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
CHECK_NULL_VOID(stack);
|
||||||
auto nodeId = stack->ClaimNodeId();
|
auto nodeId = stack->ClaimNodeId();
|
||||||
ACE_LAYOUT_SCOPED_TRACE("Create[%s][self:%d]", V2::HYPERLINK_ETS_TAG, nodeId);
|
ACE_LAYOUT_SCOPED_TRACE("Create[%s][self:%d]", V2::HYPERLINK_ETS_TAG, nodeId);
|
||||||
auto hyperlinkNode = FrameNode::GetOrCreateFrameNode(
|
auto hyperlinkNode = FrameNode::GetOrCreateFrameNode(
|
||||||
|
@ -22,6 +22,7 @@ namespace OHOS::Ace::NG {
|
|||||||
void SymbolModelNG::Create(const std::uint32_t& unicode)
|
void SymbolModelNG::Create(const std::uint32_t& unicode)
|
||||||
{
|
{
|
||||||
auto* stack = ViewStackProcessor::GetInstance();
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
CHECK_NULL_VOID(stack);
|
||||||
auto nodeId = stack->ClaimNodeId();
|
auto nodeId = stack->ClaimNodeId();
|
||||||
auto symbolNode = FrameNode::GetOrCreateFrameNode(
|
auto symbolNode = FrameNode::GetOrCreateFrameNode(
|
||||||
V2::SYMBOL_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr<TextPattern>(); });
|
V2::SYMBOL_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr<TextPattern>(); });
|
||||||
|
@ -34,14 +34,19 @@ namespace {
|
|||||||
constexpr int32_t SYMBOL_SPAN_LENGTH = 2;
|
constexpr int32_t SYMBOL_SPAN_LENGTH = 2;
|
||||||
float GetContentOffsetY(LayoutWrapper* layoutWrapper)
|
float GetContentOffsetY(LayoutWrapper* layoutWrapper)
|
||||||
{
|
{
|
||||||
auto size = layoutWrapper->GetGeometryNode()->GetFrameSize();
|
CHECK_NULL_RETURN(layoutWrapper, 0.0f);
|
||||||
const auto& padding = layoutWrapper->GetLayoutProperty()->CreatePaddingAndBorder();
|
auto geometryNode = layoutWrapper->GetGeometryNode();
|
||||||
|
CHECK_NULL_RETURN(geometryNode, 0.0f);
|
||||||
|
auto layoutProperty = layoutWrapper->GetLayoutProperty();
|
||||||
|
CHECK_NULL_RETURN(layoutProperty, 0.0f);
|
||||||
|
auto size = geometryNode->GetFrameSize();
|
||||||
|
const auto& padding = layoutProperty->CreatePaddingAndBorder();
|
||||||
auto offsetY = padding.top.value_or(0);
|
auto offsetY = padding.top.value_or(0);
|
||||||
auto align = Alignment::CENTER;
|
auto align = Alignment::CENTER;
|
||||||
if (layoutWrapper->GetLayoutProperty()->GetPositionProperty()) {
|
if (layoutProperty->GetPositionProperty()) {
|
||||||
align = layoutWrapper->GetLayoutProperty()->GetPositionProperty()->GetAlignment().value_or(align);
|
align = layoutProperty->GetPositionProperty()->GetAlignment().value_or(align);
|
||||||
}
|
}
|
||||||
const auto& content = layoutWrapper->GetGeometryNode()->GetContent();
|
const auto& content = geometryNode->GetContent();
|
||||||
if (content) {
|
if (content) {
|
||||||
offsetY += Alignment::GetAlignPosition(size, content->GetRect().GetSize(), align).GetY();
|
offsetY += Alignment::GetAlignPosition(size, content->GetRect().GetSize(), align).GetY();
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,9 @@ RefPtr<SpanBase> FontSpan::GetSubSpan(int32_t start, int32_t end)
|
|||||||
|
|
||||||
void FontSpan::AddSpanStyle(const RefPtr<NG::SpanItem>& spanItem) const
|
void FontSpan::AddSpanStyle(const RefPtr<NG::SpanItem>& spanItem) const
|
||||||
{
|
{
|
||||||
|
if (!spanItem || !spanItem->fontStyle) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (font_.fontColor.has_value()) {
|
if (font_.fontColor.has_value()) {
|
||||||
spanItem->fontStyle->UpdateTextColor(font_.fontColor.value());
|
spanItem->fontStyle->UpdateTextColor(font_.fontColor.value());
|
||||||
}
|
}
|
||||||
@ -260,11 +263,19 @@ RefPtr<SpanBase> BaselineOffsetSpan::GetSubSpan(int32_t start, int32_t end)
|
|||||||
|
|
||||||
void BaselineOffsetSpan::AddBaselineOffsetStyle(const RefPtr<NG::SpanItem>& spanItem) const
|
void BaselineOffsetSpan::AddBaselineOffsetStyle(const RefPtr<NG::SpanItem>& spanItem) const
|
||||||
{
|
{
|
||||||
|
CHECK_NULL_VOID(spanItem);
|
||||||
|
if (!spanItem->textLineStyle) {
|
||||||
|
spanItem->textLineStyle = std::make_unique<NG::TextLineStyle>();
|
||||||
|
}
|
||||||
spanItem->textLineStyle->UpdateBaselineOffset(baselineOffset_);
|
spanItem->textLineStyle->UpdateBaselineOffset(baselineOffset_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaselineOffsetSpan::RemoveBaselineOffsetStyle(const RefPtr<NG::SpanItem>& spanItem)
|
void BaselineOffsetSpan::RemoveBaselineOffsetStyle(const RefPtr<NG::SpanItem>& spanItem)
|
||||||
{
|
{
|
||||||
|
CHECK_NULL_VOID(spanItem);
|
||||||
|
if (!spanItem->textLineStyle) {
|
||||||
|
spanItem->textLineStyle = std::make_unique<NG::TextLineStyle>();
|
||||||
|
}
|
||||||
spanItem->textLineStyle->ResetBaselineOffset();
|
spanItem->textLineStyle->ResetBaselineOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,6 +429,7 @@ void SpanModelNG::ResetFont(UINode *uiNode)
|
|||||||
void SpanModelNG::CreateContainSpan()
|
void SpanModelNG::CreateContainSpan()
|
||||||
{
|
{
|
||||||
auto* stack = ViewStackProcessor::GetInstance();
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
CHECK_NULL_VOID(stack);
|
||||||
auto nodeId = stack->ClaimNodeId();
|
auto nodeId = stack->ClaimNodeId();
|
||||||
auto spanNode = ContainerSpanNode::GetOrCreateSpanNode(nodeId);
|
auto spanNode = ContainerSpanNode::GetOrCreateSpanNode(nodeId);
|
||||||
stack->Push(spanNode);
|
stack->Push(spanNode);
|
||||||
|
@ -62,7 +62,7 @@ const FontWeight FONT_WEIGHT_CONVERT_MAP[] = {
|
|||||||
|
|
||||||
inline FontWeight ConvertFontWeight(FontWeight fontWeight)
|
inline FontWeight ConvertFontWeight(FontWeight fontWeight)
|
||||||
{
|
{
|
||||||
return FONT_WEIGHT_CONVERT_MAP[(int)fontWeight];
|
return FONT_WEIGHT_CONVERT_MAP[static_cast<int>(fontWeight)];
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -256,11 +256,10 @@ void TextLayoutAlgorithm::GrayDisplayAISpan(const DragSpanPosition& dragSpanPosi
|
|||||||
std::string TextLayoutAlgorithm::StringOutBoundProtection(int32_t position, int32_t length, std::wstring wTextForAI)
|
std::string TextLayoutAlgorithm::StringOutBoundProtection(int32_t position, int32_t length, std::wstring wTextForAI)
|
||||||
{
|
{
|
||||||
int32_t wTextForAILength = static_cast<int32_t>(wTextForAI.length());
|
int32_t wTextForAILength = static_cast<int32_t>(wTextForAI.length());
|
||||||
if (position >= wTextForAILength || length > wTextForAILength - position) {
|
if (position >= 0 && position < wTextForAILength && length >= 0 && length <= wTextForAILength - position) {
|
||||||
return "";
|
|
||||||
} else {
|
|
||||||
return StringUtils::ToString(wTextForAI.substr(position, length));
|
return StringUtils::ToString(wTextForAI.substr(position, length));
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextLayoutAlgorithm::CreateParagraph(
|
bool TextLayoutAlgorithm::CreateParagraph(
|
||||||
|
@ -35,6 +35,7 @@ constexpr float DEFAULT_OPACITY = 0.2;
|
|||||||
void TextModelNG::Create(const std::u16string& content)
|
void TextModelNG::Create(const std::u16string& content)
|
||||||
{
|
{
|
||||||
auto* stack = ViewStackProcessor::GetInstance();
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
CHECK_NULL_VOID(stack);
|
||||||
auto nodeId = stack->ClaimNodeId();
|
auto nodeId = stack->ClaimNodeId();
|
||||||
ACE_LAYOUT_SCOPED_TRACE("Create[%s][self:%d]", V2::TEXT_ETS_TAG, nodeId);
|
ACE_LAYOUT_SCOPED_TRACE("Create[%s][self:%d]", V2::TEXT_ETS_TAG, nodeId);
|
||||||
auto frameNode =
|
auto frameNode =
|
||||||
@ -54,6 +55,7 @@ void TextModelNG::Create(const std::u16string& content)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto textPattern = frameNode->GetPattern<TextPattern>();
|
auto textPattern = frameNode->GetPattern<TextPattern>();
|
||||||
|
CHECK_NULL_VOID(textPattern);
|
||||||
textPattern->SetTextController(AceType::MakeRefPtr<TextController>());
|
textPattern->SetTextController(AceType::MakeRefPtr<TextController>());
|
||||||
textPattern->GetTextController()->SetPattern(WeakPtr(textPattern));
|
textPattern->GetTextController()->SetPattern(WeakPtr(textPattern));
|
||||||
textPattern->ClearSelectionMenu();
|
textPattern->ClearSelectionMenu();
|
||||||
|
@ -48,7 +48,7 @@ constexpr float ROUND_VALUE = 0.5f;
|
|||||||
|
|
||||||
inline FontWeight ConvertFontWeight(FontWeight fontWeight)
|
inline FontWeight ConvertFontWeight(FontWeight fontWeight)
|
||||||
{
|
{
|
||||||
return FONT_WEIGHT_CONVERT_MAP[(int)fontWeight];
|
return FONT_WEIGHT_CONVERT_MAP[static_cast<int>(fontWeight)];
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -65,6 +65,7 @@ void TextFieldContentModifier::onDraw(DrawingContext& context)
|
|||||||
CHECK_NULL_VOID(textFieldPattern);
|
CHECK_NULL_VOID(textFieldPattern);
|
||||||
auto paragraph = textFieldPattern->GetParagraph();
|
auto paragraph = textFieldPattern->GetParagraph();
|
||||||
CHECK_NULL_VOID(paragraph);
|
CHECK_NULL_VOID(paragraph);
|
||||||
|
CHECK_NULL_VOID(contentOffset_);
|
||||||
auto contentOffset = contentOffset_->Get();
|
auto contentOffset = contentOffset_->Get();
|
||||||
auto contentRect = textFieldPattern->GetContentRect();
|
auto contentRect = textFieldPattern->GetContentRect();
|
||||||
auto clipRectHeight = 0.0f;
|
auto clipRectHeight = 0.0f;
|
||||||
|
@ -1802,6 +1802,7 @@ UserUnderlineColor TextFieldModelNG::GetUnderLineColor(FrameNode* frameNode)
|
|||||||
{
|
{
|
||||||
CHECK_NULL_RETURN(frameNode, UserUnderlineColor());
|
CHECK_NULL_RETURN(frameNode, UserUnderlineColor());
|
||||||
auto pattern = frameNode->GetPattern<TextFieldPattern>();
|
auto pattern = frameNode->GetPattern<TextFieldPattern>();
|
||||||
|
CHECK_NULL_RETURN(pattern, UserUnderlineColor());
|
||||||
return pattern->GetUserUnderlineColor();
|
return pattern->GetUserUnderlineColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ void TextFieldPaintProperty::ToJsonValue(std::unique_ptr<JsonValue>& json, const
|
|||||||
{
|
{
|
||||||
PaintProperty::ToJsonValue(json, filter);
|
PaintProperty::ToJsonValue(json, filter);
|
||||||
/* no fixed attr below, just return */
|
/* no fixed attr below, just return */
|
||||||
if (filter.IsFastFilter()) {
|
if (!json || filter.IsFastFilter()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck();
|
auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck();
|
||||||
|
@ -32,6 +32,7 @@ TxtFontCollection::TxtFontCollection()
|
|||||||
{
|
{
|
||||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||||
auto rosenCollection = RSFontCollection::GetInstance(false);
|
auto rosenCollection = RSFontCollection::GetInstance(false);
|
||||||
|
CHECK_NULL_VOID(rosenCollection);
|
||||||
auto collectionTxtBase = rosenCollection->GetFontCollection();
|
auto collectionTxtBase = rosenCollection->GetFontCollection();
|
||||||
auto collectionTxt = std::static_pointer_cast<rosen::FontCollectionTxt>(collectionTxtBase);
|
auto collectionTxt = std::static_pointer_cast<rosen::FontCollectionTxt>(collectionTxtBase);
|
||||||
if (collectionTxt) {
|
if (collectionTxt) {
|
||||||
|
@ -35,6 +35,7 @@ constexpr int NUM_32 = 32;
|
|||||||
constexpr int DEFAULT_LENGTH = 4;
|
constexpr int DEFAULT_LENGTH = 4;
|
||||||
void SetSpanContent(ArkUINodeHandle node, const char* value)
|
void SetSpanContent(ArkUINodeHandle node, const char* value)
|
||||||
{
|
{
|
||||||
|
CHECK_NULL_VOID(value);
|
||||||
auto* uiNode = reinterpret_cast<UINode*>(node);
|
auto* uiNode = reinterpret_cast<UINode*>(node);
|
||||||
CHECK_NULL_VOID(uiNode);
|
CHECK_NULL_VOID(uiNode);
|
||||||
std::string content(value);
|
std::string content(value);
|
||||||
|
@ -387,6 +387,7 @@ void SetTextInputContentType(ArkUINodeHandle node, ArkUI_Uint32 contentType)
|
|||||||
CHECK_NULL_VOID(frameNode);
|
CHECK_NULL_VOID(frameNode);
|
||||||
if (contentType < 0 || contentType > static_cast<ArkUI_Uint32>(TextContentType::END)) {
|
if (contentType < 0 || contentType > static_cast<ArkUI_Uint32>(TextContentType::END)) {
|
||||||
contentType = -1;
|
contentType = -1;
|
||||||
|
TAG_LOGW(AceLogTag::ACE_TEXT_FIELD, "TextInput content type is invalid");
|
||||||
}
|
}
|
||||||
TextFieldModelNG::SetContentType(frameNode, static_cast<NG::TextContentType>(contentType));
|
TextFieldModelNG::SetContentType(frameNode, static_cast<NG::TextContentType>(contentType));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user