diff --git a/frameworks/core/components_ng/layout/layout_property.cpp b/frameworks/core/components_ng/layout/layout_property.cpp index 5ce53b46b93df61a0ad0869484bfda2cb59ce6d6..cfe856c51fc9591d86286056a8fe0448275cd1e6 100644 --- a/frameworks/core/components_ng/layout/layout_property.cpp +++ b/frameworks/core/components_ng/layout/layout_property.cpp @@ -717,6 +717,14 @@ void LayoutProperty::ConstraintContentByPadding() void LayoutProperty::ConstraintContentByBorder() { CHECK_NULL_VOID(borderWidth_); + auto host = GetHost(); + if (host) { + auto pattern = host->GetPattern(); + if (pattern && pattern->BorderUnoccupied()) { + return; + } + } + auto borderWidthF = ConvertToBorderWidthPropertyF( *borderWidth_, contentConstraint_->scaleProperty, layoutConstraint_->percentReference.Width()); if (AceApplicationInfo::GetInstance().GreatOrEqualTargetAPIVersion(PlatformVersion::VERSION_TWELVE)) { @@ -785,6 +793,13 @@ PaddingPropertyF LayoutProperty::CreatePaddingAndBorder(bool includeSafeAreaPadd padding_, ScaleProperty::CreateScaleProperty(), layoutConstraint_->percentReference.Width()); auto borderWidth = ConvertToBorderWidthPropertyF( borderWidth_, ScaleProperty::CreateScaleProperty(), layoutConstraint_->percentReference.Width()); + auto host = GetHost(); + if (host) { + auto pattern = host->GetPattern(); + if (pattern && pattern->BorderUnoccupied()) { + borderWidth = BorderWidthPropertyF(); + } + } return CombinePaddingsAndBorder(safeAreaPadding, padding, borderWidth, {}); } auto padding = ConvertToPaddingPropertyF( diff --git a/frameworks/core/components_ng/pattern/pattern.h b/frameworks/core/components_ng/pattern/pattern.h index 6996fcef9fcf7dea5bff745686b41158677f181c..ae7da5be8c8f3ff3e7c77a85535af9e6af986a90 100644 --- a/frameworks/core/components_ng/pattern/pattern.h +++ b/frameworks/core/components_ng/pattern/pattern.h @@ -682,6 +682,11 @@ public: virtual void EndTranslate() {}; virtual void SendTranslateResult(std::string results) {}; + virtual bool BorderUnoccupied() const + { + return false; + } + protected: virtual void OnAttachToFrameNode() {} virtual void OnDetachFromFrameNode(FrameNode* frameNode) {}