servo / html5ever

High-performance browser-grade HTML5 parser
Other
2.14k stars 222 forks source link

Remove mutability from parser/tokenizer APIs. #548

Closed jdm closed 2 months ago

jdm commented 3 months ago

This is incompatible with a re-entrant parsing algorithm which is required by the web platform's document.write API.

jdm commented 3 months ago

FYI @Taym95

Taym95 commented 3 months ago

FYI @Taym95

Thanks, Should I close the other PR? lets me knew is you need help here in clean up.

jdm commented 3 months ago

FYI @Taym95

Thanks, Should I close the other PR? lets me knew is you need help here in clean up.

We can still merge the other PR, but we should remove all uses of &mut BufferQueue from the codebase in it (and uses like &mut input).

jdm commented 2 months ago

Ok, the code's cleaned up and commits are split into:

  1. mechanical changes - lots of removing &mut self from methods and adding Cell/RefCell
  2. new APIs needed by https://github.com/servo/servo/pull/32820
  3. functional changes - the TreeSink API for obtaining an element's name relies on borrowed data in ways that do not play nicely with naive usage of RefCell to store the element name data (ExpandedName docs)
  4. (and remaining commits) getting CI to pass
jdm commented 2 months ago

@Taym95 Would you like to review this?