Skip to content

Commit

Permalink
Bug 1134280 - Get rid of Tag() - patch 2.7 - layout/generic - Fix all…
Browse files Browse the repository at this point in the history
… the occurrences
  • Loading branch information
rmottola committed Feb 17, 2019
1 parent 61e06ff commit bbe5865
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 66 deletions.
4 changes: 2 additions & 2 deletions layout/generic/nsBlockFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6640,7 +6640,7 @@ nsBlockFrame::AccessibleType()
}

// block frame may be for <hr>
if (mContent->Tag() == nsGkAtoms::hr) {
if (mContent->IsHTMLElement(nsGkAtoms::hr)) {
return a11y::eHTMLHRType;
}

Expand Down Expand Up @@ -6990,7 +6990,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 {
Expand Down
8 changes: 4 additions & 4 deletions layout/generic/nsFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1638,9 +1638,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
Expand Down Expand Up @@ -5737,7 +5737,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);
Expand Down Expand Up @@ -8937,7 +8937,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);
Expand Down
5 changes: 2 additions & 3 deletions layout/generic/nsFrameSetFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions layout/generic/nsGfxScrollFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3712,10 +3712,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;
Expand Down
6 changes: 2 additions & 4 deletions layout/generic/nsHTMLReflowState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1789,15 +1789,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
Expand Down
3 changes: 2 additions & 1 deletion layout/generic/nsImageFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,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);
}
Expand Down
41 changes: 20 additions & 21 deletions layout/generic/nsImageMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

// 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);
}
// 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->IsHTMLElement(nsGkAtoms::a)) {
aFoundAnchor = true;
rv = AddArea(child);
NS_ENSURE_SUCCESS(rv, rv);
}

if (child->IsElement()) {
Expand Down
5 changes: 2 additions & 3 deletions layout/generic/nsInlineFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,10 +1016,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;
Expand Down
7 changes: 3 additions & 4 deletions layout/generic/nsLineLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2262,11 +2262,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;
}
}
Expand Down
10 changes: 5 additions & 5 deletions layout/generic/nsPluginFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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...
Expand Down
23 changes: 8 additions & 15 deletions layout/generic/nsSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ nsIAtom *GetTag(nsINode *aNode)
return nullptr;
}

return content->Tag();
return content->NodeInfo()->NameAtom();
}

// Returns the parent
Expand Down Expand Up @@ -2226,9 +2226,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*
Expand Down Expand Up @@ -2984,8 +2982,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;
}
}
Expand Down Expand Up @@ -3125,9 +3122,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;
}
Expand All @@ -3137,11 +3132,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;
}

Expand Down Expand Up @@ -4967,7 +4960,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
Expand Down Expand Up @@ -5508,7 +5501,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)) {
Expand Down
2 changes: 1 addition & 1 deletion layout/generic/nsSubDocumentFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,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) {
Expand Down
2 changes: 1 addition & 1 deletion layout/generic/nsTextFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bbe5865

Please sign in to comment.