зеркало из https://github.com/mozilla/gecko-dev.git
Improve the speed of viewsource - Patch of Boris Zbarsky <bzbarsky@mit.edu> b=74486 r=rbs r=attinasi
This commit is contained in:
Родитель
3937ca299c
Коммит
67e1cb2bbb
|
@ -197,6 +197,7 @@ sub InstallNonChromeResources()
|
|||
MakeAlias(":mozilla:layout:html:document:src:html.css", "$resource_dir");
|
||||
MakeAlias(":mozilla:layout:html:document:src:forms.css", "$resource_dir");
|
||||
MakeAlias(":mozilla:layout:html:document:src:quirk.css", "$resource_dir");
|
||||
MakeAlias(":mozilla:layout:html:document:src:viewsource.css", "$resource_dir");
|
||||
MakeAlias(":mozilla:layout:html:document:src:arrow.gif", "$resource_dir");
|
||||
MakeAlias(":mozilla:webshell:tests:viewer:resources:viewer.properties", "$resource_dir");
|
||||
MakeAlias(":mozilla:intl:uconv:src:charsetalias.properties", "$resource_dir");
|
||||
|
|
|
@ -218,7 +218,8 @@ chrome/embed.jar
|
|||
; res:
|
||||
;
|
||||
res/html.css
|
||||
res/quirk.css
|
||||
res/quirk.css
|
||||
res/viewsource.css
|
||||
res/ua.css
|
||||
res/forms.css
|
||||
res/builtin/*
|
||||
|
|
|
@ -218,7 +218,8 @@ chrome\embed.jar
|
|||
; res:
|
||||
;
|
||||
res\html.css
|
||||
res\quirk.css
|
||||
res\quirk.css
|
||||
res\viewsource.css
|
||||
res\ua.css
|
||||
res\forms.css
|
||||
res\builtin\*
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#endif
|
||||
|
||||
#define VIEW_SOURCE_HTML
|
||||
#define VIEW_SOURCE_COLORING
|
||||
|
||||
#include "nsIDTDDebug.h"
|
||||
#include "nsViewSourceHTML.h"
|
||||
|
@ -65,13 +64,11 @@
|
|||
#include "nsHTMLEntities.h"
|
||||
#endif // VIEW_SOURCE_HTML
|
||||
|
||||
#ifdef VIEW_SOURCE_COLORING
|
||||
// For Coloring pref only
|
||||
// If we aren't going to define it, then should save on bloat.
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
#endif // VIEW_SOURCE_COLORING
|
||||
|
||||
#include "COtherDTD.h"
|
||||
#include "nsElementTable.h"
|
||||
|
@ -100,7 +97,7 @@ static int gErrorThreshold = 10;
|
|||
#endif
|
||||
|
||||
#ifdef VIEW_SOURCE_HTML
|
||||
static const char* kPreStyle = "font-family: -moz-fixed; font-weight:normal; color:black; padding-top:4px; margin-left:4px;";
|
||||
static const char* kPreClass = "viewsource";
|
||||
#endif // VIEW_SOURCE_HTML
|
||||
|
||||
/**
|
||||
|
@ -229,23 +226,21 @@ enum {
|
|||
VIEW_SOURCE_MARKUPDECLARATION = 12
|
||||
};
|
||||
|
||||
#ifdef VIEW_SOURCE_COLORING
|
||||
static char* kElementStyles[] = {
|
||||
"color: purple; font-weight:bold;",
|
||||
"color: purple; font-weight:bold;",
|
||||
"color: green; font-style:italic;",
|
||||
"color: #CC0066;",
|
||||
"color:steelblue; font-style:italic;",
|
||||
"color:orchid; font-style:italic;",
|
||||
"color:#FF4500; font-weight:normal;",
|
||||
"font-weight: normal;",
|
||||
"color: black; font-weight:bold;",
|
||||
"color: blue; font-weight:normal;",
|
||||
"display:block; background-color:#FFFFCC; width:90%; border:solid; border-width:1pt; font-family: Sans-serif;",
|
||||
"font-weight: normal;",
|
||||
"color:steelblue; font-style:italic;"
|
||||
static char* kElementClasses[] = {
|
||||
"start-tag",
|
||||
"end-tag",
|
||||
"comment",
|
||||
"cdata",
|
||||
"doctype",
|
||||
"pi",
|
||||
"entity",
|
||||
"text",
|
||||
"attribute-name",
|
||||
"attribute-value",
|
||||
"summary",
|
||||
"popup",
|
||||
"markupdeclaration"
|
||||
};
|
||||
#endif
|
||||
|
||||
static char* kBeforeText[] = {
|
||||
"<",
|
||||
|
@ -305,6 +300,12 @@ CViewSourceHTML::CViewSourceHTML() : mTags(), mErrors() {
|
|||
mValue = VIEW_SOURCE_ATTRIBUTE_VALUE;
|
||||
mSummaryTag = VIEW_SOURCE_SUMMARY;
|
||||
mPopupTag = VIEW_SOURCE_POPUP;
|
||||
nsresult result=NS_OK;
|
||||
mSyntaxHighlight = PR_FALSE;
|
||||
// This determines the value of the boolean syntax_highlight preference.
|
||||
NS_WITH_SERVICE(nsIPref, thePrefsService, kPrefCID, &result);
|
||||
if (NS_SUCCEEDED(result) && thePrefsService)
|
||||
thePrefsService->GetBoolPref("view_source.syntax_highlight", &mSyntaxHighlight);
|
||||
#else
|
||||
mStartTag.AssignWithConversion("start");
|
||||
mEndTag.AssignWithConversion("end");
|
||||
|
@ -433,7 +434,7 @@ nsresult CViewSourceHTML::WillBuildModel( const CParserContext& aParserContext,
|
|||
if((!aParserContext.mPrevContext) && (mSink)) {
|
||||
|
||||
mTags.Truncate();
|
||||
mErrors.AssignWithConversion(" HTML 4.0 Strict-DTD validation (enabled); [Should use Transitional?].\n");
|
||||
mErrors.Assign(NS_LITERAL_STRING(" HTML 4.0 Strict-DTD validation (enabled); [Should use Transitional?].\n"));
|
||||
|
||||
mValidator=aParserContext.mValidator;
|
||||
mDocType=aParserContext.mDocType;
|
||||
|
@ -483,12 +484,12 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
|
|||
// token allocator, because there are no attributes on the tokens.
|
||||
nsAutoString tag;
|
||||
|
||||
tag.AssignWithConversion("HTML");
|
||||
tag.Assign(NS_LITERAL_STRING("HTML"));
|
||||
CStartToken htmlToken(tag, eHTMLTag_html);
|
||||
nsCParserNode htmlNode(&htmlToken,0,0/*stack token*/);
|
||||
mSink->OpenHTML(htmlNode);
|
||||
|
||||
tag.AssignWithConversion("BODY");
|
||||
tag.Assign(NS_LITERAL_STRING("BODY"));
|
||||
CStartToken bodyToken(tag, eHTMLTag_body);
|
||||
nsCParserNode bodyNode(&bodyToken,0,0/*stack token*/);
|
||||
mSink->OpenBody(bodyNode);
|
||||
|
@ -501,7 +502,7 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
|
|||
nsTokenAllocator* theAllocator=mTokenizer->GetTokenAllocator();
|
||||
if(theAllocator) {
|
||||
#ifdef VIEW_SOURCE_HTML
|
||||
tag.AssignWithConversion("PRE");
|
||||
tag.Assign(NS_LITERAL_STRING("PRE"));
|
||||
CStartToken* theToken=NS_STATIC_CAST(CStartToken*,theAllocator->CreateTokenOfType(eToken_start,eHTMLTag_pre,tag));
|
||||
#else
|
||||
//now let's automatically open the root container...
|
||||
|
@ -514,8 +515,8 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
|
|||
nsCParserNode theNode(theToken,0,theAllocator);
|
||||
|
||||
#ifdef VIEW_SOURCE_HTML
|
||||
theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_ConvertASCIItoUCS2(kPreStyle));
|
||||
theAttr->SetKey(NS_LITERAL_STRING("style"));
|
||||
theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_ConvertASCIItoUCS2(kPreClass));
|
||||
theAttr->SetKey(NS_LITERAL_STRING("class"));
|
||||
#else
|
||||
theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_LITERAL_STRING("http://www.mozilla.org/viewsource"));
|
||||
theAttr->SetKey(NS_LITERAL_STRING("xmlns"));
|
||||
|
@ -876,13 +877,6 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
|
|||
nsresult result=NS_OK;
|
||||
|
||||
CSharedVSContext& theContext=CSharedVSContext::GetSharedContext();
|
||||
#ifdef VIEW_SOURCE_COLORING
|
||||
// This determines the value of the boolean syntax_highlight preference.
|
||||
PRBool syntaxHighlight = PR_FALSE;
|
||||
NS_WITH_SERVICE(nsIPref, thePrefsService, kPrefCID, &result);
|
||||
if (NS_SUCCEEDED(result) && thePrefsService)
|
||||
thePrefsService->GetBoolPref("view_source.syntax_highlight", &syntaxHighlight);
|
||||
#endif // VIEW_SOURCE_COLORING
|
||||
|
||||
nsTokenAllocator* theAllocator=mTokenizer->GetTokenAllocator();
|
||||
NS_ASSERTION(0!=theAllocator,"Error: no allocator");
|
||||
|
@ -898,31 +892,25 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
|
|||
mSink->AddLeaf(theNode);
|
||||
}
|
||||
|
||||
#ifdef VIEW_SOURCE_COLORING
|
||||
nsAutoString tag (NS_LITERAL_STRING("SPAN"));
|
||||
CStartToken* theTagToken=NS_STATIC_CAST(CStartToken*,theAllocator->CreateTokenOfType(eToken_start,eHTMLTag_span,tag));
|
||||
#endif // VIEW_SOURCE_COLORING
|
||||
CStartToken* theTagToken=NS_STATIC_CAST(CStartToken*,theAllocator->CreateTokenOfType(eToken_start,eHTMLTag_span,NS_LITERAL_STRING("SPAN")));
|
||||
#else
|
||||
CStartToken* theTagToken=NS_STATIC_CAST(CStartToken*,theAllocator->CreateTokenOfType(eToken_start,eHTMLTag_unknown,theXMLTagName));
|
||||
#endif // VIEW_SOURCE_HTML
|
||||
|
||||
#ifdef VIEW_SOURCE_COLORING
|
||||
if (syntaxHighlight)
|
||||
if (mSyntaxHighlight)
|
||||
{
|
||||
theContext.mStartNode.Init(theTagToken,mLineNumber,theAllocator);
|
||||
theContext.mStartNode.Init(theTagToken,mLineNumber,theAllocator);
|
||||
#ifdef VIEW_SOURCE_HTML
|
||||
CAttributeToken* theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_ConvertASCIItoUCS2(kElementStyles[aTagType]));
|
||||
theAttr->SetKey(NS_LITERAL_STRING("style"));
|
||||
CAttributeToken* theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_ConvertASCIItoUCS2(kElementClasses[aTagType]));
|
||||
theAttr->SetKey(NS_LITERAL_STRING("class"));
|
||||
theContext.mStartNode.AddAttribute(theAttr);
|
||||
}
|
||||
#endif // VIEW_SOURCE_HTML
|
||||
}
|
||||
|
||||
STOP_TIMER();
|
||||
|
||||
mSink->OpenContainer(theContext.mStartNode); //emit <starttag>...
|
||||
|
||||
#endif // VIEW_SOURCE_COLORING
|
||||
|
||||
#ifdef rickgdebug
|
||||
|
||||
if(aNewlineRequired) {
|
||||
|
@ -946,15 +934,13 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
|
|||
}
|
||||
|
||||
#ifdef VIEW_SOURCE_HTML
|
||||
#ifdef VIEW_SOURCE_COLORING
|
||||
if (syntaxHighlight)
|
||||
if (mSyntaxHighlight)
|
||||
{
|
||||
theContext.mStartNode.ReleaseAll();
|
||||
CEndToken theEndToken(eHTMLTag_span);
|
||||
theContext.mEndNode.Init(&theEndToken,mLineNumber,0/*stack token*/);
|
||||
mSink->CloseContainer(theContext.mEndNode); //emit </starttag>...
|
||||
}
|
||||
#endif // VIEW_SOURCE_COLORING
|
||||
if (kAfterText[aTagType][0] != 0) {
|
||||
nsAutoString afterText;
|
||||
afterText.AssignWithConversion(kAfterText[aTagType]);
|
||||
|
|
|
@ -274,6 +274,7 @@ protected:
|
|||
PRInt32 mValue;
|
||||
PRInt32 mPopupTag;
|
||||
PRInt32 mSummaryTag;
|
||||
PRBool mSyntaxHighlight;
|
||||
#else
|
||||
nsAutoString mStartTag;
|
||||
nsAutoString mEndTag;
|
||||
|
|
|
@ -48,6 +48,8 @@ static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
|
|||
|
||||
// URL for the "user agent" style sheet
|
||||
#define UA_CSS_URL "resource:/res/ua.css"
|
||||
// URL for the "view source" style sheet
|
||||
#define VIEW_SOURCE_CSS_URL "resource:/res/viewsource.css"
|
||||
|
||||
// Factory code for creating variations on html documents
|
||||
|
||||
|
@ -198,14 +200,28 @@ nsLayoutDLF::CreateInstance(const char *aCommand,
|
|||
nsresult rv = NS_OK;
|
||||
if (!GetUAStyleSheet()) {
|
||||
// Load the UA style sheet
|
||||
nsCOMPtr<nsIURI> uaURL;
|
||||
rv = NS_NewURI(getter_AddRefs(uaURL), UA_CSS_URL);
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewURI(getter_AddRefs(uri), UA_CSS_URL);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsICSSLoader> cssLoader(do_CreateInstance(kCSSLoaderCID,&rv));
|
||||
if (cssLoader) {
|
||||
PRBool complete;
|
||||
rv = cssLoader->LoadAgentSheet(uaURL, nsLayoutModule::gUAStyleSheet, complete,
|
||||
nsnull);
|
||||
rv = cssLoader->LoadAgentSheet(uri, nsLayoutModule::gUAStyleSheet,
|
||||
complete, nsnull);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// also cache the view source stylesheet
|
||||
if (NS_SUCCEEDED(NS_NewURI(getter_AddRefs(uri), VIEW_SOURCE_CSS_URL))) {
|
||||
PRBool bHasSheet = PR_FALSE;
|
||||
nsLayoutModule::gUAStyleSheet->
|
||||
ContainsStyleSheet(uri,
|
||||
bHasSheet,
|
||||
&nsLayoutModule::gViewSourceStyleSheet);
|
||||
// assert if we found a stylesheet but it's nsnull -- should not happen
|
||||
NS_ASSERTION(!bHasSheet || nsLayoutModule::gViewSourceStyleSheet,
|
||||
"gViewSourceStyleSheet must be set: ContainsStyleSheet is hosed");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -261,6 +277,20 @@ nsLayoutDLF::CreateInstance(const char *aCommand,
|
|||
else
|
||||
aContentType=gXMLTypes[0];
|
||||
#endif
|
||||
|
||||
if (nsLayoutModule::gViewSourceStyleSheet) {
|
||||
#ifdef DEBUG
|
||||
printf( "Enabling View Source StyleSheet\n");
|
||||
#endif
|
||||
nsLayoutModule::gViewSourceStyleSheet->SetEnabled(PR_TRUE);
|
||||
}
|
||||
} else {
|
||||
if (nsLayoutModule::gViewSourceStyleSheet) {
|
||||
#ifdef DEBUG
|
||||
printf( "Disabling View Source StyleSheet\n");
|
||||
#endif
|
||||
nsLayoutModule::gViewSourceStyleSheet->SetEnabled(PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
// Try html
|
||||
|
|
|
@ -174,6 +174,7 @@ LayoutScriptNameSet::AddNameSet(nsIScriptContext* aScriptContext)
|
|||
|
||||
nsIScriptNameSetRegistry* nsLayoutModule::gRegistry;
|
||||
nsICSSStyleSheet* nsLayoutModule::gUAStyleSheet = nsnull;
|
||||
nsIStyleSheet* nsLayoutModule::gViewSourceStyleSheet = nsnull;
|
||||
|
||||
nsLayoutModule::nsLayoutModule()
|
||||
: mInitialized(PR_FALSE)
|
||||
|
@ -279,6 +280,7 @@ nsLayoutModule::Shutdown()
|
|||
|
||||
NS_IF_RELEASE(gRegistry);
|
||||
NS_IF_RELEASE(gUAStyleSheet);
|
||||
NS_IF_RELEASE(gViewSourceStyleSheet);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nslayout.h"
|
||||
#include "nsIModule.h"
|
||||
|
||||
class nsIStyleSheet;
|
||||
class nsICSSStyleSheet;
|
||||
class nsIScriptNameSetRegistry;
|
||||
|
||||
|
@ -58,6 +59,7 @@ protected:
|
|||
|
||||
public:
|
||||
static nsICSSStyleSheet* gUAStyleSheet;
|
||||
static nsIStyleSheet* gViewSourceStyleSheet;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -49,10 +49,10 @@ INCLUDES += \
|
|||
-I$(srcdir)/../../content/src \
|
||||
$(NULL)
|
||||
|
||||
GARBAGE += $(DIST)/bin/res/ua.css $(DIST)/bin/res/html.css $(DIST)/bin/res/forms.css $(DIST)/bin/res/quirk.css $(DIST)/bin/res/arrow.gif
|
||||
GARBAGE += $(DIST)/bin/res/ua.css $(DIST)/bin/res/html.css $(DIST)/bin/res/forms.css $(DIST)/bin/res/quirk.css $(DIST)/bin/res/viewsource.css $(DIST)/bin/res/arrow.gif
|
||||
|
||||
install:: $(TARGETS)
|
||||
$(INSTALL) $(srcdir)/html.css $(srcdir)/forms.css $(srcdir)/quirk.css $(srcdir)/arrow.gif $(DIST)/bin/res
|
||||
$(INSTALL) $(srcdir)/html.css $(srcdir)/forms.css $(srcdir)/quirk.css $(srcdir)/viewsource.css $(srcdir)/arrow.gif $(DIST)/bin/res
|
||||
rm -f $(DIST)/bin/res/ua.css
|
||||
cp $(srcdir)/ua.css $(DIST)/bin/res
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ install:: $(LIBRARY)
|
|||
$(MAKE_INSTALL) html.css $(DIST)\bin\res
|
||||
$(MAKE_INSTALL) forms.css $(DIST)\bin\res
|
||||
$(MAKE_INSTALL) quirk.css $(DIST)\bin\res
|
||||
$(MAKE_INSTALL) viewsource.css $(DIST)\bin\res
|
||||
$(MAKE_INSTALL) arrow.gif $(DIST)\bin\res
|
||||
$(MAKE_INSTALL) arrowd.gif $(DIST)\bin\res
|
||||
|
||||
|
@ -71,5 +72,6 @@ clobber::
|
|||
rm -f $(DIST)\bin\res\html.css
|
||||
rm -f $(DIST)\bin\res\forms.css
|
||||
rm -f $(DIST)\bin\res\quirk.css
|
||||
rm -f $(DIST)\bin\res\viewsource.css
|
||||
rm -f $(DIST)\bin\res\arrow.gif
|
||||
rm -f $(DIST)\bin\res\arrowd.gif
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
@import url(resource:/res/html.css);
|
||||
@import url(chrome://global/content/xul.css);
|
||||
@import url(resource:/res/quirk.css);
|
||||
@import url(resource:/res/viewsource.css);
|
||||
|
||||
parsererror {
|
||||
display: block;
|
||||
|
|
|
@ -20,108 +20,67 @@
|
|||
* Blake Ross <BlakeR1234@aol.com>
|
||||
*/
|
||||
|
||||
@namespace url(http://www.mozilla.org/viewsource);
|
||||
@namespace url(http://www.w3.org/1999/xhtml); /* set default namespace to HTML */
|
||||
|
||||
viewsource {
|
||||
font-family: monospace;
|
||||
font-weight: normal;
|
||||
color: black;
|
||||
.viewsource {
|
||||
font-family: monospace;
|
||||
font-weight: normal;
|
||||
color: black;
|
||||
white-space: pre;
|
||||
font-size: 12px;
|
||||
font-size: 12px;
|
||||
padding-top: 8px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
summary {
|
||||
display: block;
|
||||
background-color: #FFFFCC;
|
||||
width: 90%;
|
||||
border: solid;
|
||||
border-width: 1px;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
key {
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
key:before {
|
||||
color: black;
|
||||
}
|
||||
|
||||
val {
|
||||
color: blue;
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
val:before {
|
||||
content: "=";
|
||||
color: black;
|
||||
}
|
||||
|
||||
entity {
|
||||
color:#FF4500;
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
entity:before {
|
||||
content: "&";
|
||||
}
|
||||
|
||||
comment {
|
||||
color: green;
|
||||
font-style:italic;
|
||||
}
|
||||
|
||||
cdata {
|
||||
color: #CC0066;
|
||||
}
|
||||
|
||||
doctype {
|
||||
color: steelblue;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
pi {
|
||||
color: orchid;
|
||||
font-style: italic;
|
||||
.start-tag {
|
||||
color: purple;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
start {
|
||||
color: purple;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
start:before {
|
||||
content: "<";
|
||||
color: black;
|
||||
}
|
||||
|
||||
start:after {
|
||||
content: ">";
|
||||
color: black;
|
||||
}
|
||||
|
||||
end {
|
||||
color: purple;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
end:before {
|
||||
content: "</";
|
||||
color: black;
|
||||
}
|
||||
|
||||
end:after {
|
||||
content: ">";
|
||||
color: black;
|
||||
.end-tag {
|
||||
color: purple;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
txt {
|
||||
font-weight: normal;
|
||||
.comment {
|
||||
color: green;
|
||||
font-style: italic;
|
||||
}
|
||||
.cdata {
|
||||
color: #CC0066;
|
||||
}
|
||||
.doctype {
|
||||
color: steelblue;
|
||||
font-style: italic;
|
||||
}
|
||||
.pi {
|
||||
color: orchid;
|
||||
font-style: italic;
|
||||
}
|
||||
.entity {
|
||||
color:#FF4500;
|
||||
font-weight: normal;
|
||||
}
|
||||
.text {
|
||||
font-weight: normal;
|
||||
}
|
||||
.attribute-name {
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
}
|
||||
.attribute-value {
|
||||
color: blue;
|
||||
font-weight: normal;
|
||||
}
|
||||
.summary {
|
||||
display: block;
|
||||
background-color: #FFFFCC;
|
||||
width: 90%;
|
||||
border: solid;
|
||||
border-width: 1pt;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
.popup {
|
||||
font-weight: normal;
|
||||
}
|
||||
.markupdeclaration {
|
||||
color: steelblue;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
error {
|
||||
background-color: #FFFFCC;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
@import url(resource:/res/html.css);
|
||||
@import url(chrome://global/content/xul.css);
|
||||
@import url(resource:/res/quirk.css);
|
||||
@import url(resource:/res/viewsource.css);
|
||||
|
||||
parsererror {
|
||||
display: block;
|
||||
|
|
|
@ -20,108 +20,67 @@
|
|||
* Blake Ross <BlakeR1234@aol.com>
|
||||
*/
|
||||
|
||||
@namespace url(http://www.mozilla.org/viewsource);
|
||||
@namespace url(http://www.w3.org/1999/xhtml); /* set default namespace to HTML */
|
||||
|
||||
viewsource {
|
||||
font-family: monospace;
|
||||
font-weight: normal;
|
||||
color: black;
|
||||
.viewsource {
|
||||
font-family: monospace;
|
||||
font-weight: normal;
|
||||
color: black;
|
||||
white-space: pre;
|
||||
font-size: 12px;
|
||||
font-size: 12px;
|
||||
padding-top: 8px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
summary {
|
||||
display: block;
|
||||
background-color: #FFFFCC;
|
||||
width: 90%;
|
||||
border: solid;
|
||||
border-width: 1px;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
key {
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
key:before {
|
||||
color: black;
|
||||
}
|
||||
|
||||
val {
|
||||
color: blue;
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
val:before {
|
||||
content: "=";
|
||||
color: black;
|
||||
}
|
||||
|
||||
entity {
|
||||
color:#FF4500;
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
entity:before {
|
||||
content: "&";
|
||||
}
|
||||
|
||||
comment {
|
||||
color: green;
|
||||
font-style:italic;
|
||||
}
|
||||
|
||||
cdata {
|
||||
color: #CC0066;
|
||||
}
|
||||
|
||||
doctype {
|
||||
color: steelblue;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
pi {
|
||||
color: orchid;
|
||||
font-style: italic;
|
||||
.start-tag {
|
||||
color: purple;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
start {
|
||||
color: purple;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
start:before {
|
||||
content: "<";
|
||||
color: black;
|
||||
}
|
||||
|
||||
start:after {
|
||||
content: ">";
|
||||
color: black;
|
||||
}
|
||||
|
||||
end {
|
||||
color: purple;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
end:before {
|
||||
content: "</";
|
||||
color: black;
|
||||
}
|
||||
|
||||
end:after {
|
||||
content: ">";
|
||||
color: black;
|
||||
.end-tag {
|
||||
color: purple;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
txt {
|
||||
font-weight: normal;
|
||||
.comment {
|
||||
color: green;
|
||||
font-style: italic;
|
||||
}
|
||||
.cdata {
|
||||
color: #CC0066;
|
||||
}
|
||||
.doctype {
|
||||
color: steelblue;
|
||||
font-style: italic;
|
||||
}
|
||||
.pi {
|
||||
color: orchid;
|
||||
font-style: italic;
|
||||
}
|
||||
.entity {
|
||||
color:#FF4500;
|
||||
font-weight: normal;
|
||||
}
|
||||
.text {
|
||||
font-weight: normal;
|
||||
}
|
||||
.attribute-name {
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
}
|
||||
.attribute-value {
|
||||
color: blue;
|
||||
font-weight: normal;
|
||||
}
|
||||
.summary {
|
||||
display: block;
|
||||
background-color: #FFFFCC;
|
||||
width: 90%;
|
||||
border: solid;
|
||||
border-width: 1pt;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
.popup {
|
||||
font-weight: normal;
|
||||
}
|
||||
.markupdeclaration {
|
||||
color: steelblue;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
error {
|
||||
background-color: #FFFFCC;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#endif
|
||||
|
||||
#define VIEW_SOURCE_HTML
|
||||
#define VIEW_SOURCE_COLORING
|
||||
|
||||
#include "nsIDTDDebug.h"
|
||||
#include "nsViewSourceHTML.h"
|
||||
|
@ -65,13 +64,11 @@
|
|||
#include "nsHTMLEntities.h"
|
||||
#endif // VIEW_SOURCE_HTML
|
||||
|
||||
#ifdef VIEW_SOURCE_COLORING
|
||||
// For Coloring pref only
|
||||
// If we aren't going to define it, then should save on bloat.
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
#endif // VIEW_SOURCE_COLORING
|
||||
|
||||
#include "COtherDTD.h"
|
||||
#include "nsElementTable.h"
|
||||
|
@ -100,7 +97,7 @@ static int gErrorThreshold = 10;
|
|||
#endif
|
||||
|
||||
#ifdef VIEW_SOURCE_HTML
|
||||
static const char* kPreStyle = "font-family: -moz-fixed; font-weight:normal; color:black; padding-top:4px; margin-left:4px;";
|
||||
static const char* kPreClass = "viewsource";
|
||||
#endif // VIEW_SOURCE_HTML
|
||||
|
||||
/**
|
||||
|
@ -229,23 +226,21 @@ enum {
|
|||
VIEW_SOURCE_MARKUPDECLARATION = 12
|
||||
};
|
||||
|
||||
#ifdef VIEW_SOURCE_COLORING
|
||||
static char* kElementStyles[] = {
|
||||
"color: purple; font-weight:bold;",
|
||||
"color: purple; font-weight:bold;",
|
||||
"color: green; font-style:italic;",
|
||||
"color: #CC0066;",
|
||||
"color:steelblue; font-style:italic;",
|
||||
"color:orchid; font-style:italic;",
|
||||
"color:#FF4500; font-weight:normal;",
|
||||
"font-weight: normal;",
|
||||
"color: black; font-weight:bold;",
|
||||
"color: blue; font-weight:normal;",
|
||||
"display:block; background-color:#FFFFCC; width:90%; border:solid; border-width:1pt; font-family: Sans-serif;",
|
||||
"font-weight: normal;",
|
||||
"color:steelblue; font-style:italic;"
|
||||
static char* kElementClasses[] = {
|
||||
"start-tag",
|
||||
"end-tag",
|
||||
"comment",
|
||||
"cdata",
|
||||
"doctype",
|
||||
"pi",
|
||||
"entity",
|
||||
"text",
|
||||
"attribute-name",
|
||||
"attribute-value",
|
||||
"summary",
|
||||
"popup",
|
||||
"markupdeclaration"
|
||||
};
|
||||
#endif
|
||||
|
||||
static char* kBeforeText[] = {
|
||||
"<",
|
||||
|
@ -305,6 +300,12 @@ CViewSourceHTML::CViewSourceHTML() : mTags(), mErrors() {
|
|||
mValue = VIEW_SOURCE_ATTRIBUTE_VALUE;
|
||||
mSummaryTag = VIEW_SOURCE_SUMMARY;
|
||||
mPopupTag = VIEW_SOURCE_POPUP;
|
||||
nsresult result=NS_OK;
|
||||
mSyntaxHighlight = PR_FALSE;
|
||||
// This determines the value of the boolean syntax_highlight preference.
|
||||
NS_WITH_SERVICE(nsIPref, thePrefsService, kPrefCID, &result);
|
||||
if (NS_SUCCEEDED(result) && thePrefsService)
|
||||
thePrefsService->GetBoolPref("view_source.syntax_highlight", &mSyntaxHighlight);
|
||||
#else
|
||||
mStartTag.AssignWithConversion("start");
|
||||
mEndTag.AssignWithConversion("end");
|
||||
|
@ -433,7 +434,7 @@ nsresult CViewSourceHTML::WillBuildModel( const CParserContext& aParserContext,
|
|||
if((!aParserContext.mPrevContext) && (mSink)) {
|
||||
|
||||
mTags.Truncate();
|
||||
mErrors.AssignWithConversion(" HTML 4.0 Strict-DTD validation (enabled); [Should use Transitional?].\n");
|
||||
mErrors.Assign(NS_LITERAL_STRING(" HTML 4.0 Strict-DTD validation (enabled); [Should use Transitional?].\n"));
|
||||
|
||||
mValidator=aParserContext.mValidator;
|
||||
mDocType=aParserContext.mDocType;
|
||||
|
@ -483,12 +484,12 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
|
|||
// token allocator, because there are no attributes on the tokens.
|
||||
nsAutoString tag;
|
||||
|
||||
tag.AssignWithConversion("HTML");
|
||||
tag.Assign(NS_LITERAL_STRING("HTML"));
|
||||
CStartToken htmlToken(tag, eHTMLTag_html);
|
||||
nsCParserNode htmlNode(&htmlToken,0,0/*stack token*/);
|
||||
mSink->OpenHTML(htmlNode);
|
||||
|
||||
tag.AssignWithConversion("BODY");
|
||||
tag.Assign(NS_LITERAL_STRING("BODY"));
|
||||
CStartToken bodyToken(tag, eHTMLTag_body);
|
||||
nsCParserNode bodyNode(&bodyToken,0,0/*stack token*/);
|
||||
mSink->OpenBody(bodyNode);
|
||||
|
@ -501,7 +502,7 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
|
|||
nsTokenAllocator* theAllocator=mTokenizer->GetTokenAllocator();
|
||||
if(theAllocator) {
|
||||
#ifdef VIEW_SOURCE_HTML
|
||||
tag.AssignWithConversion("PRE");
|
||||
tag.Assign(NS_LITERAL_STRING("PRE"));
|
||||
CStartToken* theToken=NS_STATIC_CAST(CStartToken*,theAllocator->CreateTokenOfType(eToken_start,eHTMLTag_pre,tag));
|
||||
#else
|
||||
//now let's automatically open the root container...
|
||||
|
@ -514,8 +515,8 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
|
|||
nsCParserNode theNode(theToken,0,theAllocator);
|
||||
|
||||
#ifdef VIEW_SOURCE_HTML
|
||||
theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_ConvertASCIItoUCS2(kPreStyle));
|
||||
theAttr->SetKey(NS_LITERAL_STRING("style"));
|
||||
theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_ConvertASCIItoUCS2(kPreClass));
|
||||
theAttr->SetKey(NS_LITERAL_STRING("class"));
|
||||
#else
|
||||
theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_LITERAL_STRING("http://www.mozilla.org/viewsource"));
|
||||
theAttr->SetKey(NS_LITERAL_STRING("xmlns"));
|
||||
|
@ -876,13 +877,6 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
|
|||
nsresult result=NS_OK;
|
||||
|
||||
CSharedVSContext& theContext=CSharedVSContext::GetSharedContext();
|
||||
#ifdef VIEW_SOURCE_COLORING
|
||||
// This determines the value of the boolean syntax_highlight preference.
|
||||
PRBool syntaxHighlight = PR_FALSE;
|
||||
NS_WITH_SERVICE(nsIPref, thePrefsService, kPrefCID, &result);
|
||||
if (NS_SUCCEEDED(result) && thePrefsService)
|
||||
thePrefsService->GetBoolPref("view_source.syntax_highlight", &syntaxHighlight);
|
||||
#endif // VIEW_SOURCE_COLORING
|
||||
|
||||
nsTokenAllocator* theAllocator=mTokenizer->GetTokenAllocator();
|
||||
NS_ASSERTION(0!=theAllocator,"Error: no allocator");
|
||||
|
@ -898,31 +892,25 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
|
|||
mSink->AddLeaf(theNode);
|
||||
}
|
||||
|
||||
#ifdef VIEW_SOURCE_COLORING
|
||||
nsAutoString tag (NS_LITERAL_STRING("SPAN"));
|
||||
CStartToken* theTagToken=NS_STATIC_CAST(CStartToken*,theAllocator->CreateTokenOfType(eToken_start,eHTMLTag_span,tag));
|
||||
#endif // VIEW_SOURCE_COLORING
|
||||
CStartToken* theTagToken=NS_STATIC_CAST(CStartToken*,theAllocator->CreateTokenOfType(eToken_start,eHTMLTag_span,NS_LITERAL_STRING("SPAN")));
|
||||
#else
|
||||
CStartToken* theTagToken=NS_STATIC_CAST(CStartToken*,theAllocator->CreateTokenOfType(eToken_start,eHTMLTag_unknown,theXMLTagName));
|
||||
#endif // VIEW_SOURCE_HTML
|
||||
|
||||
#ifdef VIEW_SOURCE_COLORING
|
||||
if (syntaxHighlight)
|
||||
if (mSyntaxHighlight)
|
||||
{
|
||||
theContext.mStartNode.Init(theTagToken,mLineNumber,theAllocator);
|
||||
theContext.mStartNode.Init(theTagToken,mLineNumber,theAllocator);
|
||||
#ifdef VIEW_SOURCE_HTML
|
||||
CAttributeToken* theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_ConvertASCIItoUCS2(kElementStyles[aTagType]));
|
||||
theAttr->SetKey(NS_LITERAL_STRING("style"));
|
||||
CAttributeToken* theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_ConvertASCIItoUCS2(kElementClasses[aTagType]));
|
||||
theAttr->SetKey(NS_LITERAL_STRING("class"));
|
||||
theContext.mStartNode.AddAttribute(theAttr);
|
||||
}
|
||||
#endif // VIEW_SOURCE_HTML
|
||||
}
|
||||
|
||||
STOP_TIMER();
|
||||
|
||||
mSink->OpenContainer(theContext.mStartNode); //emit <starttag>...
|
||||
|
||||
#endif // VIEW_SOURCE_COLORING
|
||||
|
||||
#ifdef rickgdebug
|
||||
|
||||
if(aNewlineRequired) {
|
||||
|
@ -946,15 +934,13 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
|
|||
}
|
||||
|
||||
#ifdef VIEW_SOURCE_HTML
|
||||
#ifdef VIEW_SOURCE_COLORING
|
||||
if (syntaxHighlight)
|
||||
if (mSyntaxHighlight)
|
||||
{
|
||||
theContext.mStartNode.ReleaseAll();
|
||||
CEndToken theEndToken(eHTMLTag_span);
|
||||
theContext.mEndNode.Init(&theEndToken,mLineNumber,0/*stack token*/);
|
||||
mSink->CloseContainer(theContext.mEndNode); //emit </starttag>...
|
||||
}
|
||||
#endif // VIEW_SOURCE_COLORING
|
||||
if (kAfterText[aTagType][0] != 0) {
|
||||
nsAutoString afterText;
|
||||
afterText.AssignWithConversion(kAfterText[aTagType]);
|
||||
|
|
|
@ -274,6 +274,7 @@ protected:
|
|||
PRInt32 mValue;
|
||||
PRInt32 mPopupTag;
|
||||
PRInt32 mSummaryTag;
|
||||
PRBool mSyntaxHighlight;
|
||||
#else
|
||||
nsAutoString mStartTag;
|
||||
nsAutoString mEndTag;
|
||||
|
|
|
@ -235,6 +235,7 @@ viewer:defaults:wallet:StateSchema.tbl
|
|||
viewer:res:html:*
|
||||
viewer:res:html.css
|
||||
viewer:res:quirk.css
|
||||
viewer:res:viewsource.css
|
||||
viewer:res:maccharset.properties
|
||||
viewer:res:rdf:article.gif
|
||||
viewer:res:rdf:collapser.gif
|
||||
|
|
|
@ -255,6 +255,7 @@ bin/res/langGroups.properties
|
|||
bin/res/language.properties
|
||||
bin/res/html.css
|
||||
bin/res/quirk.css
|
||||
bin/res/viewsource.css
|
||||
bin/res/html/*
|
||||
bin/res/rdf/article.gif
|
||||
bin/res/rdf/document.gif
|
||||
|
|
|
@ -248,6 +248,7 @@ bin\res\html.css
|
|||
bin\res\ua.css
|
||||
bin\res\forms.css
|
||||
bin\res\quirk.css
|
||||
bin\res\viewsource.css
|
||||
bin\res\arrow.gif
|
||||
bin\res\html\*
|
||||
bin\defaults\wallet\VcardSchema.tbl
|
||||
|
|
Загрузка…
Ссылка в новой задаче