diff --git a/frameworks/base/geometry/calc_dimension.h b/frameworks/base/geometry/calc_dimension.h index b3e40533a69ce34ad414e569b6d1f38adcc061da..edf8dbcf044ce737d958ef267aa5f494aae041a5 100644 --- a/frameworks/base/geometry/calc_dimension.h +++ b/frameworks/base/geometry/calc_dimension.h @@ -58,6 +58,11 @@ public: return *this; } + std::string ToString() const + { + return calcvalue_.empty() ? Dimension::ToString() : calcvalue_ + "calc"; + } + private: std::string calcvalue_ = ""; }; diff --git a/frameworks/base/log/log_wrapper.h b/frameworks/base/log/log_wrapper.h index 2cafc3e9663b333b46c523618ac24a8ca5e3650b..1717bb3fdd754d0435840fa3280abc2c9302ccf2 100644 --- a/frameworks/base/log/log_wrapper.h +++ b/frameworks/base/log/log_wrapper.h @@ -80,6 +80,34 @@ constexpr uint32_t APP_DOMAIN = 0xC0D0; #define APP_LOGE(fmt, ...) PRINT_APP_LOG(ERROR, fmt, ##__VA_ARGS__) #define APP_LOGF(fmt, ...) PRINT_APP_LOG(FATAL, fmt, ##__VA_ARGS__) +#define JSON_STRING_PUT_INT(jsonValue, var) jsonValue->Put(#var, static_cast(var)) +#define JSON_STRING_PUT_BOOL(jsonValue, var) jsonValue->Put(#var, var) +#define JSON_STRING_PUT_STRING(jsonValue, var) jsonValue->Put(#var, var.c_str()) +#define JSON_STRING_PUT_STRINGABLE(jsonValue, var) jsonValue->Put(#var, var.ToString().c_str()) + +#define JSON_STRING_PUT_OPTIONAL_INT(jsonValue, var) \ + do { \ + if (var) { \ + jsonValue->Put(#var, static_cast(*var)); \ + } \ + } while (0) \ + +#define JSON_STRING_PUT_OPTIONAL_STRING(jsonValue, var) \ + do { \ + if (var) { \ + jsonValue->Put(#var, var->c_str()); \ + } \ + } while (0) \ + + +#define JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, var) \ + do { \ + if (var) { \ + jsonValue->Put(#var, var->ToString().c_str()); \ + } \ + } while (0) \ + + namespace OHOS::Ace { enum AceLogTag : uint8_t { ACE_DEFAULT_DOMAIN = 0, // C03900 diff --git a/frameworks/core/components/common/properties/color.h b/frameworks/core/components/common/properties/color.h index b004d52e853390a495ec212ad83ff2fe0cccef39..c46c5fbd0811d5f469cccd8cf6500adf658d30f1 100644 --- a/frameworks/core/components/common/properties/color.h +++ b/frameworks/core/components/common/properties/color.h @@ -137,6 +137,15 @@ public: static Color ColorFromString(const std::string& str); + std::string ToString() const + { + return "[ARGB](" + + std::to_string(colorValue_.argb.alpha) + ", " + + std::to_string(colorValue_.argb.red) + ", " + + std::to_string(colorValue_.argb.green) + ", " + + std::to_string(colorValue_.argb.blue) + ")"; + } + private: constexpr explicit Color(ColorParam colorValue) : colorValue_(colorValue) {} diff --git a/frameworks/core/components/common/properties/text_style.h b/frameworks/core/components/common/properties/text_style.h index c5e2dbf3d57fedcaffbf8d9fbeb1078c3cd75ac7..32d22796a2dc2423ee95a1fb16002ccbe763ab2c 100644 --- a/frameworks/core/components/common/properties/text_style.h +++ b/frameworks/core/components/common/properties/text_style.h @@ -551,42 +551,74 @@ public: { return textBackgroundStyle_; } + + std::string ToString() const + { + auto jsonValue = JsonUtil::Create(true); + JSON_STRING_PUT_STRINGABLE(jsonValue, fontSize_); + JSON_STRING_PUT_STRINGABLE(jsonValue, lineHeight_); + JSON_STRING_PUT_STRINGABLE(jsonValue, baselineOffset_); + JSON_STRING_PUT_STRINGABLE(jsonValue, wordSpacing_); + JSON_STRING_PUT_STRINGABLE(jsonValue, textIndent_); + JSON_STRING_PUT_STRINGABLE(jsonValue, letterSpacing_); + + JSON_STRING_PUT_INT(jsonValue, fontWeight_); + JSON_STRING_PUT_INT(jsonValue, fontStyle_); + JSON_STRING_PUT_INT(jsonValue, textBaseline_); + JSON_STRING_PUT_INT(jsonValue, textOverflow_); + JSON_STRING_PUT_INT(jsonValue, verticalAlign_); + JSON_STRING_PUT_INT(jsonValue, textAlign_); + JSON_STRING_PUT_INT(jsonValue, textDecorationStyle_); + JSON_STRING_PUT_INT(jsonValue, textDecoration_); + JSON_STRING_PUT_INT(jsonValue, whiteSpace_); + JSON_STRING_PUT_INT(jsonValue, wordBreak_); + JSON_STRING_PUT_INT(jsonValue, textCase_); + JSON_STRING_PUT_INT(jsonValue, ellipsisMode_); + + std::stringstream ss; + std::for_each(renderColors_.begin(), renderColors_.end(), [&ss](const Color& c) { ss << c.ToString() << ","; }); + jsonValue->Put("renderColors", ss.str().c_str()); + JSON_STRING_PUT_INT(jsonValue, renderStrategy_); + JSON_STRING_PUT_INT(jsonValue, effectStrategy_); + return jsonValue->ToString(); + } + private: std::vector fontFamilies_; std::unordered_map fontFeatures_; std::vector preferFontSizes_; std::vector preferTextSizeGroups_; + std::vector textShadows_; // use 14px for normal font size. Dimension fontSize_ { 14, DimensionUnit::PX }; Dimension adaptMinFontSize_; Dimension adaptMaxFontSize_; Dimension adaptFontSizeStep_; Dimension lineHeight_; - bool hasHeightOverride_ = false; + Dimension baselineOffset_; + Dimension wordSpacing_; + Dimension textIndent_ { 0.0f, DimensionUnit::PX }; + Dimension letterSpacing_; FontWeight fontWeight_ { FontWeight::NORMAL }; FontStyle fontStyle_ { FontStyle::NORMAL }; TextBaseline textBaseline_ { TextBaseline::ALPHABETIC }; - Dimension baselineOffset_; TextOverflow textOverflow_ { TextOverflow::CLIP }; VerticalAlign verticalAlign_ { VerticalAlign::NONE }; TextAlign textAlign_ { TextAlign::START }; - Color textColor_ { Color::BLACK }; - Color textDecorationColor_ { Color::BLACK }; TextDecorationStyle textDecorationStyle_ { TextDecorationStyle::SOLID }; TextDecoration textDecoration_ { TextDecoration::NONE }; - std::vector textShadows_; WhiteSpace whiteSpace_ { WhiteSpace::PRE }; - Dimension wordSpacing_; - Dimension textIndent_ { 0.0f, DimensionUnit::PX }; - Dimension letterSpacing_; + WordBreak wordBreak_ { WordBreak::BREAK_WORD }; + TextCase textCase_ { TextCase::NORMAL }; + EllipsisMode ellipsisMode_ = EllipsisMode::TAIL; + Color textColor_ { Color::BLACK }; + Color textDecorationColor_ { Color::BLACK }; uint32_t maxLines_ = UINT32_MAX; + bool hasHeightOverride_ = false; bool adaptTextSize_ = false; bool adaptHeight_ = false; // whether adjust text size with height. bool allowScale_ = true; bool halfLeading_ = false; - WordBreak wordBreak_ { WordBreak::BREAK_WORD }; - TextCase textCase_ { TextCase::NORMAL }; - EllipsisMode ellipsisMode_ = EllipsisMode::TAIL; // for Symbol std::vector renderColors_; diff --git a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_content_modifier.cpp b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_content_modifier.cpp index 4f0a4e630f1805c8c87b1144f4c0de7899890df1..fd0d5b4ef96a5f3de0c9c8e4a90efc4e49035915 100644 --- a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_content_modifier.cpp +++ b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_content_modifier.cpp @@ -15,6 +15,7 @@ #include "core/components_ng/pattern/rich_editor/rich_editor_content_modifier.h" #include "core/components_ng/pattern/rich_editor/rich_editor_pattern.h" +#include "base/log/ace_trace.h" namespace OHOS::Ace::NG { RichEditorContentModifier::RichEditorContentModifier(const std::optional& textStyle, @@ -35,6 +36,7 @@ RichEditorContentModifier::RichEditorContentModifier(const std::optional(pattern_.Upgrade()); CHECK_NULL_VOID(richEditorPattern); diff --git a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_layout_algorithm.cpp index bbf5af2a922fd2c4d98c5de7d90590320f3a5adc..15f7620630fa9771838551006c92e1063b35234d 100644 --- a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_layout_algorithm.cpp @@ -20,6 +20,7 @@ #include "core/components_ng/pattern/rich_editor/rich_editor_theme.h" #include "core/components_ng/pattern/text/text_layout_algorithm.h" #include "core/components_ng/render/paragraph.h" +#include "base/log/ace_trace.h" namespace OHOS::Ace::NG { RichEditorLayoutAlgorithm::RichEditorLayoutAlgorithm(std::list> spans, ParagraphManager* paragraphs) @@ -62,6 +63,7 @@ RichEditorLayoutAlgorithm::RichEditorLayoutAlgorithm(std::list> std::optional RichEditorLayoutAlgorithm::MeasureContent( const LayoutConstraintF& contentConstraint, LayoutWrapper* layoutWrapper) { + ACE_SCOPED_TRACE("RichEditorMeasureContent"); pManager_->Reset(); SetPlaceholder(layoutWrapper); if (spans_.empty()) { @@ -79,6 +81,7 @@ std::optional RichEditorLayoutAlgorithm::MeasureContent( float textHeight = 0.0f; for (auto&& group : spans_) { // layout each paragraph + ACE_SCOPED_TRACE("LayoutEachParagraph"); SetSpans(group); SetParagraph(nullptr); auto size = TextLayoutAlgorithm::MeasureContent(contentConstraint, layoutWrapper); diff --git a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model.h b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model.h index c811174bddc4198f1a3adc3629f0553057e176c5..e8165a592bbd052f703f00c8f7397d733bbca0cb 100644 --- a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model.h +++ b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model.h @@ -42,6 +42,14 @@ struct UserGestureOptions { struct ImageSpanSize { CalcDimension width; CalcDimension height; + + std::string ToString() const + { + auto jsonValue = JsonUtil::Create(true); + JSON_STRING_PUT_STRINGABLE(jsonValue, width); + JSON_STRING_PUT_STRINGABLE(jsonValue, height); + return jsonValue->ToString(); + } }; struct ImageSpanAttribute { @@ -50,11 +58,29 @@ struct ImageSpanAttribute { std::optional objectFit; std::optional marginProp; std::optional borderRadius; + + std::string ToString() const + { + auto jsonValue = JsonUtil::Create(true); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, size); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, verticalAlign); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, objectFit); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, marginProp); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, borderRadius); + return jsonValue->ToString(); + } }; struct SpanOptionBase { std::optional offset; UserGestureOptions userGestureOption; + + std::string ToString() const + { + auto jsonValue = JsonUtil::Create(true); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, offset); + return jsonValue->ToString(); + } }; struct ImageSpanOptions : SpanOptionBase { @@ -64,6 +90,26 @@ struct ImageSpanOptions : SpanOptionBase { std::optional moduleName; std::optional> imagePixelMap; std::optional imageAttribute; + + std::string ToString() const + { + auto jsonValue = JsonUtil::Create(true); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, offset); + JSON_STRING_PUT_OPTIONAL_STRING(jsonValue, image); + JSON_STRING_PUT_OPTIONAL_STRING(jsonValue, bundleName); + JSON_STRING_PUT_OPTIONAL_STRING(jsonValue, moduleName); + JSON_STRING_PUT_OPTIONAL_STRING(jsonValue, image); + if (imagePixelMap && *imagePixelMap) { + std::string pixSize = "["; + pixSize += std::to_string((*imagePixelMap)->GetWidth()); + pixSize += "*"; + pixSize += std::to_string((*imagePixelMap)->GetHeight()); + pixSize += "]"; + jsonValue->Put("pixelMapSize", pixSize.c_str()); + } + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, imageAttribute); + return jsonValue->ToString(); + } }; struct SpanPositionInfo { @@ -84,10 +130,12 @@ struct SpanPositionInfo { int32_t spanEnd_ = 0; int32_t spanOffset_ = 0; - std::string ToString() + std::string ToString() const { - return "spanIndex: " + std::to_string(spanIndex_) + ", spanStart: " + std::to_string(spanStart_) + ", spanEnd" + - std::to_string(spanEnd_) + ", spanOffset: " + std::to_string(spanOffset_); + return "spanIndex: " + std::to_string(spanIndex_) + + ", spanStart: " + std::to_string(spanStart_) + + ", spanEnd" + std::to_string(spanEnd_) + + ", spanOffset: " + std::to_string(spanOffset_); } }; @@ -142,6 +190,29 @@ struct UpdateSpanStyle { bool hasResourceFontColor = false; bool hasResourceDecorationColor = false; bool isSymbolStyle = false; + + std::string ToString() const + { + auto jsonValue = JsonUtil::Create(true); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, updateTextColor); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, updateFontSize); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, updateItalicFontStyle); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, updateFontWeight); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, updateTextDecoration); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, updateTextDecorationColor); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, updateSymbolRenderingStrategy); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, updateSymbolEffectStrategy); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, updateImageWidth); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, updateImageHeight); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, updateImageVerticalAlign); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, updateImageFit); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, marginProp); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, borderRadius); + JSON_STRING_PUT_BOOL(jsonValue, hasResourceFontColor); + JSON_STRING_PUT_BOOL(jsonValue, hasResourceDecorationColor); + JSON_STRING_PUT_BOOL(jsonValue, isSymbolStyle); + return jsonValue->ToString(); + } }; struct UpdateParagraphStyle { @@ -154,11 +225,29 @@ struct UpdateParagraphStyle { std::optional textAlign; std::optional leadingMargin; std::optional wordBreak; + + std::string ToString() const + { + auto jsonValue = JsonUtil::Create(true); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, textAlign); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, leadingMargin); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, wordBreak); + return jsonValue->ToString(); + } }; struct RangeOptions { std::optional start; std::optional end; + + std::string ToString() const + { + return "[" + + (start ? std::to_string(*start) : "nullopt") + + "," + + (end ? std::to_string(*end) : "nullopt") + + "]"; + } }; struct TextSpanOptions : SpanOptionBase { @@ -169,6 +258,18 @@ struct TextSpanOptions : SpanOptionBase { UserGestureOptions userGestureOption; bool hasResourceFontColor = false; bool hasResourceDecorationColor = false; + + std::string ToString() const + { + auto jsonValue = JsonUtil::Create(true); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, offset); + JSON_STRING_PUT_STRING(jsonValue, value); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, style); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, paraStyle); + JSON_STRING_PUT_BOOL(jsonValue, hasResourceFontColor); + JSON_STRING_PUT_BOOL(jsonValue, hasResourceDecorationColor); + return jsonValue->ToString(); + } }; struct SymbolSpanOptions : SpanOptionBase { @@ -176,6 +277,15 @@ struct SymbolSpanOptions : SpanOptionBase { uint32_t symbolId; std::optional style; RefPtr resourceObject; + + std::string ToString() const + { + auto jsonValue = JsonUtil::Create(true); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, offset); + JSON_STRING_PUT_INT(jsonValue, symbolId); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, style); + return jsonValue->ToString(); + } }; struct PlaceholderOptions { @@ -185,6 +295,17 @@ struct PlaceholderOptions { std::optional fontColor; std::optional fontStyle; std::vector fontFamilies; + + std::string ToString() const + { + auto jsonValue = JsonUtil::Create(true); + JSON_STRING_PUT_OPTIONAL_STRING(jsonValue, value); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, fontWeight); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, fontSize); + JSON_STRING_PUT_OPTIONAL_STRINGABLE(jsonValue, fontColor); + JSON_STRING_PUT_OPTIONAL_INT(jsonValue, fontStyle); + return jsonValue->ToString(); + } }; class ACE_EXPORT RichEditorControllerBase : public AceType { diff --git a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_overlay_modifier.cpp b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_overlay_modifier.cpp index d77664b91e6f365439c7e5f1c15fa9cbd405475a..c2953bfbf630eeceb2de86215adc5cc8bca43375 100644 --- a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_overlay_modifier.cpp +++ b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_overlay_modifier.cpp @@ -21,6 +21,7 @@ #include "core/components_ng/render/drawing.h" #include "core/components_ng/render/drawing_prop_convertor.h" #include "core/pipeline_ng/pipeline_context.h" +#include "base/log/ace_trace.h" namespace OHOS::Ace::NG { RichEditorOverlayModifier::RichEditorOverlayModifier(const WeakPtr& pattern, @@ -158,6 +159,7 @@ void RichEditorOverlayModifier::PaintEdgeEffect(const SizeF& frameSize, RSCanvas void RichEditorOverlayModifier::onDraw(DrawingContext& drawingContext) { + ACE_SCOPED_TRACE("RichEditorOverlayOnDraw"); if (!showSelect_->Get()) { PaintScrollBar(drawingContext); PaintEdgeEffect(frameSize_->Get(), drawingContext.canvas); diff --git a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.cpp b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.cpp index 6b8a21a663a9d823b63a66ffca7a6134f5cc6f7f..9fdc0b33a3e05f5718b524dd4a650e0e7e89e05e 100644 --- a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.cpp +++ b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_pattern.cpp @@ -29,6 +29,7 @@ #include "base/geometry/ng/rect_t.h" #include "base/geometry/offset.h" #include "base/log/dump_log.h" +#include "base/log/ace_trace.h" #include "base/log/log_wrapper.h" #include "base/memory/ace_type.h" #include "base/utils/string_utils.h" @@ -183,6 +184,7 @@ void RichEditorPattern::HandleEnabled() void RichEditorPattern::BeforeCreateLayoutWrapper() { + ACE_SCOPED_TRACE("RichEditorBeforeCreateLayoutWrapper"); TextPattern::PreCreateLayoutWrapper(); } @@ -291,7 +293,8 @@ int32_t RichEditorPattern::AddImageSpan(const ImageSpanOptions& options, bool is { auto host = GetHost(); CHECK_NULL_RETURN(host, -1); - + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "options=%{public}s", options.ToString().c_str()); + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "isPaste=%{public}d, index=%{public}d", isPaste, index); auto imageNode = ImageSpanNode::GetOrCreateSpanNode(V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr(); }); auto imageLayoutProperty = imageNode->GetLayoutProperty(); @@ -406,6 +409,8 @@ int32_t RichEditorPattern::AddPlaceholderSpan(const RefPtr& customNode, CHECK_NULL_RETURN(customNode, 0); auto host = GetHost(); CHECK_NULL_RETURN(host, 0); + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "AddPlaceholderSpan"); + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "options=%{public}s", options.ToString().c_str()); auto placeholderSpanNode = PlaceholderSpanNode::GetOrCreateSpanNode(V2::PLACEHOLDER_SPAN_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr(); }); CHECK_NULL_RETURN(placeholderSpanNode, 0); @@ -467,6 +472,8 @@ void RichEditorPattern::SetSelfAndChildDraggableFalse(const RefPtr& cust int32_t RichEditorPattern::AddTextSpan(const TextSpanOptions& options, bool isPaste, int32_t index) { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "options=%{public}s", options.ToString().c_str()); + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "isPaste=%{public}d, index=%{public}d", isPaste, index); OperationRecord record; record.beforeCaretPosition = options.offset.value_or(static_cast(GetTextContentLength())); record.addText = options.value; @@ -566,6 +573,8 @@ int32_t RichEditorPattern::AddTextSpanOperation( int32_t RichEditorPattern::AddSymbolSpan(const SymbolSpanOptions& options, bool isPaste, int32_t index) { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "options=%{public}s", options.ToString().c_str()); + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "isPaste=%{public}d, index=%{public}d", isPaste, index); OperationRecord record; record.beforeCaretPosition = options.offset.value_or(static_cast(GetTextContentLength())); record.addText = " "; @@ -995,6 +1004,7 @@ bool RichEditorPattern::SetCaretOffset(int32_t caretPosition) { bool success = false; success = SetCaretPosition(caretPosition); + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "caretPosition=%{public}d, success=%{public}d", caretPosition, success); auto host = GetHost(); CHECK_NULL_RETURN(host, false); auto focusHub = host->GetOrCreateFocusHub(); @@ -1065,6 +1075,9 @@ bool RichEditorPattern::SetCaretPosition(int32_t pos) ResetLastClickOffset(); if (pos == correctPos) { FireOnSelectionChange(correctPos); + if (caretPosition_ != correctPos) { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "caret:%{public}d->%{public}d", caretPosition_, correctPos); + } caretPosition_ = correctPos; UpdateCaretInfoToController(); return true; @@ -1121,6 +1134,8 @@ bool RichEditorPattern::GetCaretVisible() const void RichEditorPattern::SetUpdateSpanStyle(struct UpdateSpanStyle updateSpanStyle) { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "SetUpdateSpanStyle"); + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "updateSpanStyle=%{public}s", updateSpanStyle.ToString().c_str()); updateSpanStyle_ = updateSpanStyle; } @@ -1277,7 +1292,9 @@ bool RichEditorPattern::SymbolSpanUpdateStyle( void RichEditorPattern::UpdateSpanStyle( int32_t start, int32_t end, const TextStyle& textStyle, const ImageSpanAttribute& imageStyle) { - TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "range=[%{public}d, %{public}d]", start, end); + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "range=[%{public}d,%{public}d]", start, end); + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "textStyle=%{public}s, imageStyle=%{public}s", + textStyle.ToString().c_str(), imageStyle.ToString().c_str()); auto host = GetHost(); CHECK_NULL_VOID(host); int32_t spanStart = 0; @@ -1326,7 +1343,6 @@ void RichEditorPattern::UpdateSpanStyle( // Custom menus do not actively close. if (!SelectOverlayIsOn() || selectOverlayProxy_->GetSelectOverlayMangerInfo().menuInfo.menuBuilder == nullptr) { - TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "CloseSelectOverlay"); CloseSelectOverlay(); } } @@ -1439,6 +1455,8 @@ std::vector> RichEditorPattern::GetParagraphNodes(int32_t start void RichEditorPattern::UpdateParagraphStyle(int32_t start, int32_t end, const struct UpdateParagraphStyle& style) { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "range=[%{public}d,%{public}d]", start, end); + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "style=%{public}s", style.ToString().c_str()); auto spanNodes = GetParagraphNodes(start, end); for (const auto& spanNode : spanNodes) { if (style.textAlign.has_value()) { @@ -1483,6 +1501,7 @@ void RichEditorPattern::StartTwinkling() caretTwinklingTask_.Cancel(); // Fire on selecion change when caret invisible -> visible if (!caretTwinkling_) { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "StartTwinkling"); caretTwinkling_ = true; FireOnSelectionChange(caretPosition_, caretPosition_); } @@ -1503,6 +1522,9 @@ void RichEditorPattern::OnCaretTwinkling() void RichEditorPattern::StopTwinkling() { + if (caretTwinkling_) { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "StopTwinkling"); + } caretTwinkling_ = false; caretTwinklingTask_.Cancel(); if (caretVisible_) { @@ -1538,7 +1560,7 @@ void RichEditorPattern::HandleClickEvent(GestureEvent& info) void RichEditorPattern::HandleSingleClickEvent(OHOS::Ace::GestureEvent& info) { - TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "in handleSingleClickEvent"); + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "handleSingleClick"); hasClicked_ = true; lastClickTimeStamp_ = info.GetTimeStamp(); if (info.GetSourceDevice() != SourceType::MOUSE && SelectOverlayIsOn() && @@ -1632,7 +1654,7 @@ void RichEditorPattern::MoveCaretAndStartFocus(const Offset& textOffset) void RichEditorPattern::HandleDoubleClickEvent(OHOS::Ace::GestureEvent& info) { - TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "in double HandleDoubleClickEvent,use mouse:%{public}d", info.GetSourceDevice()); + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "HandleDoubleClickEvent"); caretUpdateType_ = CaretUpdateType::DOUBLE_CLICK; HandleDoubleClickOrLongPress(info); caretUpdateType_ = CaretUpdateType::NONE; @@ -1641,6 +1663,7 @@ void RichEditorPattern::HandleDoubleClickEvent(OHOS::Ace::GestureEvent& info) bool RichEditorPattern::HandleUserGestureEvent( GestureEvent& info, std::function item, GestureEvent& info)>&& gestureFunc) { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "HandleUserGestureEvent"); RectF textContentRect = contentRect_; textContentRect.SetTop(contentRect_.GetY() - std::min(baselineOffset_, 0.0f)); textContentRect.SetHeight(contentRect_.Height() - std::max(baselineOffset_, 0.0f)); @@ -1760,6 +1783,7 @@ void RichEditorPattern::InitClickEvent(const RefPtr& gestureHub { CHECK_NULL_VOID(!clickEventInitialized_); auto clickCallback = [weak = WeakClaim(this)](GestureEvent& info) { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "click callback, sourceType=%{public}d", info.GetSourceDevice()); auto pattern = weak.Upgrade(); CHECK_NULL_VOID(pattern); pattern->sourceType_ = info.GetSourceDevice(); @@ -1774,14 +1798,14 @@ void RichEditorPattern::InitFocusEvent(const RefPtr& focusHub) { CHECK_NULL_VOID(!focusEventInitialized_); auto focusTask = [weak = WeakClaim(this)]() { - TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "rich editor in focus"); + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "rich editor in focus"); auto pattern = weak.Upgrade(); CHECK_NULL_VOID(pattern); pattern->HandleFocusEvent(); }; focusHub->SetOnFocusInternal(focusTask); auto blurTask = [weak = WeakClaim(this)]() { - TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "rich editor in blur"); + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "rich editor in blur"); auto pattern = weak.Upgrade(); CHECK_NULL_VOID(pattern); pattern->HandleBlurEvent(); @@ -1803,8 +1827,9 @@ bool RichEditorPattern::CheckBlurReason() auto curFocusHub = host->GetFocusHub(); CHECK_NULL_RETURN(curFocusHub, false); auto curBlurReason = curFocusHub->GetBlurReason(); + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "curBlurReason=%{public}d", curBlurReason); if (curBlurReason == BlurReason::FRAME_DESTROY) { - TAG_LOGI(AceLogTag::ACE_KEYBOARD, "TextFieldPattern CheckBlurReason, Close Keyboard."); + TAG_LOGI(AceLogTag::ACE_KEYBOARD, "Close Keyboard."); return true; } return false; @@ -1812,6 +1837,7 @@ bool RichEditorPattern::CheckBlurReason() void RichEditorPattern::HandleBlurEvent() { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "HandleBlurEvent"); isLongPress_ = false; if (textDetectEnable_) { if (CanStartAITask()) { @@ -1834,6 +1860,7 @@ void RichEditorPattern::HandleBlurEvent() void RichEditorPattern::HandleFocusEvent() { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "HandleFocusEvent"); auto host = GetHost(); if (host && textDetectEnable_ && !dataDetectorAdapter_->aiSpanMap_.empty()) { host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); @@ -1861,6 +1888,7 @@ void RichEditorPattern::UseHostToUpdateTextFieldManager() void RichEditorPattern::OnVisibleChange(bool isVisible) { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "isVisible=%{public}d", isVisible); TextPattern::OnVisibleChange(isVisible); StopTwinkling(); CloseKeyboard(true); @@ -1874,7 +1902,7 @@ bool RichEditorPattern::CloseKeyboard(bool forceClose) if (customKeyboardBuilder_ && isCustomKeyboardAttached_) { return CloseCustomKeyboard(); } - TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "Request close soft keyboard."); + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "Request close soft keyboard."); #if defined(ENABLE_STANDARD_INPUT) #if defined(OHOS_STANDARD_SYSTEM) && !defined(PREVIEW) if (!imeAttached_) { @@ -1988,7 +2016,7 @@ void RichEditorPattern::HandleLongPress(GestureEvent& info) if (!focusHub->IsFocusable()) { return; } - TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "handle long press!"); + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "HandleLongPress"); caretUpdateType_ = CaretUpdateType::LONG_PRESSED; selectionMenuOffsetClick_ = OffsetF( static_cast(info.GetGlobalLocation().GetX()), static_cast(info.GetGlobalLocation().GetY())); @@ -1998,6 +2026,7 @@ void RichEditorPattern::HandleLongPress(GestureEvent& info) void RichEditorPattern::HandleDoubleClickOrLongPress(GestureEvent& info) { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "caretUpdateType=%{public}d", caretUpdateType_); if (caretUpdateType_ == CaretUpdateType::LONG_PRESSED) { HandleUserLongPressEvent(info); } @@ -2060,6 +2089,7 @@ bool RichEditorPattern::HandleUserLongPressEvent(GestureEvent& info) void RichEditorPattern::HandleMenuCallbackOnSelectAll() { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "HandleMenuCallbackOnSelectAll"); auto textSize = static_cast(GetWideText().length()) + placeholderCount_; textSelector_.Update(0, textSize); CalculateHandleOffsetAndShowOverlay(); @@ -2088,6 +2118,7 @@ void RichEditorPattern::InitLongPressEvent(const RefPtr& gestur { CHECK_NULL_VOID(!longPressEvent_); auto longPressCallback = [weak = WeakClaim(this)](GestureEvent& info) { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "long press callback"); auto pattern = weak.Upgrade(); CHECK_NULL_VOID(pattern); pattern->sourceType_ = info.GetSourceDevice(); @@ -2279,6 +2310,7 @@ void RichEditorPattern::UpdateEditingValue(const std::shared_ptrGetId(); @@ -2376,7 +2409,7 @@ bool RichEditorPattern::EnableStandardInput(bool needShowSoftKeyboard) CHECK_NULL_RETURN(inputMethod, false); auto miscTextConfig = GetMiscTextConfig(); CHECK_NULL_RETURN(miscTextConfig.has_value(), false); - TAG_LOGI( + TAG_LOGD( AceLogTag::ACE_RICH_TEXT, "RequestKeyboard set calling window id is : %{public}u", miscTextConfig->windowId); MiscServices::TextConfig textconfig = miscTextConfig.value(); #ifdef WINDOW_SCENE_SUPPORTED @@ -2478,8 +2511,10 @@ void RichEditorPattern::OnColorConfigurationUpdate() CHECK_NULL_VOID(theme); auto textLayoutProperty = GetLayoutProperty(); CHECK_NULL_VOID(textLayoutProperty); - textLayoutProperty->UpdateTextColor(theme->GetTextStyle().GetTextColor()); - textLayoutProperty->UpdateTextDecorationColor(theme->GetTextStyle().GetTextColor()); + const Color& themeTextColor = theme->GetTextStyle().GetTextColor(); + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "themeTextColor=%{public}s", themeTextColor.ToString().c_str()); + textLayoutProperty->UpdateTextColor(themeTextColor); + textLayoutProperty->UpdateTextDecorationColor(themeTextColor); for (auto span : spans) { auto spanNode = DynamicCast(span); if (!spanNode) { @@ -2518,10 +2553,9 @@ void RichEditorPattern::UpdateCaretInfoToController() MiscServices::InputMethodController::GetInstance()->OnCursorUpdate(cursorInfo); MiscServices::InputMethodController::GetInstance()->OnSelectionChange( StringUtils::Str8ToStr16(text), textSelector_.GetStart(), textSelector_.GetEnd()); - TAG_LOGI(AceLogTag::ACE_RICH_TEXT, - "Caret position update, left %{public}f, top %{public}f, width %{public}f, height %{public}f; textSelector_ " - "Start " - "%{public}d, end %{public}d", + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, + "Caret update, pos=[%{public}.2f,%{public}.2f], size=[%{public}.2f,%{public}.2f], " + "textSelector=[%{public}d,%{public}d]", cursorInfo.left, cursorInfo.top, cursorInfo.width, cursorInfo.height, textSelector_.GetStart(), textSelector_.GetEnd()); #else @@ -2886,6 +2920,7 @@ void RichEditorPattern::AfterInsertValue( bool RichEditorPattern::AfterIMEInsertValue(const RefPtr& spanNode, int32_t insertValueLength, bool isCreate) { + ACE_SCOPED_TRACE("RichEditorAfterIMEInsertValue"); auto host = GetHost(); CHECK_NULL_RETURN(host, false); auto eventHub = GetEventHub(); @@ -3004,6 +3039,7 @@ void RichEditorPattern::HandleOnDelete(bool backward) void RichEditorPattern::DeleteBackward(int32_t length) { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "length=%{public}d", length); OperationRecord record; record.beforeCaretPosition = caretPosition_; std::wstring deleteText = DeleteBackwardOperation(length); @@ -3068,6 +3104,7 @@ std::wstring RichEditorPattern::DeleteBackwardOperation(int32_t length) void RichEditorPattern::DeleteForward(int32_t length) { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "length=%{public}d", length); OperationRecord record; record.beforeCaretPosition = caretPosition_; std::wstring deleteText = DeleteForwardOperation(length); @@ -3132,7 +3169,7 @@ bool RichEditorPattern::OnBackPressed() { auto tmpHost = GetHost(); CHECK_NULL_RETURN(tmpHost, false); - TAG_LOGI(AceLogTag::ACE_TEXT_FIELD, "RichEditor %{public}d receives back press event", tmpHost->GetId()); + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "RichEditor %{public}d receives back press event", tmpHost->GetId()); if (SelectOverlayIsOn()) { CloseSelectOverlay(); textSelector_.Update(textSelector_.destinationOffset); @@ -3494,6 +3531,7 @@ int32_t RichEditorPattern::GetParagraphEndPosition(int32_t caretPosition) void RichEditorPattern::HandleOnSelectAll() { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "HandleOnSelectAll"); CloseSelectOverlay(); auto host = GetHost(); CHECK_NULL_VOID(host); @@ -3531,6 +3569,7 @@ int32_t RichEditorPattern::CaretPositionSelectEmoji(CaretMoveIntent direction) void RichEditorPattern::HandleSelect(CaretMoveIntent direction) { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "direction=%{public}d", direction); CloseSelectOverlay(); auto host = GetHost(); CHECK_NULL_VOID(host); @@ -3615,6 +3654,7 @@ bool RichEditorPattern::HandleOnEscape() void RichEditorPattern::HandleOnUndoAction() { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "HandleOnUndoAction"); if (operationRecords_.empty()) { return; } @@ -3648,6 +3688,7 @@ void RichEditorPattern::HandleOnUndoAction() void RichEditorPattern::HandleOnRedoAction() { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "HandleOnRedoAction"); if (redoOperationRecords_.empty()) { return; } @@ -3864,6 +3905,9 @@ int32_t RichEditorPattern::DeleteValueSetTextSpan( void RichEditorPattern::DeleteByDeleteValueInfo(const RichEditorDeleteValue& info) { auto deleteSpans = info.GetRichEditorDeleteSpans(); + if (deleteSpans.empty()) { + return; + } auto host = GetHost(); CHECK_NULL_VOID(host); std::list> deleteNode; @@ -3918,6 +3962,7 @@ bool RichEditorPattern::OnKeyEvent(const KeyEvent& keyEvent) void RichEditorPattern::CursorMove(CaretMoveIntent direction) { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "direction=%{public}d", direction); switch (direction) { case CaretMoveIntent::Left: CursorMoveLeft(); @@ -4286,6 +4331,8 @@ void RichEditorPattern::HandleMouseEvent(const MouseInfo& info) void RichEditorPattern::OnHandleMoveDone(const RectF& handleRect, bool isFirstHandle) { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "handleRect=%{public}s, isFirstHandle=%{public}d", + handleRect.ToString().c_str(), isFirstHandle); auto host = GetHost(); CHECK_NULL_VOID(host); auto selectStart = std::min(textSelector_.baseOffset, textSelector_.destinationOffset); @@ -4352,6 +4399,9 @@ void RichEditorPattern::CopySelectionMenuParams(SelectOverlayInfo& selectInfo, T void RichEditorPattern::ShowSelectOverlay(const RectF& firstHandle, const RectF& secondHandle, bool isCopyAll, TextResponseType responseType, bool handleReverse) { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "firstHandle=%{public}s, secondHandle=%{public}s, isCopyAll=%{public}d," + "responseType=%{public}d, handleReverse=%{public}d", + firstHandle.ToString().c_str(), secondHandle.ToString().c_str(), isCopyAll, responseType, handleReverse); auto pipeline = PipelineContext::GetCurrentContext(); CHECK_NULL_VOID(pipeline); showSelect_ = true; @@ -4381,6 +4431,7 @@ void RichEditorPattern::ShowSelectOverlay(const RectF& firstHandle, const RectF& pattern->OnHandleMove(handleRect, isFirst); }; selectInfo.onHandleMoveDone = [weak](const RectF& handleRect, bool isFirst) { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "onHandleMoveDone callback"); auto pattern = weak.Upgrade(); CHECK_NULL_VOID(pattern); pattern->OnHandleMoveDone(handleRect, isFirst); @@ -4390,6 +4441,7 @@ void RichEditorPattern::ShowSelectOverlay(const RectF& firstHandle, const RectF& CHECK_NULL_VOID(host); selectInfo.menuCallback.onCopy = [weak, usingMouse]() { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "menu onCopy"); auto pattern = weak.Upgrade(); CHECK_NULL_VOID(pattern); pattern->HandleOnCopy(); @@ -4403,18 +4455,21 @@ void RichEditorPattern::ShowSelectOverlay(const RectF& firstHandle, const RectF& }; selectInfo.menuCallback.onCut = [weak]() { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "menu onCut"); auto pattern = weak.Upgrade(); CHECK_NULL_VOID(pattern); pattern->HandleOnCut(); }; selectInfo.menuCallback.onPaste = [weak]() { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "menu onPaste"); auto pattern = weak.Upgrade(); CHECK_NULL_VOID(pattern); pattern->HandleOnPaste(); pattern->CloseSelectOverlay(); }; selectInfo.menuCallback.onSelectAll = [weak, usingMouse]() { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "menu onSelectAll"); auto pattern = weak.Upgrade(); CHECK_NULL_VOID(pattern); pattern->isMousePressed_ = usingMouse; @@ -4429,6 +4484,7 @@ void RichEditorPattern::ShowSelectOverlay(const RectF& firstHandle, const RectF& if (pattern->GetTextDetectEnable() && !pattern->HasFocus()) { selectInfo.onClose = [weak](bool closedByGlobalEvent) { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "menu onClose"); auto pattern = weak.Upgrade(); CHECK_NULL_VOID(pattern); if (closedByGlobalEvent) { @@ -4481,6 +4537,8 @@ void RichEditorPattern::CheckEditorTypeChange() void RichEditorPattern::HandleOnCopy(bool isUsingExternalKeyboard) { CHECK_NULL_VOID(clipboard_); + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, + "isUsingExternalKeyboard=%{public}d, copyOption=%{public}d", isUsingExternalKeyboard, copyOption_); if (copyOption_ == CopyOptions::None) { return; } @@ -4520,6 +4578,7 @@ void RichEditorPattern::HandleOnCopy(bool isUsingExternalKeyboard) void RichEditorPattern::ResetAfterPaste() { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "ResetAfterPaste"); OperationRecord record; record.beforeCaretPosition = caretPosition_ + moveLength_; auto pasteStr = GetPasteStr(); @@ -4550,6 +4609,7 @@ void RichEditorPattern::HandleOnPaste() CHECK_NULL_VOID(eventHub); TextCommonEvent event; eventHub->FireOnPaste(event); + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "HandleOnPaste, preventDefault=%{public}d", event.IsPreventDefault()); if (event.IsPreventDefault()) { CloseSelectOverlay(); ResetSelection(); @@ -4558,6 +4618,7 @@ void RichEditorPattern::HandleOnPaste() } CHECK_NULL_VOID(clipboard_); auto pasteCallback = [weak = WeakClaim(this)](const std::string& data) { + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "pasteCallback callback"); auto richEditor = weak.Upgrade(); CHECK_NULL_VOID(richEditor); if (data.empty()) { @@ -4657,6 +4718,8 @@ void RichEditorPattern::SetCaretSpanIndex(int32_t index) void RichEditorPattern::HandleOnCut() { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "copyOption=%{public}d, textSelector_.IsValid()=%{public}d", + copyOption_, textSelector_.IsValid()); if (copyOption_ == CopyOptions::None) { return; } @@ -4787,6 +4850,10 @@ void RichEditorPattern::CloseSelectionMenu() void RichEditorPattern::CloseSelectOverlay() { + if (!selectOverlayProxy_ || selectOverlayProxy_->IsClosed()) { + return; + } + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "CloseSelectOverlay"); TextPattern::CloseSelectOverlay(true); } @@ -4837,6 +4904,7 @@ bool RichEditorPattern::IsSingleHandle() void RichEditorPattern::ResetSelection() { + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "ResetSelection"); bool selectNothing = textSelector_.SelectNothing(); textSelector_.Update(-1, -1); if (!selectNothing) { @@ -4991,7 +5059,9 @@ void RichEditorPattern::HandleSelectOverlayWithOptions(const SelectionOptions& o void RichEditorPattern::SetSelection(int32_t start, int32_t end, const std::optional& options) { - CHECK_NULL_VOID(HasFocus()); + bool hasFocus = HasFocus(); + TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "range=[%{public}d,%{public}d], hasFocus=%{public}d", start, end, hasFocus); + CHECK_NULL_VOID(hasFocus); bool changeSelected = false; if (start > end) { changeSelected = textSelector_.IsValid(); @@ -5688,7 +5758,7 @@ std::string RichEditorPattern::GetPositionSpansText(int32_t position, int32_t& s start = std::clamp(start, 0, GetTextContentLength()); end = std::clamp(end, 0, GetTextContentLength()); - TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "get span pos:%{public}d-start:%{public}d-end:%{public}d", position, start, end); + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "caret=%{public}d, range=[%{public}d,%{public}d]", position, start, end); // get all the spans between start and end, then filter the valid text auto infos = GetSpansInfo(start, end, GetSpansMethod::ONSELECT); @@ -5718,7 +5788,7 @@ std::string RichEditorPattern::GetPositionSpansText(int32_t position, int32_t& s } } - TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "get spans text ret spanStart:%{public}d", startSpan); + TAG_LOGD(AceLogTag::ACE_RICH_TEXT, "get spans text ret spanStart:%{public}d", startSpan); return sstream.str(); } diff --git a/frameworks/core/components_ng/render/paragraph.h b/frameworks/core/components_ng/render/paragraph.h index 1b69d5d17fa8795046f86a88fd7911961aabe76f..504e24304223b860ed3cb229e5c24e5eb62d9406 100644 --- a/frameworks/core/components_ng/render/paragraph.h +++ b/frameworks/core/components_ng/render/paragraph.h @@ -35,6 +35,16 @@ struct LeadingMargin { { return size == other.size && pixmap == other.pixmap; } + + std::string ToString() const + { + auto jsonValue = JsonUtil::Create(true); + JSON_STRING_PUT_STRINGABLE(jsonValue, size); + jsonValue->Put("pixmap", pixmap + ? ("size=" + std::to_string(pixmap->GetWidth()) + "," + std::to_string(pixmap->GetHeight())).c_str() + : "nullptr"); + return jsonValue->ToString(); + } }; struct ParagraphStyle { diff --git a/frameworks/core/event/key_event.h b/frameworks/core/event/key_event.h index 32792fb70af47086dadee7ef74d7e251061a0979..29c7ff145260b7b31530b6893444ef0327e61f47 100644 --- a/frameworks/core/event/key_event.h +++ b/frameworks/core/event/key_event.h @@ -585,6 +585,18 @@ struct KeyEvent final { std::vector enhanceData; std::shared_ptr rawKeyEvent; std::string msg = ""; + + std::string ToString() const + { + std::stringstream ss; + ss << "code=" << static_cast(code) << ", "; + ss << "action=" << static_cast(action) << ", "; + ss << "pressedCodes=["; + std::for_each(pressedCodes.begin(), pressedCodes.end(), + [&ss](const KeyCode& code) { ss << static_cast(code) << ", "; }); + ss << "]"; + return ss.str(); + } }; class ACE_EXPORT KeyEventInfo : public BaseEventInfo {