Skip to content

Commit

Permalink
Port "Add missing js implementation for PR facebook#200 "
Browse files Browse the repository at this point in the history
  • Loading branch information
jordwalke committed Oct 6, 2016
1 parent 40a56a6 commit a9d3666
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/re-layout/src/Layout.re
Original file line number Diff line number Diff line change
Expand Up @@ -1261,21 +1261,35 @@ let layoutNode (node, availableWidth, availableHeight, parentDirection) => {
gCurrentGenerationCount.contents = gCurrentGenerationCount.contents + 1;
/* If the caller didn't specify a height/width, use the dimensions*/
/* specified in the style.*/
let availableWidth =
if (isUndefined availableWidth && isStyleDimDefined node CSS_FLEX_DIRECTION_ROW) {
node.style.width +. getMarginAxis node CSS_FLEX_DIRECTION_ROW
open ReJsPrelude;
let (availableWidth, widthMeasureMode) =
if !(isUndefined availableWidth) {
(availableWidth, CSS_MEASURE_MODE_EXACTLY)
} else if (
isStyleDimDefined node CSS_FLEX_DIRECTION_ROW
) {
(node.style.width +. getMarginAxis node CSS_FLEX_DIRECTION_ROW, CSS_MEASURE_MODE_EXACTLY)
} else if (
node.style.maxWidth >= 0.0
) {
(node.style.maxWidth, CSS_MEASURE_MODE_AT_MOST)
} else {
availableWidth
(availableWidth, CSS_MEASURE_MODE_UNDEFINED)
};
let availableHeight =
if (isUndefined availableHeight && isStyleDimDefined node CSS_FLEX_DIRECTION_COLUMN) {
node.style.height +. getMarginAxis node CSS_FLEX_DIRECTION_COLUMN
let (availableHeight, heightMeasureMode) =
if !(isUndefined availableHeight) {
(availableHeight, CSS_MEASURE_MODE_EXACTLY)
} else if (
isStyleDimDefined node CSS_FLEX_DIRECTION_COLUMN
) {
(node.style.height +. getMarginAxis node CSS_FLEX_DIRECTION_COLUMN, CSS_MEASURE_MODE_EXACTLY)
} else if (
node.style.maxHeight >= 0.0
) {
(node.style.maxHeight, CSS_MEASURE_MODE_AT_MOST)
} else {
availableHeight
(availableHeight, CSS_MEASURE_MODE_UNDEFINED)
};
let widthMeasureMode = isUndefined availableWidth ? CSS_MEASURE_MODE_UNDEFINED : CSS_MEASURE_MODE_EXACTLY;
let heightMeasureMode =
isUndefined availableHeight ? CSS_MEASURE_MODE_UNDEFINED : CSS_MEASURE_MODE_EXACTLY;
if (
layoutNodeInternal
node availableWidth availableHeight parentDirection widthMeasureMode heightMeasureMode true "initial"
Expand Down

0 comments on commit a9d3666

Please sign in to comment.