Bug 214025 [@ nsHTMLCSSUtils::IsCSSEditableProperty]

r=glazou sr=bz
This commit is contained in:
timeless%mozdev.org 2003-07-29 14:48:44 +00:00
Родитель 1dfc704125
Коммит 5ecd2e0bb8
2 изменённых файлов: 33 добавлений и 26 удалений

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

@ -336,12 +336,16 @@ nsHTMLCSSUtils::IsCSSEditableProperty(nsIDOMNode * aNode,
nsIAtom * aProperty, nsIAtom * aProperty,
const nsAString * aAttribute) const nsAString * aAttribute)
{ {
NS_ASSERTION(aNode, "Shouldn't you pass aNode? - Bug 214025");
nsCOMPtr<nsIDOMNode> node = aNode; nsCOMPtr<nsIDOMNode> node = aNode;
// we need an element node here // we need an element node here
if (mHTMLEditor->IsTextNode(aNode)) { if (mHTMLEditor->IsTextNode(aNode)) {
aNode->GetParentNode(getter_AddRefs(node)); aNode->GetParentNode(getter_AddRefs(node));
} }
nsCOMPtr<nsIContent> content = do_QueryInterface(node); nsCOMPtr<nsIContent> content = do_QueryInterface(node);
if (!content) return PR_FALSE;
nsCOMPtr<nsIAtom> tagName; nsCOMPtr<nsIAtom> tagName;
content->GetTag(getter_AddRefs(tagName)); content->GetTag(getter_AddRefs(tagName));

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK ***** /* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
* *
@ -838,36 +838,39 @@ nsHTMLEditRules::GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
if (!blockParent) return NS_ERROR_FAILURE; if (!blockParent) return NS_ERROR_FAILURE;
if (useCSS && mHTMLEditor->mHTMLCSSUtils->IsCSSEditableProperty(blockParent, dummyProperty, &typeAttrName)) if (useCSS)
{ {
// we are in CSS mode and we know how to align this element with CSS nsCOMPtr<nsIContent> blockParentContent = do_QueryInterface(blockParent);
nsAutoString value; if (blockParentContent &&
// let's get the value(s) of text-align or margin-left/margin-right mHTMLEditor->mHTMLCSSUtils->IsCSSEditableProperty(blockParent, dummyProperty, &typeAttrName))
mHTMLEditor->mHTMLCSSUtils->GetCSSEquivalentToHTMLInlineStyleSet(blockParent, {
// we are in CSS mode and we know how to align this element with CSS
nsAutoString value;
// let's get the value(s) of text-align or margin-left/margin-right
mHTMLEditor->mHTMLCSSUtils->GetCSSEquivalentToHTMLInlineStyleSet(blockParent,
dummyProperty, dummyProperty,
&typeAttrName, &typeAttrName,
value, value,
COMPUTED_STYLE_TYPE); COMPUTED_STYLE_TYPE);
if (value.Equals(NS_LITERAL_STRING("center")) || if (value.Equals(NS_LITERAL_STRING("center")) ||
value.Equals(NS_LITERAL_STRING("-moz-center")) || value.Equals(NS_LITERAL_STRING("-moz-center")) ||
value.Equals(NS_LITERAL_STRING("auto auto"))) value.Equals(NS_LITERAL_STRING("auto auto")))
{ {
*aAlign = nsIHTMLEditor::eCenter; *aAlign = nsIHTMLEditor::eCenter;
return NS_OK; return NS_OK;
} }
else if (value.Equals(NS_LITERAL_STRING("right")) || if (value.Equals(NS_LITERAL_STRING("right")) ||
value.Equals(NS_LITERAL_STRING("-moz-right")) || value.Equals(NS_LITERAL_STRING("-moz-right")) ||
value.Equals(NS_LITERAL_STRING("auto 0px"))) value.Equals(NS_LITERAL_STRING("auto 0px")))
{ {
*aAlign = nsIHTMLEditor::eRight; *aAlign = nsIHTMLEditor::eRight;
return NS_OK; return NS_OK;
} }
else if (value.Equals(NS_LITERAL_STRING("justify"))) if (value.Equals(NS_LITERAL_STRING("justify")))
{ {
*aAlign = nsIHTMLEditor::eJustify; *aAlign = nsIHTMLEditor::eJustify;
return NS_OK; return NS_OK;
} }
else {
*aAlign = nsIHTMLEditor::eLeft; *aAlign = nsIHTMLEditor::eLeft;
return NS_OK; return NS_OK;
} }