mirror of
https://github.com/servo/servo.git
synced 2025-06-24 09:04:33 +01:00
Pass &JS<Window> to some constructors.
This commit is contained in:
parent
b6138580d3
commit
6291aac170
11 changed files with 29 additions and 24 deletions
|
@ -43,22 +43,22 @@ impl Attr {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(window: &Window, local_name: DOMString, value: DOMString) -> JS<Attr> {
|
||||
pub fn new(window: &JS<Window>, local_name: DOMString, value: DOMString) -> JS<Attr> {
|
||||
let name = local_name.clone();
|
||||
Attr::new_helper(window, local_name, value, name, Null, None)
|
||||
}
|
||||
|
||||
pub fn new_ns(window: &Window, local_name: DOMString, value: DOMString,
|
||||
pub fn new_ns(window: &JS<Window>, local_name: DOMString, value: DOMString,
|
||||
name: DOMString, namespace: Namespace,
|
||||
prefix: Option<DOMString>) -> JS<Attr> {
|
||||
Attr::new_helper(window, local_name, value, name, namespace, prefix)
|
||||
}
|
||||
|
||||
fn new_helper(window: &Window, local_name: DOMString, value: DOMString,
|
||||
fn new_helper(window: &JS<Window>, local_name: DOMString, value: DOMString,
|
||||
name: DOMString, namespace: Namespace,
|
||||
prefix: Option<DOMString>) -> JS<Attr> {
|
||||
let attr = Attr::new_inherited(local_name, value, name, namespace, prefix);
|
||||
reflect_dom_object(~attr, window, AttrBinding::Wrap)
|
||||
reflect_dom_object(~attr, window.get(), AttrBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn set_value(&mut self, value: DOMString) {
|
||||
|
|
|
@ -85,6 +85,11 @@ DOMInterfaces = {
|
|||
'ValidityState': {},
|
||||
'Window': {
|
||||
'createGlobal': True,
|
||||
'needsAbstract': [
|
||||
'console',
|
||||
'location',
|
||||
'navigator',
|
||||
],
|
||||
},
|
||||
|
||||
'WindowProxy': {},
|
||||
|
|
|
@ -20,8 +20,8 @@ impl Console {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(window: &Window) -> JS<Console> {
|
||||
reflect_dom_object(~Console::new_inherited(), window, ConsoleBinding::Wrap)
|
||||
pub fn new(window: &JS<Window>) -> JS<Console> {
|
||||
reflect_dom_object(~Console::new_inherited(), window.get(), ConsoleBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn Log(&self, message: DOMString) {
|
||||
|
|
|
@ -48,8 +48,8 @@ impl DOMException {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(window: &Window, code: DOMErrorName) -> JS<DOMException> {
|
||||
reflect_dom_object(~DOMException::new_inherited(code), window, DOMExceptionBinding::Wrap)
|
||||
pub fn new(window: &JS<Window>, code: DOMErrorName) -> JS<DOMException> {
|
||||
reflect_dom_object(~DOMException::new_inherited(code), window.get(), DOMExceptionBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ impl Element {
|
|||
None => {
|
||||
let doc = self.node.owner_doc();
|
||||
let doc = doc.get();
|
||||
let new_attr = Attr::new_ns(doc.window.get(), local_name.clone(), value.clone(),
|
||||
let new_attr = Attr::new_ns(&doc.window, local_name.clone(), value.clone(),
|
||||
name.clone(), namespace.clone(),
|
||||
prefix);
|
||||
self.attrs.push(new_attr);
|
||||
|
|
|
@ -41,9 +41,9 @@ impl Location {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(window: &Window, page: Rc<Page>) -> JS<Location> {
|
||||
pub fn new(window: &JS<Window>, page: Rc<Page>) -> JS<Location> {
|
||||
reflect_dom_object(~Location::new_inherited(page),
|
||||
window,
|
||||
window.get(),
|
||||
LocationBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ impl Navigator {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(window: &Window) -> JS<Navigator> {
|
||||
pub fn new(window: &JS<Window>) -> JS<Navigator> {
|
||||
reflect_dom_object(~Navigator::new_inherited(),
|
||||
window,
|
||||
window.get(),
|
||||
NavigatorBinding::Wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -31,18 +31,18 @@ impl NodeList {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(window: JS<Window>,
|
||||
pub fn new(window: &JS<Window>,
|
||||
list_type: NodeListType) -> JS<NodeList> {
|
||||
reflect_dom_object(~NodeList::new_inherited(window.clone(), list_type),
|
||||
window.get(), NodeListBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn new_simple_list(window: &JS<Window>, elements: ~[JS<Node>]) -> JS<NodeList> {
|
||||
NodeList::new(window.clone(), Simple(elements))
|
||||
NodeList::new(window, Simple(elements))
|
||||
}
|
||||
|
||||
pub fn new_child_list(window: &JS<Window>, node: &JS<Node>) -> JS<NodeList> {
|
||||
NodeList::new(window.clone(), Children(node.clone()))
|
||||
NodeList::new(window, Children(node.clone()))
|
||||
}
|
||||
|
||||
pub fn Length(&self) -> u32 {
|
||||
|
|
|
@ -175,23 +175,23 @@ impl Window {
|
|||
None
|
||||
}
|
||||
|
||||
pub fn Location(&mut self) -> JS<Location> {
|
||||
pub fn Location(&mut self, abstract_self: &JS<Window>) -> JS<Location> {
|
||||
if self.location.is_none() {
|
||||
self.location = Some(Location::new(self, self.extra.page.clone()));
|
||||
self.location = Some(Location::new(abstract_self, self.extra.page.clone()));
|
||||
}
|
||||
self.location.get_ref().clone()
|
||||
}
|
||||
|
||||
pub fn Console(&mut self) -> JS<Console> {
|
||||
pub fn Console(&mut self, abstract_self: &JS<Window>) -> JS<Console> {
|
||||
if self.console.is_none() {
|
||||
self.console = Some(Console::new(self));
|
||||
self.console = Some(Console::new(abstract_self));
|
||||
}
|
||||
self.console.get_ref().clone()
|
||||
}
|
||||
|
||||
pub fn Navigator(&mut self) -> JS<Navigator> {
|
||||
pub fn Navigator(&mut self, abstract_self: &JS<Window>) -> JS<Navigator> {
|
||||
if self.navigator.is_none() {
|
||||
self.navigator = Some(Navigator::new(self));
|
||||
self.navigator = Some(Navigator::new(abstract_self));
|
||||
}
|
||||
self.navigator.get_ref().clone()
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ pub struct WindowProxy {
|
|||
}
|
||||
|
||||
impl WindowProxy {
|
||||
pub fn new(owner: JS<Window>) -> JS<WindowProxy> {
|
||||
pub fn new(owner: &JS<Window>) -> JS<WindowProxy> {
|
||||
let proxy = ~WindowProxy {
|
||||
reflector_: Reflector::new()
|
||||
};
|
||||
|
|
|
@ -984,7 +984,7 @@ impl ScriptTask {
|
|||
Some(ref frame) => {
|
||||
// http://dev.w3.org/csswg/cssom-view/#resizing-viewports
|
||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-resize
|
||||
let window_proxy: JS<WindowProxy> = WindowProxy::new(frame.window.clone());
|
||||
let window_proxy: JS<WindowProxy> = WindowProxy::new(&frame.window);
|
||||
let mut uievent = UIEvent::new(&frame.window);
|
||||
uievent.get_mut().InitUIEvent(~"resize", false, false, Some(window_proxy), 0i32);
|
||||
let event: &mut JS<Event> = &mut EventCast::from(&uievent);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue