Bug 763861 - Assign a flag in nsINode to say whether the node is content; r=ehsan
authorJignesh Kakadiya <jigneshhk1992@gmail.com>
Mon, 18 Jun 2012 23:47:35 -0400
changeset 96993 87e09d2f6098a2b353547619918097070d2ab9b1
parent 96992 63a91a66c14c3a492e5a415bda6596aecbf60e23
child 96994 fe2fdd5d3aae80b06464b133fea832bbe1246df6
push id10810
push usereakhgari@mozilla.com
push dateTue, 19 Jun 2012 03:47:42 +0000
treeherdermozilla-inbound@87e09d2f6098 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs763861
milestone16.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 763861 - Assign a flag in nsINode to say whether the node is content; r=ehsan
content/base/public/nsIContent.h
content/base/public/nsINode.h
--- a/content/base/public/nsIContent.h
+++ b/content/base/public/nsIContent.h
@@ -60,16 +60,17 @@ public:
   // If you're using the external API, the only thing you can know about
   // nsIContent is that it exists with an IID
 
   nsIContent(already_AddRefed<nsINodeInfo> aNodeInfo)
     : nsINode(aNodeInfo)
   {
     NS_ASSERTION(mNodeInfo,
                  "No nsINodeInfo passed to nsIContent, PREPARE TO CRASH!!!");
+    SetNodeIsContent();
   }
 #endif // MOZILLA_INTERNAL_API
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_IID)
 
   /**
    * Bind this content node to a tree.  If this method throws, the caller must
    * call UnbindFromTree() on the node.  In the typical case of a node being
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -370,23 +370,16 @@ public:
 
   /**
    * Return this node as an Element.  Should only be used for nodes
    * for which IsElement() is true.  This is defined inline in Element.h.
    */
   mozilla::dom::Element* AsElement();
 
   /**
-   * Return whether the node is a content node
-   */
-  bool IsContent() const {
-    return IsNodeOfType(eCONTENT);
-  }
-
-  /**
    * Return this node as nsIContent.  Should only be used for nodes for which
    * IsContent() is true.  This is defined inline in nsIContent.h.
    */
   nsIContent* AsContent();
 
   virtual nsIDOMNode* AsDOMNode() = 0;
 
   /**
@@ -1277,16 +1270,18 @@ private:
     // Set if the node has an explicit base URI stored
     NodeHasExplicitBaseURI,
     // Set if the element has some style states locked
     ElementHasLockedStyleStates,
     // Set if element has pointer locked
     ElementHasPointerLock,
     // Set if the node may have DOMMutationObserver attached to it.
     NodeMayHaveDOMMutationObserver,
+    // Set if node is Content
+    NodeIsContent,
     // Guard value
     BooleanFlagCount
   };
 
   void SetBoolFlag(BooleanFlag name, bool value) {
     PR_STATIC_ASSERT(BooleanFlagCount <= 8*sizeof(mBoolFlags));
     mBoolFlags = (mBoolFlags & ~(1 << name)) | (value << name);
   }
@@ -1306,16 +1301,17 @@ private:
     return mBoolFlags & (1 << name);
   }
 
 public:
   bool HasRenderingObservers() const
     { return GetBoolFlag(NodeHasRenderingObservers); }
   void SetHasRenderingObservers(bool aValue)
     { SetBoolFlag(NodeHasRenderingObservers, aValue); }
+  bool IsContent() const { return GetBoolFlag(NodeIsContent); }
   bool HasID() const { return GetBoolFlag(ElementHasID); }
   bool MayHaveStyle() const { return GetBoolFlag(ElementMayHaveStyle); }
   bool HasName() const { return GetBoolFlag(ElementHasName); }
   bool MayHaveContentEditableAttr() const
     { return GetBoolFlag(ElementMayHaveContentEditableAttr); }
   bool IsCommonAncestorForRangeInSelection() const
     { return GetBoolFlag(NodeIsCommonAncestorForRangeInSelection); }
   void SetCommonAncestorForRangeInSelection()
@@ -1344,16 +1340,17 @@ public:
     { SetBoolFlag(NodeMayHaveDOMMutationObserver, true); }
   bool HasListenerManager() { return HasFlag(NODE_HAS_LISTENERMANAGER); }
   bool HasPointerLock() const { return GetBoolFlag(ElementHasPointerLock); }
   void SetPointerLock() { SetBoolFlag(ElementHasPointerLock); }
   void ClearPointerLock() { ClearBoolFlag(ElementHasPointerLock); }
 protected:
   void SetParentIsContent(bool aValue) { SetBoolFlag(ParentIsContent, aValue); }
   void SetInDocument() { SetBoolFlag(IsInDocument); }
+  void SetNodeIsContent() { SetBoolFlag(NodeIsContent); }
   void ClearInDocument() { ClearBoolFlag(IsInDocument); }
   void SetIsElement() { SetBoolFlag(NodeIsElement); }
   void ClearIsElement() { ClearBoolFlag(NodeIsElement); }
   void SetHasID() { SetBoolFlag(ElementHasID); }
   void ClearHasID() { ClearBoolFlag(ElementHasID); }
   void SetMayHaveStyle() { SetBoolFlag(ElementMayHaveStyle); }
   void SetHasName() { SetBoolFlag(ElementHasName); }
   void ClearHasName() { ClearBoolFlag(ElementHasName); }