BREAKING - Fix sizing of container with child overflowing parent
Summary: Fixes issue brought up in https://github.com/facebook/react-native/issues/10603 The gist of the problem is that in css it is fine for a child to overflow a parent if it feels the need to, we were not respecting this. Reviewed By: mmmulani Differential Revision: D4182141 fbshipit-source-id: c73fd15d2577ab846fc8a202d529d0e6e1207b75
This commit is contained in:
committed by
Facebook Github Bot
parent
2c8c2bffda
commit
0bcec80dfe
177
csharp/tests/Facebook.Yoga/YGSizeOverflowTest.cs
Normal file
177
csharp/tests/Facebook.Yoga/YGSizeOverflowTest.cs
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Facebook.Yoga
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class YGSizeOverflowTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void Test_nested_overflowing_child()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.Width = 100;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child0 = new YogaNode();
|
||||||
|
root_child0_child0.Width = 200;
|
||||||
|
root_child0_child0.Height = 200;
|
||||||
|
root_child0.Insert(0, root_child0_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-100f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_nested_overflowing_child_in_constraint_parent()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.Width = 100;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.Width = 100;
|
||||||
|
root_child0.Height = 100;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child0 = new YogaNode();
|
||||||
|
root_child0_child0.Width = 200;
|
||||||
|
root_child0_child0.Height = 200;
|
||||||
|
root_child0.Insert(0, root_child0_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-100f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_parent_wrap_child_size_overflowing_parent()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.Width = 100;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.Width = 100;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child0 = new YogaNode();
|
||||||
|
root_child0_child0.Width = 100;
|
||||||
|
root_child0_child0.Height = 200;
|
||||||
|
root_child0.Insert(0, root_child0_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
17
gentest/fixtures/YGSizeOverflowTest.html
Normal file
17
gentest/fixtures/YGSizeOverflowTest.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<div id="nested_overflowing_child" style="height: 100px; width: 100px;">
|
||||||
|
<div>
|
||||||
|
<div style="height: 200px; width: 200px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="nested_overflowing_child_in_constraint_parent" style="height: 100px; width: 100px;">
|
||||||
|
<div style="height: 100px; width: 100px;">
|
||||||
|
<div style="height: 200px; width: 200px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="parent_wrap_child_size_overflowing_parent" style="width: 100px; height: 100px;">
|
||||||
|
<div style="width: 100px;">
|
||||||
|
<div style="width: 100px; height: 200px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
172
java/tests/com/facebook/yoga/YGSizeOverflowTest.java
Normal file
172
java/tests/com/facebook/yoga/YGSizeOverflowTest.java
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html
|
||||||
|
|
||||||
|
package com.facebook.yoga;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class YGSizeOverflowTest {
|
||||||
|
@Test
|
||||||
|
public void test_nested_overflowing_child() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setWidth(100f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = new YogaNode();
|
||||||
|
root_child0_child0.setWidth(200f);
|
||||||
|
root_child0_child0.setHeight(200f);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(-100f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_nested_overflowing_child_in_constraint_parent() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setWidth(100f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setWidth(100f);
|
||||||
|
root_child0.setHeight(100f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = new YogaNode();
|
||||||
|
root_child0_child0.setWidth(200f);
|
||||||
|
root_child0_child0.setHeight(200f);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(-100f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_parent_wrap_child_size_overflowing_parent() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setWidth(100f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setWidth(100f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = new YogaNode();
|
||||||
|
root_child0_child0.setWidth(100f);
|
||||||
|
root_child0_child0.setHeight(200f);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
172
javascript/tests/Facebook.Yoga/YGSizeOverflowTest.js
Normal file
172
javascript/tests/Facebook.Yoga/YGSizeOverflowTest.js
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html
|
||||||
|
|
||||||
|
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||||
|
|
||||||
|
it("nested_overflowing_child", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setWidth(100);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
var root_child0_child0 = Yoga.Node.create();
|
||||||
|
root_child0_child0.setWidth(200);
|
||||||
|
root_child0_child0.setHeight(200);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root_child0.getComputedHeight(), "200 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||||
|
console.assert(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root_child0.getComputedHeight(), "200 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(-100 === root_child0_child0.getComputedLeft(), "-100 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||||
|
console.assert(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("nested_overflowing_child_in_constraint_parent", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setWidth(100);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setWidth(100);
|
||||||
|
root_child0.setHeight(100);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
var root_child0_child0 = Yoga.Node.create();
|
||||||
|
root_child0_child0.setWidth(200);
|
||||||
|
root_child0_child0.setHeight(200);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||||
|
console.assert(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(-100 === root_child0_child0.getComputedLeft(), "-100 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||||
|
console.assert(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("parent_wrap_child_size_overflowing_parent", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setWidth(100);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setWidth(100);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
var root_child0_child0 = Yoga.Node.create();
|
||||||
|
root_child0_child0.setWidth(100);
|
||||||
|
root_child0_child0.setHeight(200);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root_child0.getComputedHeight(), "200 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root_child0.getComputedHeight(), "200 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
163
tests/YGSizeOverflowTest.cpp
Normal file
163
tests/YGSizeOverflowTest.cpp
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html
|
||||||
|
|
||||||
|
#include <yoga/Yoga.h>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
TEST(YogaTest, nested_overflowing_child) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root, 100);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0, 200);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0, 200);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, nested_overflowing_child_in_constraint_parent) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root, 100);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root_child0, 100);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 100);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0, 200);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0, 200);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, parent_wrap_child_size_overflowing_parent) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root, 100);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root_child0, 100);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0, 100);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0, 200);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
16
yoga/Yoga.c
16
yoga/Yoga.c
@@ -985,7 +985,9 @@ static inline YGDirection YGNodeResolveDirection(const YGNodeRef node,
|
|||||||
|
|
||||||
static float YGBaseline(const YGNodeRef node) {
|
static float YGBaseline(const YGNodeRef node) {
|
||||||
if (node->baseline != NULL) {
|
if (node->baseline != NULL) {
|
||||||
const float baseline = node->baseline(node, node->layout.measuredDimensions[YGDimensionWidth], node->layout.measuredDimensions[YGDimensionHeight]);
|
const float baseline = node->baseline(node,
|
||||||
|
node->layout.measuredDimensions[YGDimensionWidth],
|
||||||
|
node->layout.measuredDimensions[YGDimensionHeight]);
|
||||||
YG_ASSERT(!YGFloatIsUndefined(baseline), "Expect custom baseline function to not return NaN")
|
YG_ASSERT(!YGFloatIsUndefined(baseline), "Expect custom baseline function to not return NaN")
|
||||||
return baseline;
|
return baseline;
|
||||||
}
|
}
|
||||||
@@ -2672,19 +2674,22 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
|
|
||||||
// If the user didn't specify a width or height for the node, set the
|
// If the user didn't specify a width or height for the node, set the
|
||||||
// dimensions based on the children.
|
// dimensions based on the children.
|
||||||
if (measureModeMainDim == YGMeasureModeUndefined) {
|
if (measureModeMainDim == YGMeasureModeUndefined ||
|
||||||
|
(node->style.overflow != YGOverflowScroll && measureModeMainDim == YGMeasureModeAtMost)) {
|
||||||
// Clamp the size to the min/max size, if specified, and make sure it
|
// Clamp the size to the min/max size, if specified, and make sure it
|
||||||
// doesn't go below the padding and border amount.
|
// doesn't go below the padding and border amount.
|
||||||
node->layout.measuredDimensions[dim[mainAxis]] =
|
node->layout.measuredDimensions[dim[mainAxis]] =
|
||||||
YGNodeBoundAxis(node, mainAxis, maxLineMainDim, mainAxisParentSize, parentWidth);
|
YGNodeBoundAxis(node, mainAxis, maxLineMainDim, mainAxisParentSize, parentWidth);
|
||||||
} else if (measureModeMainDim == YGMeasureModeAtMost) {
|
} else if (measureModeMainDim == YGMeasureModeAtMost &&
|
||||||
|
node->style.overflow == YGOverflowScroll) {
|
||||||
node->layout.measuredDimensions[dim[mainAxis]] = fmaxf(
|
node->layout.measuredDimensions[dim[mainAxis]] = fmaxf(
|
||||||
fminf(availableInnerMainDim + paddingAndBorderAxisMain,
|
fminf(availableInnerMainDim + paddingAndBorderAxisMain,
|
||||||
YGNodeBoundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim, mainAxisParentSize)),
|
YGNodeBoundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim, mainAxisParentSize)),
|
||||||
paddingAndBorderAxisMain);
|
paddingAndBorderAxisMain);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (measureModeCrossDim == YGMeasureModeUndefined) {
|
if (measureModeCrossDim == YGMeasureModeUndefined ||
|
||||||
|
(node->style.overflow != YGOverflowScroll && measureModeCrossDim == YGMeasureModeAtMost)) {
|
||||||
// Clamp the size to the min/max size, if specified, and make sure it
|
// Clamp the size to the min/max size, if specified, and make sure it
|
||||||
// doesn't go below the padding and border amount.
|
// doesn't go below the padding and border amount.
|
||||||
node->layout.measuredDimensions[dim[crossAxis]] =
|
node->layout.measuredDimensions[dim[crossAxis]] =
|
||||||
@@ -2693,7 +2698,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
totalLineCrossDim + paddingAndBorderAxisCross,
|
totalLineCrossDim + paddingAndBorderAxisCross,
|
||||||
crossAxisParentSize,
|
crossAxisParentSize,
|
||||||
parentWidth);
|
parentWidth);
|
||||||
} else if (measureModeCrossDim == YGMeasureModeAtMost) {
|
} else if (measureModeCrossDim == YGMeasureModeAtMost &&
|
||||||
|
node->style.overflow == YGOverflowScroll) {
|
||||||
node->layout.measuredDimensions[dim[crossAxis]] =
|
node->layout.measuredDimensions[dim[crossAxis]] =
|
||||||
fmaxf(fminf(availableInnerCrossDim + paddingAndBorderAxisCross,
|
fmaxf(fminf(availableInnerCrossDim + paddingAndBorderAxisCross,
|
||||||
YGNodeBoundAxisWithinMinAndMax(node,
|
YGNodeBoundAxisWithinMinAndMax(node,
|
||||||
|
Reference in New Issue
Block a user