diff --git a/frameworks/core/components_ng/base/frame_node.cpp b/frameworks/core/components_ng/base/frame_node.cpp index d611ae7d1e7e41b52f308a6693c0099f4f2939eb..1a34948317340e1b875deca3a3fd98d2e01ffe58 100644 --- a/frameworks/core/components_ng/base/frame_node.cpp +++ b/frameworks/core/components_ng/base/frame_node.cpp @@ -704,14 +704,27 @@ void FrameNode::InitializePatternAndContext() } } +void FrameNode::DumpLayoutInfo() +{ + auto layoutInfoString = layoutProperty_->LayoutInfoToString(); + if (!layoutInfoString.empty()) { + DumpLog::GetInstance().AddDesc(std::string("LayoutInfo: ").append(layoutInfoString.c_str())); + } + const auto& flexItemProperty = layoutProperty_->GetFlexItemProperty(); + if (flexItemProperty) { + auto flexLayoutInfoString = flexItemProperty->FlexLayoutInfoToString(); + if (!flexLayoutInfoString.empty()) { + DumpLog::GetInstance().AddDesc(std::string("FlexLayoutInfo: ").append(flexLayoutInfoString.c_str())); + } + } +} + void FrameNode::DumpSafeAreaInfo() { auto&& opts = layoutProperty_->GetSafeAreaExpandOpts(); if (opts) { - DumpLog::GetInstance().AddDesc(layoutProperty_->GetSafeAreaExpandOpts() - ->ToString() - .append(",hostPageId: ") - .append(std::to_string(GetPageId()).c_str())); + DumpLog::GetInstance().AddDesc( + opts->ToString().append(",hostPageId: ").append(std::to_string(GetPageId()).c_str())); } if (layoutProperty_->GetSafeAreaInsets()) { DumpLog::GetInstance().AddDesc(layoutProperty_->GetSafeAreaInsets()->ToString()); @@ -814,6 +827,7 @@ void FrameNode::DumpCommonInfo() } DumpExtensionHandlerInfo(); DumpSafeAreaInfo(); + DumpLayoutInfo(); if (layoutProperty_->GetCalcLayoutConstraint()) { DumpLog::GetInstance().AddDesc(std::string("User defined constraint: ") .append(layoutProperty_->GetCalcLayoutConstraint()->ToString().c_str())); diff --git a/frameworks/core/components_ng/base/frame_node.h b/frameworks/core/components_ng/base/frame_node.h index 5a4a138e94248ae6ac981a4a512612d8f26c27ab..b9f72fc798c6ecac93243f87a2d83034e91ca481 100644 --- a/frameworks/core/components_ng/base/frame_node.h +++ b/frameworks/core/components_ng/base/frame_node.h @@ -1400,6 +1400,8 @@ private: void BuildLayoutInfo(std::unique_ptr& json); void DumpSafeAreaInfo(); + // add flexLayout && direction && align && aspectRatio dumpInfo + void DumpLayoutInfo(); void DumpAlignRulesInfo(); void DumpExtensionHandlerInfo(); void DumpAdvanceInfo() override; diff --git a/frameworks/core/components_ng/layout/layout_property.cpp b/frameworks/core/components_ng/layout/layout_property.cpp index a1a4b203aaa818b2fc21821df4e9cbd956d9c4fb..78f4b8ae01fb93bd436822358231f8342fc44471 100644 --- a/frameworks/core/components_ng/layout/layout_property.cpp +++ b/frameworks/core/components_ng/layout/layout_property.cpp @@ -2081,6 +2081,23 @@ void LayoutProperty::CheckLocalizedBorderImageOutset(const TextDirection& direct target->UpdateBorderImage(borderImageProperty); } +std::string LayoutProperty::LayoutInfoToString() +{ + std::stringstream ss; + if (HasAspectRatio()) { + ss << "aspectRatio: " << magicItemProperty_.GetAspectRatioValue() << ","; + } + if (magicItemProperty_.GetLayoutWeight().has_value()) { + ss << "layoutWeight: " << magicItemProperty_.GetLayoutWeight().value() << ","; + } + if (GetPositionProperty() && GetPositionProperty()->GetAlignment().has_value()) { + ss << GetPositionProperty()->GetAlignment().value().ToString() << ","; + } + if (GetLayoutDirection() != TextDirection::AUTO) { + ss << "layoutDirection: " << static_cast(GetLayoutDirection()); + } + return ss.str(); +} RefPtr LayoutProperty::GetGeometryTransition() const { return geometryTransition_.Upgrade(); diff --git a/frameworks/core/components_ng/layout/layout_property.h b/frameworks/core/components_ng/layout/layout_property.h index a51d8f22dfa2715a8932c94ccf040e13690d1e49..611a0e82859d0093788d9d45053a2722aa03278a 100644 --- a/frameworks/core/components_ng/layout/layout_property.h +++ b/frameworks/core/components_ng/layout/layout_property.h @@ -410,6 +410,8 @@ public: virtual void OnPropertyChangeMeasure() {} + std::string LayoutInfoToString(); + protected: void UpdateLayoutProperty(const LayoutProperty* layoutProperty); diff --git a/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_pattern.h b/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_pattern.h index 142356a36278fd19376fea067ee9ba304c8dcd75..54b7972dab5de6a9b0d9cb6eb8f3f8ec2adc959c 100644 --- a/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_pattern.h +++ b/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_pattern.h @@ -18,6 +18,7 @@ #include "grid_col_layout_property.h" +#include "base/log/dump_log.h" #include "base/utils/macros.h" #include "core/components_ng/pattern/linear_layout/linear_layout_algorithm.h" #include "core/components_ng/pattern/pattern.h" @@ -50,6 +51,15 @@ public: { return { false, true, ScopeType::OTHERS }; } + + void DumpInfo() override + { + auto host = GetHost(); + CHECK_NULL_VOID(host); + auto layoutProperty = DynamicCast(host->GetLayoutProperty()); + CHECK_NULL_VOID(layoutProperty); + DumpLog::GetInstance().AddDesc(layoutProperty->ToString().c_str()); + } }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_property.cpp b/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_property.cpp index 9a4196da4047a762899de7781913b1a77481b078..e57ec43b9f8dfa9a1054b0c570c57364f9bc13f1 100644 --- a/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_property.cpp +++ b/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_property.cpp @@ -16,6 +16,7 @@ #include "core/components_ng/pattern/grid_col/grid_col_layout_property.h" #include "core/components_v2/grid_layout/grid_container_utils.h" +#include namespace OHOS::Ace::NG { @@ -65,4 +66,17 @@ int32_t GridColLayoutProperty::GetPropValue(const V2::GridContainerSize& prop, V } } +std::string GridColLayoutProperty::ToString() const +{ + auto sizeType = GetSizeTypeValue(V2::GridSizeType::UNDEFINED); + auto span = GetSpan(sizeType); + auto offset = GetOffset(sizeType); + auto order = GetOrder(sizeType); + std::stringstream ss; + ss << "[span:" << span << ", "; + ss << "offset:" << offset << ", "; + ss << "order:" << order << ", "; + ss << "sizeType:" << static_cast(sizeType) << "]"; + return ss.str(); +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_property.h b/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_property.h index 38d76e219cce2e98aa1658388e89868fd99bb774..405c09578940889dd67be8c32037299f1df9f4ba 100644 --- a/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_property.h +++ b/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_property.h @@ -74,6 +74,8 @@ public: return GetPropValue(offset, sizeType); } + std::string ToString() const; + private: static int32_t GetPropValue(const V2::GridContainerSize& prop, V2::GridSizeType sizeType); }; diff --git a/frameworks/core/components_ng/pattern/grid_row/grid_row_layout_pattern.h b/frameworks/core/components_ng/pattern/grid_row/grid_row_layout_pattern.h index e4fefa9b8ba72c762c7c1a8235d5a5b14c281e86..2df5ecaa1a0323e1b16ae010c5307695bd0f18cf 100644 --- a/frameworks/core/components_ng/pattern/grid_row/grid_row_layout_pattern.h +++ b/frameworks/core/components_ng/pattern/grid_row/grid_row_layout_pattern.h @@ -18,6 +18,7 @@ #include +#include "base/log/dump_log.h" #include "base/utils/macros.h" #include "core/components_ng/pattern/grid_row/grid_row_event_hub.h" #include "core/components_ng/pattern/grid_row/grid_row_layout_algorithm.h" @@ -63,6 +64,42 @@ public: { return { false, true, ScopeType::OTHERS }; } + + void DumpInfo() override + { + auto host = GetHost(); + CHECK_NULL_VOID(host); + auto layoutProperty = DynamicCast(host->GetLayoutProperty()); + CHECK_NULL_VOID(layoutProperty); + auto columns = layoutProperty->GetColumns(); + if (columns.has_value()) { + DumpLog::GetInstance().AddDesc(std::string("columns: ").append(columns.value().ToString().c_str())); + } + auto gutter = layoutProperty->GetGutter(); + if (gutter.has_value()) { + DumpLog::GetInstance().AddDesc(std::string("gutter: ").append(gutter.value().ToString().c_str())); + } + auto breakPoints = layoutProperty->GetBreakPoints(); + if (breakPoints.has_value()) { + DumpLog::GetInstance().AddDesc(std::string("breakPoints: ").append(breakPoints.value().ToString().c_str())); + } + auto direction = layoutProperty->GetDirection(); + if (direction.has_value()) { + DumpLog::GetInstance().AddDesc( + std::string("direction: ").append(std::to_string(static_cast(direction.value())).c_str())); + } + auto sizeType = layoutProperty->GetSizeType(); + if (sizeType.has_value()) { + DumpLog::GetInstance().AddDesc( + std::string("sizeType: ").append(std::to_string(static_cast(sizeType.value())).c_str())); + } + auto alignItems = layoutProperty->GetAlignItems(); + if (alignItems.has_value()) { + DumpLog::GetInstance().AddDesc( + std::string("alignItems: ").append(std::to_string(static_cast(alignItems.value())).c_str())); + } + } + private: std::optional callbackId_; diff --git a/frameworks/core/components_ng/property/flex_property.h b/frameworks/core/components_ng/property/flex_property.h index d552c60061005c23a2ac077143e52ec70f011d87..a05936149597a1b626ee60638a11c6c9e892fc0b 100644 --- a/frameworks/core/components_ng/property/flex_property.h +++ b/frameworks/core/components_ng/property/flex_property.h @@ -20,6 +20,7 @@ #include "base/geometry/dimension.h" #include "base/json/json_util.h" +#include "base/log/dump_log.h" #include "core/components/common/layout/constants.h" #include "core/components/common/layout/position_param.h" #include "core/components_ng/base/inspector_filter.h" @@ -231,6 +232,27 @@ public: needMarkParentMeasure_ = mark; } + std::string FlexLayoutInfoToString() + { + std::stringstream ss; + if (GetFlexBasis().has_value()) { + ss << "flexBasis:" << GetFlexBasis().value().ToString() << ", "; + } + if (GetFlexGrow().has_value()) { + ss << "flexGrow:" << GetFlexGrow().value() << ", "; + } + if (GetFlexShrink().has_value()) { + ss << "flexshrink:" << GetFlexShrink().value() << ", "; + } + if (GetAlignSelf().has_value()) { + ss << "alignSelf:" << static_cast(GetAlignSelf().value()) << ", "; + } + if (GetDisplayIndex().has_value()) { + ss << "displayPriority:" << GetDisplayIndex().value(); + } + return ss.str(); + } + ACE_DEFINE_PROPERTY_GROUP_ITEM(FlexGrow, float); ACE_DEFINE_PROPERTY_GROUP_ITEM(FlexShrink, float); ACE_DEFINE_PROPERTY_GROUP_ITEM(AlignSelf, FlexAlign); diff --git a/frameworks/core/components_v2/grid_layout/grid_container_util_class.h b/frameworks/core/components_v2/grid_layout/grid_container_util_class.h index b5fa1d3a0914e961fb1240c096fb2fcfaabbf072..59b22223d3a3a3cddb0e3c74278e4594c0776d99 100644 --- a/frameworks/core/components_v2/grid_layout/grid_container_util_class.h +++ b/frameworks/core/components_v2/grid_layout/grid_container_util_class.h @@ -16,6 +16,7 @@ #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_GRID_LAYOUT_GRID_CONTAINER_UTIL_CLASS_H #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_GRID_LAYOUT_GRID_CONTAINER_UTIL_CLASS_H +#include #include #include "base/geometry/dimension.h" @@ -45,6 +46,20 @@ struct GridContainerSize : public Referenced { int32_t lg = DEFAULT_COLUMN_NUMBER; int32_t xl = DEFAULT_COLUMN_NUMBER; int32_t xxl = DEFAULT_COLUMN_NUMBER; + + std::string ToString() + { + std::stringstream ss; + ss << "GridContainerSize: {"; + ss << "xs: " << xs << ", "; + ss << "sm: " << sm << ", "; + ss << "md: " << md << ", "; + ss << "lg: " << lg << ", "; + ss << "xl: " << xl << ", "; + ss << "xxl: " << xxl; + ss << " }"; + return ss.str(); + } }; enum class BreakPointsReference { @@ -125,6 +140,26 @@ public: Dimension yXl; Dimension xXXl; Dimension yXXl; + + std::string ToString() + { + std::stringstream ss; + ss << "Gutter: {"; + ss << "xXs: " << xXs.ToString().c_str() << ", "; + ss << "yXs: " << yXs.ToString().c_str() << ", "; + ss << "xSm: " << xSm.ToString().c_str() << ", "; + ss << "ySm: " << ySm.ToString().c_str() << ", "; + ss << "xMd: " << xMd.ToString().c_str() << ", "; + ss << "yMd: " << yMd.ToString().c_str() << ", "; + ss << "xLg: " << xLg.ToString().c_str() << ", "; + ss << "yLg: " << yLg.ToString().c_str() << ", "; + ss << "xXl: " << xXl.ToString().c_str() << ", "; + ss << "yXl: " << yXl.ToString().c_str() << ", "; + ss << "xXXl: " << xXXl.ToString().c_str() << ", "; + ss << "yXXl: " << yXXl.ToString().c_str(); + ss << " }"; + return ss.str(); + } }; class BreakPoints : public AceType { @@ -136,6 +171,20 @@ public: BreakPoints, (reference)(breakpoints)) BreakPointsReference reference = BreakPointsReference::WindowSize; std::vector breakpoints { "320vp", "600vp", "840vp" }; + + std::string ToString() + { + std::stringstream ss; + ss << "BreakPoints: {"; + ss << "reference: " << static_cast(reference) << ", "; + ss << "breakpoints: ["; + for (const auto& breakpoint : breakpoints) { + ss << breakpoint << ", "; + } + ss << "]"; + ss << " }"; + return ss.str(); + } }; } // namespace OHOS::Ace::V2