mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
xcomponent layout增加判空
Signed-off-by: WangYing225 <wangying397@huawei.com> Change-Id: If964002579a5c12dfb0a3d7ce64c832a90f2c34d
This commit is contained in:
parent
6dbd1330c7
commit
f1ca507a4d
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/utils/utils.h"
|
||||
#include "core/components_ng/pattern/xcomponent/xcomponent_layout_algorithm.h"
|
||||
#include "core/components_ng/pattern/linear_layout/linear_layout_utils.h"
|
||||
#include "core/components_ng/pattern/xcomponent/xcomponent_layout_property.h"
|
||||
@ -22,6 +23,7 @@ std::optional<SizeF> XComponentLayoutAlgorithm::MeasureContent(
|
||||
const LayoutConstraintF& contentConstraint, LayoutWrapper* layoutWrapper)
|
||||
{
|
||||
auto layoutProperty = DynamicCast<XComponentLayoutProperty>(layoutWrapper->GetLayoutProperty());
|
||||
CHECK_NULL_RETURN(layoutProperty, SizeF(0, 0));
|
||||
auto xcomponentType = layoutProperty->GetXComponentType().value_or(XComponentType::SURFACE);
|
||||
if (xcomponentType == XComponentType::COMPONENT) {
|
||||
return LayoutAlgorithm::MeasureContent(contentConstraint, layoutWrapper);
|
||||
@ -35,6 +37,7 @@ std::optional<SizeF> XComponentLayoutAlgorithm::MeasureContent(
|
||||
void XComponentLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper)
|
||||
{
|
||||
auto layoutProperty = DynamicCast<XComponentLayoutProperty>(layoutWrapper->GetLayoutProperty());
|
||||
CHECK_NULL_VOID(layoutProperty);
|
||||
auto xcomponentType = layoutProperty->GetXComponentType().value_or(XComponentType::SURFACE);
|
||||
if (xcomponentType == XComponentType::COMPONENT) {
|
||||
LinearLayoutUtils::Measure(layoutWrapper, true);
|
||||
@ -46,6 +49,7 @@ void XComponentLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper)
|
||||
void XComponentLayoutAlgorithm::Layout(LayoutWrapper* layoutWrapper)
|
||||
{
|
||||
auto layoutProperty = DynamicCast<XComponentLayoutProperty>(layoutWrapper->GetLayoutProperty());
|
||||
CHECK_NULL_VOID(layoutProperty);
|
||||
auto xcomponentType = layoutProperty->GetXComponentType().value_or(XComponentType::SURFACE);
|
||||
if (xcomponentType == XComponentType::COMPONENT) {
|
||||
LinearLayoutUtils::Layout(layoutWrapper, true, FlexAlign::CENTER, FlexAlign::FLEX_START);
|
||||
|
Loading…
Reference in New Issue
Block a user