Bug 763283 part 1 - Add new nsINode::AsContent() and nsINode::IsContent() methods; r=mounir
authorAryeh Gregor <ayg@aryeh.name>
Sun, 10 Jun 2012 15:39:21 +0300
changeset 101685 d625424ed3ed882cfb8cfc9fc317614f7bd22b06
parent 101684 09ff9a7af93e431d212390a76548e9c2007d1aed
child 101686 f15e5762f237818e177334c7789d18af50046c92
push id191
push userlsblakk@mozilla.com
push dateFri, 05 Oct 2012 17:12:53 +0000
treeherdermozilla-release@ddb22ac6c03b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs763283
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 763283 part 1 - Add new nsINode::AsContent() and nsINode::IsContent() methods; r=mounir
content/base/public/nsIContent.h
content/base/public/nsINode.h
--- a/content/base/public/nsIContent.h
+++ b/content/base/public/nsIContent.h
@@ -918,9 +918,15 @@ public:
 
   // accessibility.tabfocus_applies_to_xul pref - if it is set to true,
   // the tabfocus bit field applies to xul elements.
   static bool sTabFocusModelAppliesToXUL;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIContent, NS_ICONTENT_IID)
 
+inline nsIContent* nsINode::AsContent()
+{
+  MOZ_ASSERT(IsContent());
+  return static_cast<nsIContent*>(this);
+}
+
 #endif /* nsIContent_h___ */
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -369,16 +369,29 @@ 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;
 
   /**
    * Return if this node has any children.
    */
   bool HasChildren() const { return !!mFirstChild; }
 
   /**