Backed out changeset 2f9d54c153ed on CLOSED TREE (bug 1067325)
authorJ. Ryan Stinnett <jryans@gmail.com>
Fri, 22 May 2015 07:06:05 -0500
changeset 275852 d1829d0c6e38ec8c145d91f7569dffe3bd54fea7
parent 275851 57227938bb6af0bd2a2872f4d079f5657058f20e
child 275853 d766cf1d3fb48675ea291a0492eed7c0b3ecd038
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1067325
milestone41.0a1
backs out2f9d54c153edb9bfceff00f3c8884da6b9a5a8ae
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
Backed out changeset 2f9d54c153ed on CLOSED TREE (bug 1067325)
layout/style/viewsource.css
parser/html/nsHtml5Highlighter.cpp
parser/html/nsHtml5Highlighter.h
parser/html/nsHtml5ViewSourceUtils.cpp
--- a/layout/style/viewsource.css
+++ b/layout/style/viewsource.css
@@ -35,62 +35,62 @@ span[id]:before {
   display: inline-block;
   width: 5ch;
   margin: 0 0 0 -5ch;
   text-align: right;
   color: #ccc;
   font-weight: normal;
   font-style: normal;
 }
-.highlight .start-tag {
+.start-tag {
  color: purple;
  font-weight: bold;
 }
-.highlight .end-tag {
+.end-tag {
  color: purple;
  font-weight: bold;
 }
-.highlight .comment {
+.comment {
  color: green;
  font-style: italic;
 }
-.highlight .cdata {
+.cdata {
  color: #CC0066;
 }
-.highlight .doctype {
+.doctype {
  color: steelblue;
  font-style: italic;
 }
-.highlight .pi {
+.pi {
  color: orchid;
  font-style: italic;
 }
-.highlight .entity {
- color: #FF4500;
+.entity {
+ color:#FF4500;
  font-weight: normal;
 }
-.highlight .text {
+.text {
   font-weight: normal;
 }
-.highlight .attribute-name {
+.attribute-name {
  color: black;
  font-weight: bold;
 }
-.highlight .attribute-value {
+.attribute-value {
  color: blue;
  font-weight: normal;
 }
-.highlight .markupdeclaration {
+.markupdeclaration {
  color: steelblue;
  font-style: italic;
 }
 span:not(.error), a:not(.error) {
  unicode-bidi: embed;
 }
 span[id] {
  unicode-bidi: -moz-isolate;
 }
-.highlight .error,
-.highlight .error > :-moz-any(.start-tag, .end-tag, .comment, .cdata, .doctype,
-                              .pi, .entity, .attribute-name, .attribute-value) {
+.error, 
+.error > :-moz-any(.start-tag, .end-tag, .comment, .cdata, .doctype, .pi,
+                   .entity, .attribute-name, .attribute-value) {
   color: red;
   font-weight: bold;
 }
--- a/parser/html/nsHtml5Highlighter.cpp
+++ b/parser/html/nsHtml5Highlighter.cpp
@@ -48,16 +48,18 @@ char16_t nsHtml5Highlighter::sPi[] =
 nsHtml5Highlighter::nsHtml5Highlighter(nsAHtml5TreeOpSink* aOpSink)
  : mState(NS_HTML5TOKENIZER_DATA)
  , mCStart(INT32_MAX)
  , mPos(0)
  , mLineNumber(1)
  , mInlinesOpen(0)
  , mInCharacters(false)
  , mBuffer(nullptr)
+ , mSyntaxHighlight(Preferences::GetBool("view_source.syntax_highlight",
+                                         true))
  , mOpSink(aOpSink)
  , mCurrentRun(nullptr)
  , mAmpersand(nullptr)
  , mSlash(nullptr)
  , mHandles(new nsIContent*[NS_HTML5_HIGHLIGHTER_HANDLE_ARRAY_LENGTH])
  , mHandlesUsed(0)
  , mSeenBase(false)
 {
@@ -706,16 +708,19 @@ nsHtml5Highlighter::AppendCharacters(con
                                  aLength,
                                  CurrentNode());
 }
 
 
 void
 nsHtml5Highlighter::AddClass(const char16_t* aClass)
 {
+  if (!mSyntaxHighlight) {
+    return;
+  }
   mOpQueue.AppendElement()->InitAddClass(CurrentNode(), aClass);
 }
 
 void
 nsHtml5Highlighter::AddViewSourceHref(const nsString& aValue)
 {
   char16_t* bufferCopy = new char16_t[aValue.Length() + 1];
   memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t));
@@ -741,60 +746,78 @@ nsHtml5Highlighter::AddBase(const nsStri
   mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceBase,
                                  bufferCopy,
                                  aValue.Length());
 }
 
 void
 nsHtml5Highlighter::AddErrorToCurrentNode(const char* aMsgId)
 {
+  if (!mSyntaxHighlight) {
+    return;
+  }
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(CurrentNode(), aMsgId);
 }
 
 void
 nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId)
 {
+  if (!mSyntaxHighlight) {
+    return;
+  }
   NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(mCurrentRun, aMsgId);
 }
 
 void
 nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId,
                                          nsIAtom* aName)
 {
+  if (!mSyntaxHighlight) {
+    return;
+  }
   NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(mCurrentRun, aMsgId, aName);
 }
 
 void
 nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId,
                                          nsIAtom* aName,
                                          nsIAtom* aOther)
 {
+  if (!mSyntaxHighlight) {
+    return;
+  }
   NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(mCurrentRun, aMsgId, aName, aOther);
 }
 
 void
 nsHtml5Highlighter::AddErrorToCurrentAmpersand(const char* aMsgId)
 {
+  if (!mSyntaxHighlight) {
+    return;
+  }
   NS_PRECONDITION(mAmpersand, "Adding error to ampersand without one!");
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(mAmpersand, aMsgId);
 }
 
 void
 nsHtml5Highlighter::AddErrorToCurrentSlash(const char* aMsgId)
 {
+  if (!mSyntaxHighlight) {
+    return;
+  }
   NS_PRECONDITION(mSlash, "Adding error to slash without one!");
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(mSlash, aMsgId);
 }
--- a/parser/html/nsHtml5Highlighter.h
+++ b/parser/html/nsHtml5Highlighter.h
@@ -309,16 +309,21 @@ class nsHtml5Highlighter
     bool mInCharacters;
 
     /**
      * The current buffer being tokenized.
      */
     nsHtml5UTF16Buffer* mBuffer;
 
     /**
+     * Whether to highlight syntax visibly initially.
+     */
+    bool mSyntaxHighlight;
+
+    /**
      * The outgoing tree op queue.
      */
     nsTArray<nsHtml5TreeOperation> mOpQueue;
 
     /**
      * The tree op stage for the tree op executor.
      */
     nsAHtml5TreeOpSink* mOpSink;
--- a/parser/html/nsHtml5ViewSourceUtils.cpp
+++ b/parser/html/nsHtml5ViewSourceUtils.cpp
@@ -10,24 +10,18 @@
 // static
 nsHtml5HtmlAttributes*
 nsHtml5ViewSourceUtils::NewBodyAttributes()
 {
   nsHtml5HtmlAttributes* bodyAttrs = new nsHtml5HtmlAttributes(0);
   nsString* id = new nsString(NS_LITERAL_STRING("viewsource"));
   bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id);
 
-  nsString* klass = new nsString();
   if (mozilla::Preferences::GetBool("view_source.wrap_long_lines", true)) {
-    klass->Append(NS_LITERAL_STRING("wrap "));
-  }
-  if (mozilla::Preferences::GetBool("view_source.syntax_highlight", true)) {
-    klass->Append(NS_LITERAL_STRING("highlight"));
-  }
-  if (!klass->IsEmpty()) {
+    nsString* klass = new nsString(NS_LITERAL_STRING("wrap"));
     bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_CLASS, klass);
   }
 
   int32_t 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);