Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/parser/html/nsHtml5PlainTextUtils.cpp
Line
Count
Source (jump to first uncovered line)
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 "mozilla/Preferences.h"
7
#include "nsHtml5AttributeName.h"
8
#include "nsHtml5Portability.h"
9
#include "nsHtml5String.h"
10
#include "nsIServiceManager.h"
11
#include "nsIStringBundle.h"
12
13
// static
14
nsHtml5HtmlAttributes*
15
nsHtml5PlainTextUtils::NewLinkAttributes()
16
0
{
17
0
  nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0);
18
0
  nsHtml5String rel =
19
0
    nsHtml5Portability::newStringFromLiteral("alternate stylesheet");
20
0
  linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel, -1);
21
0
  nsHtml5String type = nsHtml5Portability::newStringFromLiteral("text/css");
22
0
  linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type, -1);
23
0
  nsHtml5String href = nsHtml5Portability::newStringFromLiteral(
24
0
    "resource://content-accessible/plaintext.css");
25
0
  linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href, -1);
26
0
27
0
  nsresult rv;
28
0
  nsCOMPtr<nsIStringBundleService> bundleService =
29
0
    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
30
0
  NS_ASSERTION(NS_SUCCEEDED(rv) && bundleService,
31
0
               "The bundle service could not be loaded");
32
0
  nsCOMPtr<nsIStringBundle> bundle;
33
0
  rv = bundleService->CreateBundle("chrome://global/locale/browser.properties",
34
0
                                   getter_AddRefs(bundle));
35
0
  NS_ASSERTION(NS_SUCCEEDED(rv) && bundle,
36
0
               "chrome://global/locale/browser.properties could not be loaded");
37
0
  nsAutoString title;
38
0
  if (bundle) {
39
0
    bundle->GetStringFromName("plainText.wordWrap", title);
40
0
  }
41
0
42
0
  linkAttrs->addAttribute(
43
0
    nsHtml5AttributeName::ATTR_TITLE, nsHtml5String::FromString(title), -1);
44
0
  return linkAttrs;
45
0
}