зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1067325 - Control syntax highlighting via a class. r=hsivonen
This commit is contained in:
Родитель
a9e07e1d86
Коммит
e1f26b0e50
|
@ -40,45 +40,45 @@ span[id]:before {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
.start-tag {
|
.highlight .start-tag {
|
||||||
color: purple;
|
color: purple;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.end-tag {
|
.highlight .end-tag {
|
||||||
color: purple;
|
color: purple;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.comment {
|
.highlight .comment {
|
||||||
color: green;
|
color: green;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
.cdata {
|
.highlight .cdata {
|
||||||
color: #CC0066;
|
color: #CC0066;
|
||||||
}
|
}
|
||||||
.doctype {
|
.highlight .doctype {
|
||||||
color: steelblue;
|
color: steelblue;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
.pi {
|
.highlight .pi {
|
||||||
color: orchid;
|
color: orchid;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
.entity {
|
.highlight .entity {
|
||||||
color:#FF4500;
|
color: #FF4500;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
.text {
|
.highlight .text {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
.attribute-name {
|
.highlight .attribute-name {
|
||||||
color: black;
|
color: black;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.attribute-value {
|
.highlight .attribute-value {
|
||||||
color: blue;
|
color: blue;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
.markupdeclaration {
|
.highlight .markupdeclaration {
|
||||||
color: steelblue;
|
color: steelblue;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
@ -88,9 +88,9 @@ span:not(.error), a:not(.error) {
|
||||||
span[id] {
|
span[id] {
|
||||||
unicode-bidi: -moz-isolate;
|
unicode-bidi: -moz-isolate;
|
||||||
}
|
}
|
||||||
.error,
|
.highlight .error,
|
||||||
.error > :-moz-any(.start-tag, .end-tag, .comment, .cdata, .doctype, .pi,
|
.highlight .error > :-moz-any(.start-tag, .end-tag, .comment, .cdata, .doctype,
|
||||||
.entity, .attribute-name, .attribute-value) {
|
.pi, .entity, .attribute-name, .attribute-value) {
|
||||||
color: red;
|
color: red;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,6 @@ nsHtml5Highlighter::nsHtml5Highlighter(nsAHtml5TreeOpSink* aOpSink)
|
||||||
, mInlinesOpen(0)
|
, mInlinesOpen(0)
|
||||||
, mInCharacters(false)
|
, mInCharacters(false)
|
||||||
, mBuffer(nullptr)
|
, mBuffer(nullptr)
|
||||||
, mSyntaxHighlight(Preferences::GetBool("view_source.syntax_highlight",
|
|
||||||
true))
|
|
||||||
, mOpSink(aOpSink)
|
, mOpSink(aOpSink)
|
||||||
, mCurrentRun(nullptr)
|
, mCurrentRun(nullptr)
|
||||||
, mAmpersand(nullptr)
|
, mAmpersand(nullptr)
|
||||||
|
@ -713,9 +711,6 @@ nsHtml5Highlighter::AppendCharacters(const char16_t* aBuffer,
|
||||||
void
|
void
|
||||||
nsHtml5Highlighter::AddClass(const char16_t* aClass)
|
nsHtml5Highlighter::AddClass(const char16_t* aClass)
|
||||||
{
|
{
|
||||||
if (!mSyntaxHighlight) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mOpQueue.AppendElement()->InitAddClass(CurrentNode(), aClass);
|
mOpQueue.AppendElement()->InitAddClass(CurrentNode(), aClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -751,9 +746,6 @@ nsHtml5Highlighter::AddBase(const nsString& aValue)
|
||||||
void
|
void
|
||||||
nsHtml5Highlighter::AddErrorToCurrentNode(const char* aMsgId)
|
nsHtml5Highlighter::AddErrorToCurrentNode(const char* aMsgId)
|
||||||
{
|
{
|
||||||
if (!mSyntaxHighlight) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||||
treeOp->Init(CurrentNode(), aMsgId);
|
treeOp->Init(CurrentNode(), aMsgId);
|
||||||
|
@ -762,9 +754,6 @@ nsHtml5Highlighter::AddErrorToCurrentNode(const char* aMsgId)
|
||||||
void
|
void
|
||||||
nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId)
|
nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId)
|
||||||
{
|
{
|
||||||
if (!mSyntaxHighlight) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
|
NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
|
||||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||||
|
@ -775,9 +764,6 @@ void
|
||||||
nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId,
|
nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId,
|
||||||
nsIAtom* aName)
|
nsIAtom* aName)
|
||||||
{
|
{
|
||||||
if (!mSyntaxHighlight) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
|
NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
|
||||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||||
|
@ -789,9 +775,6 @@ nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId,
|
||||||
nsIAtom* aName,
|
nsIAtom* aName,
|
||||||
nsIAtom* aOther)
|
nsIAtom* aOther)
|
||||||
{
|
{
|
||||||
if (!mSyntaxHighlight) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
|
NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
|
||||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||||
|
@ -801,9 +784,6 @@ nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId,
|
||||||
void
|
void
|
||||||
nsHtml5Highlighter::AddErrorToCurrentAmpersand(const char* aMsgId)
|
nsHtml5Highlighter::AddErrorToCurrentAmpersand(const char* aMsgId)
|
||||||
{
|
{
|
||||||
if (!mSyntaxHighlight) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NS_PRECONDITION(mAmpersand, "Adding error to ampersand without one!");
|
NS_PRECONDITION(mAmpersand, "Adding error to ampersand without one!");
|
||||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||||
|
@ -813,9 +793,6 @@ nsHtml5Highlighter::AddErrorToCurrentAmpersand(const char* aMsgId)
|
||||||
void
|
void
|
||||||
nsHtml5Highlighter::AddErrorToCurrentSlash(const char* aMsgId)
|
nsHtml5Highlighter::AddErrorToCurrentSlash(const char* aMsgId)
|
||||||
{
|
{
|
||||||
if (!mSyntaxHighlight) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NS_PRECONDITION(mSlash, "Adding error to slash without one!");
|
NS_PRECONDITION(mSlash, "Adding error to slash without one!");
|
||||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||||
|
|
|
@ -313,11 +313,6 @@ class nsHtml5Highlighter
|
||||||
*/
|
*/
|
||||||
nsHtml5UTF16Buffer* mBuffer;
|
nsHtml5UTF16Buffer* mBuffer;
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether to highlight syntax visibly initially.
|
|
||||||
*/
|
|
||||||
bool mSyntaxHighlight;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The outgoing tree op queue.
|
* The outgoing tree op queue.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -15,8 +15,14 @@ nsHtml5ViewSourceUtils::NewBodyAttributes()
|
||||||
nsString* id = new nsString(NS_LITERAL_STRING("viewsource"));
|
nsString* id = new nsString(NS_LITERAL_STRING("viewsource"));
|
||||||
bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id);
|
bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id);
|
||||||
|
|
||||||
|
nsString* klass = new nsString();
|
||||||
if (mozilla::Preferences::GetBool("view_source.wrap_long_lines", true)) {
|
if (mozilla::Preferences::GetBool("view_source.wrap_long_lines", true)) {
|
||||||
nsString* klass = new nsString(NS_LITERAL_STRING("wrap"));
|
klass->Append(NS_LITERAL_STRING("wrap "));
|
||||||
|
}
|
||||||
|
if (mozilla::Preferences::GetBool("view_source.syntax_highlight", true)) {
|
||||||
|
klass->Append(NS_LITERAL_STRING("highlight"));
|
||||||
|
}
|
||||||
|
if (!klass->IsEmpty()) {
|
||||||
bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_CLASS, klass);
|
bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_CLASS, klass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap"><pre id><span class="doctype"><!DOCTYPE html></span>
|
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype"><!DOCTYPE html></span>
|
||||||
<span id></span><span><<span class="start-tag">html</span>></span>
|
<span id></span><span><<span class="start-tag">html</span>></span>
|
||||||
<span id></span><span><<span class="start-tag">head</span>></span>
|
<span id></span><span><<span class="start-tag">head</span>></span>
|
||||||
<span id></span><span><<span class="start-tag">title</span>></span><span>Title</span><span></<span class="end-tag">title</span>></span>
|
<span id></span><span><<span class="start-tag">title</span>></span><span>Title</span><span></<span class="end-tag">title</span>></span>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap"><pre id><span class="pi"><?xml version="1.0" encoding="utf-8"?></span>
|
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="pi"><?xml version="1.0" encoding="utf-8"?></span>
|
||||||
<span id></span><span class="pi"><?foo bar?></span>
|
<span id></span><span class="pi"><?foo bar?></span>
|
||||||
<span id></span><span><<span class="start-tag">html</span>></span>
|
<span id></span><span><<span class="start-tag">html</span>></span>
|
||||||
<span id></span><span><<span class="start-tag">head</span>></span>
|
<span id></span><span><<span class="start-tag">head</span>></span>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap"><pre id><span class="doctype"><!DOCTYPE html></span>
|
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype"><!DOCTYPE html></span>
|
||||||
<span id></span>XX<span class="error">&</span>XX
|
<span id></span>XX<span class="error">&</span>XX
|
||||||
<span id></span>XX<span class="error">&</span>nXX
|
<span id></span>XX<span class="error">&</span>nXX
|
||||||
<span id></span>XX<span class="error">&</span>noXX
|
<span id></span>XX<span class="error">&</span>noXX
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap"><pre id><span class="error comment"><!--></span> <span class="error comment"><!X></span>
|
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="error comment"><!--></span> <span class="error comment"><!X></span>
|
||||||
<span id></span>
|
<span id></span>
|
||||||
</pre>
|
</pre>
|
||||||
<!-- View source CSS matches the <pre id> and <span id> elements and produces line numbers. -->
|
<!-- View source CSS matches the <pre id> and <span id> elements and produces line numbers. -->
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap"><pre id><span class="doctype"><!DOCTYPE html></span><span>
|
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype"><!DOCTYPE html></span><span>
|
||||||
<span id></span></span><span><<span class="start-tag">body</span>></span><span>
|
<span id></span></span><span><<span class="start-tag">body</span>></span><span>
|
||||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span></<span class="end-tag">script</span>></span><span>X
|
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span></<span class="end-tag">script</span>></span><span>X
|
||||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span></<span class="end-tag">script</span> ></span><span>X
|
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span></<span class="end-tag">script</span> ></span><span>X
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" style="-moz-tab-size: 4"><pre id="line1"><span></span><span class="doctype"><!DOCTYPE html></span><span></span><span><<span class="start-tag">table</span>></span><span></span><span title="Start tag “input” seen in “table”." class="error"><<span class="start-tag">input</span> <span class="attribute-name">type</span>=<a class="attribute-value">hidden</a>></span><span></span><span></<span class="end-tag">table</span>></span><span>
|
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="highlight" style="-moz-tab-size: 4"><pre id="line1"><span></span><span class="doctype"><!DOCTYPE html></span><span></span><span><<span class="start-tag">table</span>></span><span></span><span title="Start tag “input” seen in “table”." class="error"><<span class="start-tag">input</span> <span class="attribute-name">type</span>=<a class="attribute-value">hidden</a>></span><span></span><span></<span class="end-tag">table</span>></span><span>
|
||||||
<span id="line2"></span></span></pre></body></html>
|
<span id="line2"></span></span></pre></body></html>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче