Skip to content

Commit

Permalink
Merge pull request #203 from emilsjolander/at-most-root-js
Browse files Browse the repository at this point in the history
Add missing js implementation for PR #200
  • Loading branch information
emilsjolander authored Jul 8, 2016
2 parents 6e05325 + c4fa32c commit d878091
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
9 changes: 9 additions & 0 deletions TestResult.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--This file represents the results of running a test suite-->
<test-results name="src/csharp/Facebook.CSSLayout.Tests/bin/Release/Facebook.CSSLayout.Tests.dll" total="0" failures="0" not-run="0" date="2016-07-08" time="14:42:41">
<environment nunit-version="2.4.8.0" clr-version="4.0.30319.17020" os-version="Unix 15.5.0.0" platform="Unix" cwd="/Volumes/Source/css-layout" machine-name="emilsj-pro" user="emilsj" user-domain="emilsj-pro" />
<culture-info current-culture="en-US" current-uiculture="en-US" />
<test-suite name="src/csharp/Facebook.CSSLayout.Tests/bin/Release/Facebook.CSSLayout.Tests.dll" success="True" time="0.001" asserts="0">
<results />
</test-suite>
</test-results>
Binary file modified dist/css-layout.jar
Binary file not shown.
25 changes: 18 additions & 7 deletions dist/css-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -1683,18 +1683,29 @@ var computeLayout = (function() {
// parameters don't change.
gCurrentGenerationCount++;

// If the caller didn't specify a height/width, use the dimensions
// specified in the style.
if (isUndefined(availableWidth) && isStyleDimDefined(node, CSS_FLEX_DIRECTION_ROW)) {
var widthMeasureMode = CSS_MEASURE_MODE_UNDEFINED;
var heightMeasureMode = CSS_MEASURE_MODE_UNDEFINED;

if (!isUndefined(availableWidth)) {
widthMeasureMode = CSS_MEASURE_MODE_EXACTLY;
} else if (isStyleDimDefined(node, CSS_FLEX_DIRECTION_ROW)) {
availableWidth = node.style.width + getMarginAxis(node, CSS_FLEX_DIRECTION_ROW);
widthMeasureMode = CSS_MEASURE_MODE_EXACTLY;
} else if (node.style.maxWidth >= 0.0) {
availableWidth = node.style.maxWidth;
widthMeasureMode = CSS_MEASURE_MODE_AT_MOST;
}
if (isUndefined(availableHeight) && isStyleDimDefined(node, CSS_FLEX_DIRECTION_COLUMN)) {

if (!isUndefined(availableHeight)) {
heightMeasureMode = CSS_MEASURE_MODE_EXACTLY;
} else if (isStyleDimDefined(node, CSS_FLEX_DIRECTION_COLUMN)) {
availableHeight = node.style.height + getMarginAxis(node, CSS_FLEX_DIRECTION_COLUMN);
heightMeasureMode = CSS_MEASURE_MODE_EXACTLY;
} else if (node.style.maxHeight >= 0.0) {
availableHeight = node.style.maxHeight;
heightMeasureMode = CSS_MEASURE_MODE_AT_MOST;
}

var widthMeasureMode = isUndefined(availableWidth) ? CSS_MEASURE_MODE_UNDEFINED : CSS_MEASURE_MODE_EXACTLY;
var heightMeasureMode = isUndefined(availableHeight) ? CSS_MEASURE_MODE_UNDEFINED : CSS_MEASURE_MODE_EXACTLY;

if (layoutNodeInternal(node, availableWidth, availableHeight, parentDirection, widthMeasureMode, heightMeasureMode, true, 'initial')) {
setPosition(node, node.layout.direction);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/css-layout.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/css-layout.min.js.map

Large diffs are not rendered by default.

25 changes: 18 additions & 7 deletions src/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -1664,18 +1664,29 @@ var computeLayout = (function() {
// parameters don't change.
gCurrentGenerationCount++;

// If the caller didn't specify a height/width, use the dimensions
// specified in the style.
if (isUndefined(availableWidth) && isStyleDimDefined(node, CSS_FLEX_DIRECTION_ROW)) {
var widthMeasureMode = CSS_MEASURE_MODE_UNDEFINED;
var heightMeasureMode = CSS_MEASURE_MODE_UNDEFINED;

if (!isUndefined(availableWidth)) {
widthMeasureMode = CSS_MEASURE_MODE_EXACTLY;
} else if (isStyleDimDefined(node, CSS_FLEX_DIRECTION_ROW)) {
availableWidth = node.style.width + getMarginAxis(node, CSS_FLEX_DIRECTION_ROW);
widthMeasureMode = CSS_MEASURE_MODE_EXACTLY;
} else if (node.style.maxWidth >= 0.0) {
availableWidth = node.style.maxWidth;
widthMeasureMode = CSS_MEASURE_MODE_AT_MOST;
}
if (isUndefined(availableHeight) && isStyleDimDefined(node, CSS_FLEX_DIRECTION_COLUMN)) {

if (!isUndefined(availableHeight)) {
heightMeasureMode = CSS_MEASURE_MODE_EXACTLY;
} else if (isStyleDimDefined(node, CSS_FLEX_DIRECTION_COLUMN)) {
availableHeight = node.style.height + getMarginAxis(node, CSS_FLEX_DIRECTION_COLUMN);
heightMeasureMode = CSS_MEASURE_MODE_EXACTLY;
} else if (node.style.maxHeight >= 0.0) {
availableHeight = node.style.maxHeight;
heightMeasureMode = CSS_MEASURE_MODE_AT_MOST;
}

var widthMeasureMode = isUndefined(availableWidth) ? CSS_MEASURE_MODE_UNDEFINED : CSS_MEASURE_MODE_EXACTLY;
var heightMeasureMode = isUndefined(availableHeight) ? CSS_MEASURE_MODE_UNDEFINED : CSS_MEASURE_MODE_EXACTLY;

if (layoutNodeInternal(node, availableWidth, availableHeight, parentDirection, widthMeasureMode, heightMeasureMode, true, 'initial')) {
setPosition(node, node.layout.direction);
}
Expand Down

0 comments on commit d878091

Please sign in to comment.