YGStyle.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the LICENSE
  5. * file in the root directory of this source tree.
  6. */
  7. #include "YGStyle.h"
  8. #include "Utils.h"
  9. // Yoga specific properties, not compatible with flexbox specification
  10. bool operator==(const YGStyle& lhs, const YGStyle& rhs) {
  11. bool areNonFloatValuesEqual = lhs.direction == rhs.direction &&
  12. lhs.flexDirection == rhs.flexDirection &&
  13. lhs.justifyContent == rhs.justifyContent &&
  14. lhs.alignContent == rhs.alignContent &&
  15. lhs.alignItems == rhs.alignItems && lhs.alignSelf == rhs.alignSelf &&
  16. lhs.positionType == rhs.positionType && lhs.flexWrap == rhs.flexWrap &&
  17. lhs.overflow == rhs.overflow && lhs.display == rhs.display &&
  18. YGValueEqual(lhs.flexBasis, rhs.flexBasis) && lhs.margin == rhs.margin &&
  19. lhs.position == rhs.position && lhs.padding == rhs.padding &&
  20. lhs.border == rhs.border && lhs.dimensions == rhs.dimensions &&
  21. lhs.minDimensions == rhs.minDimensions &&
  22. lhs.maxDimensions == rhs.maxDimensions;
  23. areNonFloatValuesEqual = areNonFloatValuesEqual &&
  24. lhs.flex.isUndefined() == rhs.flex.isUndefined();
  25. if (areNonFloatValuesEqual && !lhs.flex.isUndefined() &&
  26. !rhs.flex.isUndefined()) {
  27. areNonFloatValuesEqual = areNonFloatValuesEqual && lhs.flex == rhs.flex;
  28. }
  29. areNonFloatValuesEqual = areNonFloatValuesEqual &&
  30. lhs.flexGrow.isUndefined() == rhs.flexGrow.isUndefined();
  31. if (areNonFloatValuesEqual && !lhs.flexGrow.isUndefined()) {
  32. areNonFloatValuesEqual =
  33. areNonFloatValuesEqual && lhs.flexGrow == rhs.flexGrow;
  34. }
  35. areNonFloatValuesEqual = areNonFloatValuesEqual &&
  36. lhs.flexShrink.isUndefined() == rhs.flexShrink.isUndefined();
  37. if (areNonFloatValuesEqual && !rhs.flexShrink.isUndefined()) {
  38. areNonFloatValuesEqual =
  39. areNonFloatValuesEqual && lhs.flexShrink == rhs.flexShrink;
  40. }
  41. if (!(lhs.aspectRatio.isUndefined() && rhs.aspectRatio.isUndefined())) {
  42. areNonFloatValuesEqual =
  43. areNonFloatValuesEqual && lhs.aspectRatio == rhs.aspectRatio;
  44. }
  45. return areNonFloatValuesEqual;
  46. }