From e0e7efeba96bba160096bcd7bb8a32de3b6c9c3b Mon Sep 17 00:00:00 2001 From: Wolfgang Haupt Date: Sat, 23 Nov 2024 21:04:12 +0100 Subject: [PATCH 1/5] fix: underline color of hrefs We need to explicitly set the underline color to the same blue as we set the text. fixes: https://github.com/Sub6Resources/flutter_html/issues/1414 We need to explicitly set the text decoration color. --- lib/src/builtins/interactive_element_builtin.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/builtins/interactive_element_builtin.dart b/lib/src/builtins/interactive_element_builtin.dart index d430b3a847..f0f052676c 100644 --- a/lib/src/builtins/interactive_element_builtin.dart +++ b/lib/src/builtins/interactive_element_builtin.dart @@ -30,6 +30,7 @@ class InteractiveElementBuiltIn extends HtmlExtension { style: Style( color: Colors.blue, textDecoration: TextDecoration.underline, + textDecorationColor: Colors.blue, ), node: context.node, elementId: context.id, From 0f9f70a51c03712a95320e20f63a7c0f449441dc Mon Sep 17 00:00:00 2001 From: Wolfgang Haupt Date: Sat, 23 Nov 2024 21:06:02 +0100 Subject: [PATCH 2/5] fix: underlines rendered in wrong color Cascade text decoration attributes color, thickness and style in addition to the textdecoration itself. fixes: https://github.com/Sub6Resources/flutter_html/issues/1361 --- lib/src/style.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/style.dart b/lib/src/style.dart index d19fede664..5f4d978c8e 100644 --- a/lib/src/style.dart +++ b/lib/src/style.dart @@ -404,6 +404,9 @@ class Style { child.textDecoration ?? TextDecoration.none, textDecoration ?? TextDecoration.none, ]), + textDecorationColor: child.textDecorationColor ?? textDecorationColor, + textDecorationThickness: child.textDecorationThickness ?? textDecorationThickness, + textDecorationStyle: child.textDecorationStyle ?? textDecorationStyle, textShadow: child.textShadow ?? textShadow, whiteSpace: child.whiteSpace ?? whiteSpace, wordSpacing: child.wordSpacing ?? wordSpacing, From 04772de96bd59415e1151bc6d03232ed23f60227 Mon Sep 17 00:00:00 2001 From: Wolfgang Haupt Date: Sat, 23 Nov 2024 21:10:05 +0100 Subject: [PATCH 3/5] fix: underlines of "u" tags rendered in wrong color When you use a "u" html tag, you expect the underline to match the textcolor. Therefore we need to get the style of the child element and use it's color if it exists. --- lib/src/builtins/styled_element_builtin.dart | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/src/builtins/styled_element_builtin.dart b/lib/src/builtins/styled_element_builtin.dart index a750c93187..6ab5c0bfbe 100644 --- a/lib/src/builtins/styled_element_builtin.dart +++ b/lib/src/builtins/styled_element_builtin.dart @@ -414,9 +414,17 @@ class StyledElementBuiltIn extends HtmlExtension { continue monospace; underline: case "u": - styledElement.style = Style( - textDecoration: TextDecoration.underline, - ); + for (var child in styledElement.children) { + if (child.attributes.containsKey("style")) { + final newStyle = inlineCssToStyle(child.attributes["style"], null); + if (newStyle != null) { + styledElement.style = styledElement.style.merge(Style(textDecorationColor: newStyle.color)); + } + } + } + styledElement.style = styledElement.style.merge(Style( + textDecoration: TextDecoration.underline + )); break; case "var": continue italics; From bbd8bad02668c60814aafe39988a11f17a9dca48 Mon Sep 17 00:00:00 2001 From: Wolfgang Haupt Date: Fri, 17 Jan 2025 22:28:17 +0100 Subject: [PATCH 4/5] fix: underline of colored links is in the wrong color If you have a link with a color style, the expectation is that the underline of the link is the same color, hence we need to implicitly set the text decoration color as well, when we apply the text color. --- lib/src/css_parser.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/css_parser.dart b/lib/src/css_parser.dart index 57169787bc..02cbe8a3ae 100644 --- a/lib/src/css_parser.dart +++ b/lib/src/css_parser.dart @@ -292,7 +292,7 @@ Style declarationsToStyle(Map> declarations) { style.border = newBorder; break; case 'color': - style.color = + style.color = style.textDecorationColor = ExpressionMapping.expressionToColor(value.first) ?? style.color; break; case 'direction': From 09418a6d22fdfd390258c40d881185f63a59b5a3 Mon Sep 17 00:00:00 2001 From: Matthew Whitaker Date: Wed, 12 Mar 2025 15:19:29 -0600 Subject: [PATCH 5/5] Run dart format --- lib/src/builtins/styled_element_builtin.dart | 8 ++++---- lib/src/style.dart | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/src/builtins/styled_element_builtin.dart b/lib/src/builtins/styled_element_builtin.dart index 6ab5c0bfbe..a56a8f278d 100644 --- a/lib/src/builtins/styled_element_builtin.dart +++ b/lib/src/builtins/styled_element_builtin.dart @@ -418,13 +418,13 @@ class StyledElementBuiltIn extends HtmlExtension { if (child.attributes.containsKey("style")) { final newStyle = inlineCssToStyle(child.attributes["style"], null); if (newStyle != null) { - styledElement.style = styledElement.style.merge(Style(textDecorationColor: newStyle.color)); + styledElement.style = styledElement.style + .merge(Style(textDecorationColor: newStyle.color)); } } } - styledElement.style = styledElement.style.merge(Style( - textDecoration: TextDecoration.underline - )); + styledElement.style = styledElement.style + .merge(Style(textDecoration: TextDecoration.underline)); break; case "var": continue italics; diff --git a/lib/src/style.dart b/lib/src/style.dart index 5f4d978c8e..014f7ff91f 100644 --- a/lib/src/style.dart +++ b/lib/src/style.dart @@ -405,7 +405,8 @@ class Style { textDecoration ?? TextDecoration.none, ]), textDecorationColor: child.textDecorationColor ?? textDecorationColor, - textDecorationThickness: child.textDecorationThickness ?? textDecorationThickness, + textDecorationThickness: + child.textDecorationThickness ?? textDecorationThickness, textDecorationStyle: child.textDecorationStyle ?? textDecorationStyle, textShadow: child.textShadow ?? textShadow, whiteSpace: child.whiteSpace ?? whiteSpace,