diff --git a/parser/html/nsHtml5Highlighter.cpp b/parser/html/nsHtml5Highlighter.cpp index e232d18f84ee..042915a4a752 100644 --- a/parser/html/nsHtml5Highlighter.cpp +++ b/parser/html/nsHtml5Highlighter.cpp @@ -89,6 +89,11 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle) //
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(); diff --git a/parser/html/nsHtml5TreeBuilderCppSupplement.h b/parser/html/nsHtml5TreeBuilderCppSupplement.h index 65255c2e5344..7dd4f4d2d221 100644 --- a/parser/html/nsHtml5TreeBuilderCppSupplement.h +++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h @@ -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); diff --git a/parser/html/nsHtml5ViewSourceUtils.cpp b/parser/html/nsHtml5ViewSourceUtils.cpp index 29879572631b..86fb8d8522d9 100644 --- a/parser/html/nsHtml5ViewSourceUtils.cpp +++ b/parser/html/nsHtml5ViewSourceUtils.cpp @@ -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; +} diff --git a/parser/html/nsHtml5ViewSourceUtils.h b/parser/html/nsHtml5ViewSourceUtils.h index 1644801b69d2..058b65788e0c 100644 --- a/parser/html/nsHtml5ViewSourceUtils.h +++ b/parser/html/nsHtml5ViewSourceUtils.h @@ -12,6 +12,7 @@ class nsHtml5ViewSourceUtils public: static nsHtml5HtmlAttributes* NewBodyAttributes(); static nsHtml5HtmlAttributes* NewLinkAttributes(); + static nsHtml5HtmlAttributes* NewMetaViewportAttributes(); }; #endif // nsHtml5ViewSourceUtils_h diff --git a/toolkit/content/browser-content.js b/toolkit/content/browser-content.js index 45db891a35ce..165a29a4b7cc 100644 --- a/toolkit/content/browser-content.js +++ b/toolkit/content/browser-content.js @@ -1402,7 +1402,8 @@ var ViewSelectionSource = { var source = "" + "" - + "