Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gentest/fixtures/YGAbsolutePositionTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@
<div style="width:20px; height:20px; position: absolute; align-self: flex-end;"></div>
</div>

<div id="absolute_layout_percentage_from_padded_parent" style="flex-direction:column; width:750px; height:1000px; padding-top: 100px; border-top: 100px;">
<div style="width:750px; height:50%; position: absolute;"></div>
</div>

65 changes: 49 additions & 16 deletions tests/YGAbsolutePositionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*/
// @Generated by gentest/gentest.rb from
// @Generated by gentest/gentest.rb from
// gentest/fixtures/YGAbsolutePositionTest.html

#include <gtest/gtest.h>
Expand Down Expand Up @@ -184,9 +184,7 @@ TEST(YogaTest, absolute_layout_width_height_start_top_end_bottom) {
YGConfigFree(config);
}

TEST(
YogaTest,
do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) {
TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) {
const YGConfigRef config = YGConfigNew();

const YGNodeRef root = YGNodeNewWithConfig(config);
Expand Down Expand Up @@ -578,9 +576,7 @@ TEST(YogaTest, absolute_layout_align_items_center_on_child_only) {
YGConfigFree(config);
}

TEST(
YogaTest,
absolute_layout_align_items_and_justify_content_center_and_top_position) {
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_top_position) {
const YGConfigRef config = YGConfigNew();

const YGNodeRef root = YGNodeNewWithConfig(config);
Expand Down Expand Up @@ -625,9 +621,7 @@ TEST(
YGConfigFree(config);
}

TEST(
YogaTest,
absolute_layout_align_items_and_justify_content_center_and_bottom_position) {
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_bottom_position) {
const YGConfigRef config = YGConfigNew();

const YGNodeRef root = YGNodeNewWithConfig(config);
Expand Down Expand Up @@ -672,9 +666,7 @@ TEST(
YGConfigFree(config);
}

TEST(
YogaTest,
absolute_layout_align_items_and_justify_content_center_and_left_position) {
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_left_position) {
const YGConfigRef config = YGConfigNew();

const YGNodeRef root = YGNodeNewWithConfig(config);
Expand Down Expand Up @@ -719,9 +711,7 @@ TEST(
YGConfigFree(config);
}

TEST(
YogaTest,
absolute_layout_align_items_and_justify_content_center_and_right_position) {
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_right_position) {
const YGConfigRef config = YGConfigNew();

const YGNodeRef root = YGNodeNewWithConfig(config);
Expand Down Expand Up @@ -1039,3 +1029,46 @@ TEST(YogaTest, absolute_layout_in_wrap_reverse_row_container_flex_end) {

YGConfigFree(config);
}

TEST(YogaTest, absolute_layout_percentage_from_padded_parent) {
const YGConfigRef config = YGConfigNew();

const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPadding(root, YGEdgeTop, 100);
YGNodeStyleSetBorder(root, YGEdgeTop, 100);
YGNodeStyleSetWidth(root, 750);
YGNodeStyleSetHeight(root, 1000);

const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root_child0, 750);
YGNodeStyleSetHeightPercent(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(750, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(1000, YGNodeLayoutGetHeight(root));

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(750, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root_child0));

YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(750, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(1000, YGNodeLayoutGetHeight(root));

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(750, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root_child0));

YGNodeFreeRecursive(root);

YGConfigFree(config);
}
6 changes: 3 additions & 3 deletions yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,7 @@ static void YGJustifyMainAxis(
} else if (performLayout) {
child->setLayoutPosition(
childLayout.position[pos[mainAxis]] +
node->getLeadingBorder(mainAxis) + leadingMainDim,
node->getLeadingPadding(mainAxis, ownerWidth).unwrap() + leadingMainDim,
pos[mainAxis]);
}
}
Expand Down Expand Up @@ -3522,9 +3522,9 @@ static void YGNodelayoutImpl(
YGNodeAbsoluteLayoutChild(
node,
child,
availableInnerWidth,
availableWidth,
isMainAxisRow ? measureModeMainDim : measureModeCrossDim,
availableInnerHeight,
availableHeight,
direction,
config,
layoutMarkerData,
Expand Down