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

xilem_html: Add MathML and SVG elements/DOM interface traits #153

Conversation

Philipp-M
Copy link
Contributor

This adds all remaining elements that are allowed in an HTML body (to my knowledge). There are still elements missing that aren't allowed in the body (such as <head>), not sure whether it makes sense to add support for them too...
(And deprecated elements, but I don't think it makes sense to add them)

This means all MathML elements and (raw) SVG elements.
Additionally this adds an example of the Pythagorean theorem showing raw MathML and SVG in action.

The SVG DOM interfaces are generated out of webidl files (the ones used in web_sys), the SVG elements were taken from here.

@@ -340,7 +340,7 @@ event_definitions!(
(OnFocusIn, "focusin", FocusEvent),
(OnFocusOut, "focusout", FocusEvent),
(OnFormData, "formdata", Event),
(OnInput, "input", InputEvent),
(OnInput, "input", Event),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah HTML/DOM is pulling my hair out...

For some reason <input type=range> uses the Event interface instead of InputEvent when using on_input, so that's the reason, why this takes the general Event type...

@@ -0,0 +1,4 @@
<!DOCTYPE html>
<title>Pythagorean theorem</title>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this doesn't need a head - I thought <!DOCTYPE html> enabled HTML 5, which required a <head> element

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was interested, what the minimum required valid HTML is, and it seems, that just a <title> is required.

But this will be transformed anyway by trunk, so the generated html looks more typical.

@nicoburns
Copy link
Contributor

The SVG DOM interfaces are generated out of webidl files (the ones used in web_sys)

How was the generation done? IMO it would be good to include the generation script in the PR / repo too. Such that the types can be easily updated in future if needed.

@Philipp-M
Copy link
Contributor Author

Actually a super quick n dirty hack using weedle and concatenating the interfaces together in a string. I don't think it's worth or beneficial to add an extra script. I expect that it it will be extended manually (I just wanted to be thorough, and mirror web_sys).

But if there's real need I can put it online somewhere.

Copy link
Contributor

@richard-uk1 richard-uk1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'm excited to have a go with non-html elements.

@Philipp-M Philipp-M added this pull request to the merge queue Nov 28, 2023
@richard-uk1
Copy link
Contributor

I personally don't think we need to go into webidl land - there aren't as many elements as there are webidl interfaces.

Merged via the queue into linebender:main with commit 5b3de31 Nov 28, 2023
7 checks passed
@Philipp-M
Copy link
Contributor Author

Yes that's my thinking too, I just used it, because I started with something else previously (which was discarded), and it was just a low hanging fruit to adopt it to quickly generate all the DOM interfaces (was also good to check whether the rest of the code is correct via static analysis).

@Philipp-M Philipp-M deleted the xilem_html-add-mathml-and-svg-dom-interfaces branch November 28, 2023 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants