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 window indexed getter #20615
Changes from all commits
4383b30
0806000
249e8a5
acd4e21
df23f90
File filter...
Jump to…
| @@ -1231,6 +1231,15 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> | ||
| warn!("Sending reply to get parent info failed ({:?}).", e); | ||
| } | ||
| } | ||
| FromScriptMsg::GetChildBrowsingContextId(browsing_context_id, index, sender) => { | ||
| // We increment here because the 0th element is the parent browsing context itself | ||
| let result = self.all_descendant_browsing_contexts_iter(browsing_context_id) | ||
| .nth(index + 1) | ||
KiChjang
Author
Member
|
||
| .map(|bc| bc.id); | ||
| if let Err(e) = sender.send(result) { | ||
| warn!("Sending reply to get child browsing context ID failed ({:?}).", e); | ||
| } | ||
| } | ||
| FromScriptMsg::RegisterServiceWorker(scope_things, scope) => { | ||
| debug!("constellation got store registration scope message"); | ||
| self.handle_register_serviceworker(scope_things, scope); | ||
| @@ -17,11 +17,12 @@ use dom::element::Element; | ||
| use dom::globalscope::GlobalScope; | ||
| use dom::window::Window; | ||
| use dom_struct::dom_struct; | ||
| use ipc_channel::ipc; | ||
| use js::JSCLASS_IS_GLOBAL; | ||
| use js::glue::{CreateWrapperProxyHandler, ProxyTraps}; | ||
| use js::glue::{GetProxyPrivate, SetProxyExtra, GetProxyExtra}; | ||
| use js::jsapi::{JSAutoCompartment, JSContext, JSErrNum, JSFreeOp, JSObject}; | ||
| use js::jsapi::{JSPROP_READONLY, JSTracer, JS_DefinePropertyById}; | ||
| use js::jsapi::{JSPROP_ENUMERATE, JSPROP_READONLY, JSTracer, JS_DefinePropertyById}; | ||
| use js::jsapi::{JS_ForwardGetPropertyTo, JS_ForwardSetPropertyTo}; | ||
| use js::jsapi::{JS_HasPropertyById, JS_HasOwnPropertyById}; | ||
| use js::jsapi::{JS_IsExceptionPending, JS_GetOwnPropertyDescriptorById}; | ||
| @@ -40,6 +41,8 @@ use js::rust::wrappers::{NewWindowProxy, SetWindowProxy, JS_TransplantObject}; | ||
| use msg::constellation_msg::BrowsingContextId; | ||
| use msg::constellation_msg::PipelineId; | ||
| use msg::constellation_msg::TopLevelBrowsingContextId; | ||
| use script_thread::ScriptThread; | ||
| use script_traits::ScriptMsg; | ||
| use std::cell::Cell; | ||
| use std::ptr; | ||
|
|
||
| @@ -301,17 +304,45 @@ impl WindowProxy { | ||
|
|
||
| // This is only called from extern functions, | ||
| // there's no use using the lifetimed handles here. | ||
| // https://html.spec.whatwg.org/multipage/#accessing-other-browsing-contexts | ||
| #[allow(unsafe_code)] | ||
| unsafe fn GetSubframeWindow(cx: *mut JSContext, | ||
| proxy: RawHandleObject, | ||
| id: RawHandleId) | ||
| -> Option<DomRoot<Window>> { | ||
| unsafe fn GetSubframeWindowProxy( | ||
| cx: *mut JSContext, | ||
| proxy: RawHandleObject, | ||
| id: RawHandleId | ||
| ) -> Option<(DomRoot<WindowProxy>, u32)> { | ||
KiChjang
Author
Member
|
||
| let index = get_array_index_from_id(cx, Handle::from_raw(id)); | ||
| if let Some(index) = index { | ||
| rooted!(in(cx) let target = GetProxyPrivate(*proxy).to_object()); | ||
| let win = root_from_handleobject::<Window>(target.handle()).unwrap(); | ||
| let mut found = false; | ||
| return win.IndexedGetter(index, &mut found); | ||
| if let Ok(win) = root_from_handleobject::<Window>(target.handle()) { | ||
| let browsing_context_id = win.window_proxy().browsing_context_id(); | ||
| let (result_sender, result_receiver) = ipc::channel().unwrap(); | ||
|
|
||
| let _ = win.upcast::<GlobalScope>().script_to_constellation_chan().send( | ||
| ScriptMsg::GetChildBrowsingContextId( | ||
| browsing_context_id, | ||
| index as usize, | ||
| result_sender | ||
| ) | ||
| ); | ||
| return result_receiver.recv().ok() | ||
| .and_then(|maybe_bcid| maybe_bcid) | ||
| .and_then(ScriptThread::find_window_proxy) | ||
| .map(|proxy| (proxy, JSPROP_ENUMERATE | JSPROP_READONLY)); | ||
asajeffrey
Member
|
||
| } else if let Ok(win) = root_from_handleobject::<DissimilarOriginWindow>(target.handle()) { | ||
| let browsing_context_id = win.window_proxy().browsing_context_id(); | ||
| let (result_sender, result_receiver) = ipc::channel().unwrap(); | ||
|
|
||
| let _ = win.global().script_to_constellation_chan().send(ScriptMsg::GetChildBrowsingContextId( | ||
| browsing_context_id, | ||
| index as usize, | ||
| result_sender | ||
| )); | ||
| return result_receiver.recv().ok() | ||
| .and_then(|maybe_bcid| maybe_bcid) | ||
| .and_then(ScriptThread::find_window_proxy) | ||
| .map(|proxy| (proxy, JSPROP_READONLY)); | ||
| } | ||
| } | ||
|
|
||
| None | ||
| @@ -323,12 +354,12 @@ unsafe extern "C" fn getOwnPropertyDescriptor(cx: *mut JSContext, | ||
| id: RawHandleId, | ||
| mut desc: RawMutableHandle<PropertyDescriptor>) | ||
| -> bool { | ||
| let window = GetSubframeWindow(cx, proxy, id); | ||
| if let Some(window) = window { | ||
| let window = GetSubframeWindowProxy(cx, proxy, id); | ||
| if let Some((window, attrs)) = window { | ||
| rooted!(in(cx) let mut val = UndefinedValue()); | ||
| window.to_jsval(cx, val.handle_mut()); | ||
| desc.value = val.get(); | ||
| fill_property_descriptor(MutableHandle::from_raw(desc), proxy.get(), JSPROP_READONLY); | ||
| fill_property_descriptor(MutableHandle::from_raw(desc), proxy.get(), attrs); | ||
| return true; | ||
| } | ||
|
|
||
| @@ -372,7 +403,7 @@ unsafe extern "C" fn has(cx: *mut JSContext, | ||
| id: RawHandleId, | ||
| bp: *mut bool) | ||
| -> bool { | ||
| let window = GetSubframeWindow(cx, proxy, id); | ||
| let window = GetSubframeWindowProxy(cx, proxy, id); | ||
| if window.is_some() { | ||
| *bp = true; | ||
| return true; | ||
| @@ -395,8 +426,8 @@ unsafe extern "C" fn get(cx: *mut JSContext, | ||
| id: RawHandleId, | ||
| vp: RawMutableHandleValue) | ||
| -> bool { | ||
| let window = GetSubframeWindow(cx, proxy, id); | ||
| if let Some(window) = window { | ||
| let window = GetSubframeWindowProxy(cx, proxy, id); | ||
| if let Some((window, _attrs)) = window { | ||
| window.to_jsval(cx, MutableHandle::from_raw(vp)); | ||
| return true; | ||
| } | ||
This file was deleted.
| @@ -1,13 +1,7 @@ | ||
| [elementsFromPoint.html] | ||
| [co-ordinates larger than the viewport from in iframe] | ||
| expected: FAIL | ||
|
|
||
| type: testharness | ||
| [SVG element at x,y] | ||
| expected: FAIL | ||
|
|
||
| [transformed element at x,y] | ||
| expected: FAIL | ||
|
|
||
| [no hit target at x,y] | ||
| expected: FAIL | ||
|
|
| @@ -1,5 +1,20 @@ | ||
| [matchMedia.xht] | ||
| type: testharness | ||
| [CSS Test: CSSOM View matchMedia and MediaQueryList] | ||
| expected: TIMEOUT | ||
| [window.matchMedia exists] | ||
| expected: FAIL | ||
| [MediaQueryList.matches for "(max-width: 199px), all and (min-width: 200px)"] | ||
| expected: FAIL | ||
| [MediaQueryList.matches for "(min-aspect-ratio: 1/1)"] | ||
| expected: FAIL | ||
| [MediaQueryList.matches for "(width: 200px)"] | ||
| expected: FAIL | ||
| [MediaQueryList.matches for "(min-width: 150px)"] | ||
| expected: FAIL | ||
| [Resize iframe from 200x100 to 200x50, then to 100x50] | ||
KiChjang
Author
Member
|
||
| expected: NOTRUN | ||
| [Listeners are called in the order which they have been added] | ||
| expected: NOTRUN | ||
| [Listener added twice is only called once.] | ||
| expected: NOTRUN | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Doesn't this return the nth descendant rather than the nth child?