From c47ef7bee48f2eb42f65fe4f62cc6b2b33e7505c Mon Sep 17 00:00:00 2001 From: Adam Comella Date: Wed, 20 Jul 2016 19:08:05 -0700 Subject: [PATCH] Update css-layout dependency The updated version of css-layout includes significant changes which make the layout engine conform closer to the W3C spec. For details, see https://github.com/facebook/css-layout/pull/185 The inline view implementation had to be modified slightly due to a change in the layout engine. In the updated layout engine, nodes with a measure function are treated as leaves. Consequently, nodes with a mesaure function (e.g. Text) do not have their children laid out automatically. To fix this, Text nodes now manually invoke the layout engine on each of their inline views. --- .../Views/Text/ReactSpanShadowNode.cs | 18 ++++++++++++++++++ .../Views/Text/ReactTextShadowNode.cs | 18 ++++++++++++++++++ ReactWindows/ReactNative/project.json | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/ReactWindows/ReactNative/Views/Text/ReactSpanShadowNode.cs b/ReactWindows/ReactNative/Views/Text/ReactSpanShadowNode.cs index a3987563e0d..5e3c3e99bf9 100644 --- a/ReactWindows/ReactNative/Views/Text/ReactSpanShadowNode.cs +++ b/ReactWindows/ReactNative/Views/Text/ReactSpanShadowNode.cs @@ -127,5 +127,23 @@ public override void UpdateInline(Inline inline) inline.FontWeight = _fontWeight ?? FontWeights.Normal; inline.FontFamily = _fontFamily != null ? new FontFamily(_fontFamily) : FontFamily.XamlAutoFontFamily; } + + /// + /// This method will be called by once + /// per batch, before calculating layout. This will only be called for + /// nodes that are marked as updated with or + /// require layout (i.e., marked with ). + /// + public override void OnBeforeLayout() + { + // Run flexbox on the children which are inline views. + foreach (var child in this.Children) + { + if (!(child is ReactRunShadowNode) && !(child is ReactSpanShadowNode)) + { + child.CalculateLayout(); + } + } + } } } diff --git a/ReactWindows/ReactNative/Views/Text/ReactTextShadowNode.cs b/ReactWindows/ReactNative/Views/Text/ReactTextShadowNode.cs index f8c5114b2f7..54904867a08 100644 --- a/ReactWindows/ReactNative/Views/Text/ReactTextShadowNode.cs +++ b/ReactWindows/ReactNative/Views/Text/ReactTextShadowNode.cs @@ -267,5 +267,23 @@ private void UpdateTextBlockCore(RichTextBlock textBlock, bool measureOnly) 0); } } + + /// + /// This method will be called by once + /// per batch, before calculating layout. This will only be called for + /// nodes that are marked as updated with or + /// require layout (i.e., marked with ). + /// + public override void OnBeforeLayout() + { + // Run flexbox on the children which are inline views. + foreach (var child in this.Children) + { + if (!(child is ReactRunShadowNode) && !(child is ReactSpanShadowNode)) + { + child.CalculateLayout(); + } + } + } } } diff --git a/ReactWindows/ReactNative/project.json b/ReactWindows/ReactNative/project.json index 50d9381dc25..7de5c44ed6d 100644 --- a/ReactWindows/ReactNative/project.json +++ b/ReactWindows/ReactNative/project.json @@ -1,6 +1,6 @@ { "dependencies": { - "Facebook.CSSLayout": "2.0.0-pre", + "Facebook.CSSLayout": "2.0.1-pre", "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0", "Newtonsoft.Json": "7.0.1", "Rx-Xaml": "2.2.5",