/// <summary>
        /// Called once per batch of updates by the <see cref="UIManagerModule"/>
        /// if the text node is dirty.
        /// </summary>
        public override void OnBeforeLayout()
        {
            if (_isVirtual)
            {
                return;
            }

            _inline = DispatcherHelpers.CallOnDispatcher(() => ReactTextShadowNodeInlineVisitor.Apply(this)).Result;
            MarkUpdated();
        }
        private static MeasureOutput MeasureText(CSSNode node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode)
        {
            // This is not a terribly efficient way of projecting the height of
            // the text elements. It requires that we have access to the
            // dispatcher in order to do measurement, which, for obvious
            // reasons, can cause perceived performance issues as it will block
            // the UI thread from handling other work.
            //
            // TODO: determine another way to measure text elements.
            var task = DispatcherHelpers.CallOnDispatcher(() =>
            {
                var textBlock = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.DetectFromContent,
                    TextTrimming  = TextTrimming.CharacterEllipsis,
                };

                var textNode = (ReactTextShadowNode)node;

                textBlock.CharacterSpacing = textNode._letterSpacing;
                textBlock.LineHeight       = textNode._lineHeight;
                textBlock.MaxLines         = textNode._numberOfLines;
                textBlock.TextAlignment    = textNode._textAlignment;

                textBlock.Inlines.Add(ReactTextShadowNodeInlineVisitor.Apply(node));

                try
                {
                    var normalizedWidth  = CSSConstants.IsUndefined(width) ? double.PositiveInfinity : width;
                    var normalizedHeight = CSSConstants.IsUndefined(height) ? double.PositiveInfinity : height;
                    textBlock.Measure(new Size(normalizedWidth, normalizedHeight));
                    return(new MeasureOutput(
                               (float)Math.Ceiling(textBlock.DesiredSize.Width),
                               (float)Math.Ceiling(textBlock.DesiredSize.Height)));
                }
                finally
                {
                    textBlock.Inlines.Clear();
                }
            });

            return(task.Result);
        }