mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
[Browser API] implement mozbrowsericonchange event
This commit is contained in:
parent
27e104aa1a
commit
5263a4c4c9
8 changed files with 154 additions and 25 deletions
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::attr::{Attr, AttrValue};
|
||||
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementIconChangeEventDetail;
|
||||
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
|
@ -21,8 +22,8 @@ use dom::node::{Node, window_from_node};
|
|||
use dom::urlhelper::UrlHelper;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom::window::Window;
|
||||
use js::jsapi::{JSAutoCompartment, JSAutoRequest, RootedValue};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::jsapi::{JSAutoCompartment, JSAutoRequest, RootedValue, JSContext, MutableHandleValue};
|
||||
use js::jsval::{UndefinedValue, NullValue};
|
||||
use msg::constellation_msg::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
|
||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||
use msg::constellation_msg::{ConstellationChan, IframeLoadInfo, MozBrowserEvent};
|
||||
|
@ -143,9 +144,10 @@ impl HTMLIFrameElement {
|
|||
let _ar = JSAutoRequest::new(cx);
|
||||
let _ac = JSAutoCompartment::new(cx, window.reflector().get_jsobject().get());
|
||||
let mut detail = RootedValue::new(cx, UndefinedValue());
|
||||
event.detail().to_jsval(cx, detail.handle_mut());
|
||||
let event_name = DOMString::from(event.name().to_owned());
|
||||
self.build_mozbrowser_event_detail(event, cx, detail.handle_mut());
|
||||
CustomEvent::new(GlobalRef::Window(window.r()),
|
||||
DOMString::from(event.name()),
|
||||
event_name,
|
||||
true,
|
||||
true,
|
||||
detail.handle())
|
||||
|
@ -225,6 +227,41 @@ impl HTMLIFrameElementLayoutMethods for LayoutJS<HTMLIFrameElement> {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait MozBrowserEventDetailBuilder {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn build_mozbrowser_event_detail(&self,
|
||||
event: MozBrowserEvent,
|
||||
cx: *mut JSContext,
|
||||
rval: MutableHandleValue);
|
||||
}
|
||||
|
||||
impl MozBrowserEventDetailBuilder for HTMLIFrameElement {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn build_mozbrowser_event_detail(&self,
|
||||
event: MozBrowserEvent,
|
||||
cx: *mut JSContext,
|
||||
rval: MutableHandleValue) {
|
||||
match event {
|
||||
MozBrowserEvent::AsyncScroll | MozBrowserEvent::Close | MozBrowserEvent::ContextMenu |
|
||||
MozBrowserEvent::Error | MozBrowserEvent::LoadEnd | MozBrowserEvent::LoadStart |
|
||||
MozBrowserEvent::OpenWindow | MozBrowserEvent::SecurityChange | MozBrowserEvent::OpenSearch |
|
||||
MozBrowserEvent::ShowModalPrompt | MozBrowserEvent::UsernameAndPasswordRequired => {
|
||||
rval.set(NullValue());
|
||||
}
|
||||
MozBrowserEvent::LocationChange(ref string) | MozBrowserEvent::TitleChange(ref string) => {
|
||||
string.to_jsval(cx, rval);
|
||||
}
|
||||
MozBrowserEvent::IconChange(rel, href, sizes) => {
|
||||
BrowserElementIconChangeEventDetail {
|
||||
rel: Some(DOMString::from(rel)),
|
||||
href: Some(DOMString::from(href)),
|
||||
sizes: Some(DOMString::from(sizes)),
|
||||
}.to_jsval(cx, rval);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> Fallible<()> {
|
||||
if iframe.Mozbrowser() {
|
||||
if iframe.upcast::<Node>().is_in_doc() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue