зеркало из https://github.com/mozilla/gecko-dev.git
Bug 750079 - Part a: Add IsOnlyAttribute(nsIContent*, const nsAString&); r=ehsan
This commit is contained in:
Родитель
92da02c717
Коммит
dab46f6ad2
|
@ -716,6 +716,7 @@ protected:
|
|||
bool IsAtFrontOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
|
||||
bool IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
|
||||
bool IsOnlyAttribute(nsIDOMNode *aElement, const nsAString *aAttribute);
|
||||
bool IsOnlyAttribute(const nsIContent* aElement, const nsAString& aAttribute);
|
||||
|
||||
nsresult RemoveBlockContainer(nsIDOMNode *inNode);
|
||||
nsINode* GetPriorHTMLSibling(nsINode* aNode);
|
||||
|
|
|
@ -762,20 +762,31 @@ bool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
|
|||
const nsAString *aAttribute)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode && aAttribute, false); // ooops
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(content, false); // ooops
|
||||
|
||||
PRUint32 i, attrCount = content->GetAttrCount();
|
||||
for (i = 0; i < attrCount; ++i) {
|
||||
nsAutoString attrString;
|
||||
const nsAttrName* name = content->GetAttrNameAt(i);
|
||||
|
||||
return IsOnlyAttribute(content, *aAttribute);
|
||||
}
|
||||
|
||||
bool
|
||||
nsHTMLEditor::IsOnlyAttribute(const nsIContent* aContent,
|
||||
const nsAString& aAttribute)
|
||||
{
|
||||
MOZ_ASSERT(aContent);
|
||||
|
||||
PRUint32 attrCount = aContent->GetAttrCount();
|
||||
for (PRUint32 i = 0; i < attrCount; ++i) {
|
||||
const nsAttrName* name = aContent->GetAttrNameAt(i);
|
||||
if (!name->NamespaceEquals(kNameSpaceID_None)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoString attrString;
|
||||
name->LocalName()->ToString(attrString);
|
||||
// if it's the attribute we know about, or a special _moz attribute,
|
||||
// keep looking
|
||||
if (!attrString.Equals(*aAttribute, nsCaseInsensitiveStringComparator()) &&
|
||||
if (!attrString.Equals(aAttribute, nsCaseInsensitiveStringComparator()) &&
|
||||
!StringBeginsWith(attrString, NS_LITERAL_STRING("_moz"))) {
|
||||
return false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче