Skip to content

Commit

Permalink
change default value of position styles
Browse files Browse the repository at this point in the history
Summary: Default value for positions should be undefined not 0px. Fixing this leads to more correct tests.

Reviewed By: gkassabli

Differential Revision: D4153329

fbshipit-source-id: d0f194f9c47eac93d3815ec7e55568a1016bc7fe
  • Loading branch information
Emil Sjolander authored and Facebook Github Bot committed Nov 9, 2016
1 parent e54af5e commit 6a6efe0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</div>
<div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
<div style="position: absolute; start: 0; top: 0;">
<div style="position: absolute; start: 0px; top: 0px;">
<div style="width: 100px; height: 100px;"></div>
</div>
</div>
Expand Down Expand Up @@ -219,6 +219,8 @@ public void Test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_

CSSNode root_child0 = new CSSNode();
root_child0.PositionType = CSSPositionType.Absolute;
root_child0.SetPosition(CSSEdge.Start, 0);
root_child0.SetPosition(CSSEdge.Top, 0);
root.Insert(0, root_child0);

CSSNode root_child0_child0 = new CSSNode();
Expand Down
2 changes: 1 addition & 1 deletion gentest/fixtures/CSSLayoutAbsolutePositionTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</div>

<div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
<div style="position: absolute; start: 0; top: 0;">
<div style="position: absolute; start: 0px; top: 0px;">
<div style="width: 100px; height: 100px;"></div>
</div>
</div>
17 changes: 13 additions & 4 deletions gentest/gentest.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ function checkDefaultValues() {
{style:'overflow', value:'visible'},
{style:'flex-grow', value:'0'},
{style:'flex-shrink', value:'0'},
{style:'left', value:'0px'},
{style:'top', value:'0px'},
{style:'right', value:'0px'},
{style:'bottom', value:'0px'},
{style:'left', value:'undefined'},
{style:'top', value:'undefined'},
{style:'right', value:'undefined'},
{style:'bottom', value:'undefined'},
].forEach(function(item) {
assert(item.value === getDefaultStyleValue(item.style),
item.style + ' should be ' + item.value);
Expand Down Expand Up @@ -415,6 +415,15 @@ function getDefaultStyleValue(style) {
if (style == 'position') {
return 'relative';
}
switch (style) {
case 'left':
case 'top':
case 'right':
case 'bottom':
case 'start':
case 'end':
return 'undefined';
}
var node = document.getElementById('default');
return getComputedStyle(node, null).getPropertyValue(style);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</div>
<div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
<div style="position: absolute; start: 0; top: 0;">
<div style="position: absolute; start: 0px; top: 0px;">
<div style="width: 100px; height: 100px;"></div>
</div>
</div>
Expand Down Expand Up @@ -213,6 +213,8 @@ public void test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_

final CSSNode root_child0 = new CSSNode();
root_child0.setPositionType(CSSPositionType.ABSOLUTE);
root_child0.setPosition(Spacing.START, 0);
root_child0.setPosition(Spacing.TOP, 0);
root.addChildAt(root_child0, 0);

final CSSNode root_child0_child0 = new CSSNode();
Expand Down
4 changes: 3 additions & 1 deletion tests/CSSLayoutAbsolutePositionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</div>
<div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
<div style="position: absolute; start: 0; top: 0;">
<div style="position: absolute; start: 0px; top: 0px;">
<div style="width: 100px; height: 100px;"></div>
</div>
</div>
Expand Down Expand Up @@ -204,6 +204,8 @@ TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overfl

const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 0);
CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 0);
CSSNodeInsertChild(root, root_child0, 0);

const CSSNodeRef root_child0_child0 = CSSNodeNew();
Expand Down

0 comments on commit 6a6efe0

Please sign in to comment.