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