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

This commit is contained in:
Andrea Marchesini 2015-03-03 11:09:00 +00:00
parent 77aab8ab51
commit d7989a4be0
8 changed files with 60 additions and 74 deletions

View File

@ -4091,12 +4091,11 @@ XULDocument::BroadcasterHookup::~BroadcasterHookup()
#ifdef PR_LOGGING
if (PR_LOG_TEST(gXULLog, PR_LOG_WARNING) && !mResolved) {
// Tell the world we failed
nsIAtom *tag = mObservesElement->Tag();
nsAutoString broadcasterID;
nsAutoString attribute;
if (tag == nsGkAtoms::observes) {
if (mObservesElement->IsXULElement(nsGkAtoms::observes)) {
mObservesElement->GetAttr(kNameSpaceID_None, nsGkAtoms::element, broadcasterID);
mObservesElement->GetAttr(kNameSpaceID_None, nsGkAtoms::attribute, attribute);
}
@ -4110,7 +4109,7 @@ XULDocument::BroadcasterHookup::~BroadcasterHookup()
broadcasteridC.AssignWithConversion(broadcasterID);
PR_LOG(gXULLog, PR_LOG_WARNING,
("xul: broadcaster hookup failed <%s attribute='%s'> to %s",
nsAtomCString(tag).get(),
nsAtomCString(mObservesElement->NodeInfo()->NameAtom()).get(),
attributeC.get(),
broadcasteridC.get()));
}
@ -4326,7 +4325,7 @@ XULDocument::CheckBroadcasterHookup(Element* aElement,
broadcasteridC.AssignWithConversion(broadcasterID);
PR_LOG(gXULLog, PR_LOG_NOTICE,
("xul: broadcaster hookup <%s attribute='%s'> to %s",
nsAtomCString(content->Tag()).get(),
nsAtomCString(content->NodeInfo()->NameAtom()).get(),
attributeC.get(),
broadcasteridC.get()));
}

View File

@ -632,7 +632,7 @@ nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
{
nsCOMPtr<nsIContent> content(this);
if (Tag() == nsGkAtoms::label) {
if (IsXULElement(nsGkAtoms::label)) {
nsCOMPtr<nsIDOMElement> element;
nsAutoString control;
@ -660,13 +660,12 @@ nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
nsXULElement* elm = FromContent(content);
if (elm) {
// Define behavior for each type of XUL element.
nsIAtom *tag = content->Tag();
if (tag != nsGkAtoms::toolbarbutton) {
if (!content->IsXULElement(nsGkAtoms::toolbarbutton)) {
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
nsCOMPtr<nsIDOMElement> element;
// for radio buttons, focus the radiogroup instead
if (tag == nsGkAtoms::radio) {
if (content->IsXULElement(nsGkAtoms::radio)) {
nsCOMPtr<nsIDOMXULSelectControlItemElement> controlItem(do_QueryInterface(content));
if (controlItem) {
bool disabled;
@ -685,7 +684,8 @@ nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
fm->SetFocus(element, nsIFocusManager::FLAG_BYKEY);
}
}
if (aKeyCausesActivation && tag != nsGkAtoms::textbox && tag != nsGkAtoms::menulist) {
if (aKeyCausesActivation &&
!content->IsAnyOfXULElements(nsGkAtoms::textbox, nsGkAtoms::menulist)) {
elm->ClickWithInputSource(nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD);
}
}
@ -857,7 +857,7 @@ nsXULElement::BindToTree(nsIDocument* aDocument,
// We do this during binding, not element construction, because elements
// can be moved from the document that creates them to another document.
if (!XULElementsRulesInMinimalXULSheet(Tag())) {
if (!XULElementsRulesInMinimalXULSheet(NodeInfo()->NameAtom())) {
doc->EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::XULSheet());
// To keep memory usage down it is important that we try and avoid
// pulling xul.css into non-XUL documents. That should be very rare, and
@ -1287,9 +1287,8 @@ nsresult
nsXULElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
aVisitor.mForceContentDispatch = true; //FIXME! Bug 329119
nsIAtom* tag = Tag();
if (IsRootOfNativeAnonymousSubtree() &&
(tag == nsGkAtoms::scrollbar || tag == nsGkAtoms::scrollcorner) &&
(IsAnyOfXULElements(nsGkAtoms::scrollbar, nsGkAtoms::scrollcorner)) &&
(aVisitor.mEvent->message == NS_MOUSE_CLICK ||
aVisitor.mEvent->message == NS_MOUSE_DOUBLECLICK ||
aVisitor.mEvent->message == NS_XUL_COMMAND ||
@ -1304,7 +1303,7 @@ nsXULElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
if (aVisitor.mEvent->message == NS_XUL_COMMAND &&
aVisitor.mEvent->mClass == eInputEventClass &&
aVisitor.mEvent->originalTarget == static_cast<nsIContent*>(this) &&
tag != nsGkAtoms::command) {
!IsXULElement(nsGkAtoms::command)) {
// Check that we really have an xul command event. That will be handled
// in a special way.
nsCOMPtr<nsIDOMXULCommandEvent> xulEvent =
@ -1452,8 +1451,7 @@ nsXULElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
if (aAttribute == nsGkAtoms::value &&
(aModType == nsIDOMMutationEvent::REMOVAL ||
aModType == nsIDOMMutationEvent::ADDITION)) {
nsIAtom *tag = Tag();
if (tag == nsGkAtoms::label || tag == nsGkAtoms::description)
if (IsAnyOfXULElements(nsGkAtoms::label, nsGkAtoms::description))
// Label and description dynamically morph between a normal
// block and a cropping single-line XUL text frame. If the
// value attribute is being added or removed, then we need to
@ -1584,10 +1582,8 @@ nsXULElement::LoadSrc()
{
// Allow frame loader only on objects for which a container box object
// can be obtained.
nsIAtom* tag = Tag();
if (tag != nsGkAtoms::browser &&
tag != nsGkAtoms::editor &&
tag != nsGkAtoms::iframe) {
if (!IsAnyOfXULElements(nsGkAtoms::browser, nsGkAtoms::editor,
nsGkAtoms::iframe)) {
return NS_OK;
}
if (!IsInDoc() ||

View File

@ -719,11 +719,8 @@ protected:
bool IsReadWriteTextElement() const
{
const nsIAtom* tag = Tag();
return
GetNameSpaceID() == kNameSpaceID_XUL &&
(tag == nsGkAtoms::textbox || tag == nsGkAtoms::textarea) &&
!HasAttr(kNameSpaceID_None, nsGkAtoms::readonly);
return IsAnyOfXULElements(nsGkAtoms::textbox, nsGkAtoms::textarea) &&
!HasAttr(kNameSpaceID_None, nsGkAtoms::readonly);
}
virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE;

View File

@ -140,8 +140,7 @@ nsXULPopupListener::HandleEvent(nsIDOMEvent* aEvent)
if (!targetContent) {
return NS_OK;
}
if (targetContent->Tag() == nsGkAtoms::browser &&
targetContent->IsXULElement() &&
if (targetContent->IsXULElement(nsGkAtoms::browser) &&
EventStateManager::IsRemoteTarget(targetContent)) {
return NS_OK;
}
@ -191,8 +190,8 @@ nsXULPopupListener::HandleEvent(nsIDOMEvent* aEvent)
// to show, we know (guaranteed) that we're dealing with a menu or
// submenu of an already-showing popup. We don't need to do anything at all.
if (!mIsContext) {
nsIAtom *tag = targetContent ? targetContent->Tag() : nullptr;
if (tag == nsGkAtoms::menu || tag == nsGkAtoms::menuitem)
if (targetContent &&
targetContent->IsAnyOfXULElements(nsGkAtoms::menu, nsGkAtoms::menuitem))
return NS_OK;
}
@ -307,7 +306,7 @@ GetImmediateChild(nsIContent* aContent, nsIAtom *aTag)
for (nsIContent* child = aContent->GetFirstChild();
child;
child = child->GetNextSibling()) {
if (child->Tag() == aTag) {
if (child->IsXULElement(aTag)) {
nsCOMPtr<nsIContent> ret = child;
return ret.forget();
}

View File

@ -457,9 +457,9 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
PR_LOG(gXULTemplateLog, PR_LOG_ALWAYS,
("Tags: [Template: %s Resource: %s Real: %s] for id %s",
nsAtomCString(aTemplateNode->Tag()).get(),
nsAtomCString(aResourceNode->Tag()).get(),
nsAtomCString(aRealNode->Tag()).get(), NS_ConvertUTF16toUTF8(id).get()));
nsAtomCString(aTemplateNode->NodeInfo()->NameAtom()).get(),
nsAtomCString(aResourceNode->NodeInfo()->NameAtom()).get(),
nsAtomCString(aRealNode->NodeInfo()->NameAtom()).get(), NS_ConvertUTF16toUTF8(id).get()));
}
#endif
@ -523,7 +523,7 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
MOZ_ASSERT_IF(isGenerationElement, tmplKid->IsElement());
nsIAtom *tag = tmplKid->Tag();
nsIAtom *tag = tmplKid->NodeInfo()->NameAtom();
#ifdef PR_LOGGING
if (PR_LOG_TEST(gXULTemplateLog, PR_LOG_DEBUG)) {
@ -1049,7 +1049,7 @@ nsXULContentBuilder::CreateContainerContents(nsIContent* aElement,
nsTemplateQuerySet* queryset = mQuerySets[r];
nsIAtom* tag = queryset->GetTag();
if (tag && tag != aElement->Tag())
if (tag && tag != aElement->NodeInfo()->NameAtom())
continue;
CreateContainerContentsForQuerySet(aElement, aResult, aNotify, queryset,
@ -1263,16 +1263,13 @@ bool
nsXULContentBuilder::IsOpen(nsIContent* aElement)
{
// Determine if this is a <treeitem> or <menu> element
if (!aElement->IsXULElement())
return true;
// XXXhyatt Use the XBL service to obtain a base tag.
nsIAtom *tag = aElement->Tag();
if (tag == nsGkAtoms::menu ||
tag == nsGkAtoms::menubutton ||
tag == nsGkAtoms::toolbarbutton ||
tag == nsGkAtoms::button ||
tag == nsGkAtoms::treeitem)
if (aElement->IsAnyOfXULElements(nsGkAtoms::menu,
nsGkAtoms::menubutton,
nsGkAtoms::toolbarbutton,
nsGkAtoms::button,
nsGkAtoms::treeitem))
return aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::open,
nsGkAtoms::_true, eCaseMatters);
return true;
@ -1447,7 +1444,7 @@ nsXULContentBuilder::HasGeneratedContent(nsIRDFResource* aResource,
// the root resource is always acceptable
if (aResource == rootresource) {
if (!aTag || mRoot->Tag() == aTag)
if (!aTag || mRoot->NodeInfo()->NameAtom() == aTag)
*aGenerated = true;
}
else {
@ -1473,7 +1470,7 @@ nsXULContentBuilder::HasGeneratedContent(nsIRDFResource* aResource,
nsTemplateMatch* match;
if (content == mRoot || mContentSupportMap.Get(content, &match)) {
// If we've got a tag, check it to ensure we're consistent.
if (!aTag || content->Tag() == aTag) {
if (!aTag || content->NodeInfo()->NameAtom() == aTag) {
*aGenerated = true;
return NS_OK;
}

View File

@ -75,30 +75,26 @@ XULSortServiceImpl::SetSortColumnHints(nsIContent *content,
for (nsIContent* child = content->GetFirstChild();
child;
child = child->GetNextSibling()) {
if (child->IsXULElement()) {
nsIAtom *tag = child->Tag();
if (tag == nsGkAtoms::treecols) {
SetSortColumnHints(child, sortResource, sortDirection);
} else if (tag == nsGkAtoms::treecol) {
nsAutoString value;
child->GetAttr(kNameSpaceID_None, nsGkAtoms::sort, value);
// also check the resource attribute for older code
if (value.IsEmpty())
child->GetAttr(kNameSpaceID_None, nsGkAtoms::resource, value);
if (value == sortResource) {
child->SetAttr(kNameSpaceID_None, nsGkAtoms::sortActive,
NS_LITERAL_STRING("true"), true);
child->SetAttr(kNameSpaceID_None, nsGkAtoms::sortDirection,
sortDirection, true);
// Note: don't break out of loop; want to set/unset
// attribs on ALL sort columns
} else if (!value.IsEmpty()) {
child->UnsetAttr(kNameSpaceID_None, nsGkAtoms::sortActive,
true);
child->UnsetAttr(kNameSpaceID_None, nsGkAtoms::sortDirection,
true);
}
if (child->IsXULElement(nsGkAtoms::treecols)) {
SetSortColumnHints(child, sortResource, sortDirection);
} else if (child->IsXULElement(nsGkAtoms::treecol)) {
nsAutoString value;
child->GetAttr(kNameSpaceID_None, nsGkAtoms::sort, value);
// also check the resource attribute for older code
if (value.IsEmpty())
child->GetAttr(kNameSpaceID_None, nsGkAtoms::resource, value);
if (value == sortResource) {
child->SetAttr(kNameSpaceID_None, nsGkAtoms::sortActive,
NS_LITERAL_STRING("true"), true);
child->SetAttr(kNameSpaceID_None, nsGkAtoms::sortDirection,
sortDirection, true);
// Note: don't break out of loop; want to set/unset
// attribs on ALL sort columns
} else if (!value.IsEmpty()) {
child->UnsetAttr(kNameSpaceID_None, nsGkAtoms::sortActive,
true);
child->UnsetAttr(kNameSpaceID_None, nsGkAtoms::sortDirection,
true);
}
}
}
@ -177,7 +173,7 @@ XULSortServiceImpl::GetTemplateItemsToSort(nsIContent* aContainer,
cinfo->content = child;
cinfo->result = result;
}
else if (aContainer->Tag() != nsGkAtoms::_template) {
else if (!aContainer->IsXULElement(nsGkAtoms::_template)) {
rv = GetTemplateItemsToSort(child, aBuilder, aSortState, aSortItems);
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -773,7 +773,8 @@ nsXULTemplateBuilder::UpdateResultInContainer(nsIXULTemplateResult* aOldResult,
if (aNewResult) {
// only allow a result to be inserted into containers with a matching tag
nsIAtom* tag = aQuerySet->GetTag();
if (aInsertionPoint && tag && tag != aInsertionPoint->Tag())
if (aInsertionPoint && tag &&
tag != aInsertionPoint->NodeInfo()->NameAtom())
return NS_OK;
int32_t findpriority = aQuerySet->Priority();
@ -1438,7 +1439,8 @@ nsXULTemplateBuilder::DetermineMatchedRule(nsIContent *aContainer,
// If a tag was specified, it must match the tag of the container
// where content is being inserted.
nsIAtom* tag = rule->GetTag();
if ((!aContainer || !tag || tag == aContainer->Tag()) &&
if ((!aContainer || !tag ||
tag == aContainer->NodeInfo()->NameAtom()) &&
rule->CheckMatch(aResult)) {
*aMatchedRule = rule;
*aRuleIndex = r;

View File

@ -1220,7 +1220,7 @@ nsXULTemplateQueryProcessorRDF::CompileExtendedQuery(nsRDFQuery* aQuery,
condition = condition->GetNextSibling()) {
// the <content> condition should always be the first child
if (condition->Tag() == nsGkAtoms::content) {
if (condition->IsXULElement(nsGkAtoms::content)) {
if (condition != aConditions->GetFirstChild()) {
nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_CONTENT_NOT_FIRST);
continue;
@ -1245,8 +1245,8 @@ nsXULTemplateQueryProcessorRDF::CompileExtendedQuery(nsRDFQuery* aQuery,
}
TestNode* testnode = nullptr;
nsresult rv = CompileQueryChild(condition->Tag(), aQuery, condition,
prevnode, &testnode);
nsresult rv = CompileQueryChild(condition->NodeInfo()->NameAtom(),
aQuery, condition, prevnode, &testnode);
if (NS_FAILED(rv))
return rv;