diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2013-11-09 21:39:39 -0800 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2013-11-18 11:24:11 -0800 |
commit | 155befe10dc56cfb2dfbf0cca7b652293dba9753 (patch) | |
tree | 43c3e51689cd42a3fb623eda84740f49dd667f5e /src/components/script/dom/bindings/utils.rs | |
parent | 37f9427b6c53b90234e82d219217a97c10811243 (diff) | |
download | servo-155befe10dc56cfb2dfbf0cca7b652293dba9753.tar.gz servo-155befe10dc56cfb2dfbf0cca7b652293dba9753.zip |
Rewrite flow construction to be incrementalizable and parallelizable.
This replaces flow construction with a strict bottom-up tree traversal,
allowing for parallelism. Each step of the traversal creates a flow or
a `ConstructionItem`, similar to how Gecko works. {ib} splits are
handled by not creating `InlineFlow`s until the containing block is
reached.
This should be able to be incrementalized by storing the `Flow` from
layout to layout, and performing fixups during flow construction
and/or wiping containing blocks in a previous pass.
Diffstat (limited to 'src/components/script/dom/bindings/utils.rs')
-rw-r--r-- | src/components/script/dom/bindings/utils.rs | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs index f79e8ae633a..b076810785a 100644 --- a/src/components/script/dom/bindings/utils.rs +++ b/src/components/script/dom/bindings/utils.rs @@ -863,26 +863,38 @@ pub fn CreateDOMGlobal(cx: *JSContext, class: *JSClass) -> *JSObject { } } +/// Returns the global object of the realm that the given JS object was created in. #[fixed_stack_segment] -fn cx_for_dom_reflector(obj: *JSObject) -> *JSContext { +fn global_object_for_js_object(obj: *JSObject) -> *Box<window::Window> { unsafe { let global = GetGlobalForObjectCrossCompartment(obj); let clasp = JS_GetClass(global); assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0); - //XXXjdm either don't hardcode or sanity assert prototype stuff - let win = unwrap_object::<*Box<window::Window>>(global, PrototypeList::id::Window, 1); - match win { - Ok(win) => { - match (*win).data.page.js_info { - Some(ref info) => info.js_context.ptr, - None => fail!("no JS context for DOM global") - } - } - Err(_) => fail!("found DOM global that doesn't unwrap to Window") + // FIXME(jdm): Either don't hardcode or sanity assert prototype stuff. + match unwrap_object::<*Box<window::Window>>(global, PrototypeList::id::Window, 1) { + Ok(win) => win, + Err(_) => fail!("found DOM global that doesn't unwrap to Window"), } } } +#[fixed_stack_segment] +fn cx_for_dom_reflector(obj: *JSObject) -> *JSContext { + unsafe { + let win = global_object_for_js_object(obj); + match (*win).data.page.js_info { + Some(ref info) => info.js_context.ptr, + None => fail!("no JS context for DOM global") + } + } +} + +/// Returns the global object of the realm that the given DOM object was created in. +#[fixed_stack_segment] +pub fn global_object_for_dom_object<T: Reflectable>(obj: &mut T) -> *Box<window::Window> { + global_object_for_js_object(obj.reflector().get_jsobject()) +} + pub fn cx_for_dom_object<T: Reflectable>(obj: &mut T) -> *JSContext { cx_for_dom_reflector(obj.reflector().get_jsobject()) } |