Bug 295506 - Variable tabulator width instead of fixed width of 4 spaces. r=mrbkap

This commit is contained in:
Geoff Lankow 2010-02-03 13:59:01 +01:00
parent 54c60d4726
commit a12e1a5def
2 changed files with 13 additions and 0 deletions

View File

@ -94,6 +94,7 @@ Stopwatch vsTimer;
// viewsource.css; the setting is remembered between invocations using a pref.
static const char kBodyId[] = "viewsource";
static const char kBodyClassWrap[] = "wrap";
static const char kBodyTabSize[] = "-moz-tab-size: ";
NS_IMPL_ISUPPORTS1(CViewSourceHTML, nsIDTD)
@ -197,6 +198,7 @@ CViewSourceHTML::CViewSourceHTML()
{
mSyntaxHighlight = PR_FALSE;
mWrapLongLines = PR_FALSE;
mTabSize = -1;
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
PRBool temp;
@ -206,6 +208,9 @@ CViewSourceHTML::CViewSourceHTML()
rv = prefBranch->GetBoolPref("view_source.wrap_long_lines", &temp);
mWrapLongLines = NS_SUCCEEDED(rv) ? temp : PR_FALSE;
rv = prefBranch->GetIntPref("view_source.tab_size", &temp);
mTabSize = NS_SUCCEEDED(rv) ? temp : -1;
}
mSink = 0;
@ -402,6 +407,13 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsITokenizer* aTokenizer,
NS_LITERAL_STRING("class"),
NS_ConvertASCIItoUTF16(kBodyClassWrap));
}
if (mTabSize >= 0) {
nsAutoString styleValue = NS_ConvertASCIItoUTF16(kBodyTabSize);
styleValue.AppendInt(mTabSize);
AddAttrToNode(bodyNode, theAllocator,
NS_LITERAL_STRING("style"),
styleValue);
}
result = mSink->OpenContainer(bodyNode);
if(NS_SUCCEEDED(result)) mHasOpenBody=PR_TRUE;
}

View File

@ -141,6 +141,7 @@ protected:
PRInt32 mLineNumber;
nsITokenizer* mTokenizer; // weak
PRInt32 mTabSize;
PRPackedBool mSyntaxHighlight;
PRPackedBool mWrapLongLines;
PRPackedBool mHasOpenRoot;