Bug 1378196, Make IsEventAttributeName non-virtual in common case, r=ehsan
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 04 Jul 2017 23:54:30 +0300
changeset 367337 7c192f516b97b2e64e631f0029d2b56022fa03a2
parent 367336 bc7cfe0be797acecdb98638d1961977b538ccc74
child 367338 e187342238542a1867368c83676059b35a01145c
push id32130
push usercbook@mozilla.com
push dateWed, 05 Jul 2017 11:01:49 +0000
treeherdermozilla-central@211d4dd61025 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1378196
milestone56.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 1378196, Make IsEventAttributeName non-virtual in common case, r=ehsan
dom/base/nsIContent.h
dom/base/nsIContentInlines.h
dom/base/nsXMLContentSerializer.cpp
dom/html/HTMLBodyElement.cpp
dom/html/HTMLBodyElement.h
dom/html/HTMLFrameSetElement.cpp
dom/html/HTMLFrameSetElement.h
dom/html/HTMLMediaElement.cpp
dom/html/HTMLMediaElement.h
dom/html/nsGenericHTMLElement.cpp
dom/html/nsGenericHTMLElement.h
dom/svg/SVGAnimationElement.cpp
dom/svg/SVGAnimationElement.h
dom/svg/SVGSVGElement.cpp
dom/svg/SVGSVGElement.h
dom/svg/SVGTransformableElement.cpp
dom/svg/SVGTransformableElement.h
dom/svg/nsSVGElement.cpp
dom/xul/nsXULElement.cpp
dom/xul/nsXULElement.h
--- a/dom/base/nsIContent.h
+++ b/dom/base/nsIContent.h
@@ -522,20 +522,22 @@ public:
    * NOTE: This should not be called on elements.
    */
   virtual uint32_t TextLength() const = 0;
 
   /**
    * Determines if an event attribute name (such as onclick) is valid for
    * a given element type.
    * @note calls nsContentUtils::IsEventAttributeName with right flag
-   * @note overridden by subclasses as needed
+   * @note *Internal is overridden by subclasses as needed
    * @param aName the event name to look up
    */
-  virtual bool IsEventAttributeName(nsIAtom* aName)
+  bool IsEventAttributeName(nsIAtom* aName);
+
+  virtual bool IsEventAttributeNameInternal(nsIAtom* aName)
   {
     return false;
   }
 
   /**
    * Set the text to the given value. If aNotify is true then
    * the document is notified of the content change.
    * NOTE: For elements this always ASSERTS and returns NS_ERROR_FAILURE
--- a/dom/base/nsIContentInlines.h
+++ b/dom/base/nsIContentInlines.h
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsIContentInlines_h
 #define nsIContentInlines_h
 
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsContentUtils.h"
+#include "nsIAtom.h"
 #include "mozilla/dom/Element.h"
 
 inline bool
 nsIContent::IsInHTMLDocument() const
 {
   return OwnerDoc()->IsHTMLDocument();
 }
 
@@ -89,16 +90,27 @@ nsINode::GetFlattenedTreeParentNode() co
 
 inline nsIContent*
 nsIContent::GetFlattenedTreeParent() const
 {
   nsINode* parent = GetFlattenedTreeParentNode();
   return (parent && parent->IsContent()) ? parent->AsContent() : nullptr;
 }
 
+inline bool
+nsIContent::IsEventAttributeName(nsIAtom* aName)
+{
+  const char16_t* name = aName->GetUTF16String();
+  if (name[0] != 'o' || name[1] != 'n') {
+    return false;
+  }
+
+  return IsEventAttributeNameInternal(aName);
+}
+
 inline nsINode*
 nsINode::GetFlattenedTreeParentNodeForStyle() const
 {
   return ::GetFlattenedTreeParentNode<nsIContent::eForStyle>(this);
 }
 
 inline bool
 nsINode::NodeOrAncestorHasDirAuto() const
--- a/dom/base/nsXMLContentSerializer.cpp
+++ b/dom/base/nsXMLContentSerializer.cpp
@@ -12,16 +12,17 @@
 
 #include "nsXMLContentSerializer.h"
 
 #include "nsGkAtoms.h"
 #include "nsIDOMProcessingInstruction.h"
 #include "nsIDOMComment.h"
 #include "nsIDOMDocumentType.h"
 #include "nsIContent.h"
+#include "nsIContentInlines.h"
 #include "nsIDocument.h"
 #include "nsIDocumentEncoder.h"
 #include "nsIParserService.h"
 #include "nsNameSpaceManager.h"
 #include "nsTextFragment.h"
 #include "nsString.h"
 #include "mozilla/Sprintf.h"
 #include "nsUnicharUtils.h"
--- a/dom/html/HTMLBodyElement.cpp
+++ b/dom/html/HTMLBodyElement.cpp
@@ -417,17 +417,17 @@ HTMLBodyElement::GetAssociatedEditor()
   }
 
   nsCOMPtr<nsIEditor> editor;
   docShell->GetEditor(getter_AddRefs(editor));
   return editor.forget();
 }
 
 bool
-HTMLBodyElement::IsEventAttributeName(nsIAtom *aName)
+HTMLBodyElement::IsEventAttributeNameInternal(nsIAtom *aName)
 {
   return nsContentUtils::IsEventAttributeName(aName,
                                               EventNameType_HTML |
                                               EventNameType_HTMLBodyOrFramesetOnly);
 }
 
 nsresult
 HTMLBodyElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
--- a/dom/html/HTMLBodyElement.h
+++ b/dom/html/HTMLBodyElement.h
@@ -104,17 +104,17 @@ public:
                               const nsAString& aValue,
                               nsAttrValue& aResult) override;
   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
   virtual already_AddRefed<nsIEditor> GetAssociatedEditor() override;
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
                          bool aPreallocateChildren) const override;
 
-  virtual bool IsEventAttributeName(nsIAtom* aName) override;
+  virtual bool IsEventAttributeNameInternal(nsIAtom* aName) override;
 
 
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers) override;
   /**
    * Called when an attribute has just been changed
    */
--- a/dom/html/HTMLFrameSetElement.cpp
+++ b/dom/html/HTMLFrameSetElement.cpp
@@ -332,17 +332,17 @@ HTMLFrameSetElement::ParseRowCol(const n
   aNumSpecs = count;
   // Transfer ownership to caller here
   *aSpecs = Move(specs);
 
   return NS_OK;
 }
 
 bool
-HTMLFrameSetElement::IsEventAttributeName(nsIAtom *aName)
+HTMLFrameSetElement::IsEventAttributeNameInternal(nsIAtom *aName)
 {
   return nsContentUtils::IsEventAttributeName(aName,
                                               EventNameType_HTML |
                                               EventNameType_HTMLBodyOrFramesetOnly);
 }
 
 
 #define EVENT(name_, id_, type_, struct_) /* nothing; handled by the shim */
--- a/dom/html/HTMLFrameSetElement.h
+++ b/dom/html/HTMLFrameSetElement.h
@@ -77,17 +77,17 @@ public:
   {
     GetHTMLAttr(nsGkAtoms::rows, aRows);
   }
   void SetRows(const nsAString& aRows, ErrorResult& aError)
   {
     SetHTMLAttr(nsGkAtoms::rows, aRows, aError);
   }
 
-  virtual bool IsEventAttributeName(nsIAtom *aName) override;
+  virtual bool IsEventAttributeNameInternal(nsIAtom *aName) override;
 
   // Event listener stuff; we need to declare only the ones we need to
   // forward to window that don't come from nsIDOMHTMLFrameSetElement.
 #define EVENT(name_, id_, type_, struct_) /* nothing; handled by the superclass */
 #define WINDOW_EVENT_HELPER(name_, type_)                               \
   type_* GetOn##name_();                                                \
   void SetOn##name_(type_* handler);
 #define WINDOW_EVENT(name_, id_, type_, struct_)                        \
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -7000,20 +7000,20 @@ HTMLMediaElement::DispatchEncrypted(cons
   }
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(this, event);
   asyncDispatcher->PostDOMEvent();
 }
 
 bool
-HTMLMediaElement::IsEventAttributeName(nsIAtom* aName)
+HTMLMediaElement::IsEventAttributeNameInternal(nsIAtom* aName)
 {
   return aName == nsGkAtoms::onencrypted ||
-         nsGenericHTMLElement::IsEventAttributeName(aName);
+         nsGenericHTMLElement::IsEventAttributeNameInternal(aName);
 }
 
 already_AddRefed<nsIPrincipal>
 HTMLMediaElement::GetTopLevelPrincipal()
 {
   RefPtr<nsIPrincipal> principal;
   nsCOMPtr<nsPIDOMWindowInner> window = OwnerDoc()->GetInnerWindow();
   if (!window) {
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -648,17 +648,17 @@ public:
   void SetOnencrypted(mozilla::dom::EventHandlerNonNull* aCallback);
 
   mozilla::dom::EventHandlerNonNull* GetOnwaitingforkey();
   void SetOnwaitingforkey(mozilla::dom::EventHandlerNonNull* aCallback);
 
   void DispatchEncrypted(const nsTArray<uint8_t>& aInitData,
                          const nsAString& aInitDataType) override;
 
-  bool IsEventAttributeName(nsIAtom* aName) override;
+  bool IsEventAttributeNameInternal(nsIAtom* aName) override;
 
   // Returns the principal of the "top level" document; the origin displayed
   // in the URL bar of the browser window.
   already_AddRefed<nsIPrincipal> GetTopLevelPrincipal();
 
   bool ContainsRestrictedContent();
 
   void CannotDecryptWaitingForKey();
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -2920,17 +2920,17 @@ nsGenericHTMLElement::GetWidthHeightForI
   }
 
   NS_ASSERTION(size.width >= 0, "negative width");
   NS_ASSERTION(size.height >= 0, "negative height");
   return size;
 }
 
 bool
-nsGenericHTMLElement::IsEventAttributeName(nsIAtom *aName)
+nsGenericHTMLElement::IsEventAttributeNameInternal(nsIAtom *aName)
 {
   return nsContentUtils::IsEventAttributeName(aName, EventNameType_HTML);
 }
 
 /**
  * Construct a URI from a string, as an element.src attribute
  * would be set to. Helper for the media elements.
  */
--- a/dom/html/nsGenericHTMLElement.h
+++ b/dom/html/nsGenericHTMLElement.h
@@ -196,17 +196,17 @@ public:
   void GetInnerText(mozilla::dom::DOMString& aValue, mozilla::ErrorResult& aError);
   void SetInnerText(const nsAString& aValue);
 
   /**
    * Determine whether an attribute is an event (onclick, etc.)
    * @param aName the attribute
    * @return whether the name is an event handler name
    */
-  virtual bool IsEventAttributeName(nsIAtom* aName) override;
+  virtual bool IsEventAttributeNameInternal(nsIAtom* aName) override;
 
 #define EVENT(name_, id_, type_, struct_) /* nothing; handled by nsINode */
 // The using nsINode::Get/SetOn* are to avoid warnings about shadowing the XPCOM
 // getter and setter on nsINode.
 #define FORWARDED_EVENT(name_, id_, type_, struct_)                           \
   using nsINode::GetOn##name_;                                                \
   using nsINode::SetOn##name_;                                                \
   mozilla::dom::EventHandlerNonNull* GetOn##name_();                          \
--- a/dom/svg/SVGAnimationElement.cpp
+++ b/dom/svg/SVGAnimationElement.cpp
@@ -440,17 +440,17 @@ SVGAnimationElement::EndElementAt(float 
     return;
 
   AnimationNeedsResample();
   // Force synchronous sample
   FlushAnimations();
 }
 
 bool
-SVGAnimationElement::IsEventAttributeName(nsIAtom* aName)
+SVGAnimationElement::IsEventAttributeNameInternal(nsIAtom* aName)
 {
   return nsContentUtils::IsEventAttributeName(aName, EventNameType_SMIL);
 }
 
 void
 SVGAnimationElement::UpdateHrefTarget(nsIContent* aNodeForContext,
                                       const nsAString& aHrefStr)
 {
--- a/dom/svg/SVGAnimationElement.h
+++ b/dom/svg/SVGAnimationElement.h
@@ -68,17 +68,17 @@ public:
   bool HasAnimAttr(nsIAtom* aAttName) const;
   Element* GetTargetElementContent();
   virtual bool GetTargetAttributeName(int32_t* aNamespaceID,
                                       nsIAtom** aLocalName) const;
   nsSMILTimedElement& TimedElement();
   nsSMILTimeContainer* GetTimeContainer();
   virtual nsSMILAnimationFunction& AnimationFunction() = 0;
 
-  virtual bool IsEventAttributeName(nsIAtom* aName) override;
+  virtual bool IsEventAttributeNameInternal(nsIAtom* aName) override;
 
   // Utility methods for within SVG
   void ActivateByHyperlink();
 
   // WebIDL
   nsSVGElement* GetTargetElement();
   float GetStartTime(ErrorResult& rv);
   float GetCurrentTime();
--- a/dom/svg/SVGSVGElement.cpp
+++ b/dom/svg/SVGSVGElement.cpp
@@ -569,17 +569,17 @@ SVGSVGElement::GetEventTargetParent(Even
       // we'll force a synchronous sample.
       AnimationNeedsResample();
     }
   }
   return SVGSVGElementBase::GetEventTargetParent(aVisitor);
 }
 
 bool
-SVGSVGElement::IsEventAttributeName(nsIAtom* aName)
+SVGSVGElement::IsEventAttributeNameInternal(nsIAtom* aName)
 {
   /* The events in EventNameType_SVGSVG are for events that are only
      applicable to outermost 'svg' elements. We don't check if we're an outer
      'svg' element in case we're not inserted into the document yet, but since
      the target of the events in question will always be the outermost 'svg'
      element, this shouldn't cause any real problems.
   */
   return nsContentUtils::IsEventAttributeName(aName,
--- a/dom/svg/SVGSVGElement.h
+++ b/dom/svg/SVGSVGElement.h
@@ -100,17 +100,17 @@ public:
    *
    * XXX SVGZoomEvent is no more, is this needed?
    */
   void SetCurrentScaleTranslate(float s, float x, float y);
 
   // nsIContent interface
   virtual nsresult GetEventTargetParent(
                      EventChainPreVisitor& aVisitor) override;
-  virtual bool IsEventAttributeName(nsIAtom* aName) override;
+  virtual bool IsEventAttributeNameInternal(nsIAtom* aName) override;
 
   // nsINode methods:
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
                          bool aPreallocateChildren) const override;
 
   // WebIDL
   already_AddRefed<SVGAnimatedLength> X();
   already_AddRefed<SVGAnimatedLength> Y();
--- a/dom/svg/SVGTransformableElement.cpp
+++ b/dom/svg/SVGTransformableElement.cpp
@@ -87,17 +87,17 @@ SVGTransformableElement::GetAttributeCha
       retval |= nsChangeHint_UpdatePostTransformOverflow |
                 nsChangeHint_UpdateTransformLayer;
     }
   }
   return retval;
 }
 
 bool
-SVGTransformableElement::IsEventAttributeName(nsIAtom* aName)
+SVGTransformableElement::IsEventAttributeNameInternal(nsIAtom* aName)
 {
   return nsContentUtils::IsEventAttributeName(aName, EventNameType_SVGGraphic);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement overrides
 
 gfxMatrix
--- a/dom/svg/SVGTransformableElement.h
+++ b/dom/svg/SVGTransformableElement.h
@@ -47,17 +47,17 @@ public:
   // nsIContent interface
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
 
   nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
                                       int32_t aModType) const override;
 
 
   // nsSVGElement overrides
-  virtual bool IsEventAttributeName(nsIAtom* aName) override;
+  virtual bool IsEventAttributeNameInternal(nsIAtom* aName) override;
 
 
   virtual gfxMatrix PrependLocalTransformsTo(
     const gfxMatrix &aMatrix,
     SVGTransformTypes aWhich = eAllTransforms) const override;
   virtual const gfx::Matrix* GetAnimateMotionTransform() const override;
   virtual void SetAnimateMotionTransform(const gfx::Matrix* aMatrix) override;
 
--- a/dom/svg/nsSVGElement.cpp
+++ b/dom/svg/nsSVGElement.cpp
@@ -9,16 +9,17 @@
 #include "mozilla/Unused.h"
 
 #include "nsSVGElement.h"
 
 #include "mozilla/dom/SVGSVGElement.h"
 #include "mozilla/dom/SVGTests.h"
 #include "nsContentUtils.h"
 #include "nsICSSDeclaration.h"
+#include "nsIContentInlines.h"
 #include "nsIDocument.h"
 #include "nsIDOMMutationEvent.h"
 #include "mozilla/InternalMutationEvent.h"
 #include "mozAutoDocUpdate.h"
 #include "nsError.h"
 #include "nsIPresShell.h"
 #include "nsGkAtoms.h"
 #include "nsRuleWalker.h"
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -2026,17 +2026,17 @@ nsXULElement::RecompileScriptEventListen
 
         nsAutoString value;
         GetAttr(kNameSpaceID_None, attr, value);
         SetEventHandler(attr, value, true);
     }
 }
 
 bool
-nsXULElement::IsEventAttributeName(nsIAtom *aName)
+nsXULElement::IsEventAttributeNameInternal(nsIAtom *aName)
 {
   return nsContentUtils::IsEventAttributeName(aName, EventNameType_XUL);
 }
 
 JSObject*
 nsXULElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
     return dom::XULElementBinding::Wrap(aCx, this, aGivenProto);
--- a/dom/xul/nsXULElement.h
+++ b/dom/xul/nsXULElement.h
@@ -429,17 +429,17 @@ public:
     // parent as a member instead of in the slots, as Element does.
     void SetXULBindingParent(nsIContent* aBindingParent)
     {
       mBindingParent = aBindingParent;
     }
 
     virtual nsIDOMNode* AsDOMNode() override { return this; }
 
-    virtual bool IsEventAttributeName(nsIAtom* aName) override;
+    virtual bool IsEventAttributeNameInternal(nsIAtom* aName) override;
 
     typedef mozilla::dom::DOMString DOMString;
     void GetXULAttr(nsIAtom* aName, DOMString& aResult) const
     {
         GetAttr(kNameSpaceID_None, aName, aResult);
     }
     void SetXULAttr(nsIAtom* aName, const nsAString& aValue,
                     mozilla::ErrorResult& aError)