Skip to content

Commit 104aa49

Browse files
Adam Comellarozele
Adam Comella
authored andcommitted
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 facebook/yoga#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.
1 parent 2adeff2 commit 104aa49

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

ReactWindows/ReactNative/Views/Text/ReactSpanShadowNode.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,23 @@ public override void UpdateInline(Inline inline)
127127
inline.FontWeight = _fontWeight ?? FontWeights.Normal;
128128
inline.FontFamily = _fontFamily != null ? new FontFamily(_fontFamily) : FontFamily.XamlAutoFontFamily;
129129
}
130+
131+
/// <summary>
132+
/// This method will be called by <see cref="UIManagerModule"/> once
133+
/// per batch, before calculating layout. This will only be called for
134+
/// nodes that are marked as updated with <see cref="MarkUpdated"/> or
135+
/// require layout (i.e., marked with <see cref="dirty"/>).
136+
/// </summary>
137+
public override void OnBeforeLayout()
138+
{
139+
// Run flexbox on the children which are inline views.
140+
foreach (var child in this.Children)
141+
{
142+
if (!(child is ReactRunShadowNode) && !(child is ReactSpanShadowNode))
143+
{
144+
child.CalculateLayout();
145+
}
146+
}
147+
}
130148
}
131149
}

ReactWindows/ReactNative/Views/Text/ReactTextShadowNode.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,5 +267,23 @@ private void UpdateTextBlockCore(RichTextBlock textBlock, bool measureOnly)
267267
0);
268268
}
269269
}
270+
271+
/// <summary>
272+
/// This method will be called by <see cref="UIManagerModule"/> once
273+
/// per batch, before calculating layout. This will only be called for
274+
/// nodes that are marked as updated with <see cref="MarkUpdated"/> or
275+
/// require layout (i.e., marked with <see cref="dirty"/>).
276+
/// </summary>
277+
public override void OnBeforeLayout()
278+
{
279+
// Run flexbox on the children which are inline views.
280+
foreach (var child in this.Children)
281+
{
282+
if (!(child is ReactRunShadowNode) && !(child is ReactSpanShadowNode))
283+
{
284+
child.CalculateLayout();
285+
}
286+
}
287+
}
270288
}
271289
}

ReactWindows/ReactNative/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"Facebook.CSSLayout": "2.0.0-pre",
3+
"Facebook.CSSLayout": "2.0.1-pre",
44
"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
55
"Newtonsoft.Json": "9.0.1",
66
"System.Reactive": "3.0.0",

0 commit comments

Comments
 (0)