Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider killing the TreeBuilderActions trait and its ilk #258

Closed
nox opened this issue Mar 14, 2017 · 15 comments
Closed

Consider killing the TreeBuilderActions trait and its ilk #258

nox opened this issue Mar 14, 2017 · 15 comments
Labels

Comments

@nox
Copy link
Contributor

nox commented Mar 14, 2017

They are only there for namespacing reasons.

@Ygg01
Copy link
Contributor

Ygg01 commented Mar 16, 2017

What changes does this entail? Just moving methods from TreeBuilderActions/TreeBuilderStep to TreeBuilder, correct?

@nox
Copy link
Contributor Author

nox commented Mar 16, 2017

Yep.

@Ygg01
Copy link
Contributor

Ygg01 commented Mar 17, 2017

This task seems trivial. Do you guys want to nominate this for Servo starter tasks? Or is html5ever outside of scope for such tasks?

PS. Whoever fixes TreeBuilderActions, could also fix xml5ever, as well.

@nox
Copy link
Contributor Author

nox commented Mar 17, 2017

Yes this should be made into an E-Easy issue.

@jdm
Copy link
Member

jdm commented Mar 20, 2017

Currently, these traits are only used for namespacing (see servo/html5ever#258).

This task entails:

* removing traits TreeBuilderActions/TreeBuilderStep/XmlTreeBuilderActions/XmlTreeBuilderStep
* moving implementations of above traits into TreeBuilder/XmlTreeBuilder structs.
* fixing any breaks this causes in project.

I think this could make a great first issue, for new comers.

@jdm jdm added the E-easy label Mar 20, 2017
@Januson
Copy link

Januson commented Mar 24, 2017

Hello. I would like to contribute. May I take this issue?

@jdm
Copy link
Member

jdm commented Mar 24, 2017

@Januson Please do! Ask questions if anything is unclear.

@jdm jdm added the C-assigned label Mar 24, 2017
@Januson
Copy link

Januson commented Mar 25, 2017

Thank you. I have a question about visibility. If I understand current code correctly, methods from TreeBuilderStep and TreeBuilderActions traits are private to the tree_builder mod.

First idea how to get gid of these traits was to just copy them to TreeBuilder. But I figured that is a bad idea since tree_builder/mod.rs would grow past 3k lines. So keeping them separate I run into problem with visibility as private impl method in actions.rs is not visible in tree_builder/mod.rs but public method is visible everywhere.

Is there any other way? Or am I missing something? So far I found only a SO question and this issue.

@Ygg01
Copy link
Contributor

Ygg01 commented Mar 27, 2017

@Januson I don't think having a file past 3k lines is an issue, in itself? Maybe @nox could weigh in?

@Januson
Copy link

Januson commented Apr 4, 2017

Hello again. Ihave another question. I moved most of the required methods but I am struggling with methods from TreeBuilderStep. I can't figure out how to use match_token! macro outside of tree_builder/rules.rs. It is somehow generated in macros/match_token.rs and build.rs. How can I make it visible for methods in tree_builder/mod.rs?

@SimonSapin
Copy link
Member

That sounds tricky. Can you move the relevant code into rules.rs? Or maybe a new module under tree_builder/?

@SimonSapin
Copy link
Member

If want to go with the latter, add a new call to expand_match_tokens in build.rs, and in src/tree_builder/mod.rs instead of mod foo; for the new module use include! like for rules.rs.

@Januson
Copy link

Januson commented Apr 19, 2017

Thank you for suggestion. I thought about splitting it into methods, so that functionality using match_token macro stays in rules module. But I think that would be too cumbersome splitting and I fear it would be beyond my current Rust skills. Other thing I thought of was to extend TreeBuilder with the methods of TreeBuilderStep but that would make those methods visible outside of TreeBuilder. I don't know if this is a problem. I don't know how to proceed with this last trait.

@jbg
Copy link
Contributor

jbg commented Jun 4, 2017

I made a pull request implementing these changes, feedback would be appreciated!

bors-servo pushed a commit that referenced this issue Aug 9, 2017
Remove [Xml]TreeBuilderActions and [Xml]TreeBuilderStep and move their implementations into [Xml]TreeBuilder

See issue #258

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/html5ever/274)
<!-- Reviewable:end -->
@Ygg01
Copy link
Contributor

Ygg01 commented Aug 9, 2017

@jbg Congrats! Your change is implemented and this bug can be closed :D

@jdm jdm closed this as completed Aug 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants