Back out 38814e0bafb9 through c5d44e6e957b because of test failures
authorMatt Brubeck <mbrubeck@mozilla.com>
Wed, 30 Nov 2011 11:44:50 -0800
changeset 81045 20a24dd3f56bac4574310d7f47d0905c64b97728
parent 81044 0f4282490c81d6f261834285946e0881bc8ed7c2
child 81046 72e787c04eb669b6c56858af8fe87eb49dd8a39d
push id21551
push usermak77@bonardo.net
push dateThu, 01 Dec 2011 11:17:51 +0000
treeherdermozilla-central@66a1db693790 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone11.0a1
backs out38814e0bafb91e05f847f7e82f5b305b40e1deaa
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Back out 38814e0bafb9 through c5d44e6e957b because of test failures
content/html/document/src/nsHTMLDocument.cpp
parser/html/Makefile.in
parser/html/nsHtml5Highlighter.cpp
parser/html/nsHtml5Highlighter.h
parser/html/nsHtml5Parser.cpp
parser/html/nsHtml5Parser.h
parser/html/nsHtml5StreamParser.cpp
parser/html/nsHtml5StreamParser.h
parser/html/nsHtml5TokenizerCppSupplement.h
parser/html/nsHtml5TokenizerHSupplement.h
parser/html/nsHtml5TreeBuilder.cpp
parser/html/nsHtml5TreeBuilder.h
parser/html/nsHtml5TreeBuilderCppSupplement.h
parser/html/nsHtml5TreeBuilderHSupplement.h
parser/html/nsHtml5ViewSourceUtils.cpp
parser/html/nsHtml5ViewSourceUtils.h
toolkit/components/viewsource/test/browser/Makefile.in
toolkit/components/viewsource/test/browser/browser_bug699356.js
toolkit/components/viewsource/test/browser/browser_viewsourceprefs_nonhtml.js
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -743,21 +743,17 @@ nsHTMLDocument::StartDocumentLoad(const 
   }
 
   nsCOMPtr<nsICachingChannel> cachingChan = do_QueryInterface(aChannel);
 
   if (needsParser) {
     if (loadAsHtml5) {
       mParser = nsHtml5Module::NewHtml5Parser();
       if (plainText) {
-        if (viewSource) {
-          mParser->MarkAsNotScriptCreated("view-source-plain");
-        } else {
-          mParser->MarkAsNotScriptCreated("plain-text");
-        }
+        mParser->MarkAsNotScriptCreated("plain-text");
       } else if (viewSource && !contentType.EqualsLiteral("text/html")) {
         mParser->MarkAsNotScriptCreated("view-source-xml");
       } else {
         mParser->MarkAsNotScriptCreated(aCommand);
       }
     } else {
       mParser = do_CreateInstance(kCParserCID, &rv);
       NS_ENSURE_SUCCESS(rv, rv);
--- a/parser/html/Makefile.in
+++ b/parser/html/Makefile.in
@@ -71,17 +71,16 @@ EXPORTS		= \
 		nsHtml5TreeOperation.h \
 		nsHtml5TreeOpExecutor.h \
 		nsAHtml5TreeOpSink.h \
 		nsHtml5TreeOpStage.h \
 		nsHtml5UTF16Buffer.h \
 		nsHtml5UTF16BufferHSupplement.h \
 		nsHtml5DependentUTF16Buffer.h \
 		nsHtml5OwningUTF16Buffer.h \
-		nsHtml5ViewSourceUtils.h \
 		$(NULL)
 
 CPPSRCS		= \
 		nsHtml5Atoms.cpp \
 		nsHtml5Atom.cpp \
 		nsHtml5AtomTable.cpp \
 		nsHtml5Parser.cpp \
 		nsHtml5AttributeName.cpp \
@@ -104,17 +103,16 @@ CPPSRCS		= \
 		nsHtml5TreeOpStage.cpp \
 		nsHtml5StateSnapshot.cpp \
 		nsHtml5TreeOpExecutor.cpp \
 		nsHtml5StreamParser.cpp \
 		nsHtml5Speculation.cpp \
 		nsHtml5SpeculativeLoad.cpp \
 		nsHtml5SVGLoadDispatcher.cpp \
 		nsHtml5Highlighter.cpp \
-		nsHtml5ViewSourceUtils.cpp \
 		$(NULL)
 
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES	+= \
 		-I$(srcdir)/../../content/base/src \
--- a/parser/html/nsHtml5Highlighter.cpp
+++ b/parser/html/nsHtml5Highlighter.cpp
@@ -36,17 +36,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsHtml5Highlighter.h"
 #include "nsDebug.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5AttributeName.h"
 #include "nsString.h"
 #include "nsThreadUtils.h"
-#include "nsHtml5ViewSourceUtils.h"
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
 
 // The old code had a limit of 16 tokens. 1300 is a number picked my measuring
 // the size of 16 tokens on cnn.com.
 #define NS_HTML5_HIGHLIGHTER_PRE_BREAK_THRESHOLD 1300
 
@@ -78,68 +77,90 @@ PRUnichar nsHtml5Highlighter::sDoctype[]
 PRUnichar nsHtml5Highlighter::sPi[] =
   { 'p', 'i', 0 };
 
 nsHtml5Highlighter::nsHtml5Highlighter(nsAHtml5TreeOpSink* aOpSink)
  : mState(NS_HTML5TOKENIZER_DATA)
  , mCStart(PR_INT32_MAX)
  , mPos(0)
  , mLineNumber(1)
+ , mUnicharsInThisPre(0)
  , mInlinesOpen(0)
  , mInCharacters(false)
  , mBuffer(nsnull)
  , mSyntaxHighlight(Preferences::GetBool("view_source.syntax_highlight",
                                          true))
+ , mWrapLongLines(Preferences::GetBool("view_source.wrap_long_lines", true))
+ , mTabSize(Preferences::GetInt("view_source.tab_size", 4))
  , mOpSink(aOpSink)
  , mCurrentRun(nsnull)
  , mAmpersand(nsnull)
  , mSlash(nsnull)
  , mHandles(new nsIContent*[NS_HTML5_HIGHLIGHTER_HANDLE_ARRAY_LENGTH])
  , mHandlesUsed(0)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 }
 
 nsHtml5Highlighter::~nsHtml5Highlighter()
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 }
 
 void
-nsHtml5Highlighter::Start(const nsAutoString& aTitle)
+nsHtml5Highlighter::Start()
 {
   // Doctype
   mOpQueue.AppendElement()->Init(nsGkAtoms::html, EmptyString(), EmptyString());
 
   mOpQueue.AppendElement()->Init(STANDARDS_MODE);
 
   nsIContent** root = CreateElement(nsHtml5Atoms::html, nsnull);
   mOpQueue.AppendElement()->Init(eTreeOpAppendToDocument, root);
   mStack.AppendElement(root);
 
   Push(nsGkAtoms::head, nsnull);
 
   Push(nsGkAtoms::title, nsnull);
   // XUL will add the "Source of: " prefix.
-  PRUint32 length = aTitle.Length();
-  if (length > PR_INT32_MAX) {
-    length = PR_INT32_MAX;
-  }
-  AppendCharacters(aTitle.get(), 0, (PRInt32)length);
+  AppendCharacters(mURL.get(), 0, mURL.Length());
   Pop(); // title
 
-  Push(nsGkAtoms::link, nsHtml5ViewSourceUtils::NewLinkAttributes());
+  nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0);
+  nsString* rel = new nsString(NS_LITERAL_STRING("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/viewsource.css"));
+  linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href);
+  Push(nsGkAtoms::link, linkAttrs);
 
   mOpQueue.AppendElement()->Init(eTreeOpUpdateStyleSheet, CurrentNode());
 
   Pop(); // link
 
   Pop(); // head
 
-  Push(nsGkAtoms::body, nsHtml5ViewSourceUtils::NewBodyAttributes());
+  nsHtml5HtmlAttributes* bodyAttrs = new nsHtml5HtmlAttributes(0);
+  nsString* id = new nsString(NS_LITERAL_STRING("viewsource"));
+  bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id);
+
+  if (mWrapLongLines) {
+    nsString* klass = new nsString(NS_LITERAL_STRING("wrap"));
+    bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_CLASS, klass);
+  }
+
+  if (mTabSize > 0) {
+    nsString* style = new nsString(NS_LITERAL_STRING("-moz-tab-size: "));
+    style->AppendInt(mTabSize);
+    bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_STYLE, style);
+  }
+
+  Push(nsGkAtoms::body, bodyAttrs);
 
   nsHtml5HtmlAttributes* preAttrs = new nsHtml5HtmlAttributes(0);
   nsString* preId = new nsString(NS_LITERAL_STRING("line1"));
   preAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, preId);
   Push(nsGkAtoms::pre, preAttrs);
 
   StartCharacters();
 
@@ -602,34 +623,49 @@ nsHtml5Highlighter::FlushChars()
           buf[i] = '\n';
           // fall through
         case '\n': {
           ++i;
           if (mCStart < i) {
             PRInt32 len = i - mCStart;
             AppendCharacters(buf, mCStart, len);
             mCStart = i;
+            mUnicharsInThisPre += len;
           }
           ++mLineNumber;
+          if (mUnicharsInThisPre > NS_HTML5_HIGHLIGHTER_PRE_BREAK_THRESHOLD &&
+              !mInlinesOpen && mInCharacters) {
+            mUnicharsInThisPre = 0;
+            // Split the pre. See bug 86355.
+            Pop(); // span
+            Pop(); // pre
+            Push(nsGkAtoms::pre, nsnull);
+            nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
+            NS_ASSERTION(treeOp, "Tree op allocation failed.");
+            treeOp->InitAddLineNumberId(CurrentNode(), mLineNumber);
+            Push(nsGkAtoms::span, nsnull);
+            break;
+          }
           Push(nsGkAtoms::span, nsnull);
           nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
           NS_ASSERTION(treeOp, "Tree op allocation failed.");
           treeOp->InitAddLineNumberId(CurrentNode(), mLineNumber);
           Pop();
           break;
         }
         default:
           ++i;
           break;
       }
     }
     if (mCStart < mPos) {
       PRInt32 len = mPos - mCStart;
       AppendCharacters(buf, mCStart, len);
       mCStart = mPos;
+      mUnicharsInThisPre += len;
     }
   }
 }
 
 void
 nsHtml5Highlighter::FlushCurrent()
 {
   mPos++;
--- a/parser/html/nsHtml5Highlighter.h
+++ b/parser/html/nsHtml5Highlighter.h
@@ -63,17 +63,17 @@ class nsHtml5Highlighter
     /**
      * The destructor.
      */
     ~nsHtml5Highlighter();
 
     /**
      * Starts the generated document.
      */
-    void Start(const nsAutoString& aTitle);
+    void Start();
 
     /**
      * Report a tokenizer state transition.
      *
      * @param aState the state being transitioned to
      * @param aReconsume whether this is a reconsuming transition
      * @param aPos the tokenizer's current position into the buffer
      */
@@ -317,16 +317,22 @@ class nsHtml5Highlighter
     PRInt32 mPos;
 
     /**
      * The current line number.
      */
     PRInt32 mLineNumber;
 
     /**
+     * The number of PRUnichars flushed since the start of the current pre
+     * block.
+     */
+    PRInt32 mUnicharsInThisPre;
+
+    /**
      * The number of inline elements open inside the <pre> excluding the
      * span potentially wrapping a run of characters.
      */
     PRInt32 mInlinesOpen;
 
     /**
      * Whether there's a span wrapping a run of characters (excluding CDATA
      * section) open.
@@ -334,21 +340,36 @@ class nsHtml5Highlighter
     bool mInCharacters;
 
     /**
      * The current buffer being tokenized.
      */
     nsHtml5UTF16Buffer* mBuffer;
 
     /**
+     * The URL of the document to be shown in the page title.
+     */
+    nsString mURL;
+
+    /**
      * Whether to highlight syntax visibly initially.
      */
     bool mSyntaxHighlight;
 
     /**
+     * Whether to wrap long lines.
+     */
+    bool mWrapLongLines;
+
+    /**
+     * The tab size pref.
+     */
+    PRInt32 mTabSize;
+
+    /**
      * The outgoing tree op queue.
      */
     nsTArray<nsHtml5TreeOperation> mOpQueue;
 
     /**
      * The tree op stage for the tree op executor.
      */
     nsAHtml5TreeOpSink* mOpSink;
--- a/parser/html/nsHtml5Parser.cpp
+++ b/parser/html/nsHtml5Parser.cpp
@@ -213,31 +213,30 @@ nsHtml5Parser::IsParserEnabled()
 
 NS_IMETHODIMP_(bool)
 nsHtml5Parser::IsComplete()
 {
   return mExecutor->IsComplete();
 }
 
 NS_IMETHODIMP
-nsHtml5Parser::Parse(nsIURI* aURL,
+nsHtml5Parser::Parse(nsIURI* aURL, // legacy parameter; ignored
                      nsIRequestObserver* aObserver,
                      void* aKey,
                      nsDTDMode aMode) // legacy; ignored
 {
   /*
    * Do NOT cause WillBuildModel to be called synchronously from here!
    * The document won't be ready for it until OnStartRequest!
    */
   NS_PRECONDITION(!mExecutor->HasStarted(), 
                   "Tried to start parse without initializing the parser.");
   NS_PRECONDITION(mStreamParser, 
                   "Can't call this Parse() variant on script-created parser");
   mStreamParser->SetObserver(aObserver);
-  mStreamParser->SetViewSourceTitle(aURL); // In case we're viewing source
   mExecutor->SetStreamParser(mStreamParser);
   mExecutor->SetParser(this);
   mRootContextKey = aKey;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
@@ -709,18 +708,16 @@ void
 nsHtml5Parser::MarkAsNotScriptCreated(const char* aCommand)
 {
   NS_PRECONDITION(!mStreamParser, "Must not call this twice.");
   eParserMode mode = NORMAL;
   if (!nsCRT::strcmp(aCommand, "view-source")) {
     mode = VIEW_SOURCE_HTML;
   } else if (!nsCRT::strcmp(aCommand, "view-source-xml")) {
     mode = VIEW_SOURCE_XML;
-  } else if (!nsCRT::strcmp(aCommand, "view-source-plain")) {
-    mode = VIEW_SOURCE_PLAIN;
   } else if (!nsCRT::strcmp(aCommand, "plain-text")) {
     mode = PLAIN_TEXT;
   } else if (!nsCRT::strcmp(aCommand, kLoadAsData)) {
     mode = LOAD_AS_DATA;
   }
 #ifdef DEBUG
   else {
     NS_ASSERTION(!nsCRT::strcmp(aCommand, "view") ||
--- a/parser/html/nsHtml5Parser.h
+++ b/parser/html/nsHtml5Parser.h
@@ -162,17 +162,17 @@ class nsHtml5Parser : public nsIParser,
     /**
      * Query whether the parser thinks it's done with parsing.
      */
     NS_IMETHOD_(bool) IsComplete();
 
     /**
      * Set up request observer.
      *
-     * @param   aURL used for View Source title
+     * @param   aURL ignored (for interface compat only)
      * @param   aListener a listener to forward notifications to
      * @param   aKey the root context key (used for document.write)
      * @param   aMode ignored (for interface compat only)
      */
     NS_IMETHOD Parse(nsIURI* aURL,
                      nsIRequestObserver* aListener = nsnull,
                      void* aKey = 0,
                      nsDTDMode aMode = eDTDMode_autodetect);
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -51,17 +51,16 @@
 #include "nsHtml5AtomTable.h"
 #include "nsHtml5Module.h"
 #include "nsHtml5RefPtr.h"
 #include "nsIScriptError.h"
 #include "mozilla/Preferences.h"
 #include "nsHtml5Highlighter.h"
 #include "expat_config.h"
 #include "expat.h"
-#include "nsINestedURI.h"
 
 using namespace mozilla;
 
 static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
 
 PRInt32 nsHtml5StreamParser::sTimerInitialDelay = 120;
 PRInt32 nsHtml5StreamParser::sTimerSubsequentDelay = 120;
 
@@ -287,41 +286,16 @@ nsHtml5StreamParser::Notify(const char* 
       mCharset.Assign(aCharset);
       mCharsetSource = kCharsetFromAutoDetection;
       mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
     }
   }
   return NS_OK;
 }
 
-void
-nsHtml5StreamParser::SetViewSourceTitle(nsIURI* aURL)
-{
-  if (aURL) {
-    nsCOMPtr<nsIURI> temp;
-    bool isViewSource;
-    aURL->SchemeIs("view-source", &isViewSource);
-    if (isViewSource) {
-      nsCOMPtr<nsINestedURI> nested = do_QueryInterface(aURL);
-      nested->GetInnerURI(getter_AddRefs(temp));
-    } else {
-      temp = aURL;
-    }
-    bool isData;
-    temp->SchemeIs("data", &isData);
-    if (isData) {
-      // Avoid showing potentially huge data: URLs. The three last bytes are
-      // UTF-8 for an ellipsis.
-      mViewSourceTitle.AssignLiteral("data:\xE2\x80\xA6");
-    } else {
-      temp->GetSpec(mViewSourceTitle);
-    }
-  }
-}
-
 nsresult
 nsHtml5StreamParser::SetupDecodingAndWriteSniffingBufferAndCurrentSegment(const PRUint8* aFromSegment, // can be null
                                                                           PRUint32 aCount,
                                                                           PRUint32* aWriteCount)
 {
   NS_ASSERTION(IsParserThread(), "Wrong thread!");
   nsresult rv = NS_OK;
   nsCOMPtr<nsICharsetConverterManager> convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
@@ -901,35 +875,31 @@ nsHtml5StreamParser::OnStartRequest(nsIR
   if (mObserver) {
     mObserver->OnStartRequest(aRequest, aContext);
   }
   mRequest = aRequest;
 
   mStreamState = STREAM_BEING_READ;
 
   if (mMode == VIEW_SOURCE_HTML || mMode == VIEW_SOURCE_XML) {
-    mTokenizer->StartViewSource(NS_ConvertUTF8toUTF16(mViewSourceTitle));
+    mTokenizer->StartViewSource();
   }
-
   // For View Source, the parser should run with scripts "enabled" if a normal
   // load would have scripts enabled.
   bool scriptingEnabled = mMode == LOAD_AS_DATA ?
                                    false : mExecutor->IsScriptEnabled();
   mOwner->StartTokenizer(scriptingEnabled);
   mTreeBuilder->setScriptingEnabled(scriptingEnabled);
   mTokenizer->start();
   mExecutor->Start();
   mExecutor->StartReadingFromStage();
 
   if (mMode == PLAIN_TEXT) {
     mTreeBuilder->StartPlainText();
     mTokenizer->StartPlainText();
-  } else if (mMode == VIEW_SOURCE_PLAIN) {
-    mTreeBuilder->StartPlainTextViewSource(NS_ConvertUTF8toUTF16(mViewSourceTitle));
-    mTokenizer->StartPlainText();
   }
 
   /*
    * If you move the following line, be very careful not to cause 
    * WillBuildModel to be called before the document has had its 
    * script global object set.
    */
   mExecutor->WillBuildModel(eDTDMode_unknown);
--- a/parser/html/nsHtml5StreamParser.h
+++ b/parser/html/nsHtml5StreamParser.h
@@ -72,21 +72,16 @@ enum eParserMode {
   VIEW_SOURCE_HTML,
 
   /**
    * View document as XML source
    */
   VIEW_SOURCE_XML,
 
   /**
-   * View document as plain text source
-   */
-  VIEW_SOURCE_PLAIN,
-
-  /**
    * View document as plain text
    */
   PLAIN_TEXT,
 
   /**
    * Load as data (XHR)
    */
   LOAD_AS_DATA
@@ -220,23 +215,16 @@ class nsHtml5StreamParser : public nsISt
 
     /**
      * Sets mCharset and mCharsetSource appropriately for the XML View Source
      * case if aEncoding names a supported rough ASCII superset and sets
      * the mCharset and mCharsetSource to the UTF-8 default otherwise.
      */
     void SetEncodingFromExpat(const PRUnichar* aEncoding);
 
-    /**
-     * Sets the URL for View Source title in case this parser ends up being
-     * used for View Source. If aURL is a view-source: URL, takes the inner
-     * URL. data: URLs are shown with an ellipsis instead of the actual data.
-     */
-    void SetViewSourceTitle(nsIURI* aURL);
-
   private:
 
 #ifdef DEBUG
     bool IsParserThread() {
       bool ret;
       mThread->IsOnCurrentThread(&ret);
       return ret;
     }
@@ -393,21 +381,16 @@ class nsHtml5StreamParser : public nsISt
      * a flush runnable back on the main thread.
      */
     void TimerFlush();
 
     nsCOMPtr<nsIRequest>          mRequest;
     nsCOMPtr<nsIRequestObserver>  mObserver;
 
     /**
-     * The document title to use if this turns out to be a View Source parser.
-     */
-    nsCString                     mViewSourceTitle;
-
-    /**
      * The Unicode decoder
      */
     nsCOMPtr<nsIUnicodeDecoder>   mUnicodeDecoder;
 
     /**
      * The buffer for sniffing the character encoding
      */
     nsAutoArrayPtr<PRUint8>       mSniffingBuffer;
--- a/parser/html/nsHtml5TokenizerCppSupplement.h
+++ b/parser/html/nsHtml5TokenizerCppSupplement.h
@@ -49,19 +49,19 @@ nsHtml5Tokenizer::EnableViewSource(nsHtm
 
 bool
 nsHtml5Tokenizer::FlushViewSource()
 {
   return mViewSource->FlushOps();
 }
 
 void
-nsHtml5Tokenizer::StartViewSource(const nsAutoString& aTitle)
+nsHtml5Tokenizer::StartViewSource()
 {
-  mViewSource->Start(aTitle);
+  mViewSource->Start();
 }
 
 void
 nsHtml5Tokenizer::EndViewSource()
 {
   mViewSource->End();
 }
 
--- a/parser/html/nsHtml5TokenizerHSupplement.h
+++ b/parser/html/nsHtml5TokenizerHSupplement.h
@@ -42,17 +42,17 @@ nsAutoPtr<nsHtml5Highlighter> mViewSourc
  * no corresponding EndPlainText() call.
  */
 void StartPlainText();
 
 void EnableViewSource(nsHtml5Highlighter* aHighlighter);
 
 bool FlushViewSource();
 
-void StartViewSource(const nsAutoString& aTitle);
+void StartViewSource();
 
 void EndViewSource();
 
 void errGarbageAfterLtSlash();
 
 void errLtSlashGt();
 
 void errWarnLtSlashInRcdata();
--- a/parser/html/nsHtml5TreeBuilder.cpp
+++ b/parser/html/nsHtml5TreeBuilder.cpp
@@ -47,17 +47,16 @@
 #include "nsHtml5TreeOperation.h"
 #include "nsHtml5PendingNotification.h"
 #include "nsHtml5StateSnapshot.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5TreeOpExecutor.h"
 #include "nsHtml5StreamParser.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Highlighter.h"
-#include "nsHtml5ViewSourceUtils.h"
 
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5MetaScanner.h"
 #include "nsHtml5AttributeName.h"
 #include "nsHtml5ElementName.h"
 #include "nsHtml5HtmlAttributes.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5UTF16Buffer.h"
--- a/parser/html/nsHtml5TreeBuilder.h
+++ b/parser/html/nsHtml5TreeBuilder.h
@@ -48,17 +48,16 @@
 #include "nsHtml5TreeOperation.h"
 #include "nsHtml5PendingNotification.h"
 #include "nsHtml5StateSnapshot.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5TreeOpExecutor.h"
 #include "nsHtml5StreamParser.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Highlighter.h"
-#include "nsHtml5ViewSourceUtils.h"
 
 class nsHtml5StreamParser;
 
 class nsHtml5Tokenizer;
 class nsHtml5MetaScanner;
 class nsHtml5AttributeName;
 class nsHtml5ElementName;
 class nsHtml5HtmlAttributes;
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -696,42 +696,16 @@ nsHtml5TreeBuilder::DropHandles()
 void
 nsHtml5TreeBuilder::MarkAsBroken()
 {
   mOpQueue.Clear(); // Previous ops don't matter anymore
   mOpQueue.AppendElement()->Init(eTreeOpMarkAsBroken);
 }
 
 void
-nsHtml5TreeBuilder::StartPlainTextViewSource(const nsAutoString& aTitle)
-{
-  startTag(nsHtml5ElementName::ELT_TITLE,
-           nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES,
-           false);
-
-  // XUL will add the "Source of: " prefix.
-  PRUint32 length = aTitle.Length();
-  if (length > PR_INT32_MAX) {
-    length = PR_INT32_MAX;
-  }
-  characters(aTitle.get(), 0, (PRInt32)length);
-  endTag(nsHtml5ElementName::ELT_TITLE);
-
-  startTag(nsHtml5ElementName::ELT_LINK,
-           nsHtml5ViewSourceUtils::NewLinkAttributes(),
-           false);
-
-  startTag(nsHtml5ElementName::ELT_BODY,
-           nsHtml5ViewSourceUtils::NewBodyAttributes(),
-           false);
-
-  StartPlainText();
-}
-
-void
 nsHtml5TreeBuilder::StartPlainText()
 {
   startTag(nsHtml5ElementName::ELT_PRE,
            nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES,
            false);
   needToDropLF = false;
 }
 
--- a/parser/html/nsHtml5TreeBuilderHSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderHSupplement.h
@@ -90,18 +90,16 @@
 
   public:
 
     nsHtml5TreeBuilder(nsAHtml5TreeOpSink* aOpSink,
                        nsHtml5TreeOpStage* aStage);
 
     ~nsHtml5TreeBuilder();
     
-    void StartPlainTextViewSource(const nsAutoString& aTitle);
-
     void StartPlainText();
 
     bool HasScript();
     
     void SetOpSink(nsAHtml5TreeOpSink* aOpSink) {
       mOpSink = aOpSink;
     }
 
deleted file mode 100644
--- a/parser/html/nsHtml5ViewSourceUtils.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is HTML5 View Source code.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Henri Sivonen <hsivonen@iki.fi>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#include "nsHtml5ViewSourceUtils.h"
-#include "nsHtml5AttributeName.h"
-#include "mozilla/Preferences.h"
-
-// static
-nsHtml5HtmlAttributes*
-nsHtml5ViewSourceUtils::NewBodyAttributes()
-{
-  nsHtml5HtmlAttributes* bodyAttrs = new nsHtml5HtmlAttributes(0);
-  nsString* id = new nsString(NS_LITERAL_STRING("viewsource"));
-  bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id);
-
-  if (mozilla::Preferences::GetBool("view_source.wrap_long_lines", true)) {
-    nsString* klass = new nsString(NS_LITERAL_STRING("wrap"));
-    bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_CLASS, klass);
-  }
-
-  PRInt32 tabSize = mozilla::Preferences::GetInt("view_source.tab_size", 4);
-  if (tabSize > 0) {
-    nsString* style = new nsString(NS_LITERAL_STRING("-moz-tab-size: "));
-    style->AppendInt(tabSize);
-    bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_STYLE, style);
-  }
-
-  return bodyAttrs;
-}
-
-// static
-nsHtml5HtmlAttributes*
-nsHtml5ViewSourceUtils::NewLinkAttributes()
-{
-  nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0);
-  nsString* rel = new nsString(NS_LITERAL_STRING("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/viewsource.css"));
-  linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href);
-  return linkAttrs;
-}
deleted file mode 100644
--- a/parser/html/nsHtml5ViewSourceUtils.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is HTML5 View Source code.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2011
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Henri Sivonen <hsivonen@iki.fi>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nsHtml5ViewSourceUtils_h_
-#define nsHtml5ViewSourceUtils_h_
-
-#include "nsHtml5HtmlAttributes.h"
-
-class nsHtml5ViewSourceUtils
-{
-  public:
-    static nsHtml5HtmlAttributes* NewBodyAttributes();
-    static nsHtml5HtmlAttributes* NewLinkAttributes();
-};
-
-#endif // nsHtml5ViewSourceUtils_h_
--- a/toolkit/components/viewsource/test/browser/Makefile.in
+++ b/toolkit/components/viewsource/test/browser/Makefile.in
@@ -42,14 +42,13 @@ VPATH     = @srcdir@
 relativesrcdir  = toolkit/components/viewsource/test/browser
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _BROWSER_CHROME_FILES   = \
                 browser_bug699356.js \
                 browser_viewsourceprefs.js \
-                browser_viewsourceprefs_nonhtml.js \
                 head.js \
                 $(NULL)
 
 libs:: $(_BROWSER_CHROME_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
--- a/toolkit/components/viewsource/test/browser/browser_bug699356.js
+++ b/toolkit/components/viewsource/test/browser/browser_bug699356.js
@@ -4,13 +4,13 @@
 
 function test() {
   let source = "about:blank";
 
   waitForExplicitFinish();
   openViewSourceWindow(source, function(aWindow) {
     let gBrowser = aWindow.gBrowser;
 
-    is(gBrowser.contentDocument.title, source, "Correct document title");
+    todo(gBrowser.contentDocument.title == source, "Correct document title");
     todo(aWindow.document.documentElement.getAttribute("title") == "Source of: " + source, "Correct window title");
     closeViewSourceWindow(aWindow, finish);
   });
 }
deleted file mode 100644
--- a/toolkit/components/viewsource/test/browser/browser_viewsourceprefs_nonhtml.js
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-let source = "data:text/plain,hello+world";
-let mWindow, wrapMenuItem, syntaxMenuItem;
-
-// Check the default values are set.
-function test() {
-  waitForExplicitFinish();
-
-  openViewSourceWindow(source, function(aWindow) {
-    mWindow = aWindow;
-    wrapMenuItem = aWindow.document.getElementById('menu_wrapLongLines');
-    syntaxMenuItem = aWindow.document.getElementById('menu_highlightSyntax');
-
-    // Strip checked="false" attributes, since we're not interested in them.
-    if (wrapMenuItem.getAttribute("checked") == "false")
-      wrapMenuItem.removeAttribute("checked");
-    if (syntaxMenuItem.getAttribute("checked") == "false")
-      syntaxMenuItem.removeAttribute("checked");
-
-    is(wrapMenuItem.hasAttribute("checked"), false, "Wrap menu item not checked by default");
-    is(syntaxMenuItem.hasAttribute("checked"), true, "Syntax menu item checked by default");
-    checkStyle(aWindow, "-moz-tab-size", 4);
-    checkStyle(aWindow, "white-space", "pre");
-
-    test1();
-  });
-}
-
-// Check that the Wrap Long Lines menu item works.
-function test1() {
-  simulateClick(wrapMenuItem);
-
-  is(wrapMenuItem.hasAttribute("checked"), true, "Wrap menu item checked");
-  is(SpecialPowers.getBoolPref("view_source.wrap_long_lines"), true, "Wrap pref set");
-  checkStyle(mWindow, "white-space", "pre-wrap");
-  test2();
-}
-
-function test2() {
-  simulateClick(wrapMenuItem);
-
-  is(wrapMenuItem.hasAttribute("checked"), false, "Wrap menu item unchecked");
-  is(SpecialPowers.getBoolPref("view_source.wrap_long_lines"), false, "Wrap pref set");
-  checkStyle(mWindow, "white-space", "pre");
-  test3();
-}
-
-// Check that the Syntax Highlighting menu item works.
-function test3() {
-  mWindow.gBrowser.addEventListener("pageshow", function test3Handler() {
-    mWindow.gBrowser.removeEventListener("pageshow", test3Handler, false);
-    is(syntaxMenuItem.hasAttribute("checked"), false, "Syntax menu item unchecked");
-    is(SpecialPowers.getBoolPref("view_source.syntax_highlight"), false, "Syntax highlighting pref set");
-
-    checkHighlight(mWindow, false);
-    test4();
-  }, false);
-
-  simulateClick(syntaxMenuItem);
-}
-
-function test4() {
-  mWindow.gBrowser.addEventListener("pageshow", function test4Handler() {
-    mWindow.gBrowser.removeEventListener("pageshow", test4Handler, false);
-    is(syntaxMenuItem.hasAttribute("checked"), true, "Syntax menu item checked");
-    is(SpecialPowers.getBoolPref("view_source.syntax_highlight"), true, "Syntax highlighting pref set");
-
-    checkHighlight(mWindow, false);
-    closeViewSourceWindow(mWindow, test5);
-  }, false);
-
-  simulateClick(syntaxMenuItem);
-}
-
-// Open a new view-source window to check prefs are obeyed.
-function test5() {
-  SpecialPowers.pushPrefEnv({'set': [
-    ["view_source.tab_size", 2],
-    ["view_source.wrap_long_lines", true],
-    ["view_source.syntax_highlight", false]
-  ]}, function() {
-    openViewSourceWindow(source, function(aWindow) {
-      wrapMenuItem = aWindow.document.getElementById('menu_wrapLongLines');
-      syntaxMenuItem = aWindow.document.getElementById('menu_highlightSyntax');
-
-      // Strip checked="false" attributes, since we're not interested in them.
-      if (wrapMenuItem.getAttribute("checked") == "false")
-        wrapMenuItem.removeAttribute("checked");
-      if (syntaxMenuItem.getAttribute("checked") == "false")
-        syntaxMenuItem.removeAttribute("checked");
-
-      is(wrapMenuItem.hasAttribute("checked"), true, "Wrap menu item checked");
-      is(syntaxMenuItem.hasAttribute("checked"), false, "Syntax menu item unchecked");
-      checkStyle(aWindow, "-moz-tab-size", 2);
-      checkStyle(aWindow, "white-space", "pre-wrap");
-      checkHighlight(aWindow, false);
-      closeViewSourceWindow(aWindow, finish);
-    });
-  });
-}
-
-// Simulate a menu item click, including toggling the checked state.
-// This saves us from opening the menu and trying to click on the item,
-// which doesn't work on Mac OS X.
-function simulateClick(aMenuItem) {
-  if (aMenuItem.hasAttribute("checked"))
-    aMenuItem.removeAttribute("checked");
-  else
-    aMenuItem.setAttribute("checked", "true");
-
-  aMenuItem.click();
-}
-
-function checkStyle(aWindow, aStyleProperty, aExpectedValue) {
-  let gBrowser = aWindow.gBrowser;
-  let computedStyle = gBrowser.contentWindow.getComputedStyle(gBrowser.contentDocument.body, null);
-
-  is(computedStyle.getPropertyValue(aStyleProperty), aExpectedValue, "Correct value of " + aStyleProperty);
-}
-
-function checkHighlight(aWindow, aExpected) {
-  let spans = aWindow.gBrowser.contentDocument.getElementsByTagName("span");
-  is(Array.some(spans, function(aSpan) {
-    return aSpan.className != "";
-  }), aExpected, "Syntax highlighting " + (aExpected ? "on" : "off"));
-}