Bug 1134280 - Get rid of Tag() - patch 2.10 - dom/events, dom/mathml, dom/plugins, dom/smil - Fix all the occurrences, m=smaug, r=surkov
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 03 Mar 2015 11:09:00 +0000
changeset 261901 9e7aa092d6ec34e71fb70e9530120762cee2a4cb
parent 261900 ec0d84308d7c5eeb6b6fae6069b422580be8c397
child 261902 70f156455f82408d801e1ffb4bfa377793ffcf1e
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1134280
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1134280 - Get rid of Tag() - patch 2.10 - dom/events, dom/mathml, dom/plugins, dom/smil - Fix all the occurrences, m=smaug, r=surkov
dom/events/ContentEventHandler.cpp
dom/events/EventStateManager.cpp
dom/events/IMEStateManager.cpp
dom/mathml/nsMathMLElement.cpp
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/smil/nsSMILAnimationController.cpp
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -190,18 +190,17 @@ ContentEventHandler::QueryContentRect(ns
 }
 
 // Editor places a bogus BR node under its root content if the editor doesn't
 // have any text. This happens even for single line editors.
 // When we get text content and when we change the selection,
 // we don't want to include the bogus BRs at the end.
 static bool IsContentBR(nsIContent* aContent)
 {
-  return aContent->IsHTMLElement() &&
-         aContent->Tag() == nsGkAtoms::br &&
+  return aContent->IsHTMLElement(nsGkAtoms::br) &&
          !aContent->AttrValueIs(kNameSpaceID_None,
                                 nsGkAtoms::type,
                                 nsGkAtoms::moz,
                                 eIgnoreCase) &&
          !aContent->AttrValueIs(kNameSpaceID_None,
                                 nsGkAtoms::mozeditorbogusnode,
                                 nsGkAtoms::_true,
                                 eIgnoreCase);
@@ -1387,17 +1386,17 @@ static void AdjustRangeForSelection(nsIC
     } else {
       node = node->GetParent();
       nodeOffset = node->IndexOf(*aNode) + (nodeOffset ? 1 : 0);
     }
   }
 
   nsIContent* brContent = node->GetChildAt(nodeOffset - 1);
   while (brContent && brContent->IsHTMLElement()) {
-    if (brContent->Tag() != nsGkAtoms::br || IsContentBR(brContent)) {
+    if (!brContent->IsHTMLElement(nsGkAtoms::br) || IsContentBR(brContent)) {
       break;
     }
     brContent = node->GetChildAt(--nodeOffset - 1);
   }
   *aNode = node;
   *aNodeOffset = std::max(nodeOffset, 0);
 }
 
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -885,31 +885,28 @@ IsAccessKeyTarget(nsIContent* aContent, 
   if (!aFrame->IsVisibleConsideringAncestors())
     return false;
 
   // XUL controls can be activated.
   nsCOMPtr<nsIDOMXULControlElement> control(do_QueryInterface(aContent));
   if (control)
     return true;
 
-  if (aContent->IsHTMLElement()) {
-    nsIAtom* tag = aContent->Tag();
-
-    // HTML area, label and legend elements are never focusable, so
-    // we need to check for them explicitly before giving up.
-    if (tag == nsGkAtoms::area ||
-        tag == nsGkAtoms::label ||
-        tag == nsGkAtoms::legend)
-      return true;
-
-  } else if (aContent->IsXULElement()) {
-    // XUL label elements are never focusable, so we need to check for them
-    // explicitly before giving up.
-    if (aContent->Tag() == nsGkAtoms::label)
-      return true;
+  // HTML area, label and legend elements are never focusable, so
+  // we need to check for them explicitly before giving up.
+  if (aContent->IsAnyOfHTMLElements(nsGkAtoms::area,
+                                    nsGkAtoms::label,
+                                    nsGkAtoms::legend)) {
+    return true;
+  }
+
+  // XUL label elements are never focusable, so we need to check for them
+  // explicitly before giving up.
+  if (aContent->IsXULElement(nsGkAtoms::label)) {
+    return true;
   }
 
   return false;
 }
 
 bool
 EventStateManager::ExecuteAccessKey(nsTArray<uint32_t>& aAccessCharCodes,
                                     bool aIsTrustedEvent)
@@ -1119,19 +1116,17 @@ EventStateManager::DispatchCrossProcessE
 
 bool
 EventStateManager::IsRemoteTarget(nsIContent* target) {
   if (!target) {
     return false;
   }
 
   // <browser/iframe remote=true> from XUL
-  if ((target->Tag() == nsGkAtoms::browser ||
-       target->Tag() == nsGkAtoms::iframe) &&
-      target->IsXULElement() &&
+  if (target->IsAnyOfXULElements(nsGkAtoms::browser, nsGkAtoms::iframe) &&
       target->AttrValueIs(kNameSpaceID_None, nsGkAtoms::Remote,
                           nsGkAtoms::_true, eIgnoreCase)) {
     return true;
   }
 
   // <frame/iframe mozbrowser/mozapp>
   nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(target);
   if (browserFrame && browserFrame->GetReallyIsBrowserOrApp()) {
@@ -1285,17 +1280,17 @@ EventStateManager::CreateClickHoldTimer(
   // since we'll end up conflicting and both will show.
   if (mGestureDownContent) {
     // check for the |popup| attribute
     if (nsContentUtils::HasNonEmptyAttr(mGestureDownContent, kNameSpaceID_None,
                                         nsGkAtoms::popup))
       return;
     
     // check for a <menubutton> like bookmarks
-    if (mGestureDownContent->Tag() == nsGkAtoms::menubutton)
+    if (mGestureDownContent->IsXULElement(nsGkAtoms::menubutton))
       return;
   }
 
   mClickHoldTimer = do_CreateInstance("@mozilla.org/timer;1");
   if (mClickHoldTimer) {
     int32_t clickHoldDelay =
       Preferences::GetInt("ui.click_hold_context_menus.delay", 500);
     mClickHoldTimer->InitWithFuncCallback(sClickHoldCallback, this,
@@ -1379,50 +1374,47 @@ EventStateManager::FireContextClick()
   // make sure the widget sticks around
   nsCOMPtr<nsIWidget> targetWidget;
   if (mCurrentTarget && (targetWidget = mCurrentTarget->GetNearestWidget())) {
     NS_ASSERTION(mPresContext == mCurrentTarget->PresContext(),
                  "a prescontext returned a primary frame that didn't belong to it?");
 
     // before dispatching, check that we're not on something that
     // doesn't get a context menu
-    nsIAtom *tag = mGestureDownContent->Tag();
     bool allowedToDispatch = true;
 
-    if (mGestureDownContent->IsXULElement()) {
-      if (tag == nsGkAtoms::scrollbar ||
-          tag == nsGkAtoms::scrollbarbutton ||
-          tag == nsGkAtoms::button)
+    if (mGestureDownContent->IsAnyOfXULElements(nsGkAtoms::scrollbar,
+                                                nsGkAtoms::scrollbarbutton,
+                                                nsGkAtoms::button)) {
+      allowedToDispatch = false;
+    } else if (mGestureDownContent->IsXULElement(nsGkAtoms::toolbarbutton)) {
+      // a <toolbarbutton> that has the container attribute set
+      // will already have its own dropdown.
+      if (nsContentUtils::HasNonEmptyAttr(mGestureDownContent,
+              kNameSpaceID_None, nsGkAtoms::container)) {
         allowedToDispatch = false;
-      else if (tag == nsGkAtoms::toolbarbutton) {
-        // a <toolbarbutton> that has the container attribute set
-        // will already have its own dropdown.
-        if (nsContentUtils::HasNonEmptyAttr(mGestureDownContent,
-                kNameSpaceID_None, nsGkAtoms::container)) {
+      } else {
+        // If the toolbar button has an open menu, don't attempt to open
+          // a second menu
+        if (mGestureDownContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::open,
+                                             nsGkAtoms::_true, eCaseMatters)) {
           allowedToDispatch = false;
-        } else {
-          // If the toolbar button has an open menu, don't attempt to open
-            // a second menu
-          if (mGestureDownContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::open,
-                                               nsGkAtoms::_true, eCaseMatters)) {
-            allowedToDispatch = false;
-          }
         }
       }
     }
     else if (mGestureDownContent->IsHTMLElement()) {
       nsCOMPtr<nsIFormControl> formCtrl(do_QueryInterface(mGestureDownContent));
 
       if (formCtrl) {
         allowedToDispatch = formCtrl->IsTextControl(false) ||
                             formCtrl->GetType() == NS_FORM_INPUT_FILE;
       }
-      else if (tag == nsGkAtoms::applet ||
-               tag == nsGkAtoms::embed  ||
-               tag == nsGkAtoms::object) {
+      else if (mGestureDownContent->IsAnyOfHTMLElements(nsGkAtoms::applet,
+                                                        nsGkAtoms::embed,
+                                                        nsGkAtoms::object)) {
         allowedToDispatch = false;
       }
     }
 
     if (allowedToDispatch) {
       // init the event while mCurrentTarget is still good
       WidgetMouseEvent event(true, NS_CONTEXTMENU, targetWidget,
                              WidgetMouseEvent::eReal);
@@ -4802,18 +4794,17 @@ EventStateManager::ResetLastOverForConte
 void
 EventStateManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent)
 {
   /*
    * Anchor and area elements when focused or hovered might make the UI to show
    * the current link. We want to make sure that the UI gets informed when they
    * are actually removed from the DOM.
    */
-  if (aContent->IsHTMLElement() &&
-      (aContent->Tag() == nsGkAtoms::a || aContent->Tag() == nsGkAtoms::area) &&
+  if (aContent->IsAnyOfHTMLElements(nsGkAtoms::a, nsGkAtoms::area) &&
       (aContent->AsElement()->State().HasAtLeastOneOfStates(NS_EVENT_STATE_FOCUS |
                                                             NS_EVENT_STATE_HOVER))) {
     nsGenericHTMLElement* element = static_cast<nsGenericHTMLElement*>(aContent);
     element->LeaveLink(
       element->GetPresContext(nsGenericHTMLElement::eForComposedDoc));
   }
 
   IMEStateManager::OnRemoveContent(mPresContext, aContent);
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -786,20 +786,19 @@ IMEStateManager::SetIMEState(const IMESt
 
   NS_ENSURE_TRUE_VOID(aWidget);
 
   InputContext oldContext = aWidget->GetInputContext();
 
   InputContext context;
   context.mIMEState = aState;
 
-  if (aContent && aContent->GetNameSpaceID() == kNameSpaceID_XHTML &&
-      (aContent->Tag() == nsGkAtoms::input ||
-       aContent->Tag() == nsGkAtoms::textarea)) {
-    if (aContent->Tag() != nsGkAtoms::textarea) {
+  if (aContent &&
+      aContent->IsAnyOfHTMLElements(nsGkAtoms::input, nsGkAtoms::textarea)) {
+    if (!aContent->IsHTMLElement(nsGkAtoms::textarea)) {
       // <input type=number> has an anonymous <input type=text> descendant
       // that gets focus whenever anyone tries to focus the number control. We
       // need to check if aContent is one of those anonymous text controls and,
       // if so, use the number control instead:
       nsIContent* content = aContent;
       HTMLInputElement* inputElement =
         HTMLInputElement::FromContentOrNull(aContent);
       if (inputElement) {
@@ -825,29 +824,28 @@ IMEStateManager::SetIMEState(const IMESt
 
     // Get the input content corresponding to the focused node,
     // which may be an anonymous child of the input content.
     nsIContent* inputContent = aContent->FindFirstNonChromeOnlyAccessContent();
 
     // If we don't have an action hint and
     // return won't submit the form, use "next".
     if (context.mActionHint.IsEmpty() &&
-        inputContent->Tag() == nsGkAtoms::input) {
+        inputContent->IsHTMLElement(nsGkAtoms::input)) {
       bool willSubmit = false;
       nsCOMPtr<nsIFormControl> control(do_QueryInterface(inputContent));
       mozilla::dom::Element* formElement = control->GetFormElement();
       nsCOMPtr<nsIForm> form;
       if (control) {
         // is this a form and does it have a default submit element?
         if ((form = do_QueryInterface(formElement)) &&
             form->GetDefaultSubmitElement()) {
           willSubmit = true;
         // is this an html form and does it only have a single text input element?
-        } else if (formElement && formElement->Tag() == nsGkAtoms::form &&
-                   formElement->IsHTMLElement() &&
+        } else if (formElement && formElement->IsHTMLElement(nsGkAtoms::form) &&
                    !static_cast<dom::HTMLFormElement*>(formElement)->
                      ImplicitSubmissionIsDisabled()) {
           willSubmit = true;
         }
       }
       context.mActionHint.Assign(
         willSubmit ? (control->GetType() == NS_FORM_INPUT_SEARCH ?
                        NS_LITERAL_STRING("search") : NS_LITERAL_STRING("go")) :
--- a/dom/mathml/nsMathMLElement.cpp
+++ b/dom/mathml/nsMathMLElement.cpp
@@ -145,17 +145,17 @@ nsMathMLElement::UnbindFromTree(bool aDe
 
 bool
 nsMathMLElement::ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult)
 {
   if (aNamespaceID == kNameSpaceID_None) {
-    if (Tag() == nsGkAtoms::math && aAttribute == nsGkAtoms::mode) {
+    if (IsMathMLElement(nsGkAtoms::math) && aAttribute == nsGkAtoms::mode) {
       WarnDeprecated(nsGkAtoms::mode->GetUTF16String(),
                      nsGkAtoms::display->GetUTF16String(), OwnerDoc());
     }
     if (aAttribute == nsGkAtoms::color) {
       WarnDeprecated(nsGkAtoms::color->GetUTF16String(),
                      nsGkAtoms::mathcolor_->GetUTF16String(), OwnerDoc());
     }
     if (aAttribute == nsGkAtoms::color ||
@@ -227,52 +227,50 @@ nsMathMLElement::IsAttributeMapped(const
     sCommonPresStyles
   };
   static const MappedAttributeEntry* const mrowMap[] = {
     sCommonPresStyles,
     sDirStyles
   };
 
   // We don't support mglyph (yet).
-  nsIAtom* tag = Tag();
-  if (tag == nsGkAtoms::ms_ || tag == nsGkAtoms::mi_ ||
-      tag == nsGkAtoms::mn_ || tag == nsGkAtoms::mo_ ||
-      tag == nsGkAtoms::mtext_ || tag == nsGkAtoms::mspace_)
+  if (IsAnyOfMathMLElements(nsGkAtoms::ms_, nsGkAtoms::mi_, nsGkAtoms::mn_,
+                            nsGkAtoms::mo_, nsGkAtoms::mtext_,
+                            nsGkAtoms::mspace_))
     return FindAttributeDependence(aAttribute, tokenMap);
-  if (tag == nsGkAtoms::mstyle_ ||
-      tag == nsGkAtoms::math)
+  if (IsAnyOfMathMLElements(nsGkAtoms::mstyle_, nsGkAtoms::math))
     return FindAttributeDependence(aAttribute, mstyleMap);
 
-  if (tag == nsGkAtoms::mtable_)
+  if (IsMathMLElement(nsGkAtoms::mtable_))
     return FindAttributeDependence(aAttribute, mtableMap);
 
-  if (tag == nsGkAtoms::mrow_)
+  if (IsMathMLElement(nsGkAtoms::mrow_))
     return FindAttributeDependence(aAttribute, mrowMap);
 
-  if (tag == nsGkAtoms::maction_ ||
-      tag == nsGkAtoms::maligngroup_ ||
-      tag == nsGkAtoms::malignmark_ ||
-      tag == nsGkAtoms::menclose_ ||
-      tag == nsGkAtoms::merror_ ||
-      tag == nsGkAtoms::mfenced_ ||
-      tag == nsGkAtoms::mfrac_ ||
-      tag == nsGkAtoms::mover_ ||
-      tag == nsGkAtoms::mpadded_ ||
-      tag == nsGkAtoms::mphantom_ ||
-      tag == nsGkAtoms::mprescripts_ ||
-      tag == nsGkAtoms::mroot_ ||
-      tag == nsGkAtoms::msqrt_ ||
-      tag == nsGkAtoms::msub_ ||
-      tag == nsGkAtoms::msubsup_ ||
-      tag == nsGkAtoms::msup_ ||
-      tag == nsGkAtoms::mtd_ ||
-      tag == nsGkAtoms::mtr_ ||
-      tag == nsGkAtoms::munder_ ||
-      tag == nsGkAtoms::munderover_ ||
-      tag == nsGkAtoms::none) {
+  if (IsAnyOfMathMLElements(nsGkAtoms::maction_,
+                            nsGkAtoms::maligngroup_,
+                            nsGkAtoms::malignmark_,
+                            nsGkAtoms::menclose_,
+                            nsGkAtoms::merror_,
+                            nsGkAtoms::mfenced_,
+                            nsGkAtoms::mfrac_,
+                            nsGkAtoms::mover_,
+                            nsGkAtoms::mpadded_,
+                            nsGkAtoms::mphantom_,
+                            nsGkAtoms::mprescripts_,
+                            nsGkAtoms::mroot_,
+                            nsGkAtoms::msqrt_,
+                            nsGkAtoms::msub_,
+                            nsGkAtoms::msubsup_,
+                            nsGkAtoms::msup_,
+                            nsGkAtoms::mtd_,
+                            nsGkAtoms::mtr_,
+                            nsGkAtoms::munder_,
+                            nsGkAtoms::munderover_,
+                            nsGkAtoms::none)) {
     return FindAttributeDependence(aAttribute, commonPresMap);
   }
 
   return false;
 }
 
 nsMapRuleToAttributesFunc
 nsMathMLElement::GetAttributeMappingFunction() const
@@ -966,21 +964,18 @@ nsMathMLElement::IsFocusableInternal(int
   return false;
 }
 
 bool
 nsMathMLElement::IsLink(nsIURI** aURI) const
 {
   // http://www.w3.org/TR/2010/REC-MathML3-20101021/chapter6.html#interf.link
   // The REC says that the following elements should not be linking elements:
-  nsIAtom* tag = Tag();
-  if (tag == nsGkAtoms::mprescripts_ ||
-      tag == nsGkAtoms::none         ||
-      tag == nsGkAtoms::malignmark_  ||
-      tag == nsGkAtoms::maligngroup_) {
+  if (IsAnyOfMathMLElements(nsGkAtoms::mprescripts_, nsGkAtoms::none,
+                            nsGkAtoms::malignmark_, nsGkAtoms::maligngroup_)) {
     *aURI = nullptr;
     return false;
   }
 
   bool hasHref = false;
   const nsAttrValue* href = mAttrsAndChildren.GetAttr(nsGkAtoms::href,
                                                       kNameSpaceID_None);
   if (href) {
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -988,23 +988,21 @@ NPBool nsPluginInstanceOwner::ConvertPoi
 }
 
 NS_IMETHODIMP nsPluginInstanceOwner::GetTagType(nsPluginTagType *result)
 {
   NS_ENSURE_ARG_POINTER(result);
 
   *result = nsPluginTagType_Unknown;
 
-  nsIAtom *atom = mContent->Tag();
-
-  if (atom == nsGkAtoms::applet)
+  if (mContent->IsHTMLElement(nsGkAtoms::applet))
     *result = nsPluginTagType_Applet;
-  else if (atom == nsGkAtoms::embed)
+  else if (mContent->IsHTMLElement(nsGkAtoms::embed))
     *result = nsPluginTagType_Embed;
-  else if (atom == nsGkAtoms::object)
+  else if (mContent->IsHTMLElement(nsGkAtoms::object))
     *result = nsPluginTagType_Object;
 
   return NS_OK;
 }
 
 void nsPluginInstanceOwner::GetParameters(nsTArray<MozPluginParameter>& parameters)
 {
   nsCOMPtr<nsIObjectLoadingContent> content = do_QueryInterface(mContent);
--- a/dom/smil/nsSMILAnimationController.cpp
+++ b/dom/smil/nsSMILAnimationController.cpp
@@ -773,17 +773,17 @@ nsSMILAnimationController::GetTargetIden
   if (!aAnimElem->GetTargetAttributeName(&attributeNamespaceID,
                                          getter_AddRefs(attributeName)))
     // Animation has no target attr -- skip it.
     return false;
 
   // animateTransform can only animate transforms, conversely transforms
   // can only be animated by animateTransform
   if (IsTransformAttribute(attributeNamespaceID, attributeName) !=
-      (aAnimElem->Tag() == nsGkAtoms::animateTransform))
+      (aAnimElem->IsSVGElement(nsGkAtoms::animateTransform)))
     return false;
 
   // Look up target (animated) attribute-type
   nsSMILTargetAttrType attributeType = aAnimElem->GetTargetAttributeType();
 
   // Check if an 'auto' attributeType refers to a CSS property or XML attribute.
   // Note that SMIL requires we search for CSS properties first. So if they
   // overlap, 'auto' = 'CSS'. (SMILANIM 3.1)