1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (c) Meta Platforms, Inc. and affiliates.
3//
4// SPDX-License-Identifier: MIT
5
6#include "YGStyle.h"
7#include "Utils.h"
8
9QT_YOGA_NAMESPACE_BEGIN
10
11// Yoga specific properties, not compatible with flexbox specification
12bool operator==(const YGStyle& lhs, const YGStyle& rhs) {
13 bool areNonFloatValuesEqual = lhs.direction() == rhs.direction() &&
14 lhs.flexDirection() == rhs.flexDirection() &&
15 lhs.justifyContent() == rhs.justifyContent() &&
16 lhs.alignContent() == rhs.alignContent() &&
17 lhs.alignItems() == rhs.alignItems() &&
18 lhs.alignSelf() == rhs.alignSelf() &&
19 lhs.positionType() == rhs.positionType() &&
20 lhs.flexWrap() == rhs.flexWrap() && lhs.overflow() == rhs.overflow() &&
21 lhs.display() == rhs.display() &&
22 YGValueEqual(a: lhs.flexBasis(), b: rhs.flexBasis()) &&
23 lhs.margin() == rhs.margin() && lhs.position() == rhs.position() &&
24 lhs.padding() == rhs.padding() && lhs.border() == rhs.border() &&
25 lhs.gap() == rhs.gap() && lhs.dimensions() == rhs.dimensions() &&
26 lhs.minDimensions() == rhs.minDimensions() &&
27 lhs.maxDimensions() == rhs.maxDimensions();
28
29 areNonFloatValuesEqual = areNonFloatValuesEqual &&
30 lhs.flex().isUndefined() == rhs.flex().isUndefined();
31 if (areNonFloatValuesEqual && !lhs.flex().isUndefined() &&
32 !rhs.flex().isUndefined()) {
33 areNonFloatValuesEqual = areNonFloatValuesEqual && lhs.flex() == rhs.flex();
34 }
35
36 areNonFloatValuesEqual = areNonFloatValuesEqual &&
37 lhs.flexGrow().isUndefined() == rhs.flexGrow().isUndefined();
38 if (areNonFloatValuesEqual && !lhs.flexGrow().isUndefined()) {
39 areNonFloatValuesEqual =
40 areNonFloatValuesEqual && lhs.flexGrow() == rhs.flexGrow();
41 }
42
43 areNonFloatValuesEqual = areNonFloatValuesEqual &&
44 lhs.flexShrink().isUndefined() == rhs.flexShrink().isUndefined();
45 if (areNonFloatValuesEqual && !rhs.flexShrink().isUndefined()) {
46 areNonFloatValuesEqual =
47 areNonFloatValuesEqual && lhs.flexShrink() == rhs.flexShrink();
48 }
49
50 if (!(lhs.aspectRatio().isUndefined() && rhs.aspectRatio().isUndefined())) {
51 areNonFloatValuesEqual =
52 areNonFloatValuesEqual && lhs.aspectRatio() == rhs.aspectRatio();
53 }
54
55 return areNonFloatValuesEqual;
56}
57
58QT_YOGA_NAMESPACE_END
59

source code of qtdeclarative/src/3rdparty/yoga/YGStyle.cpp