Bug 1134280 - Get rid of Tag() - patch 2.13 - Fix all the occurrences, m=smaug, r=surkov

This commit is contained in:
Andrea Marchesini 2015-03-03 11:09:00 +00:00
parent a46c9e1edf
commit 7cb290cd8b
7 changed files with 31 additions and 45 deletions

View File

@ -1051,10 +1051,9 @@ DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, char16_t **aText,
if (currElement) {
nsCOMPtr<nsIContent> content(do_QueryInterface(currElement));
if (content) {
nsIAtom *tagAtom = content->Tag();
if (tagAtom != mTag_dialog &&
tagAtom != mTag_dialogheader &&
tagAtom != mTag_window) {
if (!content->IsAnyOfXULElements(mTag_dialog,
mTag_dialogheader,
mTag_window)) {
// first try the normal title attribute...
currElement->GetAttribute(NS_LITERAL_STRING("title"), outText);
if (outText.Length()) {

View File

@ -737,19 +737,15 @@ nsFind::NextNode(nsIDOMRange* aSearchRange,
bool nsFind::IsBlockNode(nsIContent* aContent)
{
if (!aContent->IsHTMLElement()) {
return false;
if (aContent->IsAnyOfHTMLElements(nsGkAtoms::img,
nsGkAtoms::hr,
nsGkAtoms::th,
nsGkAtoms::td)) {
return true;
}
nsIAtom *atom = aContent->Tag();
if (atom == nsGkAtoms::img ||
atom == nsGkAtoms::hr ||
atom == nsGkAtoms::th ||
atom == nsGkAtoms::td)
return true;
return nsContentUtils::IsHTMLBlock(atom);
return aContent->IsHTMLElement() &&
nsContentUtils::IsHTMLBlock(aContent->NodeInfo()->NameAtom());
}
bool nsFind::IsTextNode(nsIDOMNode* aNode)
@ -778,18 +774,13 @@ bool nsFind::IsVisibleNode(nsIDOMNode *aDOMNode)
bool nsFind::SkipNode(nsIContent* aContent)
{
nsIAtom *atom;
#ifdef HAVE_BIDI_ITERATOR
atom = aContent->Tag();
// We may not need to skip comment nodes,
// now that IsTextNode distinguishes them from real text nodes.
return (aContent->IsNodeOfType(nsINode::eCOMMENT) ||
(aContent->IsHTMLElement() &&
(atom == sScriptAtom ||
atom == sNoframesAtom ||
atom == sSelectAtom)));
aContent->IsAnyOfHTMLElements(sScriptAtom,
sNoframesAtom,
sSelectAtom));
#else /* HAVE_BIDI_ITERATOR */
// Temporary: eventually we will have an iterator to do this,
@ -800,13 +791,10 @@ bool nsFind::SkipNode(nsIContent* aContent)
nsIContent *content = aContent;
while (content)
{
atom = content->Tag();
if (aContent->IsNodeOfType(nsINode::eCOMMENT) ||
(content->IsHTMLElement() &&
(atom == nsGkAtoms::script ||
atom == nsGkAtoms::noframes ||
atom == nsGkAtoms::select)))
content->IsAnyOfHTMLElements(nsGkAtoms::script,
nsGkAtoms::noframes,
nsGkAtoms::select))
{
#ifdef DEBUG_FIND
printf("Skipping node: ");

View File

@ -132,8 +132,7 @@ void nsMenuBarX::ConstructNativeMenus()
for (uint32_t i = 0; i < count; i++) {
nsIContent *menuContent = mContent->GetChildAt(i);
if (menuContent &&
menuContent->Tag() == nsGkAtoms::menu &&
menuContent->IsXULElement()) {
menuContent->IsXULElement(nsGkAtoms::menu)) {
nsMenuX* newMenu = new nsMenuX();
if (newMenu) {
nsresult rv = newMenu->Create(this, this, menuContent);

View File

@ -432,11 +432,12 @@ void nsMenuX::MenuConstruct()
nsIContent *child = menuPopup->GetChildAt(i);
if (child) {
// depending on the type, create a menu item, separator, or submenu
nsIAtom *tag = child->Tag();
if (tag == nsGkAtoms::menuitem || tag == nsGkAtoms::menuseparator)
if (child->IsAnyOfXULElements(nsGkAtoms::menuitem,
nsGkAtoms::menuseparator)) {
LoadMenuItem(child);
else if (tag == nsGkAtoms::menu)
} else if (child->IsXULElement(nsGkAtoms::menu)) {
LoadSubMenu(child);
}
}
} // for each menu item
@ -501,7 +502,7 @@ void nsMenuX::LoadMenuItem(nsIContent* inMenuItemContent)
// printf("menuitem %s \n", NS_LossyConvertUTF16toASCII(menuitemName).get());
EMenuItemType itemType = eRegularMenuItemType;
if (inMenuItemContent->Tag() == nsGkAtoms::menuseparator) {
if (inMenuItemContent->IsXULElement(nsGkAtoms::menuseparator)) {
itemType = eSeparatorMenuItemType;
}
else {

View File

@ -280,9 +280,9 @@ static BOOL IsToolbarStyleContainer(nsIFrame* aFrame)
if (!content)
return NO;
if (content->Tag() == nsGkAtoms::toolbar ||
content->Tag() == nsGkAtoms::toolbox ||
content->Tag() == nsGkAtoms::statusbar)
if (content->IsAnyOfXULElements(nsGkAtoms::toolbar,
nsGkAtoms::toolbox,
nsGkAtoms::statusbar))
return YES;
switch (aFrame->StyleDisplay()->mAppearance) {

View File

@ -37,9 +37,7 @@ nsStandaloneNativeMenu::Init(nsIDOMElement * aDOMElement)
nsCOMPtr<nsIContent> content = do_QueryInterface(aDOMElement, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsIAtom * tag = content->Tag();
if (!content->IsXULElement() ||
(tag != nsGkAtoms::menu && tag != nsGkAtoms::menupopup))
if (!content->IsAnyOfXULElements(nsGkAtoms::menu, nsGkAtoms::menupopup))
return NS_ERROR_FAILURE;
rv = nsMenuGroupOwnerX::Create(content);

View File

@ -449,12 +449,12 @@ nsNativeTheme::IsLastTreeHeaderCell(nsIFrame* aFrame)
return false;
// A tree column picker is always the last header cell.
if (aFrame->GetContent()->Tag() == nsGkAtoms::treecolpicker)
if (aFrame->GetContent()->IsXULElement(nsGkAtoms::treecolpicker))
return true;
// Find the parent tree.
nsIContent* parent = aFrame->GetContent()->GetParent();
while (parent && parent->Tag() != nsGkAtoms::tree) {
while (parent && !parent->IsXULElement(nsGkAtoms::tree)) {
parent = parent->GetParent();
}
@ -490,7 +490,8 @@ nsNativeTheme::IsFirstTab(nsIFrame* aFrame)
nsIFrame* first = aFrame->GetParent()->GetFirstPrincipalChild();
while (first) {
if (first->GetRect().width > 0 && first->GetContent()->Tag() == nsGkAtoms::tab)
if (first->GetRect().width > 0 &&
first->GetContent()->IsXULElement(nsGkAtoms::tab))
return (first == aFrame);
first = first->GetNextSibling();
}
@ -575,7 +576,7 @@ nsNativeTheme::IsSubmenu(nsIFrame* aFrame, bool* aLeftOfParent)
return false;
nsIContent* parentContent = aFrame->GetContent()->GetParent();
if (!parentContent || parentContent->Tag() != nsGkAtoms::menu)
if (!parentContent || !parentContent->IsXULElement(nsGkAtoms::menu))
return false;
nsIFrame* parent = aFrame;