36 lines
1.7 KiB
Diff
36 lines
1.7 KiB
Diff
From: mauve <ranger@mauve.moe>
|
|
Date: Mon, 30 May 2022 22:25:04 -0400
|
|
Subject: Improve plain text rendering on mobile
|
|
|
|
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
|
|
---
|
|
.../renderer/core/html/parser/text_document_parser.cc | 11 ++++++++++-
|
|
1 file changed, 10 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/third_party/blink/renderer/core/html/parser/text_document_parser.cc b/third_party/blink/renderer/core/html/parser/text_document_parser.cc
|
|
--- a/third_party/blink/renderer/core/html/parser/text_document_parser.cc
|
|
+++ b/third_party/blink/renderer/core/html/parser/text_document_parser.cc
|
|
@@ -65,10 +65,19 @@ void TextDocumentParser::InsertFakePreElement() {
|
|
TreeBuilder()->ConstructTree(&fake_meta);
|
|
attributes.clear();
|
|
|
|
+ // Scale up text to look good on Mobile
|
|
+ attributes.push_back(Attribute(html_names::kNameAttr, AtomicString("viewport")));
|
|
+ attributes.push_back(Attribute(html_names::kContentAttr,
|
|
+ AtomicString("width=device-width, initial-scale=1.0, maximum-scale=1.0")));
|
|
+ AtomicHTMLToken viewport_meta(HTMLToken::kStartTag,
|
|
+ html_names::HTMLTag::kMeta, attributes);
|
|
+ TreeBuilder()->ConstructTree(&viewport_meta);
|
|
+ attributes.clear();
|
|
+
|
|
// Wrap the actual contents of the text file in <pre>.
|
|
attributes.push_back(
|
|
Attribute(html_names::kStyleAttr,
|
|
- AtomicString("word-wrap: break-word; white-space: pre-wrap;")));
|
|
+ AtomicString("word-wrap: break-word; white-space: pre-wrap; font-family: system-ui;")));
|
|
AtomicHTMLToken fake_pre(HTMLToken::kStartTag, html_names::HTMLTag::kPre,
|
|
attributes);
|
|
TreeBuilder()->ConstructTree(&fake_pre);
|
|
--
|
|
2.25.1
|