Files
mozilla45esr/parser/html/nsHtml5ViewSourceUtils.cpp
T
roytam1 706b4d3150 import changes from tenfourfox:
- #565: M1367219 (6f63dc2cc)
- more adblock hosts (8cf4190e2)
- #565: implement nsASCIIMask from M1358297 (41b1fc937) (with vc2013 fix by replacing constexpr to MOZ_CONSTEXPR and MOZ_CONSTEXPR_VAR)
- #565: M1358225 with fix for M1548306 applied (8eed11298) (with vc2013 fix by replacing constexpr to MOZ_CONSTEXPR and MOZ_CONSTEXPR_VAR)
- even more adblock hosts (5d005926f)
- #565: M1347737 (9ab5bb0ed)
- #565: M1358297 parts 3 and 4 (3fd15a87a)
- #521: baseline parser support for async/await, with toggle, without bytecode (passes tests) (0e5746aaf)
- #521: fix yield handling (includes M1305566 pts 4-7) (2d25f717b)
- #521: make async functions throw for compatibility when enabled (46b01b5d4)
- #569: M1204714 (c45b2e8b5)
- #568: M1560495 (adapted for 45) M1562033+M1466449 M1559715 M1564449 M1573160 (d019bd3dc)
- #568: update certs, pins, TLDs, miners (ed3129eeb)
- #570: oops (dd79a9f75)
and added -bigobj compile switch to ssl/moz.build.
2019-08-27 00:22:58 +08:00

56 lines
1.9 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsHtml5ViewSourceUtils.h"
#include "nsHtml5AttributeName.h"
#include "mozilla/Preferences.h"
#include "nsHtml5String.h"
// static
nsHtml5HtmlAttributes*
nsHtml5ViewSourceUtils::NewBodyAttributes()
{
nsHtml5HtmlAttributes* bodyAttrs = new nsHtml5HtmlAttributes(0);
nsHtml5String id = nsHtml5Portability::newStringFromLiteral("viewsource");
bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id);
nsString klass;
if (mozilla::Preferences::GetBool("view_source.wrap_long_lines", true)) {
klass.Append(NS_LITERAL_STRING("wrap "));
}
if (mozilla::Preferences::GetBool("view_source.syntax_highlight", true)) {
klass.Append(NS_LITERAL_STRING("highlight"));
}
if (!klass.IsEmpty()) {
bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_CLASS, nsHtml5String::FromString(klass));
}
int32_t tabSize = mozilla::Preferences::GetInt("view_source.tab_size", 4);
if (tabSize > 0) {
nsString style;
style.AssignASCII("-moz-tab-size: ");
style.AppendInt(tabSize);
bodyAttrs->addAttribute(
nsHtml5AttributeName::ATTR_STYLE, nsHtml5String::FromString(style));
}
return bodyAttrs;
}
// static
nsHtml5HtmlAttributes*
nsHtml5ViewSourceUtils::NewLinkAttributes()
{
nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0);
nsHtml5String rel = nsHtml5Portability::newStringFromLiteral("stylesheet");
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel);
nsHtml5String type = nsHtml5Portability::newStringFromLiteral("text/css");
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type);
nsHtml5String href = nsHtml5Portability::newStringFromLiteral(
"resource://gre-resources/viewsource.css");
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href);
return linkAttrs;
}