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

Implement ResizeObserver #31006

Open
gterzian opened this issue Jan 5, 2024 · 2 comments · May be fixed by #31108
Open

Implement ResizeObserver #31006

gterzian opened this issue Jan 5, 2024 · 2 comments · May be fixed by #31108
Assignees
Labels
A-content/css Interacting with CSS from web content (parsing, serializing, introspection) A-content/dom Interacting with the DOM from web content A-content/script Related to the script thread B-interesting-project Represents work that is expected to be interesting in some fashion E-candidate-for-mentoring E-very-complex Very difficult. Do not attempt without significant relevant experience and motivation.

Comments

@gterzian
Copy link
Member

gterzian commented Jan 5, 2024

Needed for #30822

Spec: https://drafts.csswg.org/resize-observer/#resize-observer-interface

One would have to add a new WebIDL(see components/script/dom/webidl), and expose the interface on Window.

And then implement it in a new components/script/dom/resizeobserver.rs file. The WebIDL interface methods will be generated automatically and can be imported as use crate::dom::bindings::codegen::Bindings::<interface name>

For the callback part, components/script/dom/eventtarget.rs is probably a good place to look for inspiration.

@gterzian gterzian added A-content/css Interacting with CSS from web content (parsing, serializing, introspection) B-interesting-project Represents work that is expected to be interesting in some fashion A-content/script Related to the script thread E-candidate-for-mentoring A-content/dom Interacting with the DOM from web content E-very-complex Very difficult. Do not attempt without significant relevant experience and motivation. labels Jan 5, 2024
@gterzian
Copy link
Member Author

@mrobinson In order to implement the various calculations at https://drafts.csswg.org/resize-observer/#calculate-box-size-h one would have to use the LayoutRPC found on Window, right?

Some of these may have already been implemented:

pub fn bounding_content_box(&self) -> Option<Rect<Au>> {

seems to match https://www.w3.org/TR/SVG2/coords.html#BoundingBoxes

pub fn bounding_content_box(&self) -> Option<Rect<Au>> {

seems to match https://drafts.csswg.org/css-box-3/#content-area

Not sure if we have anything for https://drafts.csswg.org/css-box-4/#border-area

@gterzian
Copy link
Member Author

Note: integration with the event loop happens(among others), via https://html.spec.whatwg.org/#event-loop-processing-model:broadcast-active-resize-observations

@gterzian gterzian mentioned this issue Jan 12, 2024
4 tasks
@gterzian gterzian self-assigned this Jan 16, 2024
@gterzian gterzian linked a pull request Jan 17, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/css Interacting with CSS from web content (parsing, serializing, introspection) A-content/dom Interacting with the DOM from web content A-content/script Related to the script thread B-interesting-project Represents work that is expected to be interesting in some fashion E-candidate-for-mentoring E-very-complex Very difficult. Do not attempt without significant relevant experience and motivation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant