зеркало из https://github.com/mozilla/pjs.git
fixes several bugs at once:
could not revert to HTML attributes default value, VALIGN attribute on table elements was not CSSized, page colors of new documents were not CSSized, bad design in |nsEditor::CloneAttributes()|, new image width/height/border attributes were not CSSized, error in EdTableProps.js b=167712, b=167716, r=brade, r=jfrancis, sr=kin
This commit is contained in:
Родитель
70914494a5
Коммит
dfe457b9a4
|
@ -88,9 +88,11 @@ interface nsIEditor : nsISupports
|
|||
|
||||
void setAttributeOrEquivalent(in nsIDOMElement element,
|
||||
in AString sourceAttrName,
|
||||
in AString sourceAttrValue);
|
||||
in AString sourceAttrValue,
|
||||
in boolean aSuppressTransaction);
|
||||
void removeAttributeOrEquivalent(in nsIDOMElement element,
|
||||
in DOMString sourceAttrName);
|
||||
in DOMString sourceAttrName,
|
||||
in boolean aSuppressTransaction);
|
||||
|
||||
/**
|
||||
* postCreate should be called after Init, and is the time that the editor
|
||||
|
|
|
@ -2223,10 +2223,12 @@ nsEditor::CloneAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode)
|
|||
if (NS_SUCCEEDED(sourceAttribute->GetValue(sourceAttrValue)))
|
||||
{
|
||||
if (destInBody) {
|
||||
result = SetAttributeOrEquivalent(destElement, sourceAttrName, sourceAttrValue);
|
||||
result = SetAttributeOrEquivalent(destElement, sourceAttrName, sourceAttrValue, PR_FALSE);
|
||||
}
|
||||
else {
|
||||
destElement->SetAttribute(sourceAttrName, sourceAttrValue);
|
||||
// the element is not inserted in the document yet, we don't want to put a
|
||||
// transaction on the UndoStack
|
||||
result = SetAttributeOrEquivalent(destElement, sourceAttrName, sourceAttrValue, PR_TRUE);
|
||||
}
|
||||
} else {
|
||||
// Do we ever get here?
|
||||
|
@ -5073,14 +5075,16 @@ nsEditor::CreateHTMLContent(const nsAString& aTag, nsIContent** aContent)
|
|||
nsresult
|
||||
nsEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAString & aAttribute,
|
||||
const nsAString & aValue)
|
||||
const nsAString & aValue,
|
||||
PRBool aSuppressTransaction)
|
||||
{
|
||||
return SetAttribute(aElement, aAttribute, aValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsEditor::RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAString & aAttribute)
|
||||
const nsAString & aAttribute,
|
||||
PRBool aSuppressTransaction)
|
||||
{
|
||||
return RemoveAttribute(aElement, aAttribute);
|
||||
}
|
||||
|
|
|
@ -375,6 +375,18 @@ nsHTMLCSSUtils::IsCSSEditableProperty(nsIDOMNode * aNode,
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
if (aAttribute && (aAttribute->Equals(NS_LITERAL_STRING("valign"))) &&
|
||||
(nsIEditProperty::col == tagName
|
||||
|| nsIEditProperty::colgroup == tagName
|
||||
|| nsIEditProperty::tbody == tagName
|
||||
|| nsIEditProperty::td == tagName
|
||||
|| nsIEditProperty::th == tagName
|
||||
|| nsIEditProperty::tfoot == tagName
|
||||
|| nsIEditProperty::thead == tagName
|
||||
|| nsIEditProperty::tr == tagName)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// attributes TEXT, BACKGROUND and BGCOLOR on BODY
|
||||
if (aAttribute && (nsIEditProperty::body == tagName) &&
|
||||
(aAttribute->Equals(NS_LITERAL_STRING("text"))
|
||||
|
@ -447,12 +459,18 @@ nsHTMLCSSUtils::IsCSSEditableProperty(nsIDOMNode * aNode,
|
|||
// the lowest level above the transaction; adds the css declaration "aProperty : aValue" to
|
||||
// the inline styles carried by aElement
|
||||
nsresult
|
||||
nsHTMLCSSUtils::SetCSSProperty(nsIDOMElement *aElement, nsIAtom * aProperty, const nsAString & aValue)
|
||||
nsHTMLCSSUtils::SetCSSProperty(nsIDOMElement *aElement, nsIAtom * aProperty, const nsAString & aValue,
|
||||
PRBool aSuppressTransaction)
|
||||
{
|
||||
ChangeCSSInlineStyleTxn *txn;
|
||||
nsresult result = CreateCSSPropertyTxn(aElement, aProperty, aValue, &txn, PR_FALSE);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = mHTMLEditor->Do(txn);
|
||||
if (aSuppressTransaction) {
|
||||
result = txn->DoTransaction();
|
||||
}
|
||||
else {
|
||||
result = mHTMLEditor->Do(txn);
|
||||
}
|
||||
}
|
||||
// The transaction system (if any) has taken ownwership of txn
|
||||
NS_IF_RELEASE(txn);
|
||||
|
@ -463,12 +481,18 @@ nsHTMLCSSUtils::SetCSSProperty(nsIDOMElement *aElement, nsIAtom * aProperty, con
|
|||
// specified for the CSS property aProperty, or totally remove the declaration if this
|
||||
// property accepts only one value
|
||||
nsresult
|
||||
nsHTMLCSSUtils::RemoveCSSProperty(nsIDOMElement *aElement, nsIAtom * aProperty, const nsAString & aValue)
|
||||
nsHTMLCSSUtils::RemoveCSSProperty(nsIDOMElement *aElement, nsIAtom * aProperty, const nsAString & aValue,
|
||||
PRBool aSuppressTransaction)
|
||||
{
|
||||
ChangeCSSInlineStyleTxn *txn;
|
||||
nsresult result = CreateCSSPropertyTxn(aElement, aProperty, aValue, &txn, PR_TRUE);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = mHTMLEditor->Do(txn);
|
||||
if (aSuppressTransaction) {
|
||||
result = txn->DoTransaction();
|
||||
}
|
||||
else {
|
||||
result = mHTMLEditor->Do(txn);
|
||||
}
|
||||
}
|
||||
// The transaction system (if any) has taken ownwership of txn
|
||||
NS_IF_RELEASE(txn);
|
||||
|
@ -609,7 +633,7 @@ nsHTMLCSSUtils::RemoveCSSInlineStyle(nsIDOMNode *aNode, nsIAtom *aProperty, cons
|
|||
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(aNode);
|
||||
|
||||
// remove the property from the style attribute
|
||||
nsresult res = RemoveCSSProperty(elem, aProperty, aPropertyValue);
|
||||
nsresult res = RemoveCSSProperty(elem, aProperty, aPropertyValue, PR_FALSE);
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
if (mHTMLEditor->NodeIsType(aNode, nsIEditProperty::span)) {
|
||||
|
@ -960,7 +984,8 @@ nsHTMLCSSUtils::SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
|||
nsIAtom *aHTMLProperty,
|
||||
const nsAString *aAttribute,
|
||||
const nsAString *aValue,
|
||||
PRInt32 * aCount)
|
||||
PRInt32 * aCount,
|
||||
PRBool aSuppressTransaction)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> theElement = do_QueryInterface(aNode);
|
||||
nsresult res = NS_OK;
|
||||
|
@ -983,7 +1008,7 @@ nsHTMLCSSUtils::SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
|||
cssValueArray.StringAt(index, valueString);
|
||||
nsCOMPtr<nsIDOMElement> theElement = do_QueryInterface(aNode);
|
||||
res = SetCSSProperty(theElement, (nsIAtom *)cssPropertyArray.ElementAt(index),
|
||||
valueString);
|
||||
valueString, aSuppressTransaction);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
}
|
||||
|
@ -993,9 +1018,10 @@ nsHTMLCSSUtils::SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
|||
// Remove from aNode the CSS inline style equivalent to HTMLProperty/aAttribute/aValue for the node
|
||||
nsresult
|
||||
nsHTMLCSSUtils::RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
||||
nsIAtom *aHTMLProperty,
|
||||
const nsAString *aAttribute,
|
||||
const nsAString *aValue)
|
||||
nsIAtom *aHTMLProperty,
|
||||
const nsAString *aAttribute,
|
||||
const nsAString *aValue,
|
||||
PRBool aSuppressTransaction)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> theElement = do_QueryInterface(aNode);
|
||||
nsresult res = NS_OK;
|
||||
|
@ -1017,7 +1043,8 @@ nsHTMLCSSUtils::RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
|||
nsAutoString valueString;
|
||||
cssValueArray.StringAt(index, valueString);
|
||||
nsCOMPtr<nsIDOMElement> theElement = do_QueryInterface(aNode);
|
||||
res = RemoveCSSProperty(theElement, (nsIAtom *)cssPropertyArray.ElementAt(index), valueString);
|
||||
res = RemoveCSSProperty(theElement, (nsIAtom *)cssPropertyArray.ElementAt(index), valueString,
|
||||
aSuppressTransaction);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,11 +117,14 @@ public:
|
|||
* @param aElement [IN] a DOM element
|
||||
* @param aProperty [IN] an atom containing the CSS property to set
|
||||
* @param aValue [IN] a string containing the value of the CSS property
|
||||
* @param aSuppressTransaction [IN] a boolean indicating, when true,
|
||||
* that no transaction should be recorded
|
||||
*/
|
||||
nsresult SetCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
|
||||
const nsAString & aValue);
|
||||
const nsAString & aValue,
|
||||
PRBool aSuppressTransaction);
|
||||
nsresult RemoveCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
|
||||
const nsAString & aPropertyValue);
|
||||
const nsAString & aPropertyValue, PRBool aSuppressTransaction);
|
||||
|
||||
/** gets the specified/computed style value of a CSS property for a given node (or its element
|
||||
* ancestor if it is not an element)
|
||||
|
@ -215,12 +218,15 @@ public:
|
|||
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
|
||||
* @param aValue [IN] the attribute value
|
||||
* @param aCount [OUT] the number of CSS properties set by the call
|
||||
* @param aSuppressTransaction [IN] a boolean indicating, when true,
|
||||
* that no transaction should be recorded
|
||||
*/
|
||||
nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
||||
nsIAtom * aHTMLProperty,
|
||||
const nsAString * aAttribute,
|
||||
const nsAString * aValue,
|
||||
PRInt32 * aCount);
|
||||
PRInt32 * aCount,
|
||||
PRBool aSuppressTransaction);
|
||||
|
||||
/** removes from the node the CSS inline styles equivalent to the HTML style
|
||||
*
|
||||
|
@ -228,11 +234,14 @@ public:
|
|||
* @param aHTMLProperty [IN] an atom containing an HTML property
|
||||
* @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
|
||||
* @param aValue [IN] the attribute value
|
||||
* @param aSuppressTransaction [IN] a boolean indicating, when true,
|
||||
* that no transaction should be recorded
|
||||
*/
|
||||
nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
||||
nsIAtom *aHTMLProperty,
|
||||
const nsAString *aAttribute,
|
||||
const nsAString *aValue);
|
||||
const nsAString *aValue,
|
||||
PRBool aSuppressTransaction);
|
||||
|
||||
/** parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char
|
||||
* we need such a parser because nsIDOMCSSStyleDeclaration::GetPropertyCSSValue() is not
|
||||
|
|
|
@ -4017,7 +4017,8 @@ nsHTMLEditRules::WillAlign(nsISelection *aSelection,
|
|||
NS_NAMED_LITERAL_STRING(attrName, "align");
|
||||
PRInt32 count;
|
||||
mHTMLEditor->mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(curNode, nsnull,
|
||||
&attrName, alignType, &count);
|
||||
&attrName, alignType,
|
||||
&count, PR_FALSE);
|
||||
curDiv = 0;
|
||||
continue;
|
||||
}
|
||||
|
@ -4127,7 +4128,7 @@ nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAString *alignTyp
|
|||
// act on this div.
|
||||
nsCOMPtr<nsIDOMElement> divElem = do_QueryInterface(firstChild);
|
||||
if (useCSS) {
|
||||
res = mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, *alignType);
|
||||
res = mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, *alignType, PR_FALSE);
|
||||
}
|
||||
else {
|
||||
res = mHTMLEditor->SetAttribute(divElem, attr, *alignType);
|
||||
|
@ -4142,7 +4143,7 @@ nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAString *alignTyp
|
|||
// set up the alignment on the div
|
||||
nsCOMPtr<nsIDOMElement> divElem = do_QueryInterface(divNode);
|
||||
if (useCSS) {
|
||||
res = mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, *alignType);
|
||||
res = mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, *alignType, PR_FALSE);
|
||||
}
|
||||
else {
|
||||
res = mHTMLEditor->SetAttribute(divElem, attr, *alignType);
|
||||
|
@ -7833,7 +7834,7 @@ nsHTMLEditRules::RemoveAlignment(nsIDOMNode * aNode, const nsAString & aAlignTyp
|
|||
{
|
||||
if (nsHTMLEditUtils::IsTable(child) || nsHTMLEditUtils::IsHR(child))
|
||||
{
|
||||
res = mHTMLEditor->SetAttributeOrEquivalent(curElem, NS_LITERAL_STRING("align"), aAlignType);
|
||||
res = mHTMLEditor->SetAttributeOrEquivalent(curElem, NS_LITERAL_STRING("align"), aAlignType, PR_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8000,7 +8001,7 @@ nsHTMLEditRules::AlignBlock(nsIDOMElement * aElement, const nsAString * aAlignTy
|
|||
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->SetAttributeOrEquivalent(aElement, attr, *aAlignType);
|
||||
res = mHTMLEditor->SetAttributeOrEquivalent(aElement, attr, *aAlignType, PR_FALSE);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
else {
|
||||
|
@ -8061,10 +8062,10 @@ nsHTMLEditRules::RelativeChangeIndentation(nsIDOMNode *aNode, PRInt8 aRelativeCh
|
|||
nsAutoString newValue;
|
||||
newValue.AppendFloat(f);
|
||||
newValue.Append(unitString);
|
||||
mHTMLEditor->mHTMLCSSUtils->SetCSSProperty(element, nsIEditProperty::cssMarginLeft, newValue);
|
||||
mHTMLEditor->mHTMLCSSUtils->SetCSSProperty(element, nsIEditProperty::cssMarginLeft, newValue, PR_FALSE);
|
||||
}
|
||||
else {
|
||||
mHTMLEditor->mHTMLCSSUtils->RemoveCSSProperty(element, nsIEditProperty::cssMarginLeft, value);
|
||||
mHTMLEditor->mHTMLCSSUtils->RemoveCSSProperty(element, nsIEditProperty::cssMarginLeft, value, PR_FALSE);
|
||||
if (nsHTMLEditUtils::IsDiv(aNode)) {
|
||||
// we deal with a DIV ; let's see if it is useless and if we can remove it
|
||||
nsCOMPtr<nsIDOMNamedNodeMap> attributeList;
|
||||
|
|
|
@ -5354,14 +5354,16 @@ nsHTMLEditor::IsEmptyNodeImpl( nsIDOMNode *aNode,
|
|||
nsresult
|
||||
nsHTMLEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAString & aAttribute,
|
||||
const nsAString & aValue)
|
||||
const nsAString & aValue,
|
||||
PRBool aSuppressTransaction)
|
||||
{
|
||||
PRBool useCSS;
|
||||
nsresult res = NS_OK;
|
||||
GetIsCSSEnabled(&useCSS);
|
||||
if (useCSS && mHTMLCSSUtils) {
|
||||
PRInt32 count;
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(aElement, nsnull, &aAttribute, &aValue, &count);
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(aElement, nsnull, &aAttribute, &aValue, &count,
|
||||
aSuppressTransaction);
|
||||
if (NS_FAILED(res)) return res;
|
||||
if (count) {
|
||||
// we found an equivalence ; let's remove the HTML attribute itself if it is set
|
||||
|
@ -5404,13 +5406,15 @@ nsHTMLEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
|||
|
||||
nsresult
|
||||
nsHTMLEditor::RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAString & aAttribute)
|
||||
const nsAString & aAttribute,
|
||||
PRBool aSuppressTransaction)
|
||||
{
|
||||
PRBool useCSS;
|
||||
nsresult res = NS_OK;
|
||||
GetIsCSSEnabled(&useCSS);
|
||||
if (useCSS && mHTMLCSSUtils) {
|
||||
res = mHTMLCSSUtils->RemoveCSSEquivalentToHTMLStyle(aElement, nsnull, &aAttribute, nsnull);
|
||||
res = mHTMLCSSUtils->RemoveCSSEquivalentToHTMLStyle(aElement, nsnull, &aAttribute, nsnull,
|
||||
aSuppressTransaction);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
|
||||
|
@ -5504,7 +5508,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
cachedBlockParent = blockParent;
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(blockParent);
|
||||
PRInt32 count;
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count);
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count, PR_FALSE);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
}
|
||||
|
@ -5513,7 +5517,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
// we have no block in the document, let's apply the background to the body
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(startNode);
|
||||
PRInt32 count;
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count);
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count, PR_FALSE);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
else if ((startNode == endNode) && (((endOffset-startOffset) == 1) || (!startOffset && !endOffset)))
|
||||
|
@ -5533,7 +5537,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
cachedBlockParent = blockParent;
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(blockParent);
|
||||
PRInt32 count;
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count);
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count, PR_FALSE);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
}
|
||||
|
@ -5601,7 +5605,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
cachedBlockParent = blockParent;
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(blockParent);
|
||||
PRInt32 count;
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count);
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count, PR_FALSE);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
}
|
||||
|
@ -5629,7 +5633,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(blockParent);
|
||||
PRInt32 count;
|
||||
// and set the property on it
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count);
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count, PR_FALSE);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
arrayOfNodes->RemoveElementAt(0);
|
||||
|
@ -5647,7 +5651,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
cachedBlockParent = blockParent;
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(blockParent);
|
||||
PRInt32 count;
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count);
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count, PR_FALSE);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -397,9 +397,11 @@ public:
|
|||
|
||||
NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAString & aAttribute,
|
||||
const nsAString & aValue);
|
||||
const nsAString & aValue,
|
||||
PRBool aSuppressTransaction);
|
||||
NS_IMETHOD RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAString & aAttribute);
|
||||
const nsAString & aAttribute,
|
||||
PRBool aSuppressTransaction);
|
||||
|
||||
/** join together any afjacent editable text nodes in the range */
|
||||
NS_IMETHOD CollapseAdjacentTextNodes(nsIDOMRange *aInRange);
|
||||
|
|
|
@ -423,7 +423,7 @@ nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
|
|||
if (NS_FAILED(res)) return res;
|
||||
PRInt32 count;
|
||||
// then we add the css styles corresponding to the HTML style request
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, aProperty, aAttribute, aValue, &count);
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, aProperty, aAttribute, aValue, &count, PR_FALSE);
|
||||
if (NS_FAILED(res)) return res;
|
||||
return res;
|
||||
}
|
||||
|
@ -693,7 +693,8 @@ nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
|
|||
mHTMLCSSUtils->RemoveCSSEquivalentToHTMLStyle(aNode,
|
||||
aProperty,
|
||||
aAttribute,
|
||||
&propertyValue);
|
||||
&propertyValue,
|
||||
PR_FALSE);
|
||||
// remove the node if it is a span, if its style attribute is empty or absent,
|
||||
// and if it does not have a class nor an id
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode);
|
||||
|
|
|
@ -2152,14 +2152,16 @@ void nsPlaintextEditor::HandleEventListenerError()
|
|||
nsresult
|
||||
nsPlaintextEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAString & aAttribute,
|
||||
const nsAString & aValue)
|
||||
const nsAString & aValue,
|
||||
PRBool aSuppressTransaction)
|
||||
{
|
||||
return nsEditor::SetAttribute(aElement, aAttribute, aValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlaintextEditor::RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAString & aAttribute)
|
||||
const nsAString & aAttribute,
|
||||
PRBool aSuppressTransaction)
|
||||
{
|
||||
return nsEditor::RemoveAttribute(aElement, aAttribute);
|
||||
}
|
||||
|
|
|
@ -109,9 +109,11 @@ public:
|
|||
NS_IMETHOD BeginComposition(nsTextEventReply* aReply);
|
||||
NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAString & aAttribute,
|
||||
const nsAString & aValue);
|
||||
const nsAString & aValue,
|
||||
PRBool aSuppressTransaction);
|
||||
NS_IMETHOD RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
const nsAString & aAttribute);
|
||||
const nsAString & aAttribute,
|
||||
PRBool aSuppressTransaction);
|
||||
|
||||
/** prepare the editor for use */
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags);
|
||||
|
|
|
@ -549,12 +549,12 @@ function EditorResetFontAndColorAttributes()
|
|||
var bodyelement = GetBodyElement();
|
||||
if (bodyelement)
|
||||
{
|
||||
bodyelement.removeAttribute("text");
|
||||
bodyelement.removeAttribute("bgcolor");
|
||||
gEditor.removeAttributeOrEquivalent(bodyelement, "text", true);
|
||||
gEditor.removeAttributeOrEquivalent(bodyelement, "bgcolor", true);
|
||||
bodyelement.removeAttribute("link");
|
||||
bodyelement.removeAttribute("alink");
|
||||
bodyelement.removeAttribute("vlink");
|
||||
bodyelement.removeAttribute("background");
|
||||
gEditor.removeAttributeOrEquivalent(bodyelement, "background", true);
|
||||
}
|
||||
gColorObj.LastTextColor = "";
|
||||
gColorObj.LastBackgroundColor = "";
|
||||
|
@ -1330,9 +1330,9 @@ function EditorSelectColor(colorType, mouseEvent)
|
|||
if (bgcolor != gColorObj.BackgroundColor)
|
||||
{
|
||||
if (gColorObj.BackgroundColor)
|
||||
gEditor.setAttributeOrEquivalent(table, "bgcolor", gColorObj.BackgroundColor);
|
||||
gEditor.setAttributeOrEquivalent(table, "bgcolor", gColorObj.BackgroundColor, false);
|
||||
else
|
||||
gEditor.removeAttributeOrEquivalent(table, "bgcolor");
|
||||
gEditor.removeAttributeOrEquivalent(table, "bgcolor", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1355,7 +1355,7 @@ function EditorSelectColor(colorType, mouseEvent)
|
|||
if (defColors)
|
||||
{
|
||||
if (!bodyelement.getAttribute("text"))
|
||||
gEditor.setAttributeOrEquivalent(bodyelement, "text", defColors.TextColor);
|
||||
gEditor.setAttributeOrEquivalent(bodyelement, "text", defColors.TextColor, false);
|
||||
|
||||
// The following attributes have no individual CSS declaration counterparts
|
||||
// Getting rid of them in favor of CSS implies CSS rules management
|
||||
|
@ -2382,12 +2382,12 @@ function EditorSetDefaultPrefsAndDoctype()
|
|||
// and use them for the default text and background colors if not empty
|
||||
if (text_color)
|
||||
{
|
||||
bodyelement.setAttribute("text", text_color);
|
||||
gEditor.setAttributeOrEquivalent(bodyelement, "text", text_color, true);
|
||||
gDefaultTextColor = text_color;
|
||||
}
|
||||
if (background_color)
|
||||
{
|
||||
bodyelement.setAttribute("bgcolor", background_color);
|
||||
gEditor.setAttributeOrEquivalent(bodyelement, "bgcolor", background_color, true);
|
||||
gDefaultBackgroundColor = background_color
|
||||
}
|
||||
|
||||
|
@ -2403,7 +2403,7 @@ function EditorSetDefaultPrefsAndDoctype()
|
|||
try { background_image = gPrefs.getCharPref("editor.default_background_image"); } catch(e) {}
|
||||
|
||||
if (background_image)
|
||||
bodyelement.setAttribute("background", background_image);
|
||||
gEditor.setAttributeOrEquivalent(bodyelement, "background", background_image, true);
|
||||
}
|
||||
// auto-save???
|
||||
}
|
||||
|
|
|
@ -368,11 +368,11 @@ function ValidateData()
|
|||
// Colors values are updated as they are picked, no validation necessary
|
||||
if (gDialog.DefaultColorsRadio.selected)
|
||||
{
|
||||
globalElement.removeAttribute(textStr);
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, textStr, true);
|
||||
globalElement.removeAttribute(linkStr);
|
||||
globalElement.removeAttribute(vlinkStr);
|
||||
globalElement.removeAttribute(alinkStr);
|
||||
globalElement.removeAttribute(bgcolorStr);
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, bgcolorStr, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -383,13 +383,13 @@ function ValidateData()
|
|||
if (tmpColor != "windowtext")
|
||||
globalElement.setAttribute(textStr, customTextColor);
|
||||
else
|
||||
globalElement.removeAttribute(textStr);
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, textStr, true);
|
||||
|
||||
tmpColor = customBackgroundColor.toLowerCase();
|
||||
if (tmpColor != "window")
|
||||
globalElement.setAttribute(bgcolorStr, customBackgroundColor);
|
||||
else
|
||||
globalElement.removeAttribute(bgcolorStr);
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, bgcolorStr, true);
|
||||
|
||||
globalElement.setAttribute(linkStr, customLinkColor);
|
||||
globalElement.setAttribute(vlinkStr, customVisitedColor);
|
||||
|
@ -402,7 +402,7 @@ function ValidateData()
|
|||
if (gBackgroundImage)
|
||||
globalElement.setAttribute(backgroundStr, gBackgroundImage);
|
||||
else
|
||||
globalElement.removeAttribute(backgroundStr);
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, backgroundStr, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
// Each editor window must include this file
|
||||
// Variables shared by all dialogs:
|
||||
var editorShell;
|
||||
var gEditor;
|
||||
|
||||
// Object to attach commonly-used widgets (all dialogs should use this)
|
||||
var gDialog = {};
|
||||
|
@ -69,7 +70,7 @@ function InitEditorShell()
|
|||
// Save as a property of the window so it can be used by child dialogs
|
||||
|
||||
window.editorShell = editorShell;
|
||||
|
||||
gEditor = editorShell.editor.QueryInterface(Components.interfaces.nsIHTMLEditor);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ function ValidateData()
|
|||
if (align)
|
||||
globalElement.setAttribute("align", align);
|
||||
else
|
||||
globalElement.removeAttribute("align");
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, "align", true);
|
||||
|
||||
if (gDialog.shading.checked) {
|
||||
shading = true;
|
||||
|
|
|
@ -560,12 +560,12 @@ function ValidateImage()
|
|||
if (width)
|
||||
globalElement.setAttribute("width", width);
|
||||
else if (srcChanged)
|
||||
globalElement.removeAttribute("width");
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, "width", true);
|
||||
|
||||
if (height)
|
||||
globalElement.setAttribute("height", height);
|
||||
else if (srcChanged)
|
||||
globalElement.removeAttribute("height");
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, "height", true);
|
||||
|
||||
// spacing attributes
|
||||
gValidateTab = gDialog.tabBorder;
|
||||
|
@ -598,7 +598,7 @@ function ValidateImage()
|
|||
globalElement.setAttribute( "align", gDialog.alignTypeSelect.value );
|
||||
break;
|
||||
default:
|
||||
globalElement.removeAttribute( "align" );
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, "align", true);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -292,7 +292,7 @@ function ValidateData()
|
|||
if (gBulletStyleType && gDialog.ChangeAllRadio.selected)
|
||||
globalElement.setAttribute("type", gBulletStyleType);
|
||||
else
|
||||
globalElement.removeAttribute("type");
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, "type", true);
|
||||
|
||||
}
|
||||
else if (gListType == "ol")
|
||||
|
@ -300,7 +300,7 @@ function ValidateData()
|
|||
if (gBulletStyleType)
|
||||
globalElement.setAttribute("type", gBulletStyleType);
|
||||
else
|
||||
globalElement.removeAttribute("type");
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, "type", true);
|
||||
|
||||
var startingNumber = ConvertUserStringToStartAttr(gBulletStyleType);
|
||||
if (startingNumber)
|
||||
|
|
|
@ -316,7 +316,7 @@ function InitCellPanel()
|
|||
gDialog.CellWidthCheckbox.checked = AdvancedEditUsed && previousValue != gDialog.CellWidthInput.value;
|
||||
|
||||
var previousIndex = gDialog.CellVAlignList.selectedIndex;
|
||||
var valign = globalCellElement.vAlign.toLowerCase();
|
||||
var valign = GetHTMLOrCSSStyleValue(globalCellElement, "valign", "vertical-align").toLowerCase();
|
||||
if (valign == topStr)
|
||||
gDialog.CellVAlignList.selectedIndex = 0;
|
||||
else if (valign == bottomStr)
|
||||
|
@ -476,7 +476,7 @@ function SetColor(ColorWellID, color)
|
|||
}
|
||||
else
|
||||
{
|
||||
globalCellElement.removeAttribute(bgcolor);
|
||||
gEditor.removeAttributeOrEquivalent(globalCellElement, bgcolor, true);
|
||||
// Reveal addition message explaining "default" color
|
||||
gDialog.CellInheritColor.removeAttribute("collapsed");
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ function SetColor(ColorWellID, color)
|
|||
}
|
||||
else
|
||||
{
|
||||
globalTableElement.removeAttribute(bgcolor);
|
||||
gEditor.removeAttributeOrEquivalent(globalTableElement, bgcolor, true);
|
||||
gDialog.TableInheritColor.removeAttribute("collapsed");
|
||||
}
|
||||
SetCheckbox('CellColorCheckbox');
|
||||
|
@ -758,8 +758,9 @@ function SwitchToValidatePanel()
|
|||
function SetAlign(listID, defaultValue, element, attName)
|
||||
{
|
||||
var value = document.getElementById(listID).selectedItem.value;
|
||||
if (value == defaultValue)
|
||||
element.removeAttribute(attName);
|
||||
if (value == defaultValue) {
|
||||
gEditor.removeAttributeOrEquivalent(element, attName, true);
|
||||
}
|
||||
else
|
||||
element.setAttribute(attName, value);
|
||||
}
|
||||
|
@ -867,7 +868,7 @@ function ValidateCellData()
|
|||
if (gDialog.TextWrapList.selectedIndex == 1)
|
||||
globalCellElement.setAttribute("nowrap","nowrap");
|
||||
else
|
||||
globalCellElement.removeAttribute("nowrap");
|
||||
gEditor.removeAttributeOrEquivalent(globalCellElement, "nowrap", true);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -949,7 +950,7 @@ function ApplyTableAttributes()
|
|||
if (TableCaptionElement)
|
||||
{
|
||||
// Get current alignment
|
||||
var align = TableCaptionElement.align.toLowerCase();
|
||||
var align = GetHTMLOrCSSStyleValue(TableCaptionElement, "align", "caption-side").toLowerCase();
|
||||
// This is the default
|
||||
if (!align) align = "top";
|
||||
|
||||
|
@ -959,12 +960,12 @@ function ApplyTableAttributes()
|
|||
editorShell.DeleteElement(TableCaptionElement);
|
||||
TableCaptionElement = null;
|
||||
}
|
||||
else if( align != newAlign)
|
||||
else if(newAlign != align)
|
||||
{
|
||||
if (align == "top") // This is default, so don't explicitly set it
|
||||
editorShell.RemoveAttribute(TableCaptionElement, "align");
|
||||
if (newAlign == "top") // This is default, so don't explicitly set it
|
||||
gEditor.removeAttributeOrEquivalent(TableCaptionElement, "align", false);
|
||||
else
|
||||
editorShell.SetAttribute(TableCaptionElement, "align", newAlign);
|
||||
gEditor.setAttributeOrEquivalent(TableCaptionElement, "align", newAlign, false);
|
||||
}
|
||||
}
|
||||
else if (newAlign != "")
|
||||
|
|
Загрузка…
Ссылка в новой задаче