mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-30 19:56:10 +00:00
Skip replacing meta/viewport
This commit is contained in:
parent
f0932039cc
commit
6c460eef23
1 changed files with 26 additions and 30 deletions
|
@ -2479,43 +2479,39 @@ public class HtmlHelper {
|
||||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag
|
// https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag
|
||||||
// https://drafts.csswg.org/css-device-adapt/#viewport-meta
|
// https://drafts.csswg.org/css-device-adapt/#viewport-meta
|
||||||
Elements meta = document.select("meta").select("[name=viewport]");
|
Elements meta = document.select("meta").select("[name=viewport]");
|
||||||
|
if (meta.size() != 1)
|
||||||
|
return;
|
||||||
|
|
||||||
// Note that the browser will recognize meta elements in the body too
|
// Note that the browser will recognize meta elements in the body too
|
||||||
if (overview) {
|
if (overview) {
|
||||||
// fit width
|
// fit width
|
||||||
meta.remove();
|
//meta.remove();
|
||||||
document.head().prependElement("meta")
|
//document.head().prependElement("meta")
|
||||||
.attr("name", "viewport")
|
// .attr("name", "viewport")
|
||||||
.attr("content", "width=device-width");
|
// .attr("content", "width=device-width");
|
||||||
} else {
|
} else {
|
||||||
if (meta.size() == 1) {
|
String content = meta.attr("content");
|
||||||
String content = meta.attr("content");
|
String[] param = content.split("[;,]");
|
||||||
String[] param = content.split("[;,]");
|
for (int i = 0; i < param.length; i++) {
|
||||||
for (int i = 0; i < param.length; i++) {
|
String[] kv = param[i].split("=");
|
||||||
String[] kv = param[i].split("=");
|
if (kv.length == 2) {
|
||||||
if (kv.length == 2) {
|
String key = kv[0]
|
||||||
String key = kv[0]
|
.replaceAll("\\s+", "")
|
||||||
.replaceAll("\\s+", "")
|
.toLowerCase(Locale.ROOT);
|
||||||
.toLowerCase(Locale.ROOT);
|
switch (key) {
|
||||||
switch (key) {
|
case "user-scalable":
|
||||||
case "user-scalable":
|
kv[1] = "yes";
|
||||||
kv[1] = "yes";
|
param[i] = TextUtils.join("=", kv);
|
||||||
param[i] = TextUtils.join("=", kv);
|
break;
|
||||||
break;
|
case "minimum-scale":
|
||||||
case "minimum-scale":
|
case "maximum-scale":
|
||||||
case "maximum-scale":
|
kv[0] = "disabled-scaling";
|
||||||
kv[0] = "disabled-scaling";
|
param[i] = TextUtils.join("=", kv);
|
||||||
param[i] = TextUtils.join("=", kv);
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
meta.attr("content", TextUtils.join(",", param));
|
|
||||||
} else {
|
|
||||||
meta.remove();
|
|
||||||
document.head().prependElement("meta")
|
|
||||||
.attr("name", "viewport")
|
|
||||||
.attr("content", "width=device-width, initial-scale=1.0");
|
|
||||||
}
|
}
|
||||||
|
meta.attr("content", TextUtils.join(",", param));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BuildConfig.DEBUG)
|
if (BuildConfig.DEBUG)
|
||||||
|
|
Loading…
Reference in a new issue