Rename FromContent to FromNode

RESOLVED FIXED in Firefox 61

Status

()

enhancement
RESOLVED FIXED
Last year
5 months ago

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Tracking

unspecified
mozilla61
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox61 fixed)

Details

Attachments

(3 attachments, 1 obsolete attachment)

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.
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 #8960772 - Attachment is obsolete: true
Attachment #8960952 - Flags: review?(nika) → review+
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/eb4e6e094d20
part 1.  Rename FromContent on various DOM classes to FromNode.  r=mystor
https://hg.mozilla.org/integration/mozilla-inbound/rev/fd041053a1b5
part 2.  Rename the NS_IMPL_FROMCONTENT macros to NS_IMPL_FROMNODE.  r=mystor
https://hg.mozilla.org/integration/mozilla-inbound/rev/7db110ae9111
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.