Bug 849422 Allow plain text document word-wrap to be turned on after the fact r=bz
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Wed, 13 Mar 2013 19:56:24 +0000
changeset 131167 f3fd0c85eccbb0fdf66495b4d098afd522a0833e
parent 131166 2e6f598201ce27de53c76ce8ea0f9a4cfa5a30f7
child 131168 b65eb98101d5e0958ff4c142d9fb44ca8036bf39
push idunknown
push userunknown
push dateunknown
reviewersbz
bugs849422
milestone22.0a1
Bug 849422 Allow plain text document word-wrap to be turned on after the fact r=bz
parser/html/nsHtml5PlainTextUtils.cpp
parser/html/nsHtml5TreeBuilderCppSupplement.h
--- a/parser/html/nsHtml5PlainTextUtils.cpp
+++ b/parser/html/nsHtml5PlainTextUtils.cpp
@@ -2,23 +2,26 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 #include "nsHtml5PlainTextUtils.h"
 #include "nsHtml5AttributeName.h"
 #include "nsIServiceManager.h"
 #include "nsIStringBundle.h"
+#include "mozilla/Preferences.h"
 
 // static
 nsHtml5HtmlAttributes*
 nsHtml5PlainTextUtils::NewLinkAttributes()
 {
   nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0);
-  nsString* rel = new nsString(NS_LITERAL_STRING("stylesheet"));
+  nsString* rel = mozilla::Preferences::GetBool("plain_text.wrap_long_lines") ?
+    new nsString(NS_LITERAL_STRING("stylesheet")) :
+    new nsString(NS_LITERAL_STRING("alternate stylesheet"));
   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel);
   nsString* type = new nsString(NS_LITERAL_STRING("text/css"));
   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type);
   nsString* href = new nsString(
       NS_LITERAL_STRING("resource://gre-resources/plaintext.css"));
   linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href);
 
   nsresult rv;
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -7,17 +7,16 @@
 #include "nsError.h"
 #include "nsIPresShell.h"
 #include "nsEvent.h"
 #include "nsGUIEvent.h"
 #include "nsEventDispatcher.h"
 #include "nsNodeUtils.h"
 #include "nsIFrame.h"
 #include "mozilla/Likely.h"
-#include "mozilla/Preferences.h"
 
 class nsPresContext;
 
 nsHtml5TreeBuilder::nsHtml5TreeBuilder(nsAHtml5TreeOpSink* aOpSink,
                                        nsHtml5TreeOpStage* aStage)
   : scriptingEnabled(false)
   , fragment(false)
   , contextNode(nullptr)
@@ -724,21 +723,19 @@ nsHtml5TreeBuilder::StartPlainTextViewSo
            false);
 
   StartPlainTextBody();
 }
 
 void
 nsHtml5TreeBuilder::StartPlainText()
 {
-  if (mozilla::Preferences::GetBool("plain_text.wrap_long_lines", true)) {
-    startTag(nsHtml5ElementName::ELT_LINK,
-             nsHtml5PlainTextUtils::NewLinkAttributes(),
-             false);
-  }
+  startTag(nsHtml5ElementName::ELT_LINK,
+           nsHtml5PlainTextUtils::NewLinkAttributes(),
+           false);
 
   StartPlainTextBody();
 }
 
 void
 nsHtml5TreeBuilder::StartPlainTextBody()
 {
   startTag(nsHtml5ElementName::ELT_PRE,