It was impossible to set the background color of a table thru TableOrCell Background Color menu item.
b=127723, r=jfrancis, r=cmanske, sr=kin, a=asa git-svn-id: svn://10.0.0.236/trunk@116645 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
7528713972
commit
b231f8945d
@ -89,6 +89,8 @@ interface nsIEditor : nsISupports
|
||||
void setAttributeOrEquivalent(in nsIDOMElement element,
|
||||
in AString sourceAttrName,
|
||||
in AString sourceAttrValue);
|
||||
void removeAttributeOrEquivalent(in nsIDOMElement element,
|
||||
in DOMString sourceAttrName);
|
||||
|
||||
/**
|
||||
* postCreate should be called after Init, and is the time that the editor
|
||||
|
||||
@ -5054,3 +5054,11 @@ nsEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
{
|
||||
return SetAttribute(aElement, aAttribute, aValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsEditor::RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute)
|
||||
{
|
||||
return RemoveAttribute(aElement, aAttribute);
|
||||
}
|
||||
|
||||
|
||||
@ -4162,12 +4162,10 @@ nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAReadableString *
|
||||
// act on this div.
|
||||
nsCOMPtr<nsIDOMElement> divElem = do_QueryInterface(firstChild);
|
||||
if (useCSS) {
|
||||
res = mHTMLEditor->RemoveAttribute(divElem, attr);
|
||||
mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, *alignType);
|
||||
res = mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, *alignType);
|
||||
}
|
||||
else {
|
||||
res = mHTMLEditor->SetAttribute(divElem, attr, *alignType);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
@ -4179,13 +4177,12 @@ nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAReadableString *
|
||||
// set up the alignment on the div
|
||||
nsCOMPtr<nsIDOMElement> divElem = do_QueryInterface(divNode);
|
||||
if (useCSS) {
|
||||
res = mHTMLEditor->RemoveAttribute(divElem, attr);
|
||||
mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, *alignType);
|
||||
res = mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, *alignType);
|
||||
}
|
||||
else {
|
||||
res = mHTMLEditor->SetAttribute(divElem, attr, *alignType);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
if (NS_FAILED(res)) return res;
|
||||
// tuck the children into the end of the active div
|
||||
while (lastChild && (lastChild != divNode))
|
||||
{
|
||||
@ -5983,6 +5980,7 @@ nsHTMLEditRules::ReturnInListItem(nsISelection *aSelection,
|
||||
// may be left empty.
|
||||
nsCOMPtr<nsIDOMNode> prevItem;
|
||||
mHTMLEditor->GetPriorHTMLSibling(aListItem, address_of(prevItem));
|
||||
|
||||
if (prevItem && nsHTMLEditUtils::IsListItem(prevItem))
|
||||
{
|
||||
PRBool bIsEmptyNode;
|
||||
@ -7743,13 +7741,14 @@ nsHTMLEditRules::RemoveAlignment(nsIDOMNode * aNode, nsAReadableString & aAlignT
|
||||
{
|
||||
if (nsHTMLEditUtils::IsTable(child) || nsHTMLEditUtils::IsHR(child))
|
||||
{
|
||||
mHTMLEditor->SetAttributeOrEquivalent(curElem, NS_LITERAL_STRING("align"), aAlignType);
|
||||
res = mHTMLEditor->SetAttributeOrEquivalent(curElem, NS_LITERAL_STRING("align"), aAlignType);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsAutoString dummyCssValue;
|
||||
mHTMLEditor->mHTMLCSSUtils->RemoveCSSInlineStyle(child, nsIEditProperty::cssTextAlign, dummyCssValue);
|
||||
res = mHTMLEditor->mHTMLCSSUtils->RemoveCSSInlineStyle(child, nsIEditProperty::cssTextAlign, dummyCssValue);
|
||||
}
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
if (!nsHTMLEditUtils::IsTable(child))
|
||||
{
|
||||
@ -7771,7 +7770,8 @@ nsHTMLEditRules::RemoveAlignment(nsIDOMNode * aNode, nsAReadableString & aAlignT
|
||||
// if we are in CSS mode and if the element is a DIV, let's remove it
|
||||
// if it does not carry any style hint (style attr, class or ID)
|
||||
nsAutoString dummyCssValue;
|
||||
mHTMLEditor->mHTMLCSSUtils->RemoveCSSInlineStyle(child, nsIEditProperty::cssTextAlign, dummyCssValue);
|
||||
res = mHTMLEditor->mHTMLCSSUtils->RemoveCSSInlineStyle(child, nsIEditProperty::cssTextAlign, dummyCssValue);
|
||||
if (NS_FAILED(res)) return res;
|
||||
nsCOMPtr<nsIDOMElement> childElt = do_QueryInterface(child);
|
||||
PRBool hasStyleOrIdOrClass;
|
||||
res = mHTMLEditor->HasStyleOrIdOrClass(childElt, &hasStyleOrIdOrClass);
|
||||
@ -7908,9 +7908,8 @@ nsHTMLEditRules::AlignBlock(nsIDOMElement * aElement, const nsAReadableString *
|
||||
if (useCSS) {
|
||||
// let's use CSS alignment; we use margin-left and margin-right for tables
|
||||
// and text-align for other block-level elements
|
||||
res = mHTMLEditor->RemoveAttribute(aElement, attr);
|
||||
res = mHTMLEditor->SetAttributeOrEquivalent(aElement, attr, *aAlignType);
|
||||
if (NS_FAILED(res)) return res;
|
||||
mHTMLEditor->SetAttributeOrEquivalent(aElement, attr, *aAlignType);
|
||||
}
|
||||
else {
|
||||
// HTML case; this code is supposed to be called ONLY if the element
|
||||
|
||||
@ -5018,7 +5018,17 @@ nsHTMLEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
PRInt32 count;
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(aElement, nsnull, &aAttribute, &aValue, &count);
|
||||
if (NS_FAILED(res)) return res;
|
||||
if (!count) {
|
||||
if (count) {
|
||||
// we found an equivalence ; let's remove the HTML attribute itself if it is set
|
||||
nsAutoString existingValue;
|
||||
PRBool wasSet = PR_FALSE;
|
||||
res = GetAttributeValue(aElement, aAttribute, existingValue, &wasSet);
|
||||
if (NS_FAILED(res)) return res;
|
||||
if (wasSet) {
|
||||
res = RemoveAttribute(aElement, aAttribute);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// count is an integer that represents the number of CSS declarations applied to the
|
||||
// element. If it is zero, we found no equivalence in this implementation for the
|
||||
// attribute
|
||||
@ -5047,6 +5057,28 @@ nsHTMLEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLEditor::RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute)
|
||||
{
|
||||
PRBool useCSS;
|
||||
nsresult res = NS_OK;
|
||||
GetIsCSSEnabled(&useCSS);
|
||||
if (useCSS && mHTMLCSSUtils) {
|
||||
res = mHTMLCSSUtils->RemoveCSSEquivalentToHTMLStyle(aElement, nsnull, &aAttribute, nsnull);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
|
||||
nsAutoString existingValue;
|
||||
PRBool wasSet = PR_FALSE;
|
||||
res = GetAttributeValue(aElement, aAttribute, existingValue, &wasSet);
|
||||
if (NS_FAILED(res)) return res;
|
||||
if (wasSet) {
|
||||
res = RemoveAttribute(aElement, aAttribute);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLEditor::SetIsCSSEnabled(PRBool aIsCSSPrefChecked)
|
||||
{
|
||||
|
||||
@ -395,6 +395,8 @@ public:
|
||||
NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue);
|
||||
NS_IMETHOD RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute);
|
||||
|
||||
/** join together any afjacent editable text nodes in the range */
|
||||
NS_IMETHOD CollapseAdjacentTextNodes(nsIDOMRange *aInRange);
|
||||
|
||||
@ -2119,6 +2119,12 @@ nsPlaintextEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue)
|
||||
{
|
||||
nsEditor::SetAttribute(aElement, aAttribute, aValue);
|
||||
return NS_OK;
|
||||
return nsEditor::SetAttribute(aElement, aAttribute, aValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlaintextEditor::RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute)
|
||||
{
|
||||
return nsEditor::RemoveAttribute(aElement, aAttribute);
|
||||
}
|
||||
|
||||
@ -110,6 +110,8 @@ public:
|
||||
NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute,
|
||||
const nsAReadableString & aValue);
|
||||
NS_IMETHOD RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAReadableString & aAttribute);
|
||||
|
||||
/** prepare the editor for use */
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags);
|
||||
|
||||
@ -1165,7 +1165,7 @@ function EditorSelectColor(colorType, mouseEvent)
|
||||
}
|
||||
else if (element)
|
||||
{
|
||||
if (false /*gColorObj.Type == "Table"*/)
|
||||
if (gColorObj.Type == "Table")
|
||||
{
|
||||
// Set background on a table
|
||||
// Note that we shouldn't trust "currentColor" because of "TableOrCell" behavior
|
||||
@ -1175,9 +1175,9 @@ function EditorSelectColor(colorType, mouseEvent)
|
||||
if (bgcolor != gColorObj.BackgroundColor)
|
||||
{
|
||||
if (gColorObj.BackgroundColor)
|
||||
window.editorShell.SetAttribute(table, "bgcolor", gColorObj.BackgroundColor);
|
||||
window.editorShell.editor.setAttributeOrEquivalent(table, "bgcolor", gColorObj.BackgroundColor);
|
||||
else
|
||||
window.editorShell.RemoveAttribute(table, "bgcolor");
|
||||
window.editorShell.editor.removeAttributeOrEquivalent(table, "bgcolor");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1195,10 +1195,12 @@ function EditorSelectColor(colorType, mouseEvent)
|
||||
{
|
||||
var defColors = GetDefaultBrowserColors();
|
||||
if (defColors)
|
||||
{ // GLAZOU : this has to be changed
|
||||
{
|
||||
if (!bodyelement.getAttribute("text"))
|
||||
window.editorShell.SetAttribute(bodyelement, "text", defColors.TextColor);
|
||||
window.editorShell.editor.setAttributeOrEquivalent(bodyelement, "text", defColors.TextColor);
|
||||
|
||||
// The following attributes have no individual CSS declaration counterparts
|
||||
// Getting rid of them in favor of CSS implies CSS rules management
|
||||
if (!bodyelement.getAttribute("link"))
|
||||
window.editorShell.SetAttribute(bodyelement, "link", defColors.LinkColor);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user