mirror of https://github.com/M66B/FairEmail.git
Add context
This commit is contained in:
parent
6ddebf90f8
commit
06d63aec7c
|
@ -7391,7 +7391,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
List<CSSStyleSheet> sheets =
|
||||
HtmlHelper.parseStyles(d.head().select("style"));
|
||||
for (Element element : d.select("*")) {
|
||||
String computed = HtmlHelper.processStyles(
|
||||
String computed = HtmlHelper.processStyles(context,
|
||||
element.tagName(),
|
||||
element.className(),
|
||||
element.attr("style"),
|
||||
|
|
|
@ -5858,7 +5858,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
for (Element element : e.select("*")) {
|
||||
String tag = element.tagName();
|
||||
String clazz = element.attr("class");
|
||||
String style = HtmlHelper.processStyles(tag, clazz, null, sheets);
|
||||
String style = HtmlHelper.processStyles(context, tag, clazz, null, sheets);
|
||||
style = HtmlHelper.mergeStyles(style, element.attr("style"));
|
||||
if (!TextUtils.isEmpty(style))
|
||||
element.attr("style", style);
|
||||
|
|
|
@ -663,7 +663,7 @@ public class HtmlHelper {
|
|||
// Class style
|
||||
String tag = element.tagName();
|
||||
String clazz = element.className();
|
||||
String style = processStyles(tag, clazz, null, sheets);
|
||||
String style = processStyles(context, tag, clazz, null, sheets);
|
||||
|
||||
// Element style
|
||||
style = mergeStyles(style, element.attr("style"));
|
||||
|
@ -1780,17 +1780,17 @@ public class HtmlHelper {
|
|||
return sheets;
|
||||
}
|
||||
|
||||
static String processStyles(String tag, String clazz, String style, List<CSSStyleSheet> sheets) {
|
||||
static String processStyles(Context context, String tag, String clazz, String style, List<CSSStyleSheet> sheets) {
|
||||
for (CSSStyleSheet sheet : sheets)
|
||||
if (isScreenMedia(sheet.getMedia())) {
|
||||
style = processStyles(null, clazz, style, sheet.getCssRules(), Selector.SAC_ELEMENT_NODE_SELECTOR);
|
||||
style = processStyles(tag, clazz, style, sheet.getCssRules(), Selector.SAC_ELEMENT_NODE_SELECTOR);
|
||||
style = processStyles(tag, clazz, style, sheet.getCssRules(), Selector.SAC_CONDITIONAL_SELECTOR);
|
||||
if (isScreenMedia(context, sheet.getMedia())) {
|
||||
style = processStyles(context, null, clazz, style, sheet.getCssRules(), Selector.SAC_ELEMENT_NODE_SELECTOR);
|
||||
style = processStyles(context, tag, clazz, style, sheet.getCssRules(), Selector.SAC_ELEMENT_NODE_SELECTOR);
|
||||
style = processStyles(context, tag, clazz, style, sheet.getCssRules(), Selector.SAC_CONDITIONAL_SELECTOR);
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
private static String processStyles(String tag, String clazz, String style, CSSRuleList rules, int stype) {
|
||||
private static String processStyles(Context context, String tag, String clazz, String style, CSSRuleList rules, int stype) {
|
||||
for (int i = 0; rules != null && i < rules.getLength(); i++) {
|
||||
CSSRule rule = rules.item(i);
|
||||
switch (rule.getType()) {
|
||||
|
@ -1829,15 +1829,15 @@ public class HtmlHelper {
|
|||
|
||||
case CSSRule.MEDIA_RULE:
|
||||
CSSMediaRuleImpl mrule = (CSSMediaRuleImpl) rule;
|
||||
if (isScreenMedia(mrule.getMedia()))
|
||||
style = processStyles(tag, clazz, style, mrule.getCssRules(), stype);
|
||||
if (isScreenMedia(context, mrule.getMedia()))
|
||||
style = processStyles(context, tag, clazz, style, mrule.getCssRules(), stype);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
private static boolean isScreenMedia(MediaList media) {
|
||||
private static boolean isScreenMedia(Context context, MediaList media) {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
|
||||
// https://developers.google.com/gmail/design/reference/supported_css#supported_types
|
||||
if (media instanceof MediaListImpl) {
|
||||
|
|
Loading…
Reference in New Issue