зеркало из https://github.com/mozilla/pjs.git
backing out my fix for bug 119447 due to major side effect described in bug 120377; a=asa
This commit is contained in:
Родитель
1a1db3e353
Коммит
d751514687
|
@ -74,24 +74,6 @@ void ProcessBValue(nsAReadableString * aInputString, nsAWritableString & aOutput
|
|||
}
|
||||
}
|
||||
|
||||
static
|
||||
void ProcessIValue(nsAReadableString * aInputString, nsAWritableString & aOutputString,
|
||||
const char * aDefaultValueString,
|
||||
const char * aPrependString, const char* aAppendString)
|
||||
{
|
||||
if (aInputString) {
|
||||
if (aInputString->Equals(NS_LITERAL_STRING("-moz-editor-invert-value"))) {
|
||||
aOutputString.Assign(NS_LITERAL_STRING("normal"));
|
||||
}
|
||||
else {
|
||||
aOutputString.Assign(NS_LITERAL_STRING("italic"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
aOutputString.Assign(NS_LITERAL_STRING("italic"));
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void ProcessDefaultValue(nsAReadableString * aInputString, nsAWritableString & aOutputString,
|
||||
const char * aDefaultValueString,
|
||||
|
@ -223,7 +205,7 @@ const nsHTMLCSSUtils::CSSEquivTable boldEquivTable[] = {
|
|||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable italicEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_font_style, ProcessIValue, nsnull, nsnull, nsnull, PR_TRUE },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_font_style, ProcessDefaultValue, "italic", nsnull, nsnull, PR_TRUE },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
|
@ -661,8 +643,7 @@ nsHTMLCSSUtils::RemoveCSSInlineStyle(nsIDOMNode *aNode, nsIAtom *aProperty, nsAR
|
|||
PRBool
|
||||
nsHTMLCSSUtils::IsCSSInvertable(nsIAtom *aProperty, const nsAReadableString *aAttribute)
|
||||
{
|
||||
return PRBool(nsIEditProperty::b == aProperty
|
||||
|| nsIEditProperty::i == aProperty);
|
||||
return PRBool(nsIEditProperty::b == aProperty);
|
||||
}
|
||||
|
||||
// Get the default browser background color if we need it for GetCSSBackgroundColorState
|
||||
|
|
|
@ -719,8 +719,6 @@ protected:
|
|||
PRBool *aAll,
|
||||
nsAWritableString *outValue);
|
||||
|
||||
nsresult RemoveElementIfUselessSpan(nsIDOMElement * aElement);
|
||||
|
||||
// Data members
|
||||
protected:
|
||||
|
||||
|
|
|
@ -334,11 +334,7 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
|
|||
PRBool bHasProp;
|
||||
nsCOMPtr<nsIDOMNode> styleNode;
|
||||
IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, bHasProp, getter_AddRefs(styleNode));
|
||||
if (bHasProp &&
|
||||
!(aValue && aValue->Equals(NS_LITERAL_STRING("-moz-editor-invert-value"))))
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
if (bHasProp) return NS_OK;
|
||||
|
||||
// do we need to split the text node?
|
||||
PRUint32 textLen;
|
||||
|
@ -424,32 +420,10 @@ nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
|
|||
// children of the aNode
|
||||
res = RemoveStyleInside(tmp, aProperty, aAttribute, PR_TRUE);
|
||||
if (NS_FAILED(res)) return res;
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
res = tmp->GetParentNode(getter_AddRefs(parentNode));
|
||||
PRInt32 count;
|
||||
// then we add the css styles corresponding to the HTML style request
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, aProperty, aAttribute, aValue, &count);
|
||||
if (NS_FAILED(res)) return res;
|
||||
PRBool isSet = PR_FALSE;
|
||||
if (parentNode) {
|
||||
// let's check if the parent element already has the style we want
|
||||
nsAutoString parentValue;
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(parentNode, aProperty, aAttribute,
|
||||
isSet, parentValue,
|
||||
COMPUTED_STYLE_TYPE);
|
||||
}
|
||||
if (isSet && !(aValue && aValue->Equals(NS_LITERAL_STRING("-moz-editor-invert-value")))) {
|
||||
// the parent has the style we want to apply and we are not trying to remove this style
|
||||
// from the selection
|
||||
res = mHTMLCSSUtils->RemoveCSSEquivalentToHTMLStyle(element,
|
||||
aProperty,
|
||||
aAttribute,
|
||||
aValue);
|
||||
if (NS_FAILED(res)) return res;
|
||||
res = RemoveElementIfUselessSpan(element);
|
||||
}
|
||||
else {
|
||||
PRInt32 count;
|
||||
// add the css styles corresponding to the HTML style request
|
||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, aProperty, aAttribute, aValue, &count);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -721,9 +695,21 @@ nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
|
|||
aProperty,
|
||||
aAttribute,
|
||||
&propertyValue);
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode);
|
||||
res = RemoveElementIfUselessSpan(element);
|
||||
// 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> elem = do_QueryInterface(aNode);
|
||||
nsAutoString styleVal;
|
||||
PRBool isStyleSet;
|
||||
res = GetAttributeValue(elem, NS_LITERAL_STRING("style"), styleVal, &isStyleSet);
|
||||
if (NS_FAILED(res)) return res;
|
||||
if (NodeIsType(aNode, nsIEditProperty::span) && (!isStyleSet || (0 == styleVal.Length()))) {
|
||||
PRBool hasClassOrId ;
|
||||
res = mHTMLCSSUtils->HasClassOrID(elem, hasClassOrId);
|
||||
if (!hasClassOrId) {
|
||||
res = RemoveContainer(aNode);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1836,30 +1822,3 @@ nsHTMLEditor::IsCSSEnabled(PRBool *aIsSet)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLEditor::RemoveElementIfUselessSpan(nsIDOMElement * aElement)
|
||||
{
|
||||
NS_ENSURE_TRUE(aElement, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aElement);
|
||||
|
||||
// early way out if node is not a span element
|
||||
if (!NodeIsType(node, nsIEditProperty::span)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// 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
|
||||
nsAutoString styleVal;
|
||||
PRBool isStyleSet;
|
||||
nsresult res = GetAttributeValue(aElement, NS_LITERAL_STRING("style"), styleVal, &isStyleSet);
|
||||
if (NS_FAILED(res)) return res;
|
||||
if (!isStyleSet || (0 == styleVal.Length())) {
|
||||
PRBool hasClassOrId ;
|
||||
res = mHTMLCSSUtils->HasClassOrID(aElement, hasClassOrId);
|
||||
if (NS_FAILED(res)) return res;
|
||||
if (!hasClassOrId) {
|
||||
res = RemoveContainer(node);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче