mirror of
https://github.com/servo/servo.git
synced 2025-06-19 06:38:59 +01:00
Cleanup some code.
This commit is contained in:
parent
d99e69e244
commit
388f685549
7 changed files with 59 additions and 84 deletions
|
@ -22,9 +22,8 @@ impl Comment {
|
|||
|
||||
pub fn Constructor(owner: @mut Window, data: &DOMString) -> Fallible<AbstractNode<ScriptView>> {
|
||||
let s = null_str_as_empty(data);
|
||||
unsafe {
|
||||
let compartment = (*owner.page).js_info.get_ref().js_compartment;
|
||||
Ok(Node::as_abstract_node(compartment.cx.ptr, @Comment::new(s)))
|
||||
}
|
||||
let cx = (*owner.page).js_info.get_ref().js_compartment.cx.ptr;
|
||||
let comment = @Comment::new(s);
|
||||
Ok(unsafe { Node::as_abstract_node(cx, comment) })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,7 +258,8 @@ impl Document {
|
|||
|
||||
pub fn CreateTextNode(&self, data: &DOMString) -> AbstractNode<ScriptView> {
|
||||
let cx = self.get_cx();
|
||||
unsafe { Node::as_abstract_node(cx, @Text::new(null_str_as_empty(data))) }
|
||||
let text = @Text::new(null_str_as_empty(data));
|
||||
unsafe { Node::as_abstract_node(cx, text) }
|
||||
}
|
||||
|
||||
pub fn CreateEvent(&self, _interface: &DOMString) -> Fallible<@mut Event> {
|
||||
|
|
|
@ -277,14 +277,13 @@ impl Element {
|
|||
}
|
||||
|
||||
pub fn GetClientRects(&self, abstract_self: AbstractNode<ScriptView>) -> @mut ClientRectList {
|
||||
let (rects, cx, scope) = match self.node.owner_doc {
|
||||
Some(doc) => {
|
||||
match doc.with_base(|doc| doc.window) {
|
||||
Some(win) => {
|
||||
let document = self.node.owner_doc.expect("no document");
|
||||
let win = document.with_base(|doc| doc.window).expect("no window");
|
||||
let node = abstract_self;
|
||||
assert!(node.is_element());
|
||||
let page = win.page;
|
||||
let (port, chan) = comm::stream();
|
||||
let (rects, cx, scope) =
|
||||
match page.query_layout(ContentBoxesQuery(node, chan), port) {
|
||||
ContentBoxesResponse(rects) => {
|
||||
let cx = page.js_info.get_ref().js_compartment.cx.ptr;
|
||||
|
@ -299,30 +298,16 @@ impl Element {
|
|||
cx,
|
||||
scope)
|
||||
};
|
||||
Some((rects, cx, scope))
|
||||
(rects, cx, scope)
|
||||
},
|
||||
}
|
||||
}
|
||||
None => {
|
||||
debug!("no window");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
debug!("no document");
|
||||
None
|
||||
}
|
||||
}.unwrap();
|
||||
};
|
||||
|
||||
ClientRectList::new(rects, cx, scope)
|
||||
}
|
||||
|
||||
pub fn GetBoundingClientRect(&self, abstract_self: AbstractNode<ScriptView>) -> @mut ClientRect {
|
||||
match self.node.owner_doc {
|
||||
Some(doc) => {
|
||||
match doc.with_base(|doc| doc.window) {
|
||||
Some(win) => {
|
||||
let document = self.node.owner_doc.expect("no document");
|
||||
let win = document.with_base(|doc| doc.window).expect("no window");
|
||||
let page = win.page;
|
||||
let node = abstract_self;
|
||||
assert!(node.is_element());
|
||||
|
@ -342,12 +327,6 @@ impl Element {
|
|||
}
|
||||
}
|
||||
}
|
||||
None => fail!("no window")
|
||||
}
|
||||
}
|
||||
None => fail!("no document")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ScrollIntoView(&self, _top: bool) {
|
||||
}
|
||||
|
|
|
@ -117,9 +117,6 @@ impl HTMLFormElement {
|
|||
}
|
||||
|
||||
pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> AbstractNode<ScriptView> {
|
||||
let (_scope, cx) = self.get_scope_and_cx();
|
||||
// FIXME: This should be replaced with a proper value according to the index
|
||||
let node = @Node::new(ElementNodeTypeId(HTMLFormElementTypeId));
|
||||
unsafe { return Node::as_abstract_node(cx, node) }
|
||||
fail!("Not implemented.")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ impl Text {
|
|||
|
||||
pub fn Constructor(owner: @mut Window, text: &DOMString) -> Fallible<AbstractNode<ScriptView>> {
|
||||
let cx = owner.page.js_info.get_ref().js_compartment.cx.ptr;
|
||||
unsafe { Ok(Node::as_abstract_node(cx, @Text::new(null_str_as_empty(text)))) }
|
||||
let text = @Text::new(null_str_as_empty(text));
|
||||
Ok(unsafe { Node::as_abstract_node(cx, text) })
|
||||
}
|
||||
|
||||
pub fn SplitText(&self, _offset: u32) -> Fallible<AbstractNode<ScriptView>> {
|
||||
|
|
|
@ -291,12 +291,10 @@ pub fn build_element_from_tag(cx: *JSContext, tag: &str) -> AbstractNode<ScriptV
|
|||
handle_htmlmediaelement!(cx, tag, "audio", HTMLAudioElementTypeId, HTMLAudioElement);
|
||||
handle_htmlmediaelement!(cx, tag, "video", HTMLVideoElementTypeId, HTMLVideoElement);
|
||||
|
||||
unsafe {
|
||||
let element = @HTMLUnknownElement {
|
||||
htmlelement: HTMLElement::new(HTMLUnknownElementTypeId, tag.to_str())
|
||||
};
|
||||
Node::as_abstract_node(cx, element)
|
||||
}
|
||||
unsafe { Node::as_abstract_node(cx, element) }
|
||||
}
|
||||
|
||||
pub fn parse_html(cx: *JSContext,
|
||||
|
@ -367,8 +365,9 @@ pub fn parse_html(cx: *JSContext,
|
|||
parser.set_tree_handler(~hubbub::TreeHandler {
|
||||
create_comment: |data: ~str| {
|
||||
debug!("create comment");
|
||||
let comment = @Comment::new(data);
|
||||
unsafe {
|
||||
Node::as_abstract_node(cx, @Comment::new(data)).to_hubbub_node()
|
||||
Node::as_abstract_node(cx, comment).to_hubbub_node()
|
||||
}
|
||||
},
|
||||
create_doctype: |doctype: ~hubbub::Doctype| {
|
||||
|
@ -466,9 +465,8 @@ pub fn parse_html(cx: *JSContext,
|
|||
},
|
||||
create_text: |data: ~str| {
|
||||
debug!("create text");
|
||||
unsafe {
|
||||
Node::as_abstract_node(cx, @Text::new(data)).to_hubbub_node()
|
||||
}
|
||||
let text = @Text::new(data);
|
||||
unsafe { Node::as_abstract_node(cx, text).to_hubbub_node() }
|
||||
},
|
||||
ref_node: |_| {},
|
||||
unref_node: |_| {},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue