1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #include "nsHtml5PlainTextUtils.h"
6 #include "nsHtml5AttributeName.h"
7 #include "nsHtml5Portability.h"
8 #include "nsHtml5String.h"
9 #include "nsGkAtoms.h"
10 #include "mozilla/StaticPrefs_plain_text.h"
11 
12 // static
NewLinkAttributes()13 nsHtml5HtmlAttributes* nsHtml5PlainTextUtils::NewLinkAttributes() {
14   nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0);
15   nsHtml5String rel = nsHtml5Portability::newStringFromLiteral("stylesheet");
16   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel, -1);
17   nsHtml5String href = nsHtml5Portability::newStringFromLiteral(
18       "resource://content-accessible/plaintext.css");
19   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href, -1);
20   return linkAttrs;
21 }
22 
23 // static
NewBodyAttributes()24 nsHtml5HtmlAttributes* nsHtml5PlainTextUtils::NewBodyAttributes() {
25   if (mozilla::StaticPrefs::plain_text_wrap_long_lines()) {
26     return nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES;
27   }
28   nsHtml5HtmlAttributes* bodyAttrs = new nsHtml5HtmlAttributes(0);
29   RefPtr<nsAtom> nowrap = nsGkAtoms::nowrap;
30   bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_CLASS,
31                           nsHtml5String::FromAtom(nowrap.forget()), -1);
32   return bodyAttrs;
33 }
34