Coverage Report

Created: 2025-08-26 06:41

/src/yoga/yoga/algorithm/TrailingPosition.h
Line
Count
Source
1
/*
2
 * Copyright (c) Meta Platforms, Inc. and affiliates.
3
 *
4
 * This source code is licensed under the MIT license found in the
5
 * LICENSE file in the root directory of this source tree.
6
 */
7
8
#pragma once
9
10
#include <yoga/Yoga.h>
11
#include <yoga/algorithm/FlexDirection.h>
12
#include <yoga/event/event.h>
13
#include <yoga/node/Node.h>
14
15
namespace facebook::yoga {
16
17
// Given an offset to an edge, returns the offset to the opposite edge on the
18
// same axis. This assumes that the width/height of both nodes is determined at
19
// this point.
20
inline float getPositionOfOppositeEdge(
21
    float position,
22
    FlexDirection axis,
23
    const yoga::Node* const containingNode,
24
1.47M
    const yoga::Node* const node) {
25
1.47M
  return containingNode->getLayout().measuredDimension(dimension(axis)) -
26
1.47M
      node->getLayout().measuredDimension(dimension(axis)) - position;
27
1.47M
}
28
29
inline void setChildTrailingPosition(
30
    const yoga::Node* const node,
31
    yoga::Node* const child,
32
1.47M
    const FlexDirection axis) {
33
1.47M
  child->setLayoutPosition(
34
1.47M
      getPositionOfOppositeEdge(
35
1.47M
          child->getLayout().position(flexStartEdge(axis)), axis, node, child),
36
1.47M
      flexEndEdge(axis));
37
1.47M
}
38
39
779k
inline bool needsTrailingPosition(const FlexDirection axis) {
40
779k
  return axis == FlexDirection::RowReverse ||
41
779k
      axis == FlexDirection::ColumnReverse;
42
779k
}
43
44
} // namespace facebook::yoga