LCOV - code coverage report
Current view: top level - parser/html - nsHtml5ViewSourceUtils.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 29 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          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 "nsHtml5ViewSourceUtils.h"
       7             : #include "nsHtml5AttributeName.h"
       8             : #include "mozilla/Preferences.h"
       9             : #include "nsHtml5String.h"
      10             : 
      11             : // static
      12             : nsHtml5HtmlAttributes*
      13           0 : nsHtml5ViewSourceUtils::NewBodyAttributes()
      14             : {
      15           0 :   nsHtml5HtmlAttributes* bodyAttrs = new nsHtml5HtmlAttributes(0);
      16           0 :   nsHtml5String id = nsHtml5Portability::newStringFromLiteral("viewsource");
      17           0 :   bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id, -1);
      18             : 
      19           0 :   nsString klass;
      20           0 :   if (mozilla::Preferences::GetBool("view_source.wrap_long_lines", true)) {
      21           0 :     klass.Append(NS_LITERAL_STRING("wrap "));
      22             :   }
      23           0 :   if (mozilla::Preferences::GetBool("view_source.syntax_highlight", true)) {
      24           0 :     klass.Append(NS_LITERAL_STRING("highlight"));
      25             :   }
      26           0 :   if (!klass.IsEmpty()) {
      27           0 :     bodyAttrs->addAttribute(
      28           0 :       nsHtml5AttributeName::ATTR_CLASS, nsHtml5String::FromString(klass), -1);
      29             :   }
      30             : 
      31           0 :   int32_t tabSize = mozilla::Preferences::GetInt("view_source.tab_size", 4);
      32           0 :   if (tabSize > 0) {
      33           0 :     nsString style;
      34           0 :     style.AssignASCII("-moz-tab-size: ");
      35           0 :     style.AppendInt(tabSize);
      36           0 :     bodyAttrs->addAttribute(
      37           0 :       nsHtml5AttributeName::ATTR_STYLE, nsHtml5String::FromString(style), -1);
      38             :   }
      39             : 
      40           0 :   return bodyAttrs;
      41             : }
      42             : 
      43             : // static
      44             : nsHtml5HtmlAttributes*
      45           0 : nsHtml5ViewSourceUtils::NewLinkAttributes()
      46             : {
      47           0 :   nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0);
      48           0 :   nsHtml5String rel = nsHtml5Portability::newStringFromLiteral("stylesheet");
      49           0 :   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel, -1);
      50           0 :   nsHtml5String type = nsHtml5Portability::newStringFromLiteral("text/css");
      51           0 :   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type, -1);
      52             :   nsHtml5String href = nsHtml5Portability::newStringFromLiteral(
      53           0 :     "resource://gre-resources/viewsource.css");
      54           0 :   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href, -1);
      55           0 :   return linkAttrs;
      56             : }

Generated by: LCOV version 1.13