mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-19 02:15:28 +00:00
Inherit colors
This commit is contained in:
parent
0110fb4ec9
commit
ca23ea37bf
1 changed files with 15 additions and 2 deletions
|
@ -467,7 +467,15 @@ public class HtmlHelper {
|
|||
// Sanitize styles
|
||||
for (Element element : document.select("*")) {
|
||||
String clazz = element.attr("class");
|
||||
String style = element.attr("style");
|
||||
|
||||
// This is to workaround a TextView bug
|
||||
List<Element> parents = element.parents();
|
||||
Collections.reverse(parents);
|
||||
String style = null;
|
||||
for (Element parent : parents)
|
||||
style = mergeStyles(style, parent.attr("style"), "color");
|
||||
|
||||
style = mergeStyles(style, element.attr("style"));
|
||||
|
||||
// Process class
|
||||
if (!TextUtils.isEmpty(clazz))
|
||||
|
@ -989,6 +997,10 @@ public class HtmlHelper {
|
|||
}
|
||||
|
||||
private static String mergeStyles(String base, String style) {
|
||||
return mergeStyles(base, style, null);
|
||||
}
|
||||
|
||||
private static String mergeStyles(String base, String style, String selector) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
|
||||
List<String> params = new ArrayList<>();
|
||||
|
@ -1001,6 +1013,7 @@ public class HtmlHelper {
|
|||
int colon = param.indexOf(':');
|
||||
if (colon > 0) {
|
||||
String key = param.substring(0, colon).trim().toLowerCase(Locale.ROOT);
|
||||
if (selector == null || selector.equals(key))
|
||||
result.put(key, param);
|
||||
} else
|
||||
Log.w("Invalid style param=" + param);
|
||||
|
|
Loading…
Add table
Reference in a new issue