Bug 388980 - "Gmail compose mail (midas), background color doesn't work" [p=cpearce r=peterv sr=roc a1.9=schrep]

This commit is contained in:
reed%reedloden.com 2007-11-13 08:10:04 +00:00
Родитель 456c6b49d1
Коммит 8400059a8a
4 изменённых файлов: 74 добавлений и 12 удалений

Просмотреть файл

@ -3577,12 +3577,6 @@ nsHTMLEditRules::WillCSSIndent(nsISelection *aSelection, PRBool *aCancel, PRBool
*aHandled = PR_TRUE;
return res;
}
// Next we detect all the transitions in the array, where a transition
// means that adjacent nodes in the array don't have the same parent.
nsVoidArray transitionList;
res = MakeTransitionList(arrayOfNodes, transitionList);
if (NS_FAILED(res)) return res;
// Ok, now go through all the nodes and put them in a blockquote,
// or whatever is appropriate. Wohoo!
@ -3590,6 +3584,7 @@ nsHTMLEditRules::WillCSSIndent(nsISelection *aSelection, PRBool *aCancel, PRBool
nsCOMPtr<nsIDOMNode> curParent;
nsCOMPtr<nsIDOMNode> curQuote;
nsCOMPtr<nsIDOMNode> curList;
nsCOMPtr<nsIDOMNode> sibling;
PRInt32 listCount = arrayOfNodes.Count();
for (i=0; i<listCount; i++)
{
@ -3606,7 +3601,48 @@ nsHTMLEditRules::WillCSSIndent(nsISelection *aSelection, PRBool *aCancel, PRBool
// some logic for putting list items into nested lists...
if (nsHTMLEditUtils::IsList(curParent))
{
if (!curList || transitionList[i])
sibling = nsnull;
// Check for whether we should join a list that follows curNode.
// We do this if the next element is a list, and the list is of the
// same type (li/ol) as curNode was a part it.
mHTMLEditor->GetNextHTMLSibling(curNode, address_of(sibling));
if (sibling && nsHTMLEditUtils::IsList(sibling))
{
nsAutoString curListTag, siblingListTag;
nsEditor::GetTagString(curParent, curListTag);
nsEditor::GetTagString(sibling, siblingListTag);
if (curListTag == siblingListTag)
{
res = mHTMLEditor->MoveNode(curNode, sibling, 0);
if (NS_FAILED(res)) return res;
continue;
}
}
// Check for whether we should join a list that preceeds curNode.
// We do this if the previous element is a list, and the list is of
// the same type (li/ol) as curNode was a part of.
mHTMLEditor->GetPriorHTMLSibling(curNode, address_of(sibling));
if (sibling && nsHTMLEditUtils::IsList(sibling))
{
nsAutoString curListTag, siblingListTag;
nsEditor::GetTagString(curParent, curListTag);
nsEditor::GetTagString(sibling, siblingListTag);
if (curListTag == siblingListTag)
{
res = mHTMLEditor->MoveNode(curNode, sibling, -1);
if (NS_FAILED(res)) return res;
continue;
}
}
sibling = nsnull;
// check to see if curList is still appropriate. Which it is if
// curNode is still right after it in the same list.
if (curList)
mHTMLEditor->GetPriorHTMLSibling(curNode, address_of(sibling));
if (!curList || (sibling && sibling != curList))
{
nsAutoString listTag;
nsEditor::GetTagString(curParent,listTag);
@ -3635,7 +3671,7 @@ nsHTMLEditRules::WillCSSIndent(nsISelection *aSelection, PRBool *aCancel, PRBool
curQuote = nsnull;
}
else {
if (!curQuote) // || transitionList[i])
if (!curQuote)
{
NS_NAMED_LITERAL_STRING(divquoteType, "div");
res = SplitAsNeeded(&divquoteType, address_of(curParent), &offset);

Просмотреть файл

@ -285,8 +285,7 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell,
result = nsPlaintextEditor::Init(aDoc, aPresShell, aRoot, aSelCon, aFlags);
if (NS_FAILED(result)) { return result; }
// the HTML Editor is CSS-aware only in the case of Composer
mCSSAware = (0 == aFlags);
UpdateForFlags(aFlags);
// disable Composer-only features
if (aFlags & eEditorMailMask)
@ -417,12 +416,12 @@ nsHTMLEditor::GetFlags(PRUint32 *aFlags)
return mRules->GetFlags(aFlags);
}
NS_IMETHODIMP
nsHTMLEditor::SetFlags(PRUint32 aFlags)
{
if (!mRules) { return NS_ERROR_NULL_POINTER; }
mCSSAware = ((aFlags & (eEditorNoCSSMask | eEditorMailMask)) == 0);
UpdateForFlags(aFlags);
return mRules->SetFlags(aFlags);
}
@ -5444,6 +5443,25 @@ nsHTMLEditor::SetIsCSSEnabled(PRBool aIsCSSPrefChecked)
{
err = mHTMLCSSUtils->SetCSSEnabled(aIsCSSPrefChecked);
}
// Disable the eEditorNoCSSMask flag if we're enabling StyleWithCSS.
if (NS_SUCCEEDED(err)) {
PRUint32 flags = 0;
err = GetFlags(&flags);
NS_ENSURE_SUCCESS(err, err);
if (aIsCSSPrefChecked) {
// Turn off NoCSS as we're enabling CSS
if (flags & eEditorNoCSSMask) {
flags -= eEditorNoCSSMask;
}
} else if (!(flags & eEditorNoCSSMask)) {
// Turn on NoCSS, as we're disabling CSS.
flags += eEditorNoCSSMask;
}
err = SetFlags(flags);
NS_ENSURE_SUCCESS(err, err);
}
return err;
}

Просмотреть файл

@ -451,6 +451,13 @@ protected:
virtual void RemoveEventListeners();
// Sets mCSSAware to correspond to aFlags. This toggles whether CSS is
// used to style elements in the editor. Note that the editor is only CSS
// aware by default in Composer and in the mail editor.
void UpdateForFlags(PRUint32 aFlags) {
mCSSAware = ((aFlags & (eEditorNoCSSMask | eEditorMailMask)) == 0);
}
/** returns the layout object (nsIFrame in the real world) for aNode
* @param aNode the content to get a frame for
* @param aLayoutObject the "primary frame" for aNode, if one exists. May be null

Просмотреть файл

@ -395,6 +395,7 @@ fails == 386310-1d.html 386310-1-ref.html
== 387876-2.html 387876-2-ref.html
== 387876-3a.html 387876-3-ref.html
== 387876-3b.html 387876-3-ref.html
== 388980-1.html 388980-1-ref.html
== 389468-1.html 389468-1-ref.html
== 389636-1.html about:blank # assertion test
== 389924-1a.html 389924-1-ref.html