зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1392996 - Part 1 - Add meta viewport tag to view-source document. r=hsivonen
Adding <meta name="viewport" content="width=device-width"/> to the view-source document achieves two things when used in a mobile browser, such as Fennec: 1. When word-wrapping is turned off, the page displays at a more readable initial zoom level. 2. As of now, font inflation (when enabled) kicks in on the document when word- wrapping is turned on, which leads to the line numbers appearing in a noticeably smaller font size than the rest of the page. Adding the above meta viewport header marks the document as "mobile-friendly" and suppresses font inflation, which means that line numbers will appear normally even with word-wrapping enabled. getMathMLSelection() in browser-content.js isn't actually used in Fennec at the moment, but for consistency we add the meta viewport tag there as well. MozReview-Commit-ID: K9KVHh7g7TF --HG-- extra : rebase_source : 1054f712f5420efcd89daeaa2c8c200129544b2a
This commit is contained in:
Родитель
ab3df91217
Коммит
9c467e7e8d
|
@ -89,6 +89,11 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle)
|
|||
// <head> uses NS_NewHTMLSharedElement creator
|
||||
Push(nsGkAtoms::head, nullptr, NS_NewHTMLSharedElement);
|
||||
|
||||
Push(nsGkAtoms::meta,
|
||||
nsHtml5ViewSourceUtils::NewMetaViewportAttributes(),
|
||||
NS_NewHTMLMetaElement);
|
||||
Pop(); // meta
|
||||
|
||||
Push(nsGkAtoms::title, nullptr, NS_NewHTMLTitleElement);
|
||||
// XUL will add the "Source of: " prefix.
|
||||
uint32_t length = aTitle.Length();
|
||||
|
|
|
@ -1315,6 +1315,11 @@ void
|
|||
nsHtml5TreeBuilder::StartPlainTextViewSource(const nsAutoString& aTitle)
|
||||
{
|
||||
MOZ_ASSERT(!mBuilder, "Must not view source with builder.");
|
||||
|
||||
startTag(nsHtml5ElementName::ELT_META,
|
||||
nsHtml5ViewSourceUtils::NewMetaViewportAttributes(),
|
||||
false);
|
||||
|
||||
startTag(nsHtml5ElementName::ELT_TITLE,
|
||||
nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES,
|
||||
false);
|
||||
|
|
|
@ -54,3 +54,15 @@ nsHtml5ViewSourceUtils::NewLinkAttributes()
|
|||
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href, -1);
|
||||
return linkAttrs;
|
||||
}
|
||||
|
||||
// static
|
||||
nsHtml5HtmlAttributes*
|
||||
nsHtml5ViewSourceUtils::NewMetaViewportAttributes()
|
||||
{
|
||||
nsHtml5HtmlAttributes* metaVpAttrs = new nsHtml5HtmlAttributes(0);
|
||||
nsHtml5String name = nsHtml5Portability::newStringFromLiteral("viewport");
|
||||
metaVpAttrs->addAttribute(nsHtml5AttributeName::ATTR_NAME, name, -1);
|
||||
nsHtml5String content = nsHtml5Portability::newStringFromLiteral("width=device-width");
|
||||
metaVpAttrs->addAttribute(nsHtml5AttributeName::ATTR_CONTENT, content, -1);
|
||||
return metaVpAttrs;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ class nsHtml5ViewSourceUtils
|
|||
public:
|
||||
static nsHtml5HtmlAttributes* NewBodyAttributes();
|
||||
static nsHtml5HtmlAttributes* NewLinkAttributes();
|
||||
static nsHtml5HtmlAttributes* NewMetaViewportAttributes();
|
||||
};
|
||||
|
||||
#endif // nsHtml5ViewSourceUtils_h
|
||||
|
|
|
@ -1402,7 +1402,8 @@ var ViewSelectionSource = {
|
|||
var source =
|
||||
"<!DOCTYPE html>"
|
||||
+ "<html>"
|
||||
+ "<head><title>" + title + "</title>"
|
||||
+ '<head><meta name="viewport" content="width=device-width"/>'
|
||||
+ "<title>" + title + "</title>"
|
||||
+ '<link rel="stylesheet" type="text/css" href="' + VIEW_SOURCE_CSS + '">'
|
||||
+ '<style type="text/css">'
|
||||
+ "#target { border: dashed 1px; background-color: lightyellow; }"
|
||||
|
|
Загрузка…
Ссылка в новой задаче