Closed Bug 1447098 Opened 4 years ago Closed 4 years ago

Rename FromContent to FromNode


(Core :: DOM: Core & HTML, enhancement)

Not set



Tracking Status
firefox61 --- fixed


(Reporter: bzbarsky, Assigned: bzbarsky)




(3 files, 1 obsolete file)

In bug 1446533 I changed FromContent to take an nsINode*, because that was useful in some places.  Turns out that compiles fine.  Given that, I'd like to rename it to nsINode.
Depends on: 1446533
MozReview-Commit-ID: 202nkbmkwfR
Attachment #8960770 - Flags: review?(nika)
Some condition functions are faster on subclasses of nsINode than on nsINode itself.
Attachment #8960772 - Flags: review?(nika)
Attachment #8960770 - Flags: review?(nika) → review+
Attachment #8960771 - Flags: review?(nika) → review+
Comment on attachment 8960772 [details] [diff] [review]
part 3.  Add some FromNode overloads for different arg types

Review of attachment 8960772 [details] [diff] [review]:

::: dom/base/nsIContent.h
@@ +1013,3 @@
>  #define NS_IMPL_FROMNODE_HELPER(_class, _check)                         \
> +  template<typename ArgType>                                            \
> +  static _class* FromNode(ArgType* aNode)                               \

Hmm, this is a lot more overloads than seems like should be necessary...

This I think would let you avoid the need for a special overload for smart pointers

#define NS_IMPL_FROMNODE_HELPER(_class, _check) \
  template<typename ArgType> \
  static _class* FromNode(ArgType&& aNode) { \
    return aNode->_check ? static_cast<_class*>(static_cast<nsINode*>(aNode)) : nullptr; \
Attachment #8960772 - Flags: review?(nika)
To preserve current semantics, we need something to handle "nsINode* -> Foo*", "const nsINode* -> const Foo*", "const RefPtr<nsINode> -> Foo*" (no const on the return type here).  I don't think the rvalue proposal does that (and in particular it fails to compile as-is when "const nsIContent*" is the ArgType; I did try it before ending up with the thing I have now).
Flags: needinfo?(nika)
Attachment #8960952 - Flags: review?(nika)
Attachment #8960772 - Attachment is obsolete: true
Attachment #8960952 - Flags: review?(nika) → review+
Pushed by
part 1.  Rename FromContent on various DOM classes to FromNode.  r=mystor
part 2.  Rename the NS_IMPL_FROMCONTENT macros to NS_IMPL_FROMNODE.  r=mystor
part 3.  Add some FromNode overloads for different arg types.  r=mystor
Depends on: 1447940
Flags: needinfo?(nika)
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.