Bug 1134280 - Get rid of Tag() - patch 2.6 - layout/base and layout/form - Fix all the occurrences, m=smaug, r=surkov

This commit is contained in:
Andrea Marchesini 2015-03-03 11:09:00 +00:00
parent e0dd470b18
commit 491e547893
9 changed files with 74 additions and 76 deletions

View File

@ -179,48 +179,46 @@ IsElementClickable(nsIFrame* aFrame, nsIAtom* stopAt = nullptr)
// ancestors to look for elements accepting the click.
for (nsIContent* content = aFrame->GetContent(); content;
content = content->GetFlattenedTreeParent()) {
nsIAtom* tag = content->Tag();
if (content->IsHTMLElement() && stopAt && tag == stopAt) {
if (stopAt && content->IsHTMLElement(stopAt)) {
break;
}
if (HasTouchListener(content) || HasMouseListener(content)) {
return true;
}
if (content->IsHTMLElement()) {
if (tag == nsGkAtoms::button ||
tag == nsGkAtoms::input ||
tag == nsGkAtoms::select ||
tag == nsGkAtoms::textarea ||
tag == nsGkAtoms::label) {
return true;
}
// Bug 921928: we don't have access to the content of remote iframe.
// So fluffing won't go there. We do an optimistic assumption here:
// that the content of the remote iframe needs to be a target.
if (tag == nsGkAtoms::iframe &&
content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozbrowser,
nsGkAtoms::_true, eIgnoreCase) &&
content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::Remote,
nsGkAtoms::_true, eIgnoreCase)) {
return true;
}
} else if (content->IsXULElement()) {
nsIAtom* tag = content->Tag();
// See nsCSSFrameConstructor::FindXULTagData. This code is not
// really intended to be used with XUL, though.
if (tag == nsGkAtoms::button ||
tag == nsGkAtoms::checkbox ||
tag == nsGkAtoms::radio ||
tag == nsGkAtoms::autorepeatbutton ||
tag == nsGkAtoms::menu ||
tag == nsGkAtoms::menubutton ||
tag == nsGkAtoms::menuitem ||
tag == nsGkAtoms::menulist ||
tag == nsGkAtoms::scrollbarbutton ||
tag == nsGkAtoms::resizer) {
return true;
}
if (content->IsAnyOfHTMLElements(nsGkAtoms::button,
nsGkAtoms::input,
nsGkAtoms::select,
nsGkAtoms::textarea,
nsGkAtoms::label)) {
return true;
}
// Bug 921928: we don't have access to the content of remote iframe.
// So fluffing won't go there. We do an optimistic assumption here:
// that the content of the remote iframe needs to be a target.
if (content->IsHTMLElement(nsGkAtoms::iframe) &&
content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozbrowser,
nsGkAtoms::_true, eIgnoreCase) &&
content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::Remote,
nsGkAtoms::_true, eIgnoreCase)) {
return true;
}
// See nsCSSFrameConstructor::FindXULTagData. This code is not
// really intended to be used with XUL, though.
if (content->IsAnyOfXULElements(nsGkAtoms::button,
nsGkAtoms::checkbox,
nsGkAtoms::radio,
nsGkAtoms::autorepeatbutton,
nsGkAtoms::menu,
nsGkAtoms::menubutton,
nsGkAtoms::menuitem,
nsGkAtoms::menulist,
nsGkAtoms::scrollbarbutton,
nsGkAtoms::resizer)) {
return true;
}
static nsIContent::AttrValuesArray clickableRoles[] =
{ &nsGkAtoms::button, &nsGkAtoms::key, nullptr };
if (content->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::role,

View File

@ -184,10 +184,10 @@ public:
if (pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
mElementContexts.Put(aContent, aStyleContext);
} else if (pseudoType == nsCSSPseudoElements::ePseudo_before) {
MOZ_ASSERT(aContent->Tag() == nsGkAtoms::mozgeneratedcontentbefore);
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore);
mBeforePseudoContexts.Put(aContent->GetParent(), aStyleContext);
} else if (pseudoType == nsCSSPseudoElements::ePseudo_after) {
MOZ_ASSERT(aContent->Tag() == nsGkAtoms::mozgeneratedcontentafter);
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter);
mAfterPseudoContexts.Put(aContent->GetParent(), aStyleContext);
}
}
@ -199,11 +199,11 @@ public:
return mElementContexts.GetWeak(aContent);
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_before) {
MOZ_ASSERT(aContent->Tag() == nsGkAtoms::mozgeneratedcontentbefore);
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore);
return mBeforePseudoContexts.GetWeak(aContent->GetParent());
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_after) {
MOZ_ASSERT(aContent->Tag() == nsGkAtoms::mozgeneratedcontentafter);
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter);
return mAfterPseudoContexts.GetWeak(aContent->GetParent());
}
MOZ_ASSERT(false, "unexpected aPseudoType");

View File

@ -40,7 +40,7 @@ FrameTagToString(dom::Element* aElement)
nsFrame::ListTag(result, frame);
} else {
nsAutoString buf;
aElement->Tag()->ToString(buf);
aElement->NodeInfo()->NameAtom()->ToString(buf);
result.AppendPrintf("(%s@%p)", NS_ConvertUTF16toUTF8(buf).get(), aElement);
}
return result;

View File

@ -2529,7 +2529,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle
else
#endif
if (aDocElement->IsSVGElement()) {
if (aDocElement->Tag() != nsGkAtoms::svg) {
if (!aDocElement->IsSVGElement(nsGkAtoms::svg)) {
return nullptr;
}
// We're going to call the right function ourselves, so no need to give a
@ -2544,8 +2544,9 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle
already_AddRefed<nsStyleContext> extraRef =
nsRefPtr<nsStyleContext>(styleContext).forget();
FrameConstructionItem item(&rootSVGData, aDocElement,
aDocElement->Tag(), kNameSpaceID_SVG,
nullptr, extraRef, true, nullptr);
aDocElement->NodeInfo()->NameAtom(),
kNameSpaceID_SVG, nullptr, extraRef, true,
nullptr);
nsFrameItems frameItems;
contentFrame = static_cast<nsContainerFrame*>(
@ -2579,8 +2580,9 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle
already_AddRefed<nsStyleContext> extraRef =
nsRefPtr<nsStyleContext>(styleContext).forget();
FrameConstructionItem item(&rootTableData, aDocElement,
aDocElement->Tag(), kNameSpaceID_None,
nullptr, extraRef, true, nullptr);
aDocElement->NodeInfo()->NameAtom(),
kNameSpaceID_None, nullptr, extraRef, true,
nullptr);
nsFrameItems frameItems;
// if the document is a table then just populate it.
@ -3689,8 +3691,8 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
"Unexpected FCDATA_FORCED_NON_SCROLLABLE_BLOCK flag");
// Don't create a subdocument frame for iframes if we're creating extra frames
if (aState.mCreatingExtraFrames && aItem.mContent->IsHTMLElement() &&
aItem.mContent->Tag() == nsGkAtoms::iframe)
if (aState.mCreatingExtraFrames &&
aItem.mContent->IsHTMLElement(nsGkAtoms::iframe))
{
return;
}
@ -5392,7 +5394,8 @@ nsCSSFrameConstructor::DoAddFrameConstructionItems(nsFrameConstructorState& aSta
}
}
AddFrameConstructionItemsInternal(aState, aContent, aParentFrame,
aContent->Tag(), aContent->GetNameSpaceID(),
aContent->NodeInfo()->NameAtom(),
aContent->GetNameSpaceID(),
aSuppressWhiteSpaceOptimizations,
aStyleContext,
flags, aAnonChildren,
@ -5456,7 +5459,7 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState
aContent->IsElement(),
"Shouldn't get anything else here!");
MOZ_ASSERT(!aContent->GetPrimaryFrame() || aState.mCreatingExtraFrames ||
aContent->Tag() == nsGkAtoms::area);
aContent->NodeInfo()->NameAtom() == nsGkAtoms::area);
// The following code allows the user to specify the base tag
// of an element using XBL. XUL and HTML objects (like boxes, menus, etc.)
@ -5516,14 +5519,12 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState
nsIContent *parent = aContent->GetParent();
if (parent) {
// Check tag first, since that check will usually fail
nsIAtom* parentTag = parent->Tag();
if ((parentTag == nsGkAtoms::select || parentTag == nsGkAtoms::optgroup) &&
parent->IsHTMLElement() &&
if (parent->IsAnyOfHTMLElements(nsGkAtoms::select, nsGkAtoms::optgroup) &&
// <option> is ok no matter what
!aContent->IsHTMLElement(nsGkAtoms::option) &&
// <optgroup> is OK in <select> but not in <optgroup>
(!aContent->IsHTMLElement(nsGkAtoms::optgroup) ||
parentTag != nsGkAtoms::select) &&
!parent->IsHTMLElement(nsGkAtoms::select)) &&
// Allow native anonymous content no matter what
!aContent->IsRootOfNativeAnonymousSubtree()) {
// No frame for aContent
@ -6084,7 +6085,7 @@ AdjustAppendParentForAfterContent(nsFrameManager* aFrameManager,
nsIContent* c = child->GetContent();
if (child->IsGeneratedContentFrame()) {
nsIContent* p = c->GetParent();
if (c->Tag() == nsGkAtoms::mozgeneratedcontentafter) {
if (c->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter) {
if (!nsContentUtils::ContentIsDescendantOf(aChild, p) &&
p != aContainer &&
nsContentUtils::PositionIsBefore(p, aChild)) {
@ -6648,9 +6649,7 @@ static bool
IsSpecialFramesetChild(nsIContent* aContent)
{
// IMPORTANT: This must match the conditions in nsHTMLFramesetFrame::Init.
return aContent->IsHTMLElement() &&
(aContent->Tag() == nsGkAtoms::frameset ||
aContent->Tag() == nsGkAtoms::frame);
return aContent->IsAnyOfHTMLElements(nsGkAtoms::frameset, nsGkAtoms::frame);
}
static void
@ -7578,7 +7577,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
NS_ASSERTION(isSingleInsert || frameType != nsGkAtoms::fieldSetFrame,
"Unexpected parent");
if (IsFrameForFieldSet(insertion.mParentFrame, frameType) &&
aStartChild->Tag() == nsGkAtoms::legend) {
aStartChild->NodeInfo()->NameAtom() == nsGkAtoms::legend) {
// Just reframe the parent, since figuring out whether this
// should be the new legend and then handling it is too complex.
// We could do a little better here --- check if the fieldset already
@ -8283,8 +8282,7 @@ InvalidateCanvasIfNeeded(nsIPresShell* presShell, nsIContent* node)
}
// Check whether it's an HTML body
if (node->Tag() != nsGkAtoms::body ||
!node->IsHTMLElement()) {
if (!node->IsHTMLElement(nsGkAtoms::body)) {
return;
}
}
@ -8840,7 +8838,7 @@ nsCSSFrameConstructor::ReplicateFixedFrames(nsPageContentFrame* aParentFrame)
nsLayoutUtils::GetStyleFrame(content)->StyleContext();
FrameConstructionItemList items;
AddFrameConstructionItemsInternal(state, content, canvasFrame,
content->Tag(),
content->NodeInfo()->NameAtom(),
content->GetNameSpaceID(),
true,
styleContext,
@ -10274,7 +10272,8 @@ nsCSSFrameConstructor::AddFCItemsForAnonymousContent(
ITEM_IS_ANONYMOUSCONTENTCREATOR_CONTENT | aExtraFlags;
AddFrameConstructionItemsInternal(aState, content, aFrame,
content->Tag(), content->GetNameSpaceID(),
content->NodeInfo()->NameAtom(),
content->GetNameSpaceID(),
true, styleContext, flags,
anonChildren, aItemsToConstruct);
}
@ -10450,7 +10449,8 @@ nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState& aState,
if (!aFrame->IsGeneratedContentFrame() &&
mPresShell->GetPresContext()->IsChrome()) {
nsIContent *badKid = AnyKidsNeedBlockParent(aFrameItems.FirstChild());
nsDependentAtomString parentTag(aContent->Tag()), kidTag(badKid->Tag());
nsDependentAtomString parentTag(aContent->NodeInfo()->NameAtom()),
kidTag(badKid->NodeInfo()->NameAtom());
const char16_t* params[] = { parentTag.get(), kidTag.get() };
const nsStyleDisplay *display = frameStyleContext->StyleDisplay();
const char *message =
@ -11335,7 +11335,8 @@ nsCSSFrameConstructor::CreateListBoxContent(nsPresContext* aPresContext,
FrameConstructionItemList items;
AddFrameConstructionItemsInternal(state, aChild, aParentFrame,
aChild->Tag(), aChild->GetNameSpaceID(),
aChild->NodeInfo()->NameAtom(),
aChild->GetNameSpaceID(),
true, styleContext,
ITEM_ALLOW_XBL_BASE, nullptr, items);
ConstructFramesFromItemList(state, items, aParentFrame, frameItems);
@ -11728,7 +11729,8 @@ nsCSSFrameConstructor::BuildInlineChildItems(nsFrameConstructorState& aState,
nsRefPtr<nsStyleContext> childContext =
ResolveStyleContext(parentStyleContext, content, &aState);
AddFrameConstructionItemsInternal(aState, content, nullptr, content->Tag(),
AddFrameConstructionItemsInternal(aState, content, nullptr,
content->NodeInfo()->NameAtom(),
content->GetNameSpaceID(),
iter.XBLInvolved(), childContext,
flags, nullptr,

View File

@ -1159,7 +1159,7 @@ FindElementBackground(nsIFrame* aForFrame, nsIFrame* aRootElementFrame,
// was propagated to the viewport.
nsIContent* content = aForFrame->GetContent();
if (!content || content->Tag() != nsGkAtoms::body)
if (!content || content->NodeInfo()->NameAtom() != nsGkAtoms::body)
return true; // not frame for a "body" element
// It could be a non-HTML "body" element but that's OK, we'd fail the
// bodyContent check below

View File

@ -1191,7 +1191,7 @@ nsLayoutUtils::GetBeforeFrameForContent(nsIFrame* aFrame,
const nsTArray<nsIContent*>& pseudos(*prop);
for (uint32_t i = 0; i < pseudos.Length(); ++i) {
if (pseudos[i]->GetParent() == aContent &&
pseudos[i]->Tag() == nsGkAtoms::mozgeneratedcontentbefore) {
pseudos[i]->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore) {
return pseudos[i]->GetPrimaryFrame();
}
}
@ -1230,7 +1230,7 @@ nsLayoutUtils::GetAfterFrameForContent(nsIFrame* aFrame,
const nsTArray<nsIContent*>& pseudos(*prop);
for (uint32_t i = 0; i < pseudos.Length(); ++i) {
if (pseudos[i]->GetParent() == aContent &&
pseudos[i]->Tag() == nsGkAtoms::mozgeneratedcontentafter) {
pseudos[i]->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter) {
return pseudos[i]->GetPrimaryFrame();
}
}
@ -1335,7 +1335,7 @@ nsLayoutUtils::IsGeneratedContentFor(nsIContent* aContent,
return false;
}
return (aFrame->GetContent()->Tag() == nsGkAtoms::mozgeneratedcontentbefore) ==
return (aFrame->GetContent()->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore) ==
(aPseudoElement == nsCSSPseudoElements::before);
}

View File

@ -3214,7 +3214,7 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll,
// Ensure it's an anchor element
content = do_QueryInterface(node);
if (content) {
if (content->Tag() == nsGkAtoms::a && content->IsHTMLElement()) {
if (content->IsHTMLElement(nsGkAtoms::a)) {
break;
}
content = nullptr;
@ -7430,8 +7430,7 @@ PresShell::HandleEvent(nsIFrame* aFrame,
"Unexpected document");
nsIFrame* captureFrame = capturingContent->GetPrimaryFrame();
if (captureFrame) {
if (capturingContent->Tag() == nsGkAtoms::select &&
capturingContent->IsHTMLElement()) {
if (capturingContent->IsHTMLElement(nsGkAtoms::select)) {
// a dropdown <select> has a child in its selectPopupList and we should
// capture on that instead.
nsIFrame* childFrame = captureFrame->GetChildList(nsIFrame::kSelectPopupList).FirstChild();

View File

@ -111,8 +111,7 @@ NS_QUERYFRAME_TAIL_INHERITING(nsImageControlFrameSuper)
a11y::AccType
nsImageControlFrame::AccessibleType()
{
if (mContent->Tag() == nsGkAtoms::button ||
mContent->Tag() == nsGkAtoms::input) {
if (mContent->IsAnyOfHTMLElements(nsGkAtoms::button, nsGkAtoms::input)) {
return a11y::eHTMLButtonType;
}

View File

@ -837,7 +837,7 @@ nsTextControlFrame::SelectAllOrCollapseToEndOfText(bool aSelect)
// br under the root node!
nsIContent *child = rootContent->GetChildAt(numChildren - 1);
if (child) {
if (child->Tag() == nsGkAtoms::br)
if (child->IsHTMLElement(nsGkAtoms::br))
--numChildren;
}
if (!aSelect && numChildren) {