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

This commit is contained in:
Andrea Marchesini 2015-03-03 11:09:00 +00:00
parent 89e6f852d3
commit 00dbe99756
13 changed files with 53 additions and 65 deletions

View File

@ -6488,7 +6488,7 @@ nsBlockFrame::AccessibleType()
}
// block frame may be for <hr>
if (mContent->Tag() == nsGkAtoms::hr) {
if (mContent->IsHTMLElement(nsGkAtoms::hr)) {
return a11y::eHTMLHRType;
}
@ -6827,7 +6827,7 @@ nsBlockFrame::RenumberLists(nsPresContext* aPresContext)
// XXX Map html's start property to counter-reset style
int32_t ordinal = 1;
int32_t increment;
if (mContent->Tag() == nsGkAtoms::ol &&
if (mContent->IsHTMLElement(nsGkAtoms::ol) &&
mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::reversed)) {
increment = -1;
} else {

View File

@ -1637,9 +1637,9 @@ inline static bool IsSVGContentWithCSSClip(const nsIFrame *aFrame)
// elements regardless of the value of the 'position' property. Here we obey
// the CSS spec for outer-<svg> (since that's what we generally do), but
// obey the SVG spec for other SVG elements to which 'clip' applies.
nsIAtom *tag = aFrame->GetContent()->Tag();
return (aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT) &&
(tag == nsGkAtoms::svg || tag == nsGkAtoms::foreignObject);
aFrame->GetContent()->IsAnyOfSVGElements(nsGkAtoms::svg,
nsGkAtoms::foreignObject);
}
bool
@ -5709,7 +5709,7 @@ nsFrame::MakeFrameName(const nsAString& aType, nsAString& aResult) const
aResult = aType;
if (mContent && !mContent->IsNodeOfType(nsINode::eTEXT)) {
nsAutoString buf;
mContent->Tag()->ToString(buf);
mContent->NodeInfo()->NameAtom()->ToString(buf);
if (GetType() == nsGkAtoms::subDocumentFrame) {
nsAutoString src;
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::src, src);
@ -8912,7 +8912,7 @@ GetTagName(nsFrame* aFrame, nsIContent* aContent, int aResultSize,
{
if (aContent) {
PR_snprintf(aResult, aResultSize, "%s@%p",
nsAtomCString(aContent->Tag()).get(), aFrame);
nsAtomCString(aContent->NodeInfo()->NameAtom()).get(), aFrame);
}
else {
PR_snprintf(aResult, aResultSize, "@%p", aFrame);

View File

@ -344,13 +344,12 @@ nsHTMLFramesetFrame::Init(nsIContent* aContent,
if (!child->IsHTMLElement())
continue;
nsIAtom *tag = child->Tag();
if (tag == nsGkAtoms::frameset || tag == nsGkAtoms::frame) {
if (child->IsAnyOfHTMLElements(nsGkAtoms::frameset, nsGkAtoms::frame)) {
nsRefPtr<nsStyleContext> kidSC;
kidSC = shell->StyleSet()->ResolveStyleFor(child->AsElement(),
mStyleContext);
if (tag == nsGkAtoms::frameset) {
if (child->IsHTMLElement(nsGkAtoms::frameset)) {
frame = NS_NewHTMLFramesetFrame(shell, kidSC);
nsHTMLFramesetFrame* childFrame = (nsHTMLFramesetFrame*)frame;

View File

@ -3699,10 +3699,10 @@ ScrollFrameHelper::ReloadChildFrames()
NS_ASSERTION(!mVScrollbarBox, "Found multiple vertical scrollbars?");
mVScrollbarBox = frame;
}
} else if (content->Tag() == nsGkAtoms::resizer) {
} else if (content->IsXULElement(nsGkAtoms::resizer)) {
NS_ASSERTION(!mResizerBox, "Found multiple resizers");
mResizerBox = frame;
} else if (content->Tag() == nsGkAtoms::scrollcorner) {
} else if (content->IsXULElement(nsGkAtoms::scrollcorner)) {
// probably a scrollcorner
NS_ASSERTION(!mScrollCornerBox, "Found multiple scrollcorners");
mScrollCornerBox = frame;

View File

@ -1790,15 +1790,13 @@ CalcQuirkContainingBlockHeight(const nsHTMLReflowState* aCBReflowState)
if (firstAncestorRS) {
nsIContent* frameContent = firstAncestorRS->frame->GetContent();
if (frameContent) {
nsIAtom *contentTag = frameContent->Tag();
NS_ASSERTION(contentTag == nsGkAtoms::html, "First ancestor is not HTML");
NS_ASSERTION(frameContent->IsHTMLElement(nsGkAtoms::html), "First ancestor is not HTML");
}
}
if (secondAncestorRS) {
nsIContent* frameContent = secondAncestorRS->frame->GetContent();
if (frameContent) {
nsIAtom *contentTag = frameContent->Tag();
NS_ASSERTION(contentTag == nsGkAtoms::body, "Second ancestor is not BODY");
NS_ASSERTION(frameContent->IsHTMLElement(nsGkAtoms::body), "Second ancestor is not BODY");
}
}
#endif

View File

@ -1323,7 +1323,8 @@ nsImageFrame::DisplayAltFeedback(nsRenderingContext& aRenderingContext,
nsIContent* content = GetContent();
if (content) {
nsXPIDLString altText;
nsCSSFrameConstructor::GetAlternateTextFor(content, content->Tag(),
nsCSSFrameConstructor::GetAlternateTextFor(content,
content->NodeInfo()->NameAtom(),
altText);
DisplayAltText(PresContext(), aRenderingContext, altText, inner);
}

View File

@ -759,27 +759,26 @@ nsImageMap::SearchForAreas(nsIContent* aParent, bool& aFoundArea,
for (i = 0; i < n; i++) {
nsIContent *child = aParent->GetChildAt(i);
if (child->IsHTMLElement()) {
// If we haven't determined that the map element contains an
// <a> element yet, then look for <area>.
if (!aFoundAnchor && child->Tag() == nsGkAtoms::area) {
aFoundArea = true;
rv = AddArea(child);
NS_ENSURE_SUCCESS(rv, rv);
// If we haven't determined that the map element contains an
// <a> element yet, then look for <area>.
if (!aFoundAnchor && child->IsHTMLElement(nsGkAtoms::area)) {
aFoundArea = true;
rv = AddArea(child);
NS_ENSURE_SUCCESS(rv, rv);
// Continue to next child. This stops mContainsBlockContents from
// getting set. It also makes us ignore children of <area>s which
// is consistent with how we react to dynamic insertion of such
// children.
continue;
}
// If we haven't determined that the map element contains an
// <area> element yet, then look for <a>.
if (!aFoundArea && child->Tag() == nsGkAtoms::a) {
aFoundAnchor = true;
rv = AddArea(child);
NS_ENSURE_SUCCESS(rv, rv);
}
// Continue to next child. This stops mContainsBlockContents from
// getting set. It also makes us ignore children of <area>s which
// is consistent with how we react to dynamic insertion of such
// children.
continue;
}
// If we haven't determined that the map element contains an
// <area> element yet, then look for <a>.
if (!aFoundArea && child->IsHTMLElement(nsGkAtoms::a)) {
aFoundAnchor = true;
rv = AddArea(child);
NS_ENSURE_SUCCESS(rv, rv);
}
if (child->IsElement()) {

View File

@ -978,10 +978,9 @@ nsInlineFrame::AccessibleType()
{
// Broken image accessibles are created here, because layout
// replaces the image or image control frame with an inline frame
nsIAtom *tagAtom = mContent->Tag();
if (tagAtom == nsGkAtoms::input) // Broken <input type=image ... />
if (mContent->IsHTMLElement(nsGkAtoms::input)) // Broken <input type=image ... />
return a11y::eHTMLButtonType;
if (tagAtom == nsGkAtoms::img) // Create accessible for broken <img>
if (mContent->IsHTMLElement(nsGkAtoms::img)) // Create accessible for broken <img>
return a11y::eHyperTextType;
return a11y::eNoType;

View File

@ -2258,11 +2258,10 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
if (!applyMinLH && isLastLine) {
nsIContent* blockContent = mRootSpan->mFrame->mFrame->GetContent();
if (blockContent) {
nsIAtom *blockTagAtom = blockContent->Tag();
// (3) above, if the last line of LI, DT, or DD
if (blockTagAtom == nsGkAtoms::li ||
blockTagAtom == nsGkAtoms::dt ||
blockTagAtom == nsGkAtoms::dd) {
if (blockContent->IsAnyOfHTMLElements(nsGkAtoms::li,
nsGkAtoms::dt,
nsGkAtoms::dd)) {
applyMinLH = true;
}
}

View File

@ -378,8 +378,8 @@ nsPluginFrame::GetMinISize(nsRenderingContext *aRenderingContext)
nscoord result = 0;
if (!IsHidden(false)) {
nsIAtom *atom = mContent->Tag();
if (atom == nsGkAtoms::applet || atom == nsGkAtoms::embed) {
if (mContent->IsAnyOfHTMLElements(nsGkAtoms::applet,
nsGkAtoms::embed)) {
bool vertical = GetWritingMode().IsVertical();
result = nsPresContext::CSSPixelsToAppUnits(
vertical ? EMBED_DEF_HEIGHT : EMBED_DEF_WIDTH);
@ -440,8 +440,8 @@ nsPluginFrame::GetDesiredSize(nsPresContext* aPresContext,
aMetrics.Height() = aReflowState.ComputedHeight();
// for EMBED and APPLET, default to 240x200 for compatibility
nsIAtom *atom = mContent->Tag();
if (atom == nsGkAtoms::applet || atom == nsGkAtoms::embed) {
if (mContent->IsAnyOfHTMLElements(nsGkAtoms::applet,
nsGkAtoms::embed)) {
if (aMetrics.Width() == NS_UNCONSTRAINEDSIZE) {
aMetrics.Width() = clamped(nsPresContext::CSSPixelsToAppUnits(EMBED_DEF_WIDTH),
aReflowState.ComputedMinWidth(),
@ -731,7 +731,7 @@ nsPluginFrame::IsHidden(bool aCheckVisibilityStyle) const
}
// only <embed> tags support the HIDDEN attribute
if (mContent->Tag() == nsGkAtoms::embed) {
if (mContent->IsHTMLElement(nsGkAtoms::embed)) {
// Yes, these are really the kooky ways that you could tell 4.x
// not to hide the <embed> once you'd put the 'hidden' attribute
// on the tag...

View File

@ -755,7 +755,7 @@ nsIAtom *GetTag(nsINode *aNode)
return nullptr;
}
return content->Tag();
return content->NodeInfo()->NameAtom();
}
// Returns the parent
@ -2189,9 +2189,7 @@ nsFrameSelection::NotifySelectionListeners(SelectionType aType)
static bool IsCell(nsIContent *aContent)
{
return ((aContent->Tag() == nsGkAtoms::td ||
aContent->Tag() == nsGkAtoms::th) &&
aContent->IsHTMLElement());
return aContent->IsAnyOfHTMLElements(nsGkAtoms::td, nsGkAtoms::th);
}
nsITableCellLayout*
@ -2947,8 +2945,7 @@ nsFrameSelection::GetParentTable(nsIContent *aCell) const
for (nsIContent* parent = aCell->GetParent(); parent;
parent = parent->GetParent()) {
if (parent->Tag() == nsGkAtoms::table &&
parent->IsHTMLElement()) {
if (parent->IsHTMLElement(nsGkAtoms::table)) {
return parent;
}
}
@ -3088,9 +3085,7 @@ Selection::GetTableSelectionType(nsIDOMRange* aDOMRange,
return NS_OK;
}
nsIAtom *tag = startContent->Tag();
if (tag == nsGkAtoms::tr)
if (startContent->IsHTMLElement(nsGkAtoms::tr))
{
*aTableSelectionType = nsISelectionPrivate::TABLESELECTION_CELL;
}
@ -3100,11 +3095,9 @@ Selection::GetTableSelectionType(nsIDOMRange* aDOMRange,
if (!child)
return NS_ERROR_FAILURE;
tag = child->Tag();
if (tag == nsGkAtoms::table)
if (child->IsHTMLElement(nsGkAtoms::table))
*aTableSelectionType = nsISelectionPrivate::TABLESELECTION_TABLE;
else if (tag == nsGkAtoms::tr)
else if (child->IsHTMLElement(nsGkAtoms::tr))
*aTableSelectionType = nsISelectionPrivate::TABLESELECTION_ROW;
}
@ -4828,7 +4821,7 @@ Selection::Collapse(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv)
nsCOMPtr<nsIContent> content = do_QueryInterface(&aParentNode);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(&aParentNode);
printf ("Sel. Collapse to %p %s %d\n", &aParentNode,
content ? nsAtomCString(content->Tag()).get()
content ? nsAtomCString(content->NodeInfo()->NameAtom()).get()
: (doc ? "DOCUMENT" : "???"),
aOffset);
#endif
@ -5367,7 +5360,7 @@ Selection::Extend(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv)
}
nsCOMPtr<nsIContent> content = do_QueryInterface(&aParentNode);
printf ("Sel. Extend to %p %s %d\n", content.get(),
nsAtomCString(content->Tag()).get(), aOffset);
nsAtomCString(content->NodeInfo()->NameAtom()).get(), aOffset);
#endif
res = mFrameSelection->NotifySelectionListeners(GetType());
if (NS_FAILED(res)) {

View File

@ -859,7 +859,7 @@ nsSubDocumentFrame::AttributeChanged(int32_t aNameSpaceID,
if (aAttribute == nsGkAtoms::noresize) {
// Note that we're not doing content type checks, but that's ok -- if
// they'd fail we will just end up with a null framesetFrame.
if (mContent->GetParent()->Tag() == nsGkAtoms::frameset) {
if (mContent->GetParent()->IsHTMLElement(nsGkAtoms::frameset)) {
nsIFrame* parentFrame = GetParent();
if (parentFrame) {

View File

@ -1964,7 +1964,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
if (mLineContainer->HasAnyStateBits(TEXT_IS_IN_TOKEN_MATHML)) {
// All MathML tokens except <mtext> use 'math' script.
if (!(parent && parent->GetContent() &&
parent->GetContent()->Tag() == nsGkAtoms::mtext_)) {
parent->GetContent()->IsMathMLElement(nsGkAtoms::mtext_))) {
textFlags |= gfxTextRunFactory::TEXT_USE_MATH_SCRIPT;
}
nsIMathMLFrame* mathFrame = do_QueryFrame(parent);