parser/html/nsHtml5PlainTextUtils.cpp

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing 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/. */
     6 #include "nsHtml5PlainTextUtils.h"
     7 #include "nsHtml5AttributeName.h"
     8 #include "nsIServiceManager.h"
     9 #include "nsIStringBundle.h"
    10 #include "mozilla/Preferences.h"
    12 // static
    13 nsHtml5HtmlAttributes*
    14 nsHtml5PlainTextUtils::NewLinkAttributes()
    15 {
    16   nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0);
    17   nsString* rel = new nsString(NS_LITERAL_STRING("alternate stylesheet"));
    18   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel);
    19   nsString* type = new nsString(NS_LITERAL_STRING("text/css"));
    20   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type);
    21   nsString* href = new nsString(
    22       NS_LITERAL_STRING("resource://gre-resources/plaintext.css"));
    23   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href);
    25   nsresult rv;
    26   nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
    27   NS_ASSERTION(NS_SUCCEEDED(rv) && bundleService, "The bundle service could not be loaded");
    28   nsCOMPtr<nsIStringBundle> bundle;
    29   rv = bundleService->CreateBundle("chrome://global/locale/browser.properties",
    30                                    getter_AddRefs(bundle));
    31   NS_ASSERTION(NS_SUCCEEDED(rv) && bundle, "chrome://global/locale/browser.properties could not be loaded");
    32   nsXPIDLString title;
    33   if (bundle) {
    34     bundle->GetStringFromName(MOZ_UTF16("plainText.wordWrap"), getter_Copies(title));
    35   }
    37   nsString* titleCopy = new nsString(title);
    38   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TITLE, titleCopy);
    39   return linkAttrs;
    40 }

mercurial