From 2b0e4784d33d50999414ebe887e2697ce4e10e45 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Fri, 31 Jul 2015 12:55:45 -0700 Subject: [PATCH] Fix TextAlign.right We were applying the style to the RenderInline but we actually needed to apply it to the RenderParagraph. The lineHeight property had the same problem. --- packages/flutter/lib/painting/text_style.dart | 17 ++++++++++------- packages/flutter/lib/rendering/paragraph.dart | 9 +++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/packages/flutter/lib/painting/text_style.dart b/packages/flutter/lib/painting/text_style.dart index db5b0ecd9e..732a8e5b6e 100644 --- a/packages/flutter/lib/painting/text_style.dart +++ b/packages/flutter/lib/painting/text_style.dart @@ -140,6 +140,16 @@ class TextStyle { FontWeight.w900: '900' }[fontWeight]; } + if (decoration != null) { + cssStyle['text-decoration'] = _decorationToCSSString(decoration); + if (decorationColor != null) + cssStyle['text-decoration-color'] = _colorToCSSString(decorationColor); + if (decorationStyle != null) + cssStyle['text-decoration-style'] = _decorationStyleToCSSString(decorationStyle); + } + } + + void applyToContainerCSSStyle(CSSStyleDeclaration cssStyle) { if (textAlign != null) { cssStyle['text-align'] = const { TextAlign.left: 'left', @@ -150,13 +160,6 @@ class TextStyle { if (height != null) { cssStyle['line-height'] = '${height}'; } - if (decoration != null) { - cssStyle['text-decoration'] = _decorationToCSSString(decoration); - if (decorationColor != null) - cssStyle['text-decoration-color'] = _colorToCSSString(decorationColor); - if (decorationStyle != null) - cssStyle['text-decoration-style'] = _decorationStyleToCSSString(decorationStyle); - } } bool operator ==(other) { diff --git a/packages/flutter/lib/rendering/paragraph.dart b/packages/flutter/lib/rendering/paragraph.dart index 8bd7292a7c..aa41b67fd1 100644 --- a/packages/flutter/lib/rendering/paragraph.dart +++ b/packages/flutter/lib/rendering/paragraph.dart @@ -11,6 +11,9 @@ import 'package:sky/rendering/object.dart'; abstract class InlineBase { sky.Node _toDOM(sky.Document owner); String toString([String prefix = '']); + + void _applyStyleToContainer(sky.Element container) { + } } class InlineText extends InlineBase { @@ -48,6 +51,10 @@ class InlineStyle extends InlineBase { return parent; } + void _applyStyleToContainer(sky.Element container) { + style.applyToContainerCSSStyle(container.style); + } + bool operator ==(other) { if (identical(this, other)) return true; @@ -112,6 +119,8 @@ class RenderParagraph extends RenderBox { return; _inline = value; _layoutRoot.rootElement.setChild(_inline._toDOM(_document)); + _layoutRoot.rootElement.removeAttribute('style'); + _inline._applyStyleToContainer(_layoutRoot.rootElement); _constraintsForCurrentLayout = null; markNeedsLayout(); }