Closed Bug 1555216 Opened 4 months ago Closed 4 months ago

Cleanup BindToTree a bit.

Categories

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

task
Not set

Tracking

()

RESOLVED FIXED
mozilla69
Tracking Status
firefox69 --- fixed

People

(Reporter: emilio, Assigned: emilio)

References

Details

Attachments

(4 files)

Add a struct argument that can pass more information if wanted via members.

This was going to be more fancy when I initially thought about it, but as it turns out most of the information we need is already in the parent node.

This is all automatic, and thus there are some things that may break because of
this and will be fixed in the next patch.

Steps are:

$ for file in $(rg 'nsresult BindToTree(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document* aDocument, nsIContent* aParent,#nsresult BindToTree(BindContext&, nsINode& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document* aDocument, nsIContent* aParent,#::BindToTree(BindContext& aContext, nsINode& aParent)#g' $file; done
$ for file in $(rg '::BindToTree(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format

This patch is to be squashed with the previous one.

BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.

Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from three cpp files, instead of a
massive pain.

I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.

Depends on D32948

They're supposed to be, but they have diverged quite a bit...

This unifies them again.

Depends on D32949

Type: defect → task

And use it to avoid some pointer chases per the review comments of D32949.

Depends on D32950

Pushed by emilio@crisal.io:
https://hg.mozilla.org/integration/autoland/rev/1ec6f486c83f
Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
https://hg.mozilla.org/integration/autoland/rev/5ec67eb98069
Make CharacterData::BindToTree and Element::BindToTree more parallel. r=bzbarsky
https://hg.mozilla.org/integration/autoland/rev/eebaba0f3ed7
Cache owner doc in the BindContext. r=bzbarsky
Status: NEW → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla69
Regressions: 1556799
You need to log in before you can comment on or make changes to this bug.