Closed Bug 1473771 Opened 6 years ago Closed 6 years ago

make LinkedList work better when its element type inherits from multiple LinkedListElement<T>s

Categories

(Core :: MFBT, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: heycam, Assigned: heycam)

References

Details

Attachments

(2 files)

Currently mozilla::dom::MediaQueryList inherits from both LinkedListElement<DOMEventTargetHelper> and LinkedListElement<MediaQueryList>.  This causes some ambiguous name lookups from some LinkedList member functions.  We can make them work with some static_cast<>s.
Assignee: nobody → cam
Status: NEW → ASSIGNED
For the Iterator patch, I was considering whether to leave just a single type parameter on Iterator, and to derive whether we use a const or non-const LinkedListElement<> pointer when static_cast<>ing.  The long std::conditional<> stuff looked a bit ugly though so it was simpler just to pass in the right type to use.
Blocks: 1473735
Comment on attachment 8990166 [details]
Bug 1473771 - Part 2: Make LinkedList::Iterator work when element type inherits from multiple LinkedListElement<T>s.

https://reviewboard.mozilla.org/r/255184/#review262346

::: mfbt/LinkedList.h:436
(Diff revision 1)
>      const Iterator& operator++() {
> -      mCurrent = mCurrent->getNext();
> +      mCurrent = static_cast<Element>(mCurrent)->getNext();
>        return *this;
>      }
>  
> -    bool operator!=(const Iterator<Type>& aOther) const {
> +    bool operator!=(const Iterator<Type, Element>& aOther) const {

Just use `const Iterator& aOther` -- the type parameters are assumed if you don't provide them, here.
Attachment #8990166 - Flags: review?(jwalden+bmo) → review+
Comment on attachment 8990165 [details]
Bug 1473771 - Part 1: Make LinkedList<T>::sizeOfExcludingThis work when element type inherits from multiple LinkedListElement<T>s.

https://reviewboard.mozilla.org/r/255182/#review262340

I'm super-dubious about the desirability of multiply inheriting LinkedListElement, but this isn't really precisely *extra* code to deal with that, so.  Bleh.
Attachment #8990165 - Flags: review?(jwalden+bmo) → review+
Pushed by cam@mcc.id.au:
https://hg.mozilla.org/integration/autoland/rev/56cf99e809bd
Part 1: Make LinkedList<T>::sizeOfExcludingThis work when element type inherits from multiple LinkedListElement<T>s. r=Waldo
https://hg.mozilla.org/integration/autoland/rev/f05677e4a0f7
Part 2: Make LinkedList::Iterator work when element type inherits from multiple LinkedListElement<T>s. r=Waldo
https://hg.mozilla.org/mozilla-central/rev/56cf99e809bd
https://hg.mozilla.org/mozilla-central/rev/f05677e4a0f7
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: