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

Support mozbrowsericonchange event (Browser API) #8347

Closed
paulrouget opened this issue Nov 5, 2015 · 9 comments · Fixed by #8449
Closed

Support mozbrowsericonchange event (Browser API) #8347

paulrouget opened this issue Nov 5, 2015 · 9 comments · Fixed by #8449
Labels
A-constellation Involves the constellation A-content/dom Interacting with the DOM from web content

Comments

@paulrouget
Copy link
Contributor

No description provided.

@paulrouget
Copy link
Contributor Author

I'm giving it a try: paulrouget@97cee8b

At the moment, we are limited by the event.detail property. It only supports strings (see https://github.com/servo/servo/blob/master/components/script/dom/htmliframeelement.rs#L133).

@glennw what would you recommend here? MozBrowserEvent::detail() returns a string. Maybe it should return a json-like data structure (hashmap?) that would be converted to jsval in HTMLIframeElement::dispatch_mozbrowser_event() ? But I'm not sure a hashmap is good enough. Do we have a generic JSON-like structure in Rust/Servo? Or should we translate to a jsval directly in MozBrowserEvent::detail()?

@jdm
Copy link
Member

jdm commented Nov 5, 2015

We have two JSON representations (first, second), but I propose making detail() take a MutHandleValue argument and directly converting the values rather than having a rust-typed common return.

@tetsuharuohzeki tetsuharuohzeki added A-content/dom Interacting with the DOM from web content A-constellation Involves the constellation labels Nov 6, 2015
@paulrouget
Copy link
Contributor Author

@jdm I'm trying to use to_jsval in msg/constellation_msg.rs, so I guess I need use script::dom::bindings::conversions::{ToJSValConvertible}; which requires the script crate. Adding the script dependency in msg end up with a cyclic package dependency:

cyclic package dependency: package `devtools_traits v0.0.1 (file:///Users/paul/git/servo/components/servo)` depends on itself

What's the right approach in this case?

@eefriedman
Copy link
Contributor

I'm trying to use to_jsval in msg/constellation_msg.rs

Don't do that. You shouldn't be handling a JSContext outside of the script crate/thread.

@jdm
Copy link
Member

jdm commented Nov 6, 2015

The right approach is to make 'detail' a method of a trait that's defined in the script crate.

@paulrouget
Copy link
Contributor Author

moving detail into the script crate works, but I'm having difficulties building the JS object.

  • Should I build the object manually with RootedObject::new and JS_DefineProperty (or define_properties)?
  • Should I build the object via to_jsval? This might require adding a new conversion method conversions.rs
  • Would creating a BrowserIconChangeEventDetail interface in BrowserElement.webidl help in any way?

@jdm
Copy link
Member

jdm commented Nov 9, 2015

Creating a BrowserIconChangeEventDetail dictionary is probably the way to go, rather than an interface. That should allow us to fill out the properties of the corresponding Rust object and then calling to_jsval.

@paulrouget
Copy link
Contributor Author

feedback? paulrouget@2f5fa1b

Does this look like the right approach?

Still need to do some clean-up, address the fixme, and write some tests

@jdm
Copy link
Member

jdm commented Nov 9, 2015

It does!

bors-servo pushed a commit that referenced this issue Nov 12, 2015
mozbrowsericonchange event (Browser API)

fixes #8347

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8449)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this issue Nov 14, 2015
mozbrowsericonchange event (Browser API)

fixes #8347

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8449)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this issue Nov 14, 2015
mozbrowsericonchange event (Browser API)

fixes #8347

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8449)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-constellation Involves the constellation A-content/dom Interacting with the DOM from web content
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants