From 9ba461ec3e93bc6267fbb7eba6232fc309425455 Mon Sep 17 00:00:00 2001 From: fenglinbailu Date: Sat, 8 Feb 2025 17:42:49 +0800 Subject: [PATCH] =?UTF-8?q?onareachange=20=E5=A2=9E=E5=8A=A0positionedges?= =?UTF-8?q?=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fenglinbailu --- .../components_ng/layout/layout_wrapper.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/frameworks/core/components_ng/layout/layout_wrapper.cpp b/frameworks/core/components_ng/layout/layout_wrapper.cpp index 1bc8b5e2985..6e901fcc397 100644 --- a/frameworks/core/components_ng/layout/layout_wrapper.cpp +++ b/frameworks/core/components_ng/layout/layout_wrapper.cpp @@ -170,6 +170,16 @@ OffsetF LayoutWrapper::GetParentGlobalOffsetWithSafeArea(bool checkBoundary, boo auto renderPosition = FrameNode::ContextPositionConvertToPX( parentRenderContext, parentLayoutConstraint.value().percentReference); offset += OffsetF(static_cast(renderPosition.first), static_cast(renderPosition.second)); + } else if (checkPosition && parentRenderContext && parentRenderContext->GetPositionProperty() && + parentRenderContext->GetPositionProperty()->HasPositionEdges()) { + auto parentLayoutProp = parent->GetLayoutProperty(); + CHECK_NULL_RETURN(parentLayoutProp, offset); + auto parentLayoutConstraint = parentLayoutProp->GetLayoutConstraint(); + CHECK_EQUAL_RETURN(parentLayoutConstraint.has_value(), false, offset); + auto positionEdges = parentRenderContext->GetPositionEdgesValue(EdgesParam {}); + auto renderPosition = parentRenderContext->GetRectOffsetWithPositionEdges(positionEdges, + parentLayoutConstraint->percentReference.Width(), parentLayoutConstraint->percentReference.Height()); + offset += renderPosition; } else { offset += parent->GetFrameRectWithSafeArea().GetOffset(); } @@ -205,6 +215,18 @@ RectF LayoutWrapper::GetFrameRectWithSafeArea(bool checkPosition) const rect = RectF(OffsetF(static_cast(renderPosition.first), static_cast(renderPosition.second)), size); return rect; + } else if (checkPosition && renderContext && renderContext->GetPositionProperty() && + renderContext->GetPositionProperty()->HasPositionEdges()) { + auto layoutProp = host->GetLayoutProperty(); + CHECK_NULL_RETURN(layoutProp, rect); + auto layoutConstraint = layoutProp->GetLayoutConstraint(); + CHECK_EQUAL_RETURN(layoutConstraint.has_value(), false, rect); + auto positionEdges = renderContext->GetPositionEdgesValue(EdgesParam {}); + auto renderPosition = renderContext->GetRectOffsetWithPositionEdges(positionEdges, + layoutConstraint->percentReference.Width(), layoutConstraint->percentReference.Height()); + auto size = (geometryNode->GetSelfAdjust() + geometryNode->GetFrameRect()).GetSize(); + rect = RectF(renderPosition, size); + return rect; } return geometryNode->GetSelfAdjust() + geometryNode->GetFrameRect(); } -- Gitee