Bug 368758 - Remove obsolete workaround pref editor.quotesPreformatted. r=ehsan

This commit is contained in:
aceman 2012-03-02 17:23:01 -05:00
parent 5816447226
commit a39be24188
7 changed files with 51 additions and 93 deletions

View File

@ -108,7 +108,6 @@ nsPlainTextSerializer::nsPlainTextSerializer()
mCiteQuoteLevel = 0;
mStructs = true; // will be read from prefs later
mHeaderStrategy = 1 /*indent increasingly*/; // ditto
mQuotesPreformatted = false; // ditto
mDontWrapAnyQuotes = false; // ditto
mHasWrittenCiteBlockquote = false;
mSpanLevel = 0;
@ -210,10 +209,6 @@ nsPlainTextSerializer::Init(PRUint32 aFlags, PRUint32 aWrapColumn,
mHeaderStrategy =
Preferences::GetInt(PREF_HEADER_STRATEGY, mHeaderStrategy);
// The quotesPreformatted pref is a temporary measure. See bug 69638.
mQuotesPreformatted =
Preferences::GetBool("editor.quotesPreformatted", mQuotesPreformatted);
// DontWrapAnyQuotes is set according to whether plaintext mail
// is wrapping to window width -- see bug 134439.
// We'll only want this if we're wrapping and formatted.
@ -1636,7 +1631,7 @@ nsPlainTextSerializer::Write(const nsAString& aStr)
// that does normal formatted text. The one for preformatted text calls
// Output directly while the other code path goes through AddToLine.
if ((mPreFormatted && !mWrapColumn) || IsInPre()
|| ((((!mQuotesPreformatted && mSpanLevel > 0) || mDontWrapAnyQuotes))
|| ((mSpanLevel > 0 || mDontWrapAnyQuotes)
&& mEmptyLines >= 0 && str.First() == PRUnichar('>'))) {
// No intelligent wrapping.

View File

@ -176,11 +176,9 @@ protected:
// Quotes need to be wrapped differently from non-quoted text,
// because quoted text has a few extra characters (e.g. ">> ")
// which makes the line length longer.
// Mail can represent quotes in different ways: it can wrap
// quotes in a <pre> (if editor.quotesPreformatted is set),
// or not wrapped in any special tag (if mail.compose.wrap_to_window_width)
// or in a <span> (if neither of the above are set).
bool mQuotesPreformatted; // expect quotes wrapped in <pre>
// Mail can represent quotes in different ways:
// Not wrapped in any special tag (if mail.compose.wrap_to_window_width)
// or in a <span>.
bool mDontWrapAnyQuotes; // no special quote markers
bool mStructs; // Output structs (pref)

View File

@ -46,7 +46,6 @@ nsComposeTxtSrvFilter::nsComposeTxtSrvFilter() :
{
mBlockQuoteAtom = do_GetAtom("blockquote");
mPreAtom = do_GetAtom("pre");
mSpanAtom = do_GetAtom("span");
mTableAtom = do_GetAtom("table");
mMozQuoteAtom = do_GetAtom("_moz_quote");
@ -79,7 +78,7 @@ nsComposeTxtSrvFilter::Skip(nsIDOMNode* aNode, bool *_retval)
*_retval = content->AttrValueIs(kNameSpaceID_None, mTypeAtom,
mCiteAtom, eIgnoreCase);
}
} else if (tag == mPreAtom || tag == mSpanAtom) {
} else if (tag == mSpanAtom) {
if (mIsForMail) {
*_retval = content->AttrValueIs(kNameSpaceID_None, mMozQuoteAtom,
mTrueAtom, eIgnoreCase);

View File

@ -66,8 +66,7 @@ public:
protected:
bool mIsForMail;
nsCOMPtr<nsIAtom> mBlockQuoteAtom;
nsCOMPtr<nsIAtom> mPreAtom; // mail plain text quotes are wrapped in pre tags
nsCOMPtr<nsIAtom> mSpanAtom; //or they may be wrapped in span tags (editor.quotesPreformatted).
nsCOMPtr<nsIAtom> mSpanAtom; // mail plain text quotes are wrapped in span tags
nsCOMPtr<nsIAtom> mMozQuoteAtom; // _moz_quote_
nsCOMPtr<nsIAtom> mTableAtom;
nsCOMPtr<nsIAtom> mClassAtom;

View File

@ -1968,94 +1968,63 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText,
if (mWrapToWindow)
return nsPlaintextEditor::InsertAsQuotation(aQuotedText, aNodeInserted);
nsresult rv;
// The quotesPreformatted pref is a temporary measure. See bug 69638.
// Eventually we'll pick one way or the other.
bool quotesInPre = false;
nsCOMPtr<nsIPrefBranch> prefBranch =
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && prefBranch)
prefBranch->GetBoolPref("editor.quotesPreformatted", &quotesInPre);
nsCOMPtr<nsIDOMNode> preNode;
// get selection
nsCOMPtr<nsISelection> selection;
rv = GetSelection(getter_AddRefs(selection));
nsresult rv = GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(rv, rv);
if (!selection)
{
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
}
else
{
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpInsertQuotation, nsIEditor::eNext);
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
// give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);
bool cancel, handled;
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(rv, rv);
if (cancel) return NS_OK; // rules canceled the operation
if (!handled)
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpInsertQuotation, nsIEditor::eNext);
// give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);
bool cancel, handled;
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(rv, rv);
if (cancel) return NS_OK; // rules canceled the operation
if (!handled)
{
// Wrap the inserted quote in a <span> so it won't be wrapped:
rv = DeleteSelectionAndCreateNode(NS_LITERAL_STRING("span"), getter_AddRefs(preNode));
// If this succeeded, then set selection inside the pre
// so the inserted text will end up there.
// If it failed, we don't care what the return value was,
// but we'll fall through and try to insert the text anyway.
if (NS_SUCCEEDED(rv) && preNode)
{
// Wrap the inserted quote in a <pre> so it won't be wrapped:
nsAutoString tag;
if (quotesInPre)
tag.AssignLiteral("pre");
else
tag.AssignLiteral("span");
rv = DeleteSelectionAndCreateNode(tag, getter_AddRefs(preNode));
// If this succeeded, then set selection inside the pre
// so the inserted text will end up there.
// If it failed, we don't care what the return value was,
// but we'll fall through and try to insert the text anyway.
if (NS_SUCCEEDED(rv) && preNode)
// Add an attribute on the pre node so we'll know it's a quotation.
// Do this after the insertion, so that
nsCOMPtr<nsIDOMElement> preElement(do_QueryInterface(preNode));
if (preElement)
{
// Add an attribute on the pre node so we'll know it's a quotation.
// Do this after the insertion, so that
nsCOMPtr<nsIDOMElement> preElement (do_QueryInterface(preNode));
if (preElement)
{
preElement->SetAttribute(NS_LITERAL_STRING("_moz_quote"),
NS_LITERAL_STRING("true"));
if (quotesInPre)
{
// set style to not have unwanted vertical margins
preElement->SetAttribute(NS_LITERAL_STRING("style"),
NS_LITERAL_STRING("margin: 0 0 0 0px;"));
}
else
{
// turn off wrapping on spans
preElement->SetAttribute(NS_LITERAL_STRING("style"),
NS_LITERAL_STRING("white-space: pre;"));
}
}
// and set the selection inside it:
selection->Collapse(preNode, 0);
preElement->SetAttribute(NS_LITERAL_STRING("_moz_quote"),
NS_LITERAL_STRING("true"));
// turn off wrapping on spans
preElement->SetAttribute(NS_LITERAL_STRING("style"),
NS_LITERAL_STRING("white-space: pre;"));
}
// and set the selection inside it:
selection->Collapse(preNode, 0);
}
if (aAddCites)
rv = nsPlaintextEditor::InsertAsQuotation(aQuotedText, aNodeInserted);
else
rv = nsPlaintextEditor::InsertText(aQuotedText);
// Note that if !aAddCites, aNodeInserted isn't set.
// That's okay because the routines that use aAddCites
// don't need to know the inserted node.
if (aAddCites)
rv = nsPlaintextEditor::InsertAsQuotation(aQuotedText, aNodeInserted);
else
rv = nsPlaintextEditor::InsertText(aQuotedText);
// Note that if !aAddCites, aNodeInserted isn't set.
// That's okay because the routines that use aAddCites
// don't need to know the inserted node.
if (aNodeInserted && NS_SUCCEEDED(rv))
{
*aNodeInserted = preNode;
NS_IF_ADDREF(*aNodeInserted);
}
if (aNodeInserted && NS_SUCCEEDED(rv))
{
*aNodeInserted = preNode;
NS_IF_ADDREF(*aNodeInserted);
}
}
// Set the selection to just after the inserted node:
if (NS_SUCCEEDED(rv) && preNode)
{

View File

@ -757,7 +757,6 @@ var xml = <prefs>
<pref><name>extensions.ignoreMTimeChanges</name></pref>
<pref><name>network.hosts.pop_server</name></pref>
<pref><name>privacy.item.history</name></pref>
<pref><name>editor.quotesPreformatted</name></pref>
<pref><name>security.password_lifetime</name></pref>
<pref><name>security.ssl3.dhe_dss_aes_128_sha</name></pref>
<pref><name>font.name.monospace.x-tamil</name></pref>

View File

@ -407,7 +407,6 @@ pref("extensions.spellcheck.inline.max-misspellings", 500);
pref("editor.use_custom_colors", false);
pref("editor.singleLine.pasteNewlines", 2);
pref("editor.quotesPreformatted", false);
pref("editor.use_css", true);
pref("editor.css.default_length_unit", "px");
pref("editor.resizing.preserve_ratio", true);