Revert "Skip replacing meta/viewport"

This reverts commit 6c460eef23.
pull/215/head
M66B 1 year ago
parent 61b8c6fd36
commit da0fc61ace

@ -2481,17 +2481,15 @@ 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++) {
@ -2514,6 +2512,12 @@ public class HtmlHelper {
} }
} }
meta.attr("content", TextUtils.join(",", param)); 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");
}
} }
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG)

Loading…
Cancel
Save