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