Bug 1134280 - Get rid of Tag() - patch 2.8 - dom/html - Fix all the occurrences, m=smaug, r=surkov
This commit is contained in:
@@ -68,23 +68,21 @@ HTMLAllCollection::Collection()
|
||||
static bool
|
||||
IsAllNamedElement(nsIContent* aContent)
|
||||
{
|
||||
nsIAtom* tag = aContent->Tag();
|
||||
return
|
||||
tag == nsGkAtoms::a ||
|
||||
tag == nsGkAtoms::applet ||
|
||||
tag == nsGkAtoms::button ||
|
||||
tag == nsGkAtoms::embed ||
|
||||
tag == nsGkAtoms::form ||
|
||||
tag == nsGkAtoms::iframe ||
|
||||
tag == nsGkAtoms::img ||
|
||||
tag == nsGkAtoms::input ||
|
||||
tag == nsGkAtoms::map ||
|
||||
tag == nsGkAtoms::meta ||
|
||||
tag == nsGkAtoms::object ||
|
||||
tag == nsGkAtoms::select ||
|
||||
tag == nsGkAtoms::textarea ||
|
||||
tag == nsGkAtoms::frame ||
|
||||
tag == nsGkAtoms::frameset;
|
||||
return aContent->IsAnyOfHTMLElements(nsGkAtoms::a,
|
||||
nsGkAtoms::applet,
|
||||
nsGkAtoms::button,
|
||||
nsGkAtoms::embed,
|
||||
nsGkAtoms::form,
|
||||
nsGkAtoms::iframe,
|
||||
nsGkAtoms::img,
|
||||
nsGkAtoms::input,
|
||||
nsGkAtoms::map,
|
||||
nsGkAtoms::meta,
|
||||
nsGkAtoms::object,
|
||||
nsGkAtoms::select,
|
||||
nsGkAtoms::textarea,
|
||||
nsGkAtoms::frame,
|
||||
nsGkAtoms::frameset);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
||||
@@ -206,9 +206,7 @@ HTMLMenuElement::TraverseContent(nsIContent* aContent,
|
||||
continue;
|
||||
}
|
||||
|
||||
nsIAtom* tag = child->Tag();
|
||||
|
||||
if (tag == nsGkAtoms::menuitem) {
|
||||
if (child->IsHTMLElement(nsGkAtoms::menuitem)) {
|
||||
HTMLMenuItemElement* menuitem = HTMLMenuItemElement::FromContent(child);
|
||||
|
||||
if (menuitem->IsHidden()) {
|
||||
@@ -227,7 +225,7 @@ HTMLMenuElement::TraverseContent(nsIContent* aContent,
|
||||
aBuilder->AddItemFor(menuitem, CanLoadIcon(child, icon));
|
||||
|
||||
aSeparator = ST_FALSE;
|
||||
} else if (tag == nsGkAtoms::menu && !element->IsHidden()) {
|
||||
} else if (child->IsHTMLElement(nsGkAtoms::menu) && !element->IsHidden()) {
|
||||
if (child->HasAttr(kNameSpaceID_None, nsGkAtoms::label)) {
|
||||
nsAutoString label;
|
||||
child->GetAttr(kNameSpaceID_None, nsGkAtoms::label, label);
|
||||
|
||||
@@ -73,10 +73,10 @@ HTMLOptGroupElement::GetSelect()
|
||||
{
|
||||
nsIContent* parent = this;
|
||||
while ((parent = parent->GetParent()) && parent->IsHTMLElement()) {
|
||||
if (parent->Tag() == nsGkAtoms::select) {
|
||||
if (parent->IsHTMLElement(nsGkAtoms::select)) {
|
||||
return parent;
|
||||
}
|
||||
if (parent->Tag() != nsGkAtoms::optgroup) {
|
||||
if (!parent->IsHTMLElement(nsGkAtoms::optgroup)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ HTMLOptionElement::GetSelect()
|
||||
if (select) {
|
||||
return select;
|
||||
}
|
||||
if (parent->Tag() != nsGkAtoms::optgroup) {
|
||||
if (!parent->IsHTMLElement(nsGkAtoms::optgroup)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ HTMLPictureElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
|
||||
// Find all img siblings after this <source> to notify them of its demise
|
||||
nsCOMPtr<nsINode> child = GetChildAt(aIndex);
|
||||
nsCOMPtr<nsIContent> nextSibling;
|
||||
if (child && child->Tag() == nsGkAtoms::source) {
|
||||
if (child && child->IsHTMLElement(nsGkAtoms::source)) {
|
||||
nextSibling = child->GetNextSibling();
|
||||
}
|
||||
|
||||
|
||||
@@ -86,12 +86,12 @@ HTMLSourceElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
aName == nsGkAtoms::sizes ||
|
||||
aName == nsGkAtoms::media ||
|
||||
aName == nsGkAtoms::type) &&
|
||||
parent && parent->Tag() == nsGkAtoms::picture) {
|
||||
parent && parent->IsHTMLElement(nsGkAtoms::picture)) {
|
||||
nsString strVal = aValue ? aValue->GetStringValue() : EmptyString();
|
||||
// Find all img siblings after this <source> and notify them of the change
|
||||
nsCOMPtr<nsINode> sibling = AsContent();
|
||||
while ( (sibling = sibling->GetNextSibling()) ) {
|
||||
if (sibling->Tag() == nsGkAtoms::img) {
|
||||
if (sibling->IsHTMLElement(nsGkAtoms::img)) {
|
||||
HTMLImageElement *img = static_cast<HTMLImageElement*>(sibling.get());
|
||||
if (aName == nsGkAtoms::srcset) {
|
||||
img->PictureSourceSrcsetChanged(AsContent(), strVal, aNotify);
|
||||
@@ -147,11 +147,11 @@ HTMLSourceElement::BindToTree(nsIDocument *aDocument,
|
||||
if (aParent && aParent->IsNodeOfType(nsINode::eMEDIA)) {
|
||||
HTMLMediaElement* media = static_cast<HTMLMediaElement*>(aParent);
|
||||
media->NotifyAddedSource();
|
||||
} else if (aParent && aParent->Tag() == nsGkAtoms::picture) {
|
||||
} else if (aParent && aParent->IsHTMLElement(nsGkAtoms::picture)) {
|
||||
// Find any img siblings after this <source> and notify them
|
||||
nsCOMPtr<nsINode> sibling = AsContent();
|
||||
while ( (sibling = sibling->GetNextSibling()) ) {
|
||||
if (sibling->Tag() == nsGkAtoms::img) {
|
||||
if (sibling->IsHTMLElement(nsGkAtoms::img)) {
|
||||
HTMLImageElement *img = static_cast<HTMLImageElement*>(sibling.get());
|
||||
img->PictureSourceAdded(AsContent());
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ HTMLTableSectionElement*
|
||||
HTMLTableRowElement::GetSection() const
|
||||
{
|
||||
nsIContent* parent = GetParent();
|
||||
if (parent && parent->IsHTMLElement() &&
|
||||
(parent->Tag() == nsGkAtoms::thead ||
|
||||
parent->Tag() == nsGkAtoms::tbody ||
|
||||
parent->Tag() == nsGkAtoms::tfoot)) {
|
||||
if (parent &&
|
||||
parent->IsAnyOfHTMLElements(nsGkAtoms::thead,
|
||||
nsGkAtoms::tbody,
|
||||
nsGkAtoms::tfoot)) {
|
||||
return static_cast<HTMLTableSectionElement*>(parent);
|
||||
}
|
||||
return nullptr;
|
||||
@@ -122,10 +122,7 @@ static bool
|
||||
IsCell(nsIContent *aContent, int32_t aNamespaceID,
|
||||
nsIAtom* aAtom, void *aData)
|
||||
{
|
||||
nsIAtom* tag = aContent->Tag();
|
||||
|
||||
return ((tag == nsGkAtoms::td || tag == nsGkAtoms::th) &&
|
||||
aContent->IsHTMLElement());
|
||||
return aContent->IsAnyOfHTMLElements(nsGkAtoms::td, nsGkAtoms::th);
|
||||
}
|
||||
|
||||
nsIHTMLCollection*
|
||||
|
||||
@@ -802,7 +802,7 @@ nsGenericHTMLElement::GetEventListenerManagerForAttr(nsIAtom* aAttrName,
|
||||
EventHandlerNonNull* \
|
||||
nsGenericHTMLElement::GetOn##name_() \
|
||||
{ \
|
||||
if (Tag() == nsGkAtoms::body || Tag() == nsGkAtoms::frameset) { \
|
||||
if (IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset)) { \
|
||||
/* XXXbz note to self: add tests for this! */ \
|
||||
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
|
||||
if (win) { \
|
||||
@@ -818,7 +818,7 @@ nsGenericHTMLElement::GetOn##name_() \
|
||||
void \
|
||||
nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler) \
|
||||
{ \
|
||||
if (Tag() == nsGkAtoms::body || Tag() == nsGkAtoms::frameset) { \
|
||||
if (IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset)) { \
|
||||
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
|
||||
if (!win) { \
|
||||
return; \
|
||||
@@ -835,7 +835,7 @@ nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler) \
|
||||
already_AddRefed<EventHandlerNonNull> \
|
||||
nsGenericHTMLElement::GetOn##name_() \
|
||||
{ \
|
||||
if (Tag() == nsGkAtoms::body || Tag() == nsGkAtoms::frameset) { \
|
||||
if (IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset)) { \
|
||||
/* XXXbz note to self: add tests for this! */ \
|
||||
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
|
||||
if (win) { \
|
||||
@@ -857,7 +857,7 @@ nsGenericHTMLElement::GetOn##name_() \
|
||||
void \
|
||||
nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler) \
|
||||
{ \
|
||||
if (Tag() == nsGkAtoms::body || Tag() == nsGkAtoms::frameset) { \
|
||||
if (IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset)) { \
|
||||
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
|
||||
if (!win) { \
|
||||
return; \
|
||||
@@ -1005,7 +1005,7 @@ nsGenericHTMLElement::ParseAttribute(int32_t aNamespaceID,
|
||||
|
||||
aResult.ParseAtom(aValue);
|
||||
|
||||
if (CanHaveName(Tag())) {
|
||||
if (CanHaveName(NodeInfo()->NameAtom())) {
|
||||
SetHasName();
|
||||
AddToNameTable(aResult.GetAtomValue());
|
||||
}
|
||||
@@ -1790,16 +1790,14 @@ nsGenericHTMLElement::GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu)
|
||||
bool
|
||||
nsGenericHTMLElement::IsLabelable() const
|
||||
{
|
||||
return Tag() == nsGkAtoms::progress ||
|
||||
Tag() == nsGkAtoms::meter;
|
||||
return IsAnyOfHTMLElements(nsGkAtoms::progress, nsGkAtoms::meter);
|
||||
}
|
||||
|
||||
bool
|
||||
nsGenericHTMLElement::IsInteractiveHTMLContent() const
|
||||
{
|
||||
return Tag() == nsGkAtoms::details ||
|
||||
Tag() == nsGkAtoms::embed ||
|
||||
Tag() == nsGkAtoms::keygen ||
|
||||
return IsAnyOfHTMLElements(nsGkAtoms::details, nsGkAtoms::embed,
|
||||
nsGkAtoms::keygen) ||
|
||||
HasAttr(kNameSpaceID_None, nsGkAtoms::tabindex);
|
||||
}
|
||||
|
||||
|
||||
@@ -920,19 +920,16 @@ public:
|
||||
static inline bool
|
||||
ShouldExposeNameAsHTMLDocumentProperty(Element* aElement)
|
||||
{
|
||||
return aElement->IsHTMLElement() && CanHaveName(aElement->Tag());
|
||||
return aElement->IsHTMLElement() &&
|
||||
CanHaveName(aElement->NodeInfo()->NameAtom());
|
||||
}
|
||||
static inline bool
|
||||
ShouldExposeIdAsHTMLDocumentProperty(Element* aElement)
|
||||
{
|
||||
if (!aElement->IsHTMLElement()) {
|
||||
return false;
|
||||
}
|
||||
nsIAtom* tag = aElement->Tag();
|
||||
return tag == nsGkAtoms::img ||
|
||||
tag == nsGkAtoms::applet ||
|
||||
tag == nsGkAtoms::embed ||
|
||||
tag == nsGkAtoms::object;
|
||||
return aElement->IsAnyOfHTMLElements(nsGkAtoms::img,
|
||||
nsGkAtoms::applet,
|
||||
nsGkAtoms::embed,
|
||||
nsGkAtoms::object);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
||||
@@ -265,7 +265,7 @@ nsGenericHTMLFrameElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::src &&
|
||||
(Tag() != nsGkAtoms::iframe ||
|
||||
(!IsHTMLElement(nsGkAtoms::iframe) ||
|
||||
!HasAttr(kNameSpaceID_None,nsGkAtoms::srcdoc))) {
|
||||
// Don't propagate error here. The attribute was successfully set, that's
|
||||
// what we should reflect.
|
||||
|
||||
@@ -1055,10 +1055,10 @@ nsHTMLDocument::SetBody(nsGenericHTMLElement* newBody, ErrorResult& rv)
|
||||
// The body element must be either a body tag or a frameset tag. And we must
|
||||
// have a html root tag, otherwise GetBody will not return the newly set
|
||||
// body.
|
||||
if (!newBody || !(newBody->Tag() == nsGkAtoms::body ||
|
||||
newBody->Tag() == nsGkAtoms::frameset) ||
|
||||
if (!newBody ||
|
||||
!newBody->IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset) ||
|
||||
!root || !root->IsHTMLElement() ||
|
||||
root->Tag() != nsGkAtoms::html) {
|
||||
!root->IsHTMLElement(nsGkAtoms::html)) {
|
||||
rv.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -567,7 +567,7 @@ nsTextInputSelectionImpl::CompleteMove(bool aForward, bool aExtend)
|
||||
{
|
||||
nsIContent *child = parentDIV->GetLastChild();
|
||||
|
||||
if (child->Tag() == nsGkAtoms::br)
|
||||
if (child->IsHTMLElement(nsGkAtoms::br))
|
||||
{
|
||||
--offset;
|
||||
hint = CARET_ASSOCIATE_AFTER; // for Bug 106855
|
||||
|
||||
Reference in New Issue
Block a user