mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Get rid of a bunch of explicit derefs
This commit is contained in:
parent
ca56ebbb09
commit
722aa86c89
49 changed files with 340 additions and 360 deletions
|
@ -67,7 +67,7 @@ pub fn handle_get_root_node(page: &Rc<Page>, pipeline: PipelineId, reply: IpcSen
|
||||||
pub fn handle_get_document_element(page: &Rc<Page>, pipeline: PipelineId, reply: IpcSender<NodeInfo>) {
|
pub fn handle_get_document_element(page: &Rc<Page>, pipeline: PipelineId, reply: IpcSender<NodeInfo>) {
|
||||||
let page = get_page(&*page, pipeline);
|
let page = get_page(&*page, pipeline);
|
||||||
let document = page.document();
|
let document = page.document();
|
||||||
let document_element = document.r().GetDocumentElement().unwrap();
|
let document_element = document.GetDocumentElement().unwrap();
|
||||||
|
|
||||||
let node = document_element.upcast::<Node>();
|
let node = document_element.upcast::<Node>();
|
||||||
reply.send(node.summarize()).unwrap();
|
reply.send(node.summarize()).unwrap();
|
||||||
|
@ -79,7 +79,7 @@ fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String
|
||||||
let node = document.upcast::<Node>();
|
let node = document.upcast::<Node>();
|
||||||
|
|
||||||
for candidate in node.traverse_preorder() {
|
for candidate in node.traverse_preorder() {
|
||||||
if candidate.r().get_unique_id() == node_id {
|
if candidate.get_unique_id() == node_id {
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,8 +89,8 @@ fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String
|
||||||
|
|
||||||
pub fn handle_get_children(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: IpcSender<Vec<NodeInfo>>) {
|
pub fn handle_get_children(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: IpcSender<Vec<NodeInfo>>) {
|
||||||
let parent = find_node_by_unique_id(&*page, pipeline, node_id);
|
let parent = find_node_by_unique_id(&*page, pipeline, node_id);
|
||||||
let children = parent.r().children().map(|child| {
|
let children = parent.children().map(|child| {
|
||||||
child.r().summarize()
|
child.summarize()
|
||||||
}).collect();
|
}).collect();
|
||||||
reply.send(children).unwrap();
|
reply.send(children).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ pub fn handle_request_animation_frame(page: &Rc<Page>, id: PipelineId, actor_nam
|
||||||
let page = page.find(id).expect("There is no such page");
|
let page = page.find(id).expect("There is no such page");
|
||||||
let doc = page.document();
|
let doc = page.document();
|
||||||
let devtools_sender = page.window().devtools_chan().unwrap();
|
let devtools_sender = page.window().devtools_chan().unwrap();
|
||||||
doc.r().request_animation_frame(box move |time| {
|
doc.request_animation_frame(box move |time| {
|
||||||
let msg = ScriptToDevtoolsControlMsg::FramerateTick(actor_name, time);
|
let msg = ScriptToDevtoolsControlMsg::FramerateTick(actor_name, time);
|
||||||
devtools_sender.send(msg).unwrap();
|
devtools_sender.send(msg).unwrap();
|
||||||
});
|
});
|
||||||
|
|
|
@ -225,7 +225,7 @@ impl AttrMethods for Attr {
|
||||||
match self.owner() {
|
match self.owner() {
|
||||||
None => *self.value.borrow_mut() = AttrValue::String(value),
|
None => *self.value.borrow_mut() = AttrValue::String(value),
|
||||||
Some(owner) => {
|
Some(owner) => {
|
||||||
let value = owner.r().parse_attribute(&self.namespace, self.local_name(), value);
|
let value = owner.parse_attribute(&self.namespace, self.local_name(), value);
|
||||||
self.set_value(value, owner.r());
|
self.set_value(value, owner.r());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -760,7 +760,7 @@ pub fn native_from_handleobject<T>(obj: HandleObject) -> Result<Root<T>, ()>
|
||||||
|
|
||||||
impl<T: Reflectable> ToJSValConvertible for Root<T> {
|
impl<T: Reflectable> ToJSValConvertible for Root<T> {
|
||||||
fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
|
fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
|
||||||
self.r().reflector().to_jsval(cx, rval);
|
self.reflector().to_jsval(cx, rval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -491,7 +491,7 @@ impl RootCollection {
|
||||||
debug_assert!(task_state::get().is_script());
|
debug_assert!(task_state::get().is_script());
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut roots = &mut *self.roots.get();
|
let mut roots = &mut *self.roots.get();
|
||||||
let old_reflector = &*rooted.r().reflector();
|
let old_reflector = &*rooted.reflector();
|
||||||
match roots.iter().rposition(|r| *r == old_reflector) {
|
match roots.iter().rposition(|r| *r == old_reflector) {
|
||||||
Some(idx) => {
|
Some(idx) => {
|
||||||
roots.remove(idx);
|
roots.remove(idx);
|
||||||
|
|
|
@ -106,7 +106,7 @@ unsafe fn GetSubframeWindow(cx: *mut JSContext, proxy: HandleObject, id: HandleI
|
||||||
let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object());
|
let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object());
|
||||||
let win: Root<Window> = native_from_handleobject(target.handle()).unwrap();
|
let win: Root<Window> = native_from_handleobject(target.handle()).unwrap();
|
||||||
let mut found = false;
|
let mut found = false;
|
||||||
return win.r().IndexedGetter(index, &mut found);
|
return win.IndexedGetter(index, &mut found);
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
|
|
|
@ -298,7 +298,7 @@ impl CanvasRenderingContext2D {
|
||||||
None => return Err(Error::InvalidState),
|
None => return Err(Error::InvalidState),
|
||||||
};
|
};
|
||||||
|
|
||||||
let renderer = context.r().get_ipc_renderer();
|
let renderer = context.get_ipc_renderer();
|
||||||
let (sender, receiver) = ipc::channel::<Vec<u8>>().unwrap();
|
let (sender, receiver) = ipc::channel::<Vec<u8>>().unwrap();
|
||||||
// Reads pixels from source image
|
// Reads pixels from source image
|
||||||
renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::GetImageData(source_rect.to_i32(),
|
renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::GetImageData(source_rect.to_i32(),
|
||||||
|
@ -787,7 +787,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
self.state.borrow_mut().stroke_style = CanvasFillOrStrokeStyle::Gradient(
|
self.state.borrow_mut().stroke_style = CanvasFillOrStrokeStyle::Gradient(
|
||||||
JS::from_ref(gradient.r()));
|
JS::from_ref(gradient.r()));
|
||||||
let msg = CanvasMsg::Canvas2d(
|
let msg = CanvasMsg::Canvas2d(
|
||||||
Canvas2dMsg::SetStrokeStyle(gradient.r().to_fill_or_stroke_style()));
|
Canvas2dMsg::SetStrokeStyle(gradient.to_fill_or_stroke_style()));
|
||||||
self.ipc_renderer.send(msg).unwrap();
|
self.ipc_renderer.send(msg).unwrap();
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -824,12 +824,12 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
self.state.borrow_mut().fill_style = CanvasFillOrStrokeStyle::Gradient(
|
self.state.borrow_mut().fill_style = CanvasFillOrStrokeStyle::Gradient(
|
||||||
JS::from_rooted(&gradient));
|
JS::from_rooted(&gradient));
|
||||||
let msg = CanvasMsg::Canvas2d(
|
let msg = CanvasMsg::Canvas2d(
|
||||||
Canvas2dMsg::SetFillStyle(gradient.r().to_fill_or_stroke_style()));
|
Canvas2dMsg::SetFillStyle(gradient.to_fill_or_stroke_style()));
|
||||||
self.ipc_renderer.send(msg).unwrap();
|
self.ipc_renderer.send(msg).unwrap();
|
||||||
}
|
}
|
||||||
StringOrCanvasGradientOrCanvasPattern::eCanvasPattern(pattern) => {
|
StringOrCanvasGradientOrCanvasPattern::eCanvasPattern(pattern) => {
|
||||||
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::SetFillStyle(
|
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::SetFillStyle(
|
||||||
pattern.r().to_fill_or_stroke_style()))).unwrap();
|
pattern.to_fill_or_stroke_style()))).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -944,17 +944,15 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
repetition: DOMString) -> Fallible<Root<CanvasPattern>> {
|
repetition: DOMString) -> Fallible<Root<CanvasPattern>> {
|
||||||
let (image_data, image_size) = match image {
|
let (image_data, image_size) = match image {
|
||||||
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLImageElement(image) => {
|
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLImageElement(image) => {
|
||||||
let image_element = image.r();
|
|
||||||
// https://html.spec.whatwg.org/multipage/#img-error
|
// https://html.spec.whatwg.org/multipage/#img-error
|
||||||
// If the image argument is an HTMLImageElement object that is in the broken state,
|
// If the image argument is an HTMLImageElement object that is in the broken state,
|
||||||
// then throw an InvalidStateError exception
|
// then throw an InvalidStateError exception
|
||||||
match self.fetch_image_data(&image_element) {
|
match self.fetch_image_data(&image.r()) {
|
||||||
Some((data, size)) => (data, size),
|
Some((data, size)) => (data, size),
|
||||||
None => return Err(Error::InvalidState),
|
None => return Err(Error::InvalidState),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLCanvasElement(canvas) => {
|
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eHTMLCanvasElement(canvas) => {
|
||||||
let canvas = canvas.r();
|
|
||||||
let _ = canvas.get_or_init_2d_context();
|
let _ = canvas.get_or_init_2d_context();
|
||||||
|
|
||||||
match canvas.fetch_all_data() {
|
match canvas.fetch_all_data() {
|
||||||
|
@ -963,8 +961,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eCanvasRenderingContext2D(context) => {
|
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::eCanvasRenderingContext2D(context) => {
|
||||||
let canvas = context.r().Canvas();
|
let canvas = context.Canvas();
|
||||||
let canvas = canvas.r();
|
|
||||||
let _ = canvas.get_or_init_2d_context();
|
let _ = canvas.get_or_init_2d_context();
|
||||||
|
|
||||||
match canvas.fetch_all_data() {
|
match canvas.fetch_all_data() {
|
||||||
|
|
|
@ -156,8 +156,7 @@ impl CharacterData {
|
||||||
|
|
||||||
fn content_changed(&self) {
|
fn content_changed(&self) {
|
||||||
let node = self.upcast::<Node>();
|
let node = self.upcast::<Node>();
|
||||||
let document = node.owner_doc();
|
node.owner_doc().content_changed(node, NodeDamage::OtherNodeDamage);
|
||||||
document.r().content_changed(node, NodeDamage::OtherNodeDamage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
||||||
|
|
||||||
// Step 6
|
// Step 6
|
||||||
let window = window_from_node(&*self.owner);
|
let window = window_from_node(&*self.owner);
|
||||||
let declarations = parse_one_declaration(&property, &value, &window.r().get_url());
|
let declarations = parse_one_declaration(&property, &value, &window.get_url());
|
||||||
|
|
||||||
// Step 7
|
// Step 7
|
||||||
let declarations = if let Ok(declarations) = declarations {
|
let declarations = if let Ok(declarations) = declarations {
|
||||||
|
@ -235,7 +235,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
||||||
|
|
||||||
let document = document_from_node(element);
|
let document = document_from_node(element);
|
||||||
let node = element.upcast();
|
let node = element.upcast();
|
||||||
document.r().content_changed(node, NodeDamage::NodeStyleDamaged);
|
document.content_changed(node, NodeDamage::NodeStyleDamaged);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
||||||
|
|
||||||
let document = document_from_node(element);
|
let document = document_from_node(element);
|
||||||
let node = element.upcast();
|
let node = element.upcast();
|
||||||
document.r().content_changed(node, NodeDamage::NodeStyleDamaged);
|
document.content_changed(node, NodeDamage::NodeStyleDamaged);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ impl CustomEvent {
|
||||||
cancelable: bool,
|
cancelable: bool,
|
||||||
detail: HandleValue) -> Root<CustomEvent> {
|
detail: HandleValue) -> Root<CustomEvent> {
|
||||||
let ev = CustomEvent::new_uninitialized(global);
|
let ev = CustomEvent::new_uninitialized(global);
|
||||||
ev.r().InitCustomEvent(global.get_cx(), type_, bubbles, cancelable, detail);
|
ev.InitCustomEvent(global.get_cx(), type_, bubbles, cancelable, detail);
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
|
|
@ -449,7 +449,7 @@ impl Document {
|
||||||
let check_anchor = |node: &HTMLAnchorElement| {
|
let check_anchor = |node: &HTMLAnchorElement| {
|
||||||
let elem = node.upcast::<Element>();
|
let elem = node.upcast::<Element>();
|
||||||
elem.get_attribute(&ns!(""), &atom!("name")).map_or(false, |attr| {
|
elem.get_attribute(&ns!(""), &atom!("name")).map_or(false, |attr| {
|
||||||
&**attr.r().value() == fragid
|
&**attr.value() == fragid
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
let doc_node = self.upcast::<Node>();
|
let doc_node = self.upcast::<Node>();
|
||||||
|
@ -498,7 +498,7 @@ impl Document {
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::NotCancelable);
|
EventCancelable::NotCancelable);
|
||||||
let target = self.upcast::<EventTarget>();
|
let target = self.upcast::<EventTarget>();
|
||||||
let _ = event.r().fire(target);
|
let _ = event.fire(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return whether scripting is enabled or not
|
/// Return whether scripting is enabled or not
|
||||||
|
@ -567,7 +567,7 @@ impl Document {
|
||||||
pub fn dirty_all_nodes(&self) {
|
pub fn dirty_all_nodes(&self) {
|
||||||
let root = self.upcast::<Node>();
|
let root = self.upcast::<Node>();
|
||||||
for node in root.traverse_preorder() {
|
for node in root.traverse_preorder() {
|
||||||
node.r().dirty(NodeDamage::OtherNodeDamage)
|
node.dirty(NodeDamage::OtherNodeDamage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,7 +591,7 @@ impl Document {
|
||||||
let el = match node.downcast::<Element>() {
|
let el = match node.downcast::<Element>() {
|
||||||
Some(el) => Root::from_ref(el),
|
Some(el) => Root::from_ref(el),
|
||||||
None => {
|
None => {
|
||||||
let parent = node.r().GetParentNode();
|
let parent = node.GetParentNode();
|
||||||
match parent.and_then(Root::downcast::<Element>) {
|
match parent.and_then(Root::downcast::<Element>) {
|
||||||
Some(parent) => parent,
|
Some(parent) => parent,
|
||||||
None => return,
|
None => return,
|
||||||
|
@ -747,7 +747,7 @@ impl Document {
|
||||||
let el = match node.downcast::<Element>() {
|
let el = match node.downcast::<Element>() {
|
||||||
Some(el) => Root::from_ref(el),
|
Some(el) => Root::from_ref(el),
|
||||||
None => {
|
None => {
|
||||||
let parent = node.r().GetParentNode();
|
let parent = node.GetParentNode();
|
||||||
match parent.and_then(Root::downcast::<Element>) {
|
match parent.and_then(Root::downcast::<Element>) {
|
||||||
Some(parent) => parent,
|
Some(parent) => parent,
|
||||||
None => return false
|
None => return false
|
||||||
|
@ -923,13 +923,13 @@ impl Document {
|
||||||
for node in nodes {
|
for node in nodes {
|
||||||
match node {
|
match node {
|
||||||
NodeOrString::eNode(node) => {
|
NodeOrString::eNode(node) => {
|
||||||
try!(fragment.r().AppendChild(node.r()));
|
try!(fragment.AppendChild(node.r()));
|
||||||
},
|
},
|
||||||
NodeOrString::eString(string) => {
|
NodeOrString::eString(string) => {
|
||||||
let node = Root::upcast::<Node>(self.CreateTextNode(string));
|
let node = Root::upcast::<Node>(self.CreateTextNode(string));
|
||||||
// No try!() here because appending a text node
|
// No try!() here because appending a text node
|
||||||
// should not fail.
|
// should not fail.
|
||||||
fragment.r().AppendChild(node.r()).unwrap();
|
fragment.AppendChild(node.r()).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1108,8 +1108,8 @@ impl Document {
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.script_blocking_stylesheets_count.get() == 0 &&
|
if self.script_blocking_stylesheets_count.get() == 0 &&
|
||||||
script.r().is_ready_to_be_executed() {
|
script.is_ready_to_be_executed() {
|
||||||
script.r().execute();
|
script.execute();
|
||||||
self.pending_parsing_blocking_script.set(None);
|
self.pending_parsing_blocking_script.set(None);
|
||||||
return ParserBlockedByScript::Unblocked;
|
return ParserBlockedByScript::Unblocked;
|
||||||
}
|
}
|
||||||
|
@ -1151,10 +1151,10 @@ impl Document {
|
||||||
// Re-borrowing the list for each step because it can also be borrowed under execute.
|
// Re-borrowing the list for each step because it can also be borrowed under execute.
|
||||||
while self.asap_in_order_scripts_list.borrow().len() > 0 {
|
while self.asap_in_order_scripts_list.borrow().len() > 0 {
|
||||||
let script = Root::from_ref(&*self.asap_in_order_scripts_list.borrow()[0]);
|
let script = Root::from_ref(&*self.asap_in_order_scripts_list.borrow()[0]);
|
||||||
if !script.r().is_ready_to_be_executed() {
|
if !script.is_ready_to_be_executed() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script.r().execute();
|
script.execute();
|
||||||
self.asap_in_order_scripts_list.borrow_mut().remove(0);
|
self.asap_in_order_scripts_list.borrow_mut().remove(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1162,11 +1162,11 @@ impl Document {
|
||||||
// Re-borrowing the set for each step because it can also be borrowed under execute.
|
// Re-borrowing the set for each step because it can also be borrowed under execute.
|
||||||
while idx < self.asap_scripts_set.borrow().len() {
|
while idx < self.asap_scripts_set.borrow().len() {
|
||||||
let script = Root::from_ref(&*self.asap_scripts_set.borrow()[idx]);
|
let script = Root::from_ref(&*self.asap_scripts_set.borrow()[idx]);
|
||||||
if !script.r().is_ready_to_be_executed() {
|
if !script.is_ready_to_be_executed() {
|
||||||
idx += 1;
|
idx += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
script.r().execute();
|
script.execute();
|
||||||
self.asap_scripts_set.borrow_mut().swap_remove(idx);
|
self.asap_scripts_set.borrow_mut().swap_remove(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1205,7 +1205,7 @@ impl Document {
|
||||||
self.upcast::<Node>()
|
self.upcast::<Node>()
|
||||||
.traverse_preorder()
|
.traverse_preorder()
|
||||||
.filter_map(Root::downcast::<HTMLIFrameElement>)
|
.filter_map(Root::downcast::<HTMLIFrameElement>)
|
||||||
.find(|node| node.r().subpage_id() == Some(subpage_id))
|
.find(|node| node.subpage_id() == Some(subpage_id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1693,11 +1693,11 @@ impl DocumentMethods for Document {
|
||||||
// https://html.spec.whatwg.org/multipage/#document.title
|
// https://html.spec.whatwg.org/multipage/#document.title
|
||||||
fn Title(&self) -> DOMString {
|
fn Title(&self) -> DOMString {
|
||||||
let title = self.GetDocumentElement().and_then(|root| {
|
let title = self.GetDocumentElement().and_then(|root| {
|
||||||
if root.r().namespace() == &ns!(SVG) && root.r().local_name() == &atom!("svg") {
|
if root.namespace() == &ns!(SVG) && root.local_name() == &atom!("svg") {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
root.upcast::<Node>().child_elements().find(|node| {
|
root.upcast::<Node>().child_elements().find(|node| {
|
||||||
node.r().namespace() == &ns!(SVG) &&
|
node.namespace() == &ns!(SVG) &&
|
||||||
node.r().local_name() == &atom!("title")
|
node.local_name() == &atom!("title")
|
||||||
}).map(Root::upcast::<Node>)
|
}).map(Root::upcast::<Node>)
|
||||||
} else {
|
} else {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
|
@ -1711,7 +1711,7 @@ impl DocumentMethods for Document {
|
||||||
None => DOMString::new(),
|
None => DOMString::new(),
|
||||||
Some(ref title) => {
|
Some(ref title) => {
|
||||||
// Steps 3-4.
|
// Steps 3-4.
|
||||||
let value = Node::collect_text_contents(title.r().children());
|
let value = Node::collect_text_contents(title.children());
|
||||||
str_join(split_html_space_chars(&value), " ")
|
str_join(split_html_space_chars(&value), " ")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1724,11 +1724,11 @@ impl DocumentMethods for Document {
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
let elem = if root.r().namespace() == &ns!(SVG) &&
|
let elem = if root.namespace() == &ns!(SVG) &&
|
||||||
root.r().local_name() == &atom!("svg") {
|
root.local_name() == &atom!("svg") {
|
||||||
let elem = root.upcast::<Node>().child_elements().find(|node| {
|
let elem = root.upcast::<Node>().child_elements().find(|node| {
|
||||||
node.r().namespace() == &ns!(SVG) &&
|
node.namespace() == &ns!(SVG) &&
|
||||||
node.r().local_name() == &atom!("title")
|
node.local_name() == &atom!("title")
|
||||||
});
|
});
|
||||||
match elem {
|
match elem {
|
||||||
Some(elem) => Root::upcast::<Node>(elem),
|
Some(elem) => Root::upcast::<Node>(elem),
|
||||||
|
@ -1741,10 +1741,10 @@ impl DocumentMethods for Document {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if root.r().namespace() == &ns!(HTML) {
|
} else if root.namespace() == &ns!(HTML) {
|
||||||
let elem = root.upcast::<Node>()
|
let elem = root.upcast::<Node>()
|
||||||
.traverse_preorder()
|
.traverse_preorder()
|
||||||
.find(|node| node.r().is::<HTMLTitleElement>());
|
.find(|node| node.is::<HTMLTitleElement>());
|
||||||
match elem {
|
match elem {
|
||||||
Some(elem) => elem,
|
Some(elem) => elem,
|
||||||
None => {
|
None => {
|
||||||
|
@ -1765,7 +1765,7 @@ impl DocumentMethods for Document {
|
||||||
return
|
return
|
||||||
};
|
};
|
||||||
|
|
||||||
elem.r().SetTextContent(Some(title));
|
elem.SetTextContent(Some(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-head
|
// https://html.spec.whatwg.org/multipage/#dom-document-head
|
||||||
|
@ -1785,7 +1785,7 @@ impl DocumentMethods for Document {
|
||||||
self.get_html_element().and_then(|root| {
|
self.get_html_element().and_then(|root| {
|
||||||
let node = root.upcast::<Node>();
|
let node = root.upcast::<Node>();
|
||||||
node.children().find(|child| {
|
node.children().find(|child| {
|
||||||
match child.r().type_id() {
|
match child.type_id() {
|
||||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement)) |
|
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement)) |
|
||||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFrameSetElement)) => true,
|
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFrameSetElement)) => true,
|
||||||
_ => false
|
_ => false
|
||||||
|
@ -1845,7 +1845,7 @@ impl DocumentMethods for Document {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
element.get_attribute(&ns!(""), &atom!("name")).map_or(false, |attr| {
|
element.get_attribute(&ns!(""), &atom!("name")).map_or(false, |attr| {
|
||||||
&**attr.r().value() == &*name
|
&**attr.value() == &*name
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2028,10 +2028,10 @@ impl DocumentMethods for Document {
|
||||||
match html_elem_type {
|
match html_elem_type {
|
||||||
HTMLElementTypeId::HTMLAppletElement => {
|
HTMLElementTypeId::HTMLAppletElement => {
|
||||||
match elem.get_attribute(&ns!(""), &atom!("name")) {
|
match elem.get_attribute(&ns!(""), &atom!("name")) {
|
||||||
Some(ref attr) if attr.r().value().as_atom() == name => true,
|
Some(ref attr) if attr.value().as_atom() == name => true,
|
||||||
_ => {
|
_ => {
|
||||||
match elem.get_attribute(&ns!(""), &atom!("id")) {
|
match elem.get_attribute(&ns!(""), &atom!("id")) {
|
||||||
Some(ref attr) => attr.r().value().as_atom() == name,
|
Some(ref attr) => attr.value().as_atom() == name,
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2039,18 +2039,18 @@ impl DocumentMethods for Document {
|
||||||
},
|
},
|
||||||
HTMLElementTypeId::HTMLFormElement => {
|
HTMLElementTypeId::HTMLFormElement => {
|
||||||
match elem.get_attribute(&ns!(""), &atom!("name")) {
|
match elem.get_attribute(&ns!(""), &atom!("name")) {
|
||||||
Some(ref attr) => attr.r().value().as_atom() == name,
|
Some(ref attr) => attr.value().as_atom() == name,
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
HTMLElementTypeId::HTMLImageElement => {
|
HTMLElementTypeId::HTMLImageElement => {
|
||||||
match elem.get_attribute(&ns!(""), &atom!("name")) {
|
match elem.get_attribute(&ns!(""), &atom!("name")) {
|
||||||
Some(ref attr) => {
|
Some(ref attr) => {
|
||||||
if attr.r().value().as_atom() == name {
|
if attr.value().as_atom() == name {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
match elem.get_attribute(&ns!(""), &atom!("id")) {
|
match elem.get_attribute(&ns!(""), &atom!("id")) {
|
||||||
Some(ref attr) => attr.r().value().as_atom() == name,
|
Some(ref attr) => attr.value().as_atom() == name,
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2074,7 +2074,7 @@ impl DocumentMethods for Document {
|
||||||
*found = true;
|
*found = true;
|
||||||
// TODO: Step 2.
|
// TODO: Step 2.
|
||||||
// Step 3.
|
// Step 3.
|
||||||
return first.r().reflector().get_jsobject().get()
|
return first.reflector().get_jsobject().get()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*found = false;
|
*found = false;
|
||||||
|
@ -2085,7 +2085,7 @@ impl DocumentMethods for Document {
|
||||||
*found = true;
|
*found = true;
|
||||||
let filter = NamedElementFilter { name: name };
|
let filter = NamedElementFilter { name: name };
|
||||||
let collection = HTMLCollection::create(self.window(), root, box filter);
|
let collection = HTMLCollection::create(self.window(), root, box filter);
|
||||||
collection.r().reflector().get_jsobject().get()
|
collection.reflector().get_jsobject().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names
|
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names
|
||||||
|
@ -2133,17 +2133,17 @@ impl DocumentProgressHandler {
|
||||||
|
|
||||||
fn set_ready_state_complete(&self) {
|
fn set_ready_state_complete(&self) {
|
||||||
let document = self.addr.root();
|
let document = self.addr.root();
|
||||||
document.r().set_ready_state(DocumentReadyState::Complete);
|
document.set_ready_state(DocumentReadyState::Complete);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dispatch_load(&self) {
|
fn dispatch_load(&self) {
|
||||||
let document = self.addr.root();
|
let document = self.addr.root();
|
||||||
let window = document.r().window();
|
let window = document.window();
|
||||||
let event = Event::new(GlobalRef::Window(window), "load".to_owned(),
|
let event = Event::new(GlobalRef::Window(window), "load".to_owned(),
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::NotCancelable);
|
EventCancelable::NotCancelable);
|
||||||
let wintarget = window.upcast::<EventTarget>();
|
let wintarget = window.upcast::<EventTarget>();
|
||||||
event.r().set_trusted(true);
|
event.set_trusted(true);
|
||||||
let _ = wintarget.dispatch_event_with_target(document.upcast(), &event);
|
let _ = wintarget.dispatch_event_with_target(document.upcast(), &event);
|
||||||
|
|
||||||
let browsing_context = window.browsing_context();
|
let browsing_context = window.browsing_context();
|
||||||
|
@ -2157,10 +2157,10 @@ impl DocumentProgressHandler {
|
||||||
event.fire(frame_element.upcast());
|
event.fire(frame_element.upcast());
|
||||||
};
|
};
|
||||||
|
|
||||||
document.r().notify_constellation_load();
|
document.notify_constellation_load();
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadend
|
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadend
|
||||||
document.r().trigger_mozbrowser_event(MozBrowserEvent::LoadEnd);
|
document.trigger_mozbrowser_event(MozBrowserEvent::LoadEnd);
|
||||||
|
|
||||||
window.reflow(ReflowGoal::ForDisplay,
|
window.reflow(ReflowGoal::ForDisplay,
|
||||||
ReflowQueryType::NoQuery,
|
ReflowQueryType::NoQuery,
|
||||||
|
@ -2171,7 +2171,7 @@ impl DocumentProgressHandler {
|
||||||
impl Runnable for DocumentProgressHandler {
|
impl Runnable for DocumentProgressHandler {
|
||||||
fn handler(self: Box<DocumentProgressHandler>) {
|
fn handler(self: Box<DocumentProgressHandler>) {
|
||||||
let document = self.addr.root();
|
let document = self.addr.root();
|
||||||
let window = document.r().window();
|
let window = document.window();
|
||||||
if window.is_alive() {
|
if window.is_alive() {
|
||||||
self.set_ready_state_complete();
|
self.set_ready_state_complete();
|
||||||
self.dispatch_load();
|
self.dispatch_load();
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl DOMImplementationMethods for DOMImplementation {
|
||||||
let maybe_elem = if qname.is_empty() {
|
let maybe_elem = if qname.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
match doc.r().CreateElementNS(namespace, qname) {
|
match doc.CreateElementNS(namespace, qname) {
|
||||||
Err(error) => return Err(error),
|
Err(error) => return Err(error),
|
||||||
Ok(elem) => Some(elem)
|
Ok(elem) => Some(elem)
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ impl DOMParserMethods for DOMParser {
|
||||||
DocumentSource::FromParser,
|
DocumentSource::FromParser,
|
||||||
loader);
|
loader);
|
||||||
parse_html(document.r(), s, url, ParseContext::Owner(None));
|
parse_html(document.r(), s, url, ParseContext::Owner(None));
|
||||||
document.r().set_ready_state(DocumentReadyState::Complete);
|
document.set_ready_state(DocumentReadyState::Complete);
|
||||||
Ok(document)
|
Ok(document)
|
||||||
}
|
}
|
||||||
Text_xml => {
|
Text_xml => {
|
||||||
|
|
|
@ -642,9 +642,9 @@ impl Element {
|
||||||
pub fn summarize(&self) -> Vec<AttrInfo> {
|
pub fn summarize(&self) -> Vec<AttrInfo> {
|
||||||
let attrs = self.Attributes();
|
let attrs = self.Attributes();
|
||||||
let mut summarized = vec!();
|
let mut summarized = vec!();
|
||||||
for i in 0..attrs.r().Length() {
|
for i in 0..attrs.Length() {
|
||||||
let attr = attrs.r().Item(i).unwrap();
|
let attr = attrs.Item(i).unwrap();
|
||||||
summarized.push(attr.r().summarize());
|
summarized.push(attr.summarize());
|
||||||
}
|
}
|
||||||
summarized
|
summarized
|
||||||
}
|
}
|
||||||
|
@ -800,11 +800,11 @@ impl Element {
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
let attrs = element.Attributes();
|
let attrs = element.Attributes();
|
||||||
for i in 0..attrs.r().Length() {
|
for i in 0..attrs.Length() {
|
||||||
let attr = attrs.r().Item(i).unwrap();
|
let attr = attrs.Item(i).unwrap();
|
||||||
if *attr.r().prefix() == Some(atom!("xmlns")) &&
|
if *attr.prefix() == Some(atom!("xmlns")) &&
|
||||||
**attr.r().value() == *namespace.0 {
|
**attr.value() == *namespace.0 {
|
||||||
return Some(attr.r().LocalName());
|
return Some(attr.LocalName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -994,7 +994,7 @@ impl Element {
|
||||||
Quirks => lhs.eq_ignore_ascii_case(&rhs)
|
Quirks => lhs.eq_ignore_ascii_case(&rhs)
|
||||||
};
|
};
|
||||||
self.get_attribute(&ns!(""), &atom!("class")).map(|attr| {
|
self.get_attribute(&ns!(""), &atom!("class")).map(|attr| {
|
||||||
attr.r().value().as_tokens().iter().any(|atom| is_equal(name, atom))
|
attr.value().as_tokens().iter().any(|atom| is_equal(name, atom))
|
||||||
}).unwrap_or(false)
|
}).unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1027,7 +1027,7 @@ impl Element {
|
||||||
}
|
}
|
||||||
let url = self.get_string_attribute(local_name);
|
let url = self.get_string_attribute(local_name);
|
||||||
let doc = document_from_node(self);
|
let doc = document_from_node(self);
|
||||||
let base = doc.r().url();
|
let base = doc.url();
|
||||||
// https://html.spec.whatwg.org/multipage/#reflect
|
// https://html.spec.whatwg.org/multipage/#reflect
|
||||||
// XXXManishearth this doesn't handle `javascript:` urls properly
|
// XXXManishearth this doesn't handle `javascript:` urls properly
|
||||||
match UrlParser::new().base_url(&base).parse(&url) {
|
match UrlParser::new().base_url(&base).parse(&url) {
|
||||||
|
@ -1041,7 +1041,7 @@ impl Element {
|
||||||
|
|
||||||
pub fn get_string_attribute(&self, local_name: &Atom) -> DOMString {
|
pub fn get_string_attribute(&self, local_name: &Atom) -> DOMString {
|
||||||
match self.get_attribute(&ns!(""), local_name) {
|
match self.get_attribute(&ns!(""), local_name) {
|
||||||
Some(x) => x.r().Value(),
|
Some(x) => x.Value(),
|
||||||
None => "".to_owned()
|
None => "".to_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1076,7 +1076,7 @@ impl Element {
|
||||||
let attribute = self.get_attribute(&ns!(""), local_name);
|
let attribute = self.get_attribute(&ns!(""), local_name);
|
||||||
match attribute {
|
match attribute {
|
||||||
Some(ref attribute) => {
|
Some(ref attribute) => {
|
||||||
match *attribute.r().value() {
|
match *attribute.value() {
|
||||||
AttrValue::UInt(_, value) => value,
|
AttrValue::UInt(_, value) => value,
|
||||||
_ => panic!("Expected an AttrValue::UInt: \
|
_ => panic!("Expected an AttrValue::UInt: \
|
||||||
implement parse_plain_attribute"),
|
implement parse_plain_attribute"),
|
||||||
|
@ -1155,7 +1155,7 @@ impl ElementMethods for Element {
|
||||||
// https://dom.spec.whatwg.org/#dom-element-getattribute
|
// https://dom.spec.whatwg.org/#dom-element-getattribute
|
||||||
fn GetAttribute(&self, name: DOMString) -> Option<DOMString> {
|
fn GetAttribute(&self, name: DOMString) -> Option<DOMString> {
|
||||||
self.GetAttributeNode(name)
|
self.GetAttributeNode(name)
|
||||||
.map(|s| s.r().Value())
|
.map(|s| s.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-getattributens
|
// https://dom.spec.whatwg.org/#dom-element-getattributens
|
||||||
|
@ -1163,7 +1163,7 @@ impl ElementMethods for Element {
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
local_name: DOMString) -> Option<DOMString> {
|
local_name: DOMString) -> Option<DOMString> {
|
||||||
self.GetAttributeNodeNS(namespace, local_name)
|
self.GetAttributeNodeNS(namespace, local_name)
|
||||||
.map(|attr| attr.r().Value())
|
.map(|attr| attr.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-getattributenode
|
// https://dom.spec.whatwg.org/#dom-element-getattributenode
|
||||||
|
@ -1345,7 +1345,7 @@ impl ElementMethods for Element {
|
||||||
Some(parent) => parent,
|
Some(parent) => parent,
|
||||||
};
|
};
|
||||||
|
|
||||||
let parent = match context_parent.r().type_id() {
|
let parent = match context_parent.type_id() {
|
||||||
// Step 3.
|
// Step 3.
|
||||||
NodeTypeId::Document => return Err(Error::NoModificationAllowed),
|
NodeTypeId::Document => return Err(Error::NoModificationAllowed),
|
||||||
|
|
||||||
|
@ -1360,7 +1360,7 @@ impl ElementMethods for Element {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Step 5.
|
// Step 5.
|
||||||
let frag = try!(parent.r().parse_fragment(value));
|
let frag = try!(parent.parse_fragment(value));
|
||||||
// Step 6.
|
// Step 6.
|
||||||
try!(context_parent.ReplaceChild(frag.upcast(), context_node));
|
try!(context_parent.ReplaceChild(frag.upcast(), context_node));
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1659,7 +1659,7 @@ impl<'a> ::selectors::Element for Root<Element> {
|
||||||
where F: FnMut(&Atom)
|
where F: FnMut(&Atom)
|
||||||
{
|
{
|
||||||
if let Some(ref attr) = self.get_attribute(&ns!(""), &atom!("class")) {
|
if let Some(ref attr) = self.get_attribute(&ns!(""), &atom!("class")) {
|
||||||
let tokens = attr.r().value();
|
let tokens = attr.value();
|
||||||
let tokens = tokens.as_tokens();
|
let tokens = tokens.as_tokens();
|
||||||
for token in tokens {
|
for token in tokens {
|
||||||
callback(token);
|
callback(token);
|
||||||
|
@ -1692,7 +1692,7 @@ impl<'a> ::selectors::Element for Root<Element> {
|
||||||
NamespaceConstraint::Specific(ref ns) => {
|
NamespaceConstraint::Specific(ref ns) => {
|
||||||
self.get_attribute(ns, local_name)
|
self.get_attribute(ns, local_name)
|
||||||
.map_or(false, |attr| {
|
.map_or(false, |attr| {
|
||||||
test(&attr.r().value())
|
test(&attr.value())
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
NamespaceConstraint::Any => {
|
NamespaceConstraint::Any => {
|
||||||
|
@ -1783,7 +1783,7 @@ impl Element {
|
||||||
// Step 4
|
// Step 4
|
||||||
let e = self.nearest_activable_element();
|
let e = self.nearest_activable_element();
|
||||||
match e {
|
match e {
|
||||||
Some(ref el) => match el.r().as_maybe_activatable() {
|
Some(ref el) => match el.as_maybe_activatable() {
|
||||||
Some(elem) => {
|
Some(elem) => {
|
||||||
// Step 5-6
|
// Step 5-6
|
||||||
elem.pre_click_activation();
|
elem.pre_click_activation();
|
||||||
|
@ -1880,7 +1880,7 @@ impl Element {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
match ancestor.children()
|
match ancestor.children()
|
||||||
.find(|child| child.r().is::<HTMLLegendElement>())
|
.find(|child| child.is::<HTMLLegendElement>())
|
||||||
{
|
{
|
||||||
Some(ref legend) => {
|
Some(ref legend) => {
|
||||||
// XXXabinader: should we save previous ancestor to avoid this iteration?
|
// XXXabinader: should we save previous ancestor to avoid this iteration?
|
||||||
|
@ -1898,7 +1898,7 @@ impl Element {
|
||||||
if self.get_disabled_state() { return; }
|
if self.get_disabled_state() { return; }
|
||||||
let node = self.upcast::<Node>();
|
let node = self.upcast::<Node>();
|
||||||
if let Some(ref parent) = node.GetParentNode() {
|
if let Some(ref parent) = node.GetParentNode() {
|
||||||
if parent.r().is::<HTMLOptGroupElement>() && parent.downcast::<Element>().unwrap().get_disabled_state() {
|
if parent.is::<HTMLOptGroupElement>() && parent.downcast::<Element>().unwrap().get_disabled_state() {
|
||||||
self.set_disabled_state(true);
|
self.set_disabled_state(true);
|
||||||
self.set_enabled_state(false);
|
self.set_enabled_state(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ impl Event {
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable) -> Root<Event> {
|
cancelable: EventCancelable) -> Root<Event> {
|
||||||
let event = Event::new_uninitialized(global);
|
let event = Event::new_uninitialized(global);
|
||||||
event.r().InitEvent(type_, bubbles == EventBubbles::Bubbles, cancelable == EventCancelable::Cancelable);
|
event.InitEvent(type_, bubbles == EventBubbles::Bubbles, cancelable == EventCancelable::Cancelable);
|
||||||
event
|
event
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ impl Activatable for HTMLAnchorElement {
|
||||||
fn activation_behavior(&self, event: &Event, target: &EventTarget) {
|
fn activation_behavior(&self, event: &Event, target: &EventTarget) {
|
||||||
//Step 1. If the node document is not fully active, abort.
|
//Step 1. If the node document is not fully active, abort.
|
||||||
let doc = document_from_node(self);
|
let doc = document_from_node(self);
|
||||||
if !doc.r().is_fully_active() {
|
if !doc.is_fully_active() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//TODO: Step 2. Check if browsing context is specified and act accordingly.
|
//TODO: Step 2. Check if browsing context is specified and act accordingly.
|
||||||
|
@ -150,7 +150,7 @@ impl Activatable for HTMLAnchorElement {
|
||||||
if target.is::<HTMLImageElement>() && element.has_attribute(&atom!("ismap")) {
|
if target.is::<HTMLImageElement>() && element.has_attribute(&atom!("ismap")) {
|
||||||
|
|
||||||
let target_node = element.upcast::<Node>();
|
let target_node = element.upcast::<Node>();
|
||||||
let rect = window_from_node(target_node).r().content_box_query(
|
let rect = window_from_node(target_node).content_box_query(
|
||||||
target_node.to_trusted_node_address());
|
target_node.to_trusted_node_address());
|
||||||
ismap_suffix = Some(
|
ismap_suffix = Some(
|
||||||
format!("?{},{}", mouse_event.ClientX().to_f32().unwrap() - rect.origin.x.to_f32_px(),
|
format!("?{},{}", mouse_event.ClientX().to_f32().unwrap() - rect.origin.x.to_f32_px(),
|
||||||
|
|
|
@ -75,26 +75,22 @@ impl HTMLBodyElementMethods for HTMLBodyElement {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#the-body-element
|
// https://html.spec.whatwg.org/multipage/#the-body-element
|
||||||
fn GetOnunload(&self) -> Option<Rc<EventHandlerNonNull>> {
|
fn GetOnunload(&self) -> Option<Rc<EventHandlerNonNull>> {
|
||||||
let win = window_from_node(self);
|
window_from_node(self).GetOnunload()
|
||||||
win.r().GetOnunload()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#the-body-element
|
// https://html.spec.whatwg.org/multipage/#the-body-element
|
||||||
fn SetOnunload(&self, listener: Option<Rc<EventHandlerNonNull>>) {
|
fn SetOnunload(&self, listener: Option<Rc<EventHandlerNonNull>>) {
|
||||||
let win = window_from_node(self);
|
window_from_node(self).SetOnunload(listener)
|
||||||
win.r().SetOnunload(listener)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#the-body-element
|
// https://html.spec.whatwg.org/multipage/#the-body-element
|
||||||
fn GetOnstorage(&self) -> Option<Rc<EventHandlerNonNull>> {
|
fn GetOnstorage(&self) -> Option<Rc<EventHandlerNonNull>> {
|
||||||
let win = window_from_node(self);
|
window_from_node(self).GetOnstorage()
|
||||||
win.r().GetOnstorage()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#the-body-element
|
// https://html.spec.whatwg.org/multipage/#the-body-element
|
||||||
fn SetOnstorage(&self, listener: Option<Rc<EventHandlerNonNull>>) {
|
fn SetOnstorage(&self, listener: Option<Rc<EventHandlerNonNull>>) {
|
||||||
let win = window_from_node(self);
|
window_from_node(self).SetOnstorage(listener)
|
||||||
win.r().SetOnstorage(listener)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,9 +133,9 @@ impl VirtualMethods for HTMLBodyElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let document = window.r().Document();
|
let document = window.Document();
|
||||||
document.r().set_reflow_timeout(time::precise_time_ns() + INITIAL_REFLOW_DELAY);
|
document.set_reflow_timeout(time::precise_time_ns() + INITIAL_REFLOW_DELAY);
|
||||||
let ConstellationChan(ref chan) = window.r().constellation_chan();
|
let ConstellationChan(ref chan) = window.constellation_chan();
|
||||||
let event = ConstellationMsg::HeadParsed;
|
let event = ConstellationMsg::HeadParsed;
|
||||||
chan.send(event).unwrap();
|
chan.send(event).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ impl VirtualMethods for HTMLButtonElement {
|
||||||
|
|
||||||
let node = self.upcast::<Node>();
|
let node = self.upcast::<Node>();
|
||||||
let el = self.upcast::<Element>();
|
let el = self.upcast::<Element>();
|
||||||
if node.ancestors().any(|ancestor| ancestor.r().is::<HTMLFieldSetElement>()) {
|
if node.ancestors().any(|ancestor| ancestor.is::<HTMLFieldSetElement>()) {
|
||||||
el.check_ancestors_disabled_state_for_form_control();
|
el.check_ancestors_disabled_state_for_form_control();
|
||||||
} else {
|
} else {
|
||||||
el.check_disabled_attribute();
|
el.check_disabled_attribute();
|
||||||
|
@ -209,8 +209,8 @@ impl<'a> Activatable for &'a HTMLButtonElement {
|
||||||
//https://html.spec.whatwg.org/multipage/#attr-button-type-submit-state
|
//https://html.spec.whatwg.org/multipage/#attr-button-type-submit-state
|
||||||
ButtonType::Submit => {
|
ButtonType::Submit => {
|
||||||
self.form_owner().map(|o| {
|
self.form_owner().map(|o| {
|
||||||
o.r().submit(SubmittedFrom::NotFromFormSubmitMethod,
|
o.submit(SubmittedFrom::NotFromFormSubmitMethod,
|
||||||
FormSubmitter::ButtonElement(self.clone()))
|
FormSubmitter::ButtonElement(self.clone()))
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
|
@ -228,7 +228,7 @@ impl<'a> Activatable for &'a HTMLButtonElement {
|
||||||
}
|
}
|
||||||
node.query_selector_iter("button[type=submit]".to_owned()).unwrap()
|
node.query_selector_iter("button[type=submit]".to_owned()).unwrap()
|
||||||
.filter_map(Root::downcast::<HTMLButtonElement>)
|
.filter_map(Root::downcast::<HTMLButtonElement>)
|
||||||
.find(|r| r.r().form_owner() == owner)
|
.find(|r| r.form_owner() == owner)
|
||||||
.map(|s| s.r().synthetic_click_activation(ctrlKey, shiftKey, altKey, metaKey));
|
.map(|s| s.r().synthetic_click_activation(ctrlKey, shiftKey, altKey, metaKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,8 +215,8 @@ impl HTMLCollectionMethods for HTMLCollection {
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
self.elements_iter().find(|elem| {
|
self.elements_iter().find(|elem| {
|
||||||
elem.r().get_string_attribute(&atom!("name")) == key ||
|
elem.get_string_attribute(&atom!("name")) == key ||
|
||||||
elem.r().get_string_attribute(&atom!("id")) == key
|
elem.get_string_attribute(&atom!("id")) == key
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,19 +153,16 @@ impl HTMLElementMethods for HTMLElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#handler-onload
|
// https://html.spec.whatwg.org/multipage/#handler-onload
|
||||||
fn GetOnload(&self) -> Option<Rc<EventHandlerNonNull>> {
|
fn GetOnload(&self) -> Option<Rc<EventHandlerNonNull>> {
|
||||||
if self.is_body_or_frameset() {
|
if self.is_body_or_frameset() {
|
||||||
let win = window_from_node(self);
|
window_from_node(self).GetOnload()
|
||||||
win.r().GetOnload()
|
|
||||||
} else {
|
} else {
|
||||||
let target = self.upcast::<EventTarget>();
|
self.upcast::<EventTarget>().get_event_handler_common("load")
|
||||||
target.get_event_handler_common("load")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#handler-onload
|
// https://html.spec.whatwg.org/multipage/#handler-onload
|
||||||
fn SetOnload(&self, listener: Option<Rc<EventHandlerNonNull>>) {
|
fn SetOnload(&self, listener: Option<Rc<EventHandlerNonNull>>) {
|
||||||
if self.is_body_or_frameset() {
|
if self.is_body_or_frameset() {
|
||||||
let win = window_from_node(self);
|
window_from_node(self).SetOnload(listener)
|
||||||
win.r().SetOnload(listener)
|
|
||||||
} else {
|
} else {
|
||||||
self.upcast::<EventTarget>().set_event_handler_common("load", listener)
|
self.upcast::<EventTarget>().set_event_handler_common("load", listener)
|
||||||
}
|
}
|
||||||
|
@ -202,9 +199,9 @@ impl HTMLElementMethods for HTMLElement {
|
||||||
}
|
}
|
||||||
// https://html.spec.whatwg.org/multipage/#unfocusing-steps
|
// https://html.spec.whatwg.org/multipage/#unfocusing-steps
|
||||||
let document = document_from_node(self);
|
let document = document_from_node(self);
|
||||||
document.r().begin_focus_transaction();
|
document.begin_focus_transaction();
|
||||||
// If `request_focus` is not called, focus will be set to None.
|
// If `request_focus` is not called, focus will be set to None.
|
||||||
document.r().commit_focus_transaction(FocusType::Element);
|
document.commit_focus_transaction(FocusType::Element);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
|
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
|
||||||
|
@ -332,7 +329,7 @@ impl HTMLElement {
|
||||||
pub fn get_custom_attr(&self, local_name: DOMString) -> Option<DOMString> {
|
pub fn get_custom_attr(&self, local_name: DOMString) -> Option<DOMString> {
|
||||||
let local_name = Atom::from_slice(&to_snake_case(local_name));
|
let local_name = Atom::from_slice(&to_snake_case(local_name));
|
||||||
self.upcast::<Element>().get_attribute(&ns!(""), &local_name).map(|attr| {
|
self.upcast::<Element>().get_attribute(&ns!(""), &local_name).map(|attr| {
|
||||||
(**attr.r().value()).to_owned()
|
(**attr.value()).to_owned()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,9 +416,9 @@ impl VirtualMethods for HTMLElement {
|
||||||
match (attr.local_name(), mutation) {
|
match (attr.local_name(), mutation) {
|
||||||
(name, AttributeMutation::Set(_)) if name.starts_with("on") => {
|
(name, AttributeMutation::Set(_)) if name.starts_with("on") => {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let (cx, url, reflector) = (window.r().get_cx(),
|
let (cx, url, reflector) = (window.get_cx(),
|
||||||
window.r().get_url(),
|
window.get_url(),
|
||||||
window.r().reflector().get_jsobject());
|
window.reflector().get_jsobject());
|
||||||
let evtarget = self.upcast::<EventTarget>();
|
let evtarget = self.upcast::<EventTarget>();
|
||||||
evtarget.set_event_handler_uncompiled(cx, url, reflector,
|
evtarget.set_event_handler_uncompiled(cx, url, reflector,
|
||||||
&name[2..],
|
&name[2..],
|
||||||
|
|
|
@ -113,7 +113,7 @@ impl VirtualMethods for HTMLFieldSetElement {
|
||||||
});
|
});
|
||||||
let fields = children.flat_map(|child| {
|
let fields = children.flat_map(|child| {
|
||||||
child.traverse_preorder().filter(|descendant| {
|
child.traverse_preorder().filter(|descendant| {
|
||||||
match descendant.r().type_id() {
|
match descendant.type_id() {
|
||||||
NodeTypeId::Element(
|
NodeTypeId::Element(
|
||||||
ElementTypeId::HTMLElement(
|
ElementTypeId::HTMLElement(
|
||||||
HTMLElementTypeId::HTMLButtonElement)) |
|
HTMLElementTypeId::HTMLButtonElement)) |
|
||||||
|
|
|
@ -155,7 +155,7 @@ impl HTMLFormElement {
|
||||||
// Step 1
|
// Step 1
|
||||||
let doc = document_from_node(self);
|
let doc = document_from_node(self);
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
let base = doc.r().url();
|
let base = doc.url();
|
||||||
// TODO: Handle browsing contexts
|
// TODO: Handle browsing contexts
|
||||||
// TODO: Handle validation
|
// TODO: Handle validation
|
||||||
let event = Event::new(GlobalRef::Window(win.r()),
|
let event = Event::new(GlobalRef::Window(win.r()),
|
||||||
|
@ -163,7 +163,7 @@ impl HTMLFormElement {
|
||||||
EventBubbles::Bubbles,
|
EventBubbles::Bubbles,
|
||||||
EventCancelable::Cancelable);
|
EventCancelable::Cancelable);
|
||||||
event.fire(self.upcast());
|
event.fire(self.upcast());
|
||||||
if event.r().DefaultPrevented() {
|
if event.DefaultPrevented() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Step 6
|
// Step 6
|
||||||
|
@ -211,8 +211,8 @@ impl HTMLFormElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is wrong. https://html.spec.whatwg.org/multipage/#planned-navigation
|
// This is wrong. https://html.spec.whatwg.org/multipage/#planned-navigation
|
||||||
win.r().main_thread_script_chan().send(MainThreadScriptMsg::Navigate(
|
win.main_thread_script_chan().send(MainThreadScriptMsg::Navigate(
|
||||||
win.r().pipeline(), load_data)).unwrap();
|
win.pipeline(), load_data)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_unclean_dataset(&self, submitter: Option<FormSubmitter>) -> Vec<FormDatum> {
|
fn get_unclean_dataset(&self, submitter: Option<FormSubmitter>) -> Vec<FormDatum> {
|
||||||
|
@ -225,11 +225,11 @@ impl HTMLFormElement {
|
||||||
_ => return None,
|
_ => return None,
|
||||||
}
|
}
|
||||||
|
|
||||||
if child.r().ancestors()
|
if child.ancestors()
|
||||||
.any(|a| Root::downcast::<HTMLDataListElement>(a).is_some()) {
|
.any(|a| Root::downcast::<HTMLDataListElement>(a).is_some()) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
match child.r().type_id() {
|
match child.type_id() {
|
||||||
NodeTypeId::Element(ElementTypeId::HTMLElement(element)) => {
|
NodeTypeId::Element(ElementTypeId::HTMLElement(element)) => {
|
||||||
match element {
|
match element {
|
||||||
HTMLElementTypeId::HTMLInputElement => {
|
HTMLElementTypeId::HTMLInputElement => {
|
||||||
|
@ -315,14 +315,14 @@ impl HTMLFormElement {
|
||||||
EventBubbles::Bubbles,
|
EventBubbles::Bubbles,
|
||||||
EventCancelable::Cancelable);
|
EventCancelable::Cancelable);
|
||||||
event.fire(self.upcast());
|
event.fire(self.upcast());
|
||||||
if event.r().DefaultPrevented() {
|
if event.DefaultPrevented() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This is an incorrect way of getting controls owned
|
// TODO: This is an incorrect way of getting controls owned
|
||||||
// by the form, but good enough until html5ever lands
|
// by the form, but good enough until html5ever lands
|
||||||
for child in self.upcast::<Node>().traverse_preorder() {
|
for child in self.upcast::<Node>().traverse_preorder() {
|
||||||
match child.r().type_id() {
|
match child.type_id() {
|
||||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => {
|
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => {
|
||||||
child.downcast::<HTMLInputElement>().unwrap().reset();
|
child.downcast::<HTMLInputElement>().unwrap().reset();
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ pub trait FormControl: DerivedFrom<Element> + Reflectable {
|
||||||
let owner = elem.get_string_attribute(&atom!("form"));
|
let owner = elem.get_string_attribute(&atom!("form"));
|
||||||
if !owner.is_empty() {
|
if !owner.is_empty() {
|
||||||
let doc = document_from_node(elem);
|
let doc = document_from_node(elem);
|
||||||
let owner = doc.r().GetElementById(owner);
|
let owner = doc.GetElementById(owner);
|
||||||
match owner {
|
match owner {
|
||||||
Some(ref o) => {
|
Some(ref o) => {
|
||||||
let maybe_form = o.downcast::<HTMLFormElement>();
|
let maybe_form = o.downcast::<HTMLFormElement>();
|
||||||
|
|
|
@ -69,12 +69,12 @@ impl HTMLIFrameElement {
|
||||||
pub fn get_url(&self) -> Option<Url> {
|
pub fn get_url(&self) -> Option<Url> {
|
||||||
let element = self.upcast::<Element>();
|
let element = self.upcast::<Element>();
|
||||||
element.get_attribute(&ns!(""), &atom!("src")).and_then(|src| {
|
element.get_attribute(&ns!(""), &atom!("src")).and_then(|src| {
|
||||||
let url = src.r().value();
|
let url = src.value();
|
||||||
if url.is_empty() {
|
if url.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
UrlParser::new().base_url(&window.r().get_url())
|
UrlParser::new().base_url(&window.get_url())
|
||||||
.parse(&url).ok()
|
.parse(&url).ok()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -85,7 +85,7 @@ impl HTMLIFrameElement {
|
||||||
|
|
||||||
let old_subpage_id = self.subpage_id.get();
|
let old_subpage_id = self.subpage_id.get();
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
let subpage_id = win.r().get_next_subpage_id();
|
let subpage_id = win.get_next_subpage_id();
|
||||||
self.subpage_id.set(Some(subpage_id));
|
self.subpage_id.set(Some(subpage_id));
|
||||||
(subpage_id, old_subpage_id)
|
(subpage_id, old_subpage_id)
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ impl HTMLIFrameElement {
|
||||||
|
|
||||||
if self.Mozbrowser() {
|
if self.Mozbrowser() {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let cx = window.r().get_cx();
|
let cx = window.get_cx();
|
||||||
let _ar = JSAutoRequest::new(cx);
|
let _ar = JSAutoRequest::new(cx);
|
||||||
let _ac = JSAutoCompartment::new(cx, window.reflector().get_jsobject().get());
|
let _ac = JSAutoCompartment::new(cx, window.reflector().get_jsobject().get());
|
||||||
let mut detail = RootedValue::new(cx, UndefinedValue());
|
let mut detail = RootedValue::new(cx, UndefinedValue());
|
||||||
|
@ -272,7 +272,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
||||||
let children = window.page().children.borrow();
|
let children = window.page().children.borrow();
|
||||||
children.iter().find(|page| {
|
children.iter().find(|page| {
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
window.r().subpage() == Some(subpage_id)
|
window.subpage() == Some(subpage_id)
|
||||||
}).map(|page| page.window())
|
}).map(|page| page.window())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -284,10 +284,10 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
||||||
Some(self_url) => self_url,
|
Some(self_url) => self_url,
|
||||||
None => return None,
|
None => return None,
|
||||||
};
|
};
|
||||||
let win_url = window_from_node(self).r().get_url();
|
let win_url = window_from_node(self).get_url();
|
||||||
|
|
||||||
if UrlHelper::SameOrigin(&self_url, &win_url) {
|
if UrlHelper::SameOrigin(&self_url, &win_url) {
|
||||||
Some(window.r().Document())
|
Some(window.Document())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ impl Runnable for ImageResponseHandlerRunnable {
|
||||||
event.fire(element.upcast());
|
event.fire(element.upcast());
|
||||||
|
|
||||||
// Trigger reflow
|
// Trigger reflow
|
||||||
window.r().add_pending_reflow();
|
window.add_pending_reflow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ impl HTMLImageElement {
|
||||||
/// prefetching the image. This method must be called after `src` is changed.
|
/// prefetching the image. This method must be called after `src` is changed.
|
||||||
fn update_image(&self, value: Option<(DOMString, Url)>) {
|
fn update_image(&self, value: Option<(DOMString, Url)>) {
|
||||||
let document = document_from_node(self);
|
let document = document_from_node(self);
|
||||||
let window = document.r().window();
|
let window = document.window();
|
||||||
let image_cache = window.image_cache_task();
|
let image_cache = window.image_cache_task();
|
||||||
match value {
|
match value {
|
||||||
None => {
|
None => {
|
||||||
|
|
|
@ -367,8 +367,8 @@ fn broadcast_radio_checked(broadcaster: &HTMLInputElement, group: Option<&Atom>)
|
||||||
.filter_map(Root::downcast::<HTMLInputElement>)
|
.filter_map(Root::downcast::<HTMLInputElement>)
|
||||||
.filter(|r| in_same_group(r.r(), owner, group) && broadcaster != r.r());
|
.filter(|r| in_same_group(r.r(), owner, group) && broadcaster != r.r());
|
||||||
for ref r in iter {
|
for ref r in iter {
|
||||||
if r.r().Checked() {
|
if r.Checked() {
|
||||||
r.r().SetChecked(false);
|
r.SetChecked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -379,11 +379,9 @@ fn broadcast_radio_checked(broadcaster: &HTMLInputElement, group: Option<&Atom>)
|
||||||
// https://html.spec.whatwg.org/multipage/#radio-button-group
|
// https://html.spec.whatwg.org/multipage/#radio-button-group
|
||||||
fn in_same_group(other: &HTMLInputElement, owner: Option<&HTMLFormElement>,
|
fn in_same_group(other: &HTMLInputElement, owner: Option<&HTMLFormElement>,
|
||||||
group: Option<&Atom>) -> bool {
|
group: Option<&Atom>) -> bool {
|
||||||
let other_owner = other.form_owner();
|
|
||||||
let other_owner = other_owner.r();
|
|
||||||
other.input_type.get() == InputType::InputRadio &&
|
other.input_type.get() == InputType::InputRadio &&
|
||||||
// TODO Both a and b are in the same home subtree.
|
// TODO Both a and b are in the same home subtree.
|
||||||
other_owner == owner &&
|
other.form_owner().r() == owner &&
|
||||||
match (other.get_radio_group_name(), group) {
|
match (other.get_radio_group_name(), group) {
|
||||||
(Some(ref s1), Some(s2)) => compatibility_caseless_match_str(s1, s2) && s2 != &atom!(""),
|
(Some(ref s1), Some(s2)) => compatibility_caseless_match_str(s1, s2) && s2 != &atom!(""),
|
||||||
_ => false
|
_ => false
|
||||||
|
@ -714,7 +712,7 @@ impl Activatable for HTMLInputElement {
|
||||||
.filter_map(Root::downcast::<HTMLInputElement>)
|
.filter_map(Root::downcast::<HTMLInputElement>)
|
||||||
.find(|r| {
|
.find(|r| {
|
||||||
in_same_group(r.r(), owner.r(), group.as_ref()) &&
|
in_same_group(r.r(), owner.r(), group.as_ref()) &&
|
||||||
r.r().Checked()
|
r.Checked()
|
||||||
});
|
});
|
||||||
cache.checked_radio = checked_member.r().map(JS::from_ref);
|
cache.checked_radio = checked_member.r().map(JS::from_ref);
|
||||||
cache.checked_changed = self.checked_changed.get();
|
cache.checked_changed = self.checked_changed.get();
|
||||||
|
@ -789,8 +787,8 @@ impl Activatable for HTMLInputElement {
|
||||||
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
|
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
|
||||||
if self.mutable() /* and document owner is fully active */ {
|
if self.mutable() /* and document owner is fully active */ {
|
||||||
self.form_owner().map(|o| {
|
self.form_owner().map(|o| {
|
||||||
o.r().submit(SubmittedFrom::NotFromFormSubmitMethod,
|
o.submit(SubmittedFrom::NotFromFormSubmitMethod,
|
||||||
FormSubmitter::InputElement(self.clone()))
|
FormSubmitter::InputElement(self.clone()))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -799,7 +797,7 @@ impl Activatable for HTMLInputElement {
|
||||||
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
|
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
|
||||||
if self.mutable() /* and document owner is fully active */ {
|
if self.mutable() /* and document owner is fully active */ {
|
||||||
self.form_owner().map(|o| {
|
self.form_owner().map(|o| {
|
||||||
o.r().reset(ResetFrom::NotFromFormResetMethod)
|
o.reset(ResetFrom::NotFromFormResetMethod)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -844,18 +842,18 @@ impl Activatable for HTMLInputElement {
|
||||||
let submit_button;
|
let submit_button;
|
||||||
submit_button = node.query_selector_iter("input[type=submit]".to_owned()).unwrap()
|
submit_button = node.query_selector_iter("input[type=submit]".to_owned()).unwrap()
|
||||||
.filter_map(Root::downcast::<HTMLInputElement>)
|
.filter_map(Root::downcast::<HTMLInputElement>)
|
||||||
.find(|r| r.r().form_owner() == owner);
|
.find(|r| r.form_owner() == owner);
|
||||||
match submit_button {
|
match submit_button {
|
||||||
Some(ref button) => {
|
Some(ref button) => {
|
||||||
if button.r().is_instance_activatable() {
|
if button.is_instance_activatable() {
|
||||||
button.r().synthetic_click_activation(ctrlKey, shiftKey, altKey, metaKey)
|
button.synthetic_click_activation(ctrlKey, shiftKey, altKey, metaKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let inputs = node.query_selector_iter("input".to_owned()).unwrap()
|
let inputs = node.query_selector_iter("input".to_owned()).unwrap()
|
||||||
.filter_map(Root::downcast::<HTMLInputElement>)
|
.filter_map(Root::downcast::<HTMLInputElement>)
|
||||||
.filter(|input| {
|
.filter(|input| {
|
||||||
input.r().form_owner() == owner && match &*input.r().Type() {
|
input.form_owner() == owner && match &*input.Type() {
|
||||||
"text" | "search" | "url" | "tel" |
|
"text" | "search" | "url" | "tel" |
|
||||||
"email" | "password" | "datetime" |
|
"email" | "password" | "datetime" |
|
||||||
"date" | "month" | "week" | "time" |
|
"date" | "month" | "week" | "time" |
|
||||||
|
@ -869,8 +867,8 @@ impl Activatable for HTMLInputElement {
|
||||||
// lazily test for > 1 submission-blocking inputs
|
// lazily test for > 1 submission-blocking inputs
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
form.r().submit(SubmittedFrom::NotFromFormSubmitMethod,
|
form.submit(SubmittedFrom::NotFromFormSubmitMethod,
|
||||||
FormSubmitter::FormElement(form.r()));
|
FormSubmitter::FormElement(form.r()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl HTMLLinkElement {
|
||||||
|
|
||||||
fn get_attr(element: &Element, local_name: &Atom) -> Option<String> {
|
fn get_attr(element: &Element, local_name: &Atom) -> Option<String> {
|
||||||
let elem = element.get_attribute(&ns!(""), local_name);
|
let elem = element.get_attribute(&ns!(""), local_name);
|
||||||
elem.r().map(|e| {
|
elem.map(|e| {
|
||||||
let value = e.value();
|
let value = e.value();
|
||||||
(**value).to_owned()
|
(**value).to_owned()
|
||||||
})
|
})
|
||||||
|
@ -168,7 +168,7 @@ impl HTMLLinkElement {
|
||||||
let link_element = Trusted::new(window.get_cx(), self, window.script_chan().clone());
|
let link_element = Trusted::new(window.get_cx(), self, window.script_chan().clone());
|
||||||
let load_dispatcher = StylesheetLoadDispatcher::new(link_element);
|
let load_dispatcher = StylesheetLoadDispatcher::new(link_element);
|
||||||
|
|
||||||
let pending = doc.r().prepare_async_load(LoadType::Stylesheet(url.clone()));
|
let pending = doc.prepare_async_load(LoadType::Stylesheet(url.clone()));
|
||||||
let LayoutChan(ref layout_chan) = window.layout_chan();
|
let LayoutChan(ref layout_chan) = window.layout_chan();
|
||||||
layout_chan.send(Msg::LoadStylesheet(url, media, pending, box load_dispatcher)).unwrap();
|
layout_chan.send(Msg::LoadStylesheet(url, media, pending, box load_dispatcher)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl HTMLMetaElement {
|
||||||
if !content.is_empty() {
|
if !content.is_empty() {
|
||||||
if let Some(translated_rule) = ViewportRule::from_meta(&**content) {
|
if let Some(translated_rule) = ViewportRule::from_meta(&**content) {
|
||||||
let win = window_from_node(self);
|
let win = window_from_node(self);
|
||||||
let LayoutChan(ref layout_chan) = win.r().layout_chan();
|
let LayoutChan(ref layout_chan) = win.layout_chan();
|
||||||
|
|
||||||
layout_chan.send(Msg::AddMetaViewport(translated_rule)).unwrap();
|
layout_chan.send(Msg::AddMetaViewport(translated_rule)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,11 +154,11 @@ impl AsyncResponseListener for ScriptContext {
|
||||||
});
|
});
|
||||||
let elem = self.elem.root();
|
let elem = self.elem.root();
|
||||||
// TODO: maybe set this to None again after script execution to save memory.
|
// TODO: maybe set this to None again after script execution to save memory.
|
||||||
*elem.r().load.borrow_mut() = Some(ScriptOrigin::External(load));
|
*elem.load.borrow_mut() = Some(ScriptOrigin::External(load));
|
||||||
elem.ready_to_be_parser_executed.set(true);
|
elem.ready_to_be_parser_executed.set(true);
|
||||||
|
|
||||||
let document = document_from_node(elem.r());
|
let document = document_from_node(elem.r());
|
||||||
document.r().finish_load(LoadType::Script(self.url.clone()));
|
document.finish_load(LoadType::Script(self.url.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ impl HTMLScriptElement {
|
||||||
|
|
||||||
// Step 13.
|
// Step 13.
|
||||||
if let Some(ref charset) = element.get_attribute(&ns!(""), &atom!("charset")) {
|
if let Some(ref charset) = element.get_attribute(&ns!(""), &atom!("charset")) {
|
||||||
if let Some(encodingRef) = encoding_from_whatwg_label(&charset.r().Value()) {
|
if let Some(encodingRef) = encoding_from_whatwg_label(&charset.Value()) {
|
||||||
*self.block_character_encoding.borrow_mut() = encodingRef;
|
*self.block_character_encoding.borrow_mut() = encodingRef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ impl HTMLScriptElement {
|
||||||
listener.notify(message.to().unwrap());
|
listener.notify(message.to().unwrap());
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.r().load_async(LoadType::Script(url), response_target);
|
doc.load_async(LoadType::Script(url), response_target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
|
@ -310,32 +310,32 @@ impl HTMLScriptElement {
|
||||||
deferred &&
|
deferred &&
|
||||||
was_parser_inserted &&
|
was_parser_inserted &&
|
||||||
!async {
|
!async {
|
||||||
doc.r().add_deferred_script(self);
|
doc.add_deferred_script(self);
|
||||||
// Second part implemented in Document::process_deferred_scripts.
|
// Second part implemented in Document::process_deferred_scripts.
|
||||||
return NextParserState::Continue;
|
return NextParserState::Continue;
|
||||||
// Step 15.b, has src, was parser-inserted, is not async.
|
// Step 15.b, has src, was parser-inserted, is not async.
|
||||||
} else if is_external &&
|
} else if is_external &&
|
||||||
was_parser_inserted &&
|
was_parser_inserted &&
|
||||||
!async {
|
!async {
|
||||||
doc.r().set_pending_parsing_blocking_script(Some(self));
|
doc.set_pending_parsing_blocking_script(Some(self));
|
||||||
// Second part implemented in the load result handler.
|
// Second part implemented in the load result handler.
|
||||||
// Step 15.c, doesn't have src, was parser-inserted, is blocked on stylesheet.
|
// Step 15.c, doesn't have src, was parser-inserted, is blocked on stylesheet.
|
||||||
} else if !is_external &&
|
} else if !is_external &&
|
||||||
was_parser_inserted &&
|
was_parser_inserted &&
|
||||||
// TODO: check for script nesting levels.
|
// TODO: check for script nesting levels.
|
||||||
doc.r().get_script_blocking_stylesheets_count() > 0 {
|
doc.get_script_blocking_stylesheets_count() > 0 {
|
||||||
doc.r().set_pending_parsing_blocking_script(Some(self));
|
doc.set_pending_parsing_blocking_script(Some(self));
|
||||||
*self.load.borrow_mut() = Some(ScriptOrigin::Internal(text, base_url));
|
*self.load.borrow_mut() = Some(ScriptOrigin::Internal(text, base_url));
|
||||||
self.ready_to_be_parser_executed.set(true);
|
self.ready_to_be_parser_executed.set(true);
|
||||||
// Step 15.d, has src, isn't async, isn't non-blocking.
|
// Step 15.d, has src, isn't async, isn't non-blocking.
|
||||||
} else if is_external &&
|
} else if is_external &&
|
||||||
!async &&
|
!async &&
|
||||||
!self.non_blocking.get() {
|
!self.non_blocking.get() {
|
||||||
doc.r().push_asap_in_order_script(self);
|
doc.push_asap_in_order_script(self);
|
||||||
// Second part implemented in Document::process_asap_scripts.
|
// Second part implemented in Document::process_asap_scripts.
|
||||||
// Step 15.e, has src.
|
// Step 15.e, has src.
|
||||||
} else if is_external {
|
} else if is_external {
|
||||||
doc.r().add_asap_script(self);
|
doc.add_asap_script(self);
|
||||||
// Second part implemented in Document::process_asap_scripts.
|
// Second part implemented in Document::process_asap_scripts.
|
||||||
// Step 15.f, otherwise.
|
// Step 15.f, otherwise.
|
||||||
} else {
|
} else {
|
||||||
|
@ -347,8 +347,8 @@ impl HTMLScriptElement {
|
||||||
}
|
}
|
||||||
// TODO: make this suspension happen automatically.
|
// TODO: make this suspension happen automatically.
|
||||||
if was_parser_inserted {
|
if was_parser_inserted {
|
||||||
if let Some(parser) = doc.r().get_current_parser() {
|
if let Some(parser) = doc.get_current_parser() {
|
||||||
parser.r().suspend();
|
parser.suspend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NextParserState::Suspend;
|
return NextParserState::Suspend;
|
||||||
|
@ -432,8 +432,8 @@ impl HTMLScriptElement {
|
||||||
// Step 2.b.6.
|
// Step 2.b.6.
|
||||||
// TODO: Create a script...
|
// TODO: Create a script...
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let mut rval = RootedValue::new(window.r().get_cx(), UndefinedValue());
|
let mut rval = RootedValue::new(window.get_cx(), UndefinedValue());
|
||||||
window.r().evaluate_script_on_global_with_result(&*source,
|
window.evaluate_script_on_global_with_result(&*source,
|
||||||
&*url.serialize(),
|
&*url.serialize(),
|
||||||
rval.handle_mut());
|
rval.handle_mut());
|
||||||
|
|
||||||
|
@ -451,8 +451,8 @@ impl HTMLScriptElement {
|
||||||
if external {
|
if external {
|
||||||
self.dispatch_load_event();
|
self.dispatch_load_event();
|
||||||
} else {
|
} else {
|
||||||
let chan = window.r().script_chan();
|
let chan = window.script_chan();
|
||||||
let handler = Trusted::new(window.r().get_cx(), self, chan.clone());
|
let handler = Trusted::new(window.get_cx(), self, chan.clone());
|
||||||
let dispatcher = box EventDispatcher {
|
let dispatcher = box EventDispatcher {
|
||||||
element: handler,
|
element: handler,
|
||||||
is_error: false,
|
is_error: false,
|
||||||
|
@ -632,9 +632,9 @@ impl Runnable for EventDispatcher {
|
||||||
fn handler(self: Box<EventDispatcher>) {
|
fn handler(self: Box<EventDispatcher>) {
|
||||||
let target = self.element.root();
|
let target = self.element.root();
|
||||||
if self.is_error {
|
if self.is_error {
|
||||||
target.r().dispatch_error_event();
|
target.dispatch_error_event();
|
||||||
} else {
|
} else {
|
||||||
target.r().dispatch_load_event();
|
target.dispatch_load_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,7 @@ impl VirtualMethods for HTMLSelectElement {
|
||||||
|
|
||||||
let node = self.upcast::<Node>();
|
let node = self.upcast::<Node>();
|
||||||
let el = self.upcast::<Element>();
|
let el = self.upcast::<Element>();
|
||||||
if node.ancestors().any(|ancestor| ancestor.r().is::<HTMLFieldSetElement>()) {
|
if node.ancestors().any(|ancestor| ancestor.is::<HTMLFieldSetElement>()) {
|
||||||
el.check_ancestors_disabled_state_for_form_control();
|
el.check_ancestors_disabled_state_for_form_control();
|
||||||
} else {
|
} else {
|
||||||
el.check_disabled_attribute();
|
el.check_disabled_attribute();
|
||||||
|
|
|
@ -45,12 +45,11 @@ impl HTMLStyleElement {
|
||||||
assert!(node.is_in_doc());
|
assert!(node.is_in_doc());
|
||||||
|
|
||||||
let win = window_from_node(node);
|
let win = window_from_node(node);
|
||||||
let win = win.r();
|
|
||||||
let url = win.get_url();
|
let url = win.get_url();
|
||||||
|
|
||||||
let mq_attribute = element.get_attribute(&ns!(""), &atom!("media"));
|
let mq_attribute = element.get_attribute(&ns!(""), &atom!("media"));
|
||||||
let mq_str = match mq_attribute {
|
let mq_str = match mq_attribute {
|
||||||
Some(a) => String::from(&**a.r().value()),
|
Some(a) => String::from(&**a.value()),
|
||||||
None => String::new(),
|
None => String::new(),
|
||||||
};
|
};
|
||||||
let mut css_parser = CssParser::new(&mq_str);
|
let mut css_parser = CssParser::new(&mq_str);
|
||||||
|
|
|
@ -372,6 +372,6 @@ pub struct ChangeEventRunnable {
|
||||||
impl Runnable for ChangeEventRunnable {
|
impl Runnable for ChangeEventRunnable {
|
||||||
fn handler(self: Box<ChangeEventRunnable>) {
|
fn handler(self: Box<ChangeEventRunnable>) {
|
||||||
let target = self.element.root();
|
let target = self.element.root();
|
||||||
target.r().dispatch_change_event();
|
target.dispatch_change_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,8 +72,7 @@ impl VirtualMethods for HTMLTitleElement {
|
||||||
fn bind_to_tree(&self, is_in_doc: bool) {
|
fn bind_to_tree(&self, is_in_doc: bool) {
|
||||||
let node = self.upcast::<Node>();
|
let node = self.upcast::<Node>();
|
||||||
if is_in_doc {
|
if is_in_doc {
|
||||||
let document = node.owner_doc();
|
node.owner_doc().title_changed();
|
||||||
document.r().title_changed();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,8 +84,8 @@ impl KeyboardEvent {
|
||||||
char_code: Option<u32>,
|
char_code: Option<u32>,
|
||||||
key_code: u32) -> Root<KeyboardEvent> {
|
key_code: u32) -> Root<KeyboardEvent> {
|
||||||
let ev = KeyboardEvent::new_uninitialized(window);
|
let ev = KeyboardEvent::new_uninitialized(window);
|
||||||
ev.r().InitKeyboardEvent(type_, canBubble, cancelable, view, key_string, location,
|
ev.InitKeyboardEvent(type_, canBubble, cancelable, view, key_string, location,
|
||||||
"".to_owned(), repeat, "".to_owned());
|
"".to_owned(), repeat, "".to_owned());
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
{
|
{
|
||||||
let ev = ev.r();
|
let ev = ev.r();
|
||||||
|
|
|
@ -84,7 +84,7 @@ macro_rules! make_url_or_base_getter(
|
||||||
let url = element.get_url_attribute(&Atom::from_slice($htmlname));
|
let url = element.get_url_attribute(&Atom::from_slice($htmlname));
|
||||||
if url.is_empty() {
|
if url.is_empty() {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
window.r().get_url().serialize()
|
window.get_url().serialize()
|
||||||
} else {
|
} else {
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,11 +74,11 @@ impl MouseEvent {
|
||||||
button: i16,
|
button: i16,
|
||||||
relatedTarget: Option<&EventTarget>) -> Root<MouseEvent> {
|
relatedTarget: Option<&EventTarget>) -> Root<MouseEvent> {
|
||||||
let ev = MouseEvent::new_uninitialized(window);
|
let ev = MouseEvent::new_uninitialized(window);
|
||||||
ev.r().InitMouseEvent(type_, canBubble == EventBubbles::Bubbles, cancelable == EventCancelable::Cancelable,
|
ev.InitMouseEvent(type_, canBubble == EventBubbles::Bubbles, cancelable == EventCancelable::Cancelable,
|
||||||
view, detail,
|
view, detail,
|
||||||
screenX, screenY, clientX, clientY,
|
screenX, screenY, clientX, clientY,
|
||||||
ctrlKey, altKey, shiftKey, metaKey,
|
ctrlKey, altKey, shiftKey, metaKey,
|
||||||
button, relatedTarget);
|
button, relatedTarget);
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,7 @@ impl Node {
|
||||||
None => self.first_child.set(Some(new_child)),
|
None => self.first_child.set(Some(new_child)),
|
||||||
Some(ref last_child) => {
|
Some(ref last_child) => {
|
||||||
assert!(last_child.next_sibling.get().is_none());
|
assert!(last_child.next_sibling.get().is_none());
|
||||||
last_child.r().next_sibling.set(Some(new_child));
|
last_child.next_sibling.set(Some(new_child));
|
||||||
new_child.prev_sibling.set(Some(&last_child));
|
new_child.prev_sibling.set(Some(&last_child));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ impl Node {
|
||||||
pub fn teardown(&self) {
|
pub fn teardown(&self) {
|
||||||
self.layout_data.dispose(self);
|
self.layout_data.dispose(self);
|
||||||
for kid in self.children() {
|
for kid in self.children() {
|
||||||
kid.r().teardown();
|
kid.teardown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ impl Node {
|
||||||
|
|
||||||
// FIXME: this should have a pure version?
|
// FIXME: this should have a pure version?
|
||||||
for kid in self.children() {
|
for kid in self.children() {
|
||||||
kid.r().dump_indent(indent + 1)
|
kid.dump_indent(indent + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,8 +515,8 @@ impl Node {
|
||||||
|
|
||||||
// 4. Dirty ancestors.
|
// 4. Dirty ancestors.
|
||||||
for ancestor in self.ancestors() {
|
for ancestor in self.ancestors() {
|
||||||
if !force_ancestors && ancestor.r().get_has_dirty_descendants() { break }
|
if !force_ancestors && ancestor.get_has_dirty_descendants() { break }
|
||||||
ancestor.r().set_has_dirty_descendants(true);
|
ancestor.set_has_dirty_descendants(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,15 +585,15 @@ impl Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_bounding_content_box(&self) -> Rect<Au> {
|
pub fn get_bounding_content_box(&self) -> Rect<Au> {
|
||||||
window_from_node(self).r().content_box_query(self.to_trusted_node_address())
|
window_from_node(self).content_box_query(self.to_trusted_node_address())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_content_boxes(&self) -> Vec<Rect<Au>> {
|
pub fn get_content_boxes(&self) -> Vec<Rect<Au>> {
|
||||||
window_from_node(self).r().content_boxes_query(self.to_trusted_node_address())
|
window_from_node(self).content_boxes_query(self.to_trusted_node_address())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_client_rect(&self) -> Rect<i32> {
|
pub fn get_client_rect(&self) -> Rect<i32> {
|
||||||
window_from_node(self).r().client_rect_query(self.to_trusted_node_address())
|
window_from_node(self).client_rect_query(self.to_trusted_node_address())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-childnode-before
|
// https://dom.spec.whatwg.org/#dom-childnode-before
|
||||||
|
@ -658,9 +658,9 @@ impl Node {
|
||||||
Some(ref parent_node) => {
|
Some(ref parent_node) => {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
let doc = self.owner_doc();
|
let doc = self.owner_doc();
|
||||||
let node = try!(doc.r().node_from_nodes_and_strings(nodes));
|
let node = try!(doc.node_from_nodes_and_strings(nodes));
|
||||||
// Step 3.
|
// Step 3.
|
||||||
parent_node.r().ReplaceChild(node.r(), self).map(|_| ())
|
parent_node.ReplaceChild(node.r(), self).map(|_| ())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -669,7 +669,7 @@ impl Node {
|
||||||
pub fn prepend(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
pub fn prepend(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let doc = self.owner_doc();
|
let doc = self.owner_doc();
|
||||||
let node = try!(doc.r().node_from_nodes_and_strings(nodes));
|
let node = try!(doc.node_from_nodes_and_strings(nodes));
|
||||||
// Step 2.
|
// Step 2.
|
||||||
let first_child = self.first_child.get();
|
let first_child = self.first_child.get();
|
||||||
Node::pre_insert(node.r(), self, first_child.r()).map(|_| ())
|
Node::pre_insert(node.r(), self, first_child.r()).map(|_| ())
|
||||||
|
@ -679,7 +679,7 @@ impl Node {
|
||||||
pub fn append(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
pub fn append(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let doc = self.owner_doc();
|
let doc = self.owner_doc();
|
||||||
let node = try!(doc.r().node_from_nodes_and_strings(nodes));
|
let node = try!(doc.node_from_nodes_and_strings(nodes));
|
||||||
// Step 2.
|
// Step 2.
|
||||||
self.AppendChild(node.r()).map(|_| ())
|
self.AppendChild(node.r()).map(|_| ())
|
||||||
}
|
}
|
||||||
|
@ -745,7 +745,7 @@ impl Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_in_html_doc(&self) -> bool {
|
pub fn is_in_html_doc(&self) -> bool {
|
||||||
self.owner_doc().r().is_html_document()
|
self.owner_doc().is_html_document()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn children(&self) -> NodeSiblingIterator {
|
pub fn children(&self) -> NodeSiblingIterator {
|
||||||
|
@ -782,11 +782,11 @@ impl Node {
|
||||||
NodeInfo {
|
NodeInfo {
|
||||||
uniqueId: self.get_unique_id(),
|
uniqueId: self.get_unique_id(),
|
||||||
baseURI: self.BaseURI(),
|
baseURI: self.BaseURI(),
|
||||||
parent: self.GetParentNode().map(|node| node.r().get_unique_id()).unwrap_or("".to_owned()),
|
parent: self.GetParentNode().map(|node| node.get_unique_id()).unwrap_or("".to_owned()),
|
||||||
nodeType: self.NodeType(),
|
nodeType: self.NodeType(),
|
||||||
namespaceURI: "".to_owned(), //FIXME
|
namespaceURI: "".to_owned(), //FIXME
|
||||||
nodeName: self.NodeName(),
|
nodeName: self.NodeName(),
|
||||||
numChildren: self.ChildNodes().r().Length() as usize,
|
numChildren: self.ChildNodes().Length() as usize,
|
||||||
|
|
||||||
//FIXME doctype nodes only
|
//FIXME doctype nodes only
|
||||||
name: "".to_owned(),
|
name: "".to_owned(),
|
||||||
|
@ -809,7 +809,7 @@ impl Node {
|
||||||
pub fn parse_fragment(&self, markup: DOMString) -> Fallible<Root<DocumentFragment>> {
|
pub fn parse_fragment(&self, markup: DOMString) -> Fallible<Root<DocumentFragment>> {
|
||||||
let context_document = document_from_node(self);
|
let context_document = document_from_node(self);
|
||||||
let fragment = DocumentFragment::new(context_document.r());
|
let fragment = DocumentFragment::new(context_document.r());
|
||||||
if context_document.r().is_html_document() {
|
if context_document.is_html_document() {
|
||||||
parse_html_fragment(self.upcast(), markup, fragment.upcast());
|
parse_html_fragment(self.upcast(), markup, fragment.upcast());
|
||||||
} else {
|
} else {
|
||||||
// FIXME: XML case
|
// FIXME: XML case
|
||||||
|
@ -1052,7 +1052,7 @@ impl Iterator for NodeSiblingIterator {
|
||||||
None => return None,
|
None => return None,
|
||||||
Some(current) => current,
|
Some(current) => current,
|
||||||
};
|
};
|
||||||
self.current = current.r().GetNextSibling();
|
self.current = current.GetNextSibling();
|
||||||
Some(current)
|
Some(current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1069,7 +1069,7 @@ impl Iterator for ReverseSiblingIterator {
|
||||||
None => return None,
|
None => return None,
|
||||||
Some(current) => current,
|
Some(current) => current,
|
||||||
};
|
};
|
||||||
self.current = current.r().GetPreviousSibling();
|
self.current = current.GetPreviousSibling();
|
||||||
Some(current)
|
Some(current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1089,9 +1089,9 @@ impl Iterator for FollowingNodeIterator {
|
||||||
Some(current) => current,
|
Some(current) => current,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(first_child) = current.r().GetFirstChild() {
|
if let Some(first_child) = current.GetFirstChild() {
|
||||||
self.current = Some(first_child);
|
self.current = Some(first_child);
|
||||||
return current.r().GetFirstChild()
|
return current.GetFirstChild()
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.root == current {
|
if self.root == current {
|
||||||
|
@ -1099,18 +1099,18 @@ impl Iterator for FollowingNodeIterator {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(next_sibling) = current.r().GetNextSibling() {
|
if let Some(next_sibling) = current.GetNextSibling() {
|
||||||
self.current = Some(next_sibling);
|
self.current = Some(next_sibling);
|
||||||
return current.r().GetNextSibling()
|
return current.GetNextSibling()
|
||||||
}
|
}
|
||||||
|
|
||||||
for ancestor in current.r().inclusive_ancestors() {
|
for ancestor in current.inclusive_ancestors() {
|
||||||
if self.root == ancestor {
|
if self.root == ancestor {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if let Some(next_sibling) = ancestor.r().GetNextSibling() {
|
if let Some(next_sibling) = ancestor.GetNextSibling() {
|
||||||
self.current = Some(next_sibling);
|
self.current = Some(next_sibling);
|
||||||
return ancestor.r().GetNextSibling()
|
return ancestor.GetNextSibling()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.current = None;
|
self.current = None;
|
||||||
|
@ -1139,24 +1139,24 @@ impl Iterator for PrecedingNodeIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
let node = current;
|
let node = current;
|
||||||
if let Some(previous_sibling) = node.r().GetPreviousSibling() {
|
if let Some(previous_sibling) = node.GetPreviousSibling() {
|
||||||
if self.root == previous_sibling {
|
if self.root == previous_sibling {
|
||||||
self.current = None;
|
self.current = None;
|
||||||
return None
|
return None
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(last_child) = previous_sibling.r().descending_last_children().last() {
|
if let Some(last_child) = previous_sibling.descending_last_children().last() {
|
||||||
self.current = Some(last_child);
|
self.current = Some(last_child);
|
||||||
return previous_sibling.r().descending_last_children().last()
|
return previous_sibling.descending_last_children().last()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.current = Some(previous_sibling);
|
self.current = Some(previous_sibling);
|
||||||
return node.r().GetPreviousSibling()
|
return node.GetPreviousSibling()
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(parent_node) = node.r().GetParentNode() {
|
if let Some(parent_node) = node.GetParentNode() {
|
||||||
self.current = Some(parent_node);
|
self.current = Some(parent_node);
|
||||||
return node.r().GetParentNode()
|
return node.GetParentNode()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.current = None;
|
self.current = None;
|
||||||
|
@ -1176,7 +1176,7 @@ impl Iterator for LastChildIterator {
|
||||||
None => return None,
|
None => return None,
|
||||||
Some(current) => current,
|
Some(current) => current,
|
||||||
};
|
};
|
||||||
self.current = current.r().GetLastChild();
|
self.current = current.GetLastChild();
|
||||||
Some(current)
|
Some(current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1193,7 +1193,7 @@ impl Iterator for AncestorIterator {
|
||||||
None => return None,
|
None => return None,
|
||||||
Some(current) => current,
|
Some(current) => current,
|
||||||
};
|
};
|
||||||
self.current = current.r().GetParentNode();
|
self.current = current.GetParentNode();
|
||||||
Some(current)
|
Some(current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1221,16 +1221,16 @@ impl Iterator for TreeIterator {
|
||||||
None => return None,
|
None => return None,
|
||||||
Some(current) => current,
|
Some(current) => current,
|
||||||
};
|
};
|
||||||
if let Some(first_child) = current.r().GetFirstChild() {
|
if let Some(first_child) = current.GetFirstChild() {
|
||||||
self.current = Some(first_child);
|
self.current = Some(first_child);
|
||||||
self.depth += 1;
|
self.depth += 1;
|
||||||
return Some(current);
|
return Some(current);
|
||||||
};
|
};
|
||||||
for ancestor in current.r().inclusive_ancestors() {
|
for ancestor in current.inclusive_ancestors() {
|
||||||
if self.depth == 0 {
|
if self.depth == 0 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if let Some(next_sibling) = ancestor.r().GetNextSibling() {
|
if let Some(next_sibling) = ancestor.GetNextSibling() {
|
||||||
self.current = Some(next_sibling);
|
self.current = Some(next_sibling);
|
||||||
return Some(current);
|
return Some(current);
|
||||||
}
|
}
|
||||||
|
@ -1359,7 +1359,7 @@ impl Node {
|
||||||
NodeTypeId::DocumentFragment => {
|
NodeTypeId::DocumentFragment => {
|
||||||
// Step 6.1.1(b)
|
// Step 6.1.1(b)
|
||||||
if node.children()
|
if node.children()
|
||||||
.any(|c| c.r().is::<Text>())
|
.any(|c| c.is::<Text>())
|
||||||
{
|
{
|
||||||
return Err(Error::HierarchyRequest);
|
return Err(Error::HierarchyRequest);
|
||||||
}
|
}
|
||||||
|
@ -1372,7 +1372,7 @@ impl Node {
|
||||||
}
|
}
|
||||||
if let Some(child) = child {
|
if let Some(child) = child {
|
||||||
if child.inclusively_following_siblings()
|
if child.inclusively_following_siblings()
|
||||||
.any(|child| child.r().is_doctype()) {
|
.any(|child| child.is_doctype()) {
|
||||||
return Err(Error::HierarchyRequest);
|
return Err(Error::HierarchyRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1388,7 +1388,7 @@ impl Node {
|
||||||
}
|
}
|
||||||
if let Some(ref child) = child {
|
if let Some(ref child) = child {
|
||||||
if child.inclusively_following_siblings()
|
if child.inclusively_following_siblings()
|
||||||
.any(|child| child.r().is_doctype()) {
|
.any(|child| child.is_doctype()) {
|
||||||
return Err(Error::HierarchyRequest);
|
return Err(Error::HierarchyRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1396,7 +1396,7 @@ impl Node {
|
||||||
// Step 6.3
|
// Step 6.3
|
||||||
NodeTypeId::DocumentType => {
|
NodeTypeId::DocumentType => {
|
||||||
if parent.children()
|
if parent.children()
|
||||||
.any(|c| c.r().is_doctype())
|
.any(|c| c.is_doctype())
|
||||||
{
|
{
|
||||||
return Err(Error::HierarchyRequest);
|
return Err(Error::HierarchyRequest);
|
||||||
}
|
}
|
||||||
|
@ -1404,7 +1404,7 @@ impl Node {
|
||||||
Some(child) => {
|
Some(child) => {
|
||||||
if parent.children()
|
if parent.children()
|
||||||
.take_while(|c| c.r() != child)
|
.take_while(|c| c.r() != child)
|
||||||
.any(|c| c.r().is::<Element>())
|
.any(|c| c.is::<Element>())
|
||||||
{
|
{
|
||||||
return Err(Error::HierarchyRequest);
|
return Err(Error::HierarchyRequest);
|
||||||
}
|
}
|
||||||
|
@ -1635,7 +1635,7 @@ impl Node {
|
||||||
Some(doc) => Root::from_ref(doc),
|
Some(doc) => Root::from_ref(doc),
|
||||||
None => Root::from_ref(document.r()),
|
None => Root::from_ref(document.r()),
|
||||||
};
|
};
|
||||||
assert!(copy.r().owner_doc() == document);
|
assert!(copy.owner_doc() == document);
|
||||||
|
|
||||||
// Step 4 (some data already copied in step 2).
|
// Step 4 (some data already copied in step 2).
|
||||||
match node.type_id() {
|
match node.type_id() {
|
||||||
|
@ -1834,7 +1834,7 @@ impl NodeMethods for Node {
|
||||||
fn ChildNodes(&self) -> Root<NodeList> {
|
fn ChildNodes(&self) -> Root<NodeList> {
|
||||||
self.child_list.or_init(|| {
|
self.child_list.or_init(|| {
|
||||||
let doc = self.owner_doc();
|
let doc = self.owner_doc();
|
||||||
let window = doc.r().window();
|
let window = doc.window();
|
||||||
NodeList::new_child_list(window, self)
|
NodeList::new_child_list(window, self)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1923,7 +1923,7 @@ impl NodeMethods for Node {
|
||||||
|
|
||||||
// Notify the document that the content of this node is different
|
// Notify the document that the content of this node is different
|
||||||
let document = self.owner_doc();
|
let document = self.owner_doc();
|
||||||
document.r().content_changed(self, NodeDamage::OtherNodeDamage);
|
document.content_changed(self, NodeDamage::OtherNodeDamage);
|
||||||
}
|
}
|
||||||
NodeTypeId::DocumentType |
|
NodeTypeId::DocumentType |
|
||||||
NodeTypeId::Document => {}
|
NodeTypeId::Document => {}
|
||||||
|
@ -2102,7 +2102,7 @@ impl NodeMethods for Node {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
child.r().Normalize();
|
child.Normalize();
|
||||||
prev_text = None;
|
prev_text = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2241,7 +2241,7 @@ impl NodeMethods for Node {
|
||||||
NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
|
NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
for child in lastself.r().traverse_preorder() {
|
for child in lastself.traverse_preorder() {
|
||||||
if child.r() == other {
|
if child.r() == other {
|
||||||
// step 6.
|
// step 6.
|
||||||
return NodeConstants::DOCUMENT_POSITION_PRECEDING;
|
return NodeConstants::DOCUMENT_POSITION_PRECEDING;
|
||||||
|
@ -2279,13 +2279,13 @@ impl NodeMethods for Node {
|
||||||
},
|
},
|
||||||
NodeTypeId::Document => {
|
NodeTypeId::Document => {
|
||||||
self.downcast::<Document>().unwrap().GetDocumentElement().and_then(|element| {
|
self.downcast::<Document>().unwrap().GetDocumentElement().and_then(|element| {
|
||||||
element.r().lookup_prefix(namespace)
|
element.lookup_prefix(namespace)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
NodeTypeId::DocumentType | NodeTypeId::DocumentFragment => None,
|
NodeTypeId::DocumentType | NodeTypeId::DocumentFragment => None,
|
||||||
_ => {
|
_ => {
|
||||||
self.GetParentElement().and_then(|element| {
|
self.GetParentElement().and_then(|element| {
|
||||||
element.r().lookup_prefix(namespace)
|
element.lookup_prefix(namespace)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2330,7 +2330,7 @@ pub fn document_from_node<T: DerivedFrom<Node> + Reflectable>(derived: &T) -> Ro
|
||||||
|
|
||||||
pub fn window_from_node<T: DerivedFrom<Node> + Reflectable>(derived: &T) -> Root<Window> {
|
pub fn window_from_node<T: DerivedFrom<Node> + Reflectable>(derived: &T) -> Root<Window> {
|
||||||
let document = document_from_node(derived);
|
let document = document_from_node(derived);
|
||||||
Root::from_ref(document.r().window())
|
Root::from_ref(document.window())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VirtualMethods for Node {
|
impl VirtualMethods for Node {
|
||||||
|
|
|
@ -121,7 +121,7 @@ impl NodeIteratorMethods for NodeIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3-1.
|
// Step 3-1.
|
||||||
for following_node in node.r().following_nodes(&self.root_node) {
|
for following_node in node.following_nodes(&self.root_node) {
|
||||||
// Step 3-2.
|
// Step 3-2.
|
||||||
let result = try!(self.accept_node(following_node.r()));
|
let result = try!(self.accept_node(following_node.r()));
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ impl NodeIteratorMethods for NodeIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3-1.
|
// Step 3-1.
|
||||||
for preceding_node in node.r().preceding_nodes(&self.root_node) {
|
for preceding_node in node.preceding_nodes(&self.root_node) {
|
||||||
|
|
||||||
// Step 3-2.
|
// Step 3-2.
|
||||||
let result = try!(self.accept_node(preceding_node.r()));
|
let result = try!(self.accept_node(preceding_node.r()));
|
||||||
|
|
|
@ -810,10 +810,10 @@ fn bp_position(a_node: &Node, a_offset: u32,
|
||||||
// Step 3-1, 3-2.
|
// Step 3-1, 3-2.
|
||||||
let mut b_ancestors = b_node.inclusive_ancestors();
|
let mut b_ancestors = b_node.inclusive_ancestors();
|
||||||
let child = b_ancestors.find(|child| {
|
let child = b_ancestors.find(|child| {
|
||||||
child.r().GetParentNode().unwrap().r() == a_node
|
child.GetParentNode().unwrap().r() == a_node
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
// Step 3-3.
|
// Step 3-3.
|
||||||
if child.r().index() < a_offset {
|
if child.index() < a_offset {
|
||||||
Some(Ordering::Greater)
|
Some(Ordering::Greater)
|
||||||
} else {
|
} else {
|
||||||
// Step 4.
|
// Step 4.
|
||||||
|
|
|
@ -159,7 +159,7 @@ impl AsyncResponseListener for ParserContext {
|
||||||
Some(parser) => parser.root(),
|
Some(parser) => parser.root(),
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
parser.r().parse_chunk(data);
|
parser.parse_chunk(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,9 +175,9 @@ impl AsyncResponseListener for ParserContext {
|
||||||
// TODO(Savago): we should send a notification to callers #5463.
|
// TODO(Savago): we should send a notification to callers #5463.
|
||||||
}
|
}
|
||||||
|
|
||||||
parser.r().last_chunk_received.set(true);
|
parser.last_chunk_received.set(true);
|
||||||
if !parser.r().is_suspended() {
|
if !parser.is_suspended() {
|
||||||
parser.r().parse_sync();
|
parser.parse_sync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl TextMethods for Text {
|
||||||
// Step 5.
|
// Step 5.
|
||||||
let node = self.upcast::<Node>();
|
let node = self.upcast::<Node>();
|
||||||
let owner_doc = node.owner_doc();
|
let owner_doc = node.owner_doc();
|
||||||
let new_node = owner_doc.r().CreateTextNode(new_data);
|
let new_node = owner_doc.CreateTextNode(new_data);
|
||||||
// Step 6.
|
// Step 6.
|
||||||
let parent = node.GetParentNode();
|
let parent = node.GetParentNode();
|
||||||
if let Some(ref parent) = parent {
|
if let Some(ref parent) = parent {
|
||||||
|
@ -79,10 +79,10 @@ impl TextMethods for Text {
|
||||||
// https://dom.spec.whatwg.org/#dom-text-wholetext
|
// https://dom.spec.whatwg.org/#dom-text-wholetext
|
||||||
fn WholeText(&self) -> DOMString {
|
fn WholeText(&self) -> DOMString {
|
||||||
let first = self.upcast::<Node>().inclusively_preceding_siblings()
|
let first = self.upcast::<Node>().inclusively_preceding_siblings()
|
||||||
.take_while(|node| node.r().is::<Text>())
|
.take_while(|node| node.is::<Text>())
|
||||||
.last().unwrap();
|
.last().unwrap();
|
||||||
let nodes = first.r().inclusively_following_siblings()
|
let nodes = first.inclusively_following_siblings()
|
||||||
.take_while(|node| node.r().is::<Text>());
|
.take_while(|node| node.is::<Text>());
|
||||||
let mut text = DOMString::new();
|
let mut text = DOMString::new();
|
||||||
for ref node in nodes {
|
for ref node in nodes {
|
||||||
let cdata = node.downcast::<CharacterData>().unwrap();
|
let cdata = node.downcast::<CharacterData>().unwrap();
|
||||||
|
|
|
@ -151,7 +151,7 @@ impl TreeWalkerMethods for TreeWalker {
|
||||||
// "2. While node is not root, run these substeps:"
|
// "2. While node is not root, run these substeps:"
|
||||||
while !self.is_root_node(node.r()) {
|
while !self.is_root_node(node.r()) {
|
||||||
// "1. Let sibling be the previous sibling of node."
|
// "1. Let sibling be the previous sibling of node."
|
||||||
let mut sibling_op = node.r().GetPreviousSibling();
|
let mut sibling_op = node.GetPreviousSibling();
|
||||||
// "2. While sibling is not null, run these subsubsteps:"
|
// "2. While sibling is not null, run these subsubsteps:"
|
||||||
while sibling_op.is_some() {
|
while sibling_op.is_some() {
|
||||||
// "1. Set node to sibling."
|
// "1. Set node to sibling."
|
||||||
|
@ -183,7 +183,7 @@ impl TreeWalkerMethods for TreeWalker {
|
||||||
return Ok(None)
|
return Ok(None)
|
||||||
}
|
}
|
||||||
// "4. Set node to its parent."
|
// "4. Set node to its parent."
|
||||||
match node.r().GetParentNode() {
|
match node.GetParentNode() {
|
||||||
None =>
|
None =>
|
||||||
// This can happen if the user set the current node to somewhere
|
// This can happen if the user set the current node to somewhere
|
||||||
// outside of the tree rooted at the original root.
|
// outside of the tree rooted at the original root.
|
||||||
|
@ -214,7 +214,7 @@ impl TreeWalkerMethods for TreeWalker {
|
||||||
if NodeFilterConstants::FILTER_REJECT == result {
|
if NodeFilterConstants::FILTER_REJECT == result {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
match node.r().GetFirstChild() {
|
match node.GetFirstChild() {
|
||||||
None => break,
|
None => break,
|
||||||
Some (child) => {
|
Some (child) => {
|
||||||
// "1. Set node to its first child."
|
// "1. Set node to its first child."
|
||||||
|
|
|
@ -47,8 +47,8 @@ impl UIEvent {
|
||||||
view: Option<&Window>,
|
view: Option<&Window>,
|
||||||
detail: i32) -> Root<UIEvent> {
|
detail: i32) -> Root<UIEvent> {
|
||||||
let ev = UIEvent::new_uninitialized(window);
|
let ev = UIEvent::new_uninitialized(window);
|
||||||
ev.r().InitUIEvent(type_, can_bubble == EventBubbles::Bubbles,
|
ev.InitUIEvent(type_, can_bubble == EventBubbles::Bubbles,
|
||||||
cancelable == EventCancelable::Cancelable, view, detail);
|
cancelable == EventCancelable::Cancelable, view, detail);
|
||||||
ev
|
ev
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,11 @@ impl URLSearchParams {
|
||||||
match init {
|
match init {
|
||||||
Some(eUSVString(init)) => {
|
Some(eUSVString(init)) => {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
*query.r().list.borrow_mut() = parse(init.0.as_bytes());
|
*query.list.borrow_mut() = parse(init.0.as_bytes());
|
||||||
},
|
},
|
||||||
Some(eURLSearchParams(init)) => {
|
Some(eURLSearchParams(init)) => {
|
||||||
// Step 3.
|
// Step 3.
|
||||||
*query.r().list.borrow_mut() = init.r().list.borrow().clone();
|
*query.list.borrow_mut() = init.list.borrow().clone();
|
||||||
},
|
},
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -844,7 +844,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
(image_data.get_data_array(&global.r()), image_data.get_size())
|
(image_data.get_data_array(&global.r()), image_data.get_size())
|
||||||
},
|
},
|
||||||
ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::eHTMLImageElement(image) => {
|
ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::eHTMLImageElement(image) => {
|
||||||
let img_url = match image.r().get_url() {
|
let img_url = match image.get_url() {
|
||||||
Some(url) => url,
|
Some(url) => url,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
@ -900,7 +900,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
constants::TEXTURE_2D |
|
constants::TEXTURE_2D |
|
||||||
constants::TEXTURE_CUBE_MAP => {
|
constants::TEXTURE_CUBE_MAP => {
|
||||||
if let Some(texture) = self.bound_texture_for(target) {
|
if let Some(texture) = self.bound_texture_for(target) {
|
||||||
let result = texture.r().tex_parameter(target, name, TexParameterValue::Float(value));
|
let result = texture.tex_parameter(target, name, TexParameterValue::Float(value));
|
||||||
handle_potential_webgl_error!(self, result);
|
handle_potential_webgl_error!(self, result);
|
||||||
} else {
|
} else {
|
||||||
return self.webgl_error(InvalidOperation);
|
return self.webgl_error(InvalidOperation);
|
||||||
|
@ -917,7 +917,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
constants::TEXTURE_2D |
|
constants::TEXTURE_2D |
|
||||||
constants::TEXTURE_CUBE_MAP => {
|
constants::TEXTURE_CUBE_MAP => {
|
||||||
if let Some(texture) = self.bound_texture_for(target) {
|
if let Some(texture) = self.bound_texture_for(target) {
|
||||||
let result = texture.r().tex_parameter(target, name, TexParameterValue::Int(value));
|
let result = texture.tex_parameter(target, name, TexParameterValue::Int(value));
|
||||||
handle_potential_webgl_error!(self, result);
|
handle_potential_webgl_error!(self, result);
|
||||||
} else {
|
} else {
|
||||||
return self.webgl_error(InvalidOperation);
|
return self.webgl_error(InvalidOperation);
|
||||||
|
|
|
@ -439,7 +439,7 @@ impl Runnable for ConnectionEstablishedTask {
|
||||||
fn handler(self: Box<Self>) {
|
fn handler(self: Box<Self>) {
|
||||||
let ws = self.addr.root();
|
let ws = self.addr.root();
|
||||||
|
|
||||||
*ws.r().sender.borrow_mut() = Some(self.sender);
|
*ws.sender.borrow_mut() = Some(self.sender);
|
||||||
|
|
||||||
// Step 1: Protocols.
|
// Step 1: Protocols.
|
||||||
|
|
||||||
|
|
|
@ -379,7 +379,7 @@ impl WindowMethods for Window {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-location
|
// https://html.spec.whatwg.org/multipage/#dom-location
|
||||||
fn Location(&self) -> Root<Location> {
|
fn Location(&self) -> Root<Location> {
|
||||||
self.Document().r().Location()
|
self.Document().Location()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-sessionstorage
|
// https://html.spec.whatwg.org/multipage/#dom-sessionstorage
|
||||||
|
@ -533,13 +533,13 @@ impl WindowMethods for Window {
|
||||||
let _ = callback.Call__(Finite::wrap(now), ExceptionHandling::Report);
|
let _ = callback.Call__(Finite::wrap(now), ExceptionHandling::Report);
|
||||||
};
|
};
|
||||||
|
|
||||||
doc.r().request_animation_frame(Box::new(callback))
|
doc.request_animation_frame(Box::new(callback))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#dom-window-cancelanimationframe
|
/// https://html.spec.whatwg.org/multipage/#dom-window-cancelanimationframe
|
||||||
fn CancelAnimationFrame(&self, ident: u32) {
|
fn CancelAnimationFrame(&self, ident: u32) {
|
||||||
let doc = self.Document();
|
let doc = self.Document();
|
||||||
doc.r().cancel_animation_frame(ident);
|
doc.cancel_animation_frame(ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-window-captureevents
|
// https://html.spec.whatwg.org/multipage/#dom-window-captureevents
|
||||||
|
@ -908,7 +908,7 @@ impl Window {
|
||||||
goal: goal,
|
goal: goal,
|
||||||
page_clip_rect: self.page_clip_rect.get(),
|
page_clip_rect: self.page_clip_rect.get(),
|
||||||
},
|
},
|
||||||
document: self.Document().r().upcast::<Node>().to_trusted_node_address(),
|
document: self.Document().upcast::<Node>().to_trusted_node_address(),
|
||||||
window_size: window_size,
|
window_size: window_size,
|
||||||
script_join_chan: join_chan,
|
script_join_chan: join_chan,
|
||||||
query_type: query_type,
|
query_type: query_type,
|
||||||
|
@ -1042,8 +1042,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_url(&self) -> Url {
|
pub fn get_url(&self) -> Url {
|
||||||
let doc = self.Document();
|
(*self.Document().url()).clone()
|
||||||
(*doc.r().url()).clone()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resource_task(&self) -> ResourceTask {
|
pub fn resource_task(&self) -> ResourceTask {
|
||||||
|
@ -1140,8 +1139,7 @@ impl Window {
|
||||||
|
|
||||||
// Push the document title to the compositor since we are
|
// Push the document title to the compositor since we are
|
||||||
// activating this document due to a navigation.
|
// activating this document due to a navigation.
|
||||||
let document = self.Document();
|
self.Document().title_changed();
|
||||||
document.r().title_changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn freeze(&self) {
|
pub fn freeze(&self) {
|
||||||
|
|
|
@ -205,7 +205,7 @@ impl XMLHttpRequest {
|
||||||
if response.network_error {
|
if response.network_error {
|
||||||
let mut context = self.xhr.lock().unwrap();
|
let mut context = self.xhr.lock().unwrap();
|
||||||
let xhr = context.xhr.root();
|
let xhr = context.xhr.root();
|
||||||
xhr.r().process_partial_response(XHRProgress::Errored(context.gen_id, Error::Network));
|
xhr.process_partial_response(XHRProgress::Errored(context.gen_id, Error::Network));
|
||||||
*context.sync_status.borrow_mut() = Some(Err(Error::Network));
|
*context.sync_status.borrow_mut() = Some(Err(Error::Network));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -239,9 +239,9 @@ impl XMLHttpRequest {
|
||||||
impl AsyncResponseListener for XHRContext {
|
impl AsyncResponseListener for XHRContext {
|
||||||
fn headers_available(&mut self, metadata: Metadata) {
|
fn headers_available(&mut self, metadata: Metadata) {
|
||||||
let xhr = self.xhr.root();
|
let xhr = self.xhr.root();
|
||||||
let rv = xhr.r().process_headers_available(self.cors_request.clone(),
|
let rv = xhr.process_headers_available(self.cors_request.clone(),
|
||||||
self.gen_id,
|
self.gen_id,
|
||||||
metadata);
|
metadata);
|
||||||
if rv.is_err() {
|
if rv.is_err() {
|
||||||
*self.sync_status.borrow_mut() = Some(rv);
|
*self.sync_status.borrow_mut() = Some(rv);
|
||||||
}
|
}
|
||||||
|
@ -249,21 +249,18 @@ impl XMLHttpRequest {
|
||||||
|
|
||||||
fn data_available(&mut self, payload: Vec<u8>) {
|
fn data_available(&mut self, payload: Vec<u8>) {
|
||||||
self.buf.borrow_mut().push_all(&payload);
|
self.buf.borrow_mut().push_all(&payload);
|
||||||
let xhr = self.xhr.root();
|
self.xhr.root().process_data_available(self.gen_id, self.buf.borrow().clone());
|
||||||
xhr.r().process_data_available(self.gen_id, self.buf.borrow().clone());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn response_complete(&mut self, status: Result<(), String>) {
|
fn response_complete(&mut self, status: Result<(), String>) {
|
||||||
let xhr = self.xhr.root();
|
let rv = self.xhr.root().process_response_complete(self.gen_id, status);
|
||||||
let rv = xhr.r().process_response_complete(self.gen_id, status);
|
|
||||||
*self.sync_status.borrow_mut() = Some(rv);
|
*self.sync_status.borrow_mut() = Some(rv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PreInvoke for XHRContext {
|
impl PreInvoke for XHRContext {
|
||||||
fn should_invoke(&self) -> bool {
|
fn should_invoke(&self) -> bool {
|
||||||
let xhr = self.xhr.root();
|
self.xhr.root().generation_id.get() == self.gen_id
|
||||||
xhr.r().generation_id.get() == self.gen_id
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,8 +946,8 @@ impl XMLHttpRequest {
|
||||||
fn handler(self: Box<XHRTimeout>) {
|
fn handler(self: Box<XHRTimeout>) {
|
||||||
let this = *self;
|
let this = *self;
|
||||||
let xhr = this.xhr.root();
|
let xhr = this.xhr.root();
|
||||||
if xhr.r().ready_state.get() != XMLHttpRequestState::Done {
|
if xhr.ready_state.get() != XMLHttpRequestState::Done {
|
||||||
xhr.r().process_partial_response(XHRProgress::Errored(this.gen_id, Error::Timeout));
|
xhr.process_partial_response(XHRProgress::Errored(this.gen_id, Error::Timeout));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1110,7 +1107,7 @@ impl Extractable for SendParam {
|
||||||
},
|
},
|
||||||
eURLSearchParams(ref usp) => {
|
eURLSearchParams(ref usp) => {
|
||||||
// Default encoding is UTF-8.
|
// Default encoding is UTF-8.
|
||||||
usp.r().serialize(None).into_bytes()
|
usp.serialize(None).into_bytes()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl<'a> TreeSink for servohtmlparser::Sink {
|
||||||
ElementCreator::ParserCreated);
|
ElementCreator::ParserCreated);
|
||||||
|
|
||||||
for attr in attrs {
|
for attr in attrs {
|
||||||
elem.r().set_attribute_from_parser(attr.name, attr.value.into(), None);
|
elem.set_attribute_from_parser(attr.name, attr.value.into(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::from_ref(elem.upcast())
|
JS::from_ref(elem.upcast())
|
||||||
|
@ -92,7 +92,7 @@ impl<'a> TreeSink for servohtmlparser::Sink {
|
||||||
};
|
};
|
||||||
|
|
||||||
let child = self.get_or_create(new_node);
|
let child = self.get_or_create(new_node);
|
||||||
assert!(parent.r().InsertBefore(child.r(), Some(&*sibling)).is_ok());
|
assert!(parent.InsertBefore(child.r(), Some(&*sibling)).is_ok());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ impl<'a> TreeSink for servohtmlparser::Sink {
|
||||||
|
|
||||||
fn remove_from_parent(&mut self, target: JS<Node>) {
|
fn remove_from_parent(&mut self, target: JS<Node>) {
|
||||||
if let Some(ref parent) = target.GetParentNode() {
|
if let Some(ref parent) = target.GetParentNode() {
|
||||||
parent.r().RemoveChild(&*target).unwrap();
|
parent.RemoveChild(&*target).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ pub fn parse_html(document: &Document,
|
||||||
ParseContext::Fragment(fc) =>
|
ParseContext::Fragment(fc) =>
|
||||||
ServoHTMLParser::new_for_fragment(Some(url), document, fc),
|
ServoHTMLParser::new_for_fragment(Some(url), document, fc),
|
||||||
};
|
};
|
||||||
parser.r().parse_chunk(input.into());
|
parser.parse_chunk(input.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#parsing-html-fragments
|
// https://html.spec.whatwg.org/multipage/#parsing-html-fragments
|
||||||
|
@ -267,11 +267,11 @@ pub fn parse_html_fragment(context_node: &Node,
|
||||||
loader);
|
loader);
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
document.r().set_quirks_mode(context_document.quirks_mode());
|
document.set_quirks_mode(context_document.quirks_mode());
|
||||||
|
|
||||||
// Step 11.
|
// Step 11.
|
||||||
let form = context_node.inclusive_ancestors()
|
let form = context_node.inclusive_ancestors()
|
||||||
.find(|element| element.r().is::<HTMLFormElement>());
|
.find(|element| element.is::<HTMLFormElement>());
|
||||||
let fragment_context = FragmentContext {
|
let fragment_context = FragmentContext {
|
||||||
context_elem: context_node,
|
context_elem: context_node,
|
||||||
form_elem: form.r(),
|
form_elem: form.r(),
|
||||||
|
@ -279,7 +279,7 @@ pub fn parse_html_fragment(context_node: &Node,
|
||||||
parse_html(document.r(), input, url.clone(), ParseContext::Fragment(fragment_context));
|
parse_html(document.r(), input, url.clone(), ParseContext::Fragment(fragment_context));
|
||||||
|
|
||||||
// Step 14.
|
// Step 14.
|
||||||
let root_element = document.r().GetDocumentElement().expect("no document element");
|
let root_element = document.GetDocumentElement().expect("no document element");
|
||||||
for child in root_element.upcast::<Node>().children() {
|
for child in root_element.upcast::<Node>().children() {
|
||||||
output.AppendChild(child.r()).unwrap();
|
output.AppendChild(child.r()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,7 +451,7 @@ impl<'a> Drop for ScriptMemoryFailsafe<'a> {
|
||||||
let page = owner.page.borrow_for_script_deallocation();
|
let page = owner.page.borrow_for_script_deallocation();
|
||||||
for page in page.iter() {
|
for page in page.iter() {
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
window.r().clear_js_runtime_for_script_deallocation();
|
window.clear_js_runtime_for_script_deallocation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -714,9 +714,9 @@ impl ScriptTask {
|
||||||
for page in page.iter() {
|
for page in page.iter() {
|
||||||
// Only process a resize if layout is idle.
|
// Only process a resize if layout is idle.
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
let resize_event = window.r().steal_resize_event();
|
let resize_event = window.steal_resize_event();
|
||||||
match resize_event {
|
match resize_event {
|
||||||
Some(size) => resizes.push((window.r().pipeline(), size)),
|
Some(size) => resizes.push((window.pipeline(), size)),
|
||||||
None => ()
|
None => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -866,11 +866,11 @@ impl ScriptTask {
|
||||||
if let Some(page) = page.as_ref() {
|
if let Some(page) = page.as_ref() {
|
||||||
for page in page.iter() {
|
for page in page.iter() {
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
let pending_reflows = window.r().get_pending_reflow_count();
|
let pending_reflows = window.get_pending_reflow_count();
|
||||||
if pending_reflows > 0 {
|
if pending_reflows > 0 {
|
||||||
window.r().reflow(ReflowGoal::ForDisplay,
|
window.reflow(ReflowGoal::ForDisplay,
|
||||||
ReflowQueryType::NoQuery,
|
ReflowQueryType::NoQuery,
|
||||||
ReflowReason::ImageLoaded);
|
ReflowReason::ImageLoaded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1014,7 +1014,7 @@ impl ScriptTask {
|
||||||
pipeline ID not associated with this script task. This is a bug.");
|
pipeline ID not associated with this script task. This is a bug.");
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
|
|
||||||
window.r().handle_fire_timer(id);
|
window.handle_fire_timer(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_msg_from_devtools(&self, msg: DevtoolScriptControlMsg) {
|
fn handle_msg_from_devtools(&self, msg: DevtoolScriptControlMsg) {
|
||||||
|
@ -1086,7 +1086,7 @@ impl ScriptTask {
|
||||||
if let Some(ref page) = page.as_ref() {
|
if let Some(ref page) = page.as_ref() {
|
||||||
if let Some(ref page) = page.find(id) {
|
if let Some(ref page) = page.find(id) {
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
window.r().set_resize_event(size);
|
window.set_resize_event(size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1103,7 +1103,7 @@ impl ScriptTask {
|
||||||
if let Some(page) = page.as_ref() {
|
if let Some(page) = page.as_ref() {
|
||||||
if let Some(ref inner_page) = page.find(id) {
|
if let Some(ref inner_page) = page.find(id) {
|
||||||
let window = inner_page.window();
|
let window = inner_page.window();
|
||||||
if window.r().set_page_clip_rect_with_new_viewport(rect) {
|
if window.set_page_clip_rect_with_new_viewport(rect) {
|
||||||
let page = get_page(page, id);
|
let page = get_page(page, id);
|
||||||
self.rebuild_and_force_reflow(&*page, ReflowReason::Viewport);
|
self.rebuild_and_force_reflow(&*page, ReflowReason::Viewport);
|
||||||
}
|
}
|
||||||
|
@ -1122,7 +1122,7 @@ impl ScriptTask {
|
||||||
fn handle_resource_loaded(&self, pipeline: PipelineId, load: LoadType) {
|
fn handle_resource_loaded(&self, pipeline: PipelineId, load: LoadType) {
|
||||||
let page = get_page(&self.root_page(), pipeline);
|
let page = get_page(&self.root_page(), pipeline);
|
||||||
let doc = page.document();
|
let doc = page.document();
|
||||||
doc.r().finish_load(load);
|
doc.finish_load(load);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current state of a given pipeline.
|
/// Get the current state of a given pipeline.
|
||||||
|
@ -1143,15 +1143,15 @@ impl ScriptTask {
|
||||||
// has been kicked off. Since the script task does a join with
|
// has been kicked off. Since the script task does a join with
|
||||||
// layout, this ensures there are no race conditions that can occur
|
// layout, this ensures there are no race conditions that can occur
|
||||||
// between load completing and the first layout completing.
|
// between load completing and the first layout completing.
|
||||||
let load_pending = doc.r().ReadyState() != DocumentReadyState::Complete;
|
let load_pending = doc.ReadyState() != DocumentReadyState::Complete;
|
||||||
if load_pending {
|
if load_pending {
|
||||||
return ScriptState::DocumentLoading;
|
return ScriptState::DocumentLoading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the html element has reftest-wait attribute present.
|
// Checks if the html element has reftest-wait attribute present.
|
||||||
// See http://testthewebforward.org/docs/reftests.html
|
// See http://testthewebforward.org/docs/reftests.html
|
||||||
let html_element = doc.r().GetDocumentElement();
|
let html_element = doc.GetDocumentElement();
|
||||||
let reftest_wait = html_element.r().map_or(false, |elem| elem.has_class(&Atom::from_slice("reftest-wait")));
|
let reftest_wait = html_element.map_or(false, |elem| elem.has_class(&Atom::from_slice("reftest-wait")));
|
||||||
if reftest_wait {
|
if reftest_wait {
|
||||||
return ScriptState::DocumentLoading;
|
return ScriptState::DocumentLoading;
|
||||||
}
|
}
|
||||||
|
@ -1204,7 +1204,7 @@ impl ScriptTask {
|
||||||
|
|
||||||
// Kick off the fetch for the new resource.
|
// Kick off the fetch for the new resource.
|
||||||
let new_load = InProgressLoad::new(new_pipeline_id, Some((containing_pipeline_id, subpage_id)),
|
let new_load = InProgressLoad::new(new_pipeline_id, Some((containing_pipeline_id, subpage_id)),
|
||||||
layout_chan, parent_window.r().window_size(),
|
layout_chan, parent_window.window_size(),
|
||||||
load_data.url.clone());
|
load_data.url.clone());
|
||||||
self.start_page_load(new_load, load_data);
|
self.start_page_load(new_load, load_data);
|
||||||
}
|
}
|
||||||
|
@ -1317,7 +1317,7 @@ impl ScriptTask {
|
||||||
let page = page.find(id).expect("ScriptTask: received freeze msg for a
|
let page = page.find(id).expect("ScriptTask: received freeze msg for a
|
||||||
pipeline ID not associated with this script task. This is a bug.");
|
pipeline ID not associated with this script task. This is a bug.");
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
window.r().freeze();
|
window.freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles thaw message
|
/// Handles thaw message
|
||||||
|
@ -1332,7 +1332,7 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
window.r().thaw();
|
window.thaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_focus_iframe_msg(&self,
|
fn handle_focus_iframe_msg(&self,
|
||||||
|
@ -1345,9 +1345,9 @@ impl ScriptTask {
|
||||||
let frame_element = doc.find_iframe(subpage_id);
|
let frame_element = doc.find_iframe(subpage_id);
|
||||||
|
|
||||||
if let Some(ref frame_element) = frame_element {
|
if let Some(ref frame_element) = frame_element {
|
||||||
doc.r().begin_focus_transaction();
|
doc.begin_focus_transaction();
|
||||||
doc.r().request_focus(frame_element.upcast());
|
doc.request_focus(frame_element.upcast());
|
||||||
doc.r().commit_focus_transaction(FocusType::Parent);
|
doc.commit_focus_transaction(FocusType::Parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1365,7 +1365,7 @@ impl ScriptTask {
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(ref frame_element) = frame_element {
|
if let Some(ref frame_element) = frame_element {
|
||||||
frame_element.r().dispatch_mozbrowser_event(event);
|
frame_element.dispatch_mozbrowser_event(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1380,7 +1380,7 @@ impl ScriptTask {
|
||||||
doc.find_iframe(old_subpage_id)
|
doc.find_iframe(old_subpage_id)
|
||||||
});
|
});
|
||||||
|
|
||||||
frame_element.r().unwrap().update_subpage_id(new_subpage_id);
|
frame_element.unwrap().update_subpage_id(new_subpage_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Window was resized, but this script was not active, so don't reflow yet
|
/// Window was resized, but this script was not active, so don't reflow yet
|
||||||
|
@ -1389,7 +1389,7 @@ impl ScriptTask {
|
||||||
let page = page.find(id).expect("Received resize message for PipelineId not associated
|
let page = page.find(id).expect("Received resize message for PipelineId not associated
|
||||||
with a page in the page tree. This is a bug.");
|
with a page in the page tree. This is a bug.");
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
window.r().set_window_size(new_size);
|
window.set_window_size(new_size);
|
||||||
page.set_reflow_status(true);
|
page.set_reflow_status(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1432,7 +1432,7 @@ impl ScriptTask {
|
||||||
fn handle_get_title_msg(&self, pipeline_id: PipelineId) {
|
fn handle_get_title_msg(&self, pipeline_id: PipelineId) {
|
||||||
let page = get_page(&self.root_page(), pipeline_id);
|
let page = get_page(&self.root_page(), pipeline_id);
|
||||||
let document = page.document();
|
let document = page.document();
|
||||||
document.r().send_title_to_compositor();
|
document.send_title_to_compositor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a request to exit the script task and shut down layout.
|
/// Handles a request to exit the script task and shut down layout.
|
||||||
|
@ -1468,7 +1468,7 @@ impl ScriptTask {
|
||||||
// If root is being exited, shut down all pages
|
// If root is being exited, shut down all pages
|
||||||
let page = self.root_page();
|
let page = self.root_page();
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
if window.r().pipeline() == id {
|
if window.pipeline() == id {
|
||||||
debug!("shutting down layout for root page {:?}", id);
|
debug!("shutting down layout for root page {:?}", id);
|
||||||
shut_down_layout(&page, exit_type);
|
shut_down_layout(&page, exit_type);
|
||||||
return true
|
return true
|
||||||
|
@ -1485,7 +1485,7 @@ impl ScriptTask {
|
||||||
fn handle_tick_all_animations(&self, id: PipelineId) {
|
fn handle_tick_all_animations(&self, id: PipelineId) {
|
||||||
let page = get_page(&self.root_page(), id);
|
let page = get_page(&self.root_page(), id);
|
||||||
let document = page.document();
|
let document = page.document();
|
||||||
document.r().run_the_animation_frame_callbacks();
|
document.run_the_animation_frame_callbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a Web font being loaded. Does nothing if the page no longer exists.
|
/// Handles a Web font being loaded. Does nothing if the page no longer exists.
|
||||||
|
@ -1626,7 +1626,7 @@ impl ScriptTask {
|
||||||
loader);
|
loader);
|
||||||
|
|
||||||
let frame_element = frame_element.r().map(Castable::upcast);
|
let frame_element = frame_element.r().map(Castable::upcast);
|
||||||
window.r().init_browsing_context(document.r(), frame_element);
|
window.init_browsing_context(document.r(), frame_element);
|
||||||
|
|
||||||
// Create the root frame
|
// Create the root frame
|
||||||
page.set_frame(Some(Frame {
|
page.set_frame(Some(Frame {
|
||||||
|
@ -1639,7 +1639,7 @@ impl ScriptTask {
|
||||||
let _ar = JSAutoRequest::new(self.get_cx());
|
let _ar = JSAutoRequest::new(self.get_cx());
|
||||||
let evalstr = incomplete.url.non_relative_scheme_data().unwrap();
|
let evalstr = incomplete.url.non_relative_scheme_data().unwrap();
|
||||||
let mut jsval = RootedValue::new(self.get_cx(), UndefinedValue());
|
let mut jsval = RootedValue::new(self.get_cx(), UndefinedValue());
|
||||||
window.r().evaluate_js_on_global_with_result(evalstr, jsval.handle_mut());
|
window.evaluate_js_on_global_with_result(evalstr, jsval.handle_mut());
|
||||||
let strval = FromJSValConvertible::from_jsval(self.get_cx(), jsval.handle(),
|
let strval = FromJSValConvertible::from_jsval(self.get_cx(), jsval.handle(),
|
||||||
StringificationBehavior::Empty);
|
StringificationBehavior::Empty);
|
||||||
strval.unwrap_or("".to_owned())
|
strval.unwrap_or("".to_owned())
|
||||||
|
@ -1652,7 +1652,7 @@ impl ScriptTask {
|
||||||
|
|
||||||
page_remover.neuter();
|
page_remover.neuter();
|
||||||
|
|
||||||
document.r().get_current_parser().unwrap()
|
document.get_current_parser().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn notify_devtools(&self, title: DOMString, url: Url, ids: (PipelineId, Option<WorkerId>)) {
|
fn notify_devtools(&self, title: DOMString, url: Url, ids: (PipelineId, Option<WorkerId>)) {
|
||||||
|
@ -1691,9 +1691,9 @@ impl ScriptTask {
|
||||||
/// Reflows non-incrementally, rebuilding the entire layout tree in the process.
|
/// Reflows non-incrementally, rebuilding the entire layout tree in the process.
|
||||||
fn rebuild_and_force_reflow(&self, page: &Page, reason: ReflowReason) {
|
fn rebuild_and_force_reflow(&self, page: &Page, reason: ReflowReason) {
|
||||||
let document = page.document();
|
let document = page.document();
|
||||||
document.r().dirty_all_nodes();
|
document.dirty_all_nodes();
|
||||||
let window = window_from_node(document.r());
|
let window = window_from_node(document.r());
|
||||||
window.r().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, reason);
|
window.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is the main entry point for receiving and dispatching DOM events.
|
/// This is the main entry point for receiving and dispatching DOM events.
|
||||||
|
@ -1731,7 +1731,7 @@ impl ScriptTask {
|
||||||
// handle_mouse_move_event() in a safe RootedVec container.
|
// handle_mouse_move_event() in a safe RootedVec container.
|
||||||
let mut mouse_over_targets = RootedVec::new();
|
let mut mouse_over_targets = RootedVec::new();
|
||||||
std_mem::swap(&mut *self.mouse_over_targets.borrow_mut(), &mut *mouse_over_targets);
|
std_mem::swap(&mut *self.mouse_over_targets.borrow_mut(), &mut *mouse_over_targets);
|
||||||
document.r().handle_mouse_move_event(self.js_runtime.rt(), point, &mut mouse_over_targets);
|
document.handle_mouse_move_event(self.js_runtime.rt(), point, &mut mouse_over_targets);
|
||||||
|
|
||||||
// Notify Constellation about anchors that are no longer mouse over targets.
|
// Notify Constellation about anchors that are no longer mouse over targets.
|
||||||
for target in &*prev_mouse_over_targets {
|
for target in &*prev_mouse_over_targets {
|
||||||
|
@ -1751,7 +1751,7 @@ impl ScriptTask {
|
||||||
let status = target.get_attribute(&ns!(""), &atom!("href"))
|
let status = target.get_attribute(&ns!(""), &atom!("href"))
|
||||||
.and_then(|href| {
|
.and_then(|href| {
|
||||||
let value = href.value();
|
let value = href.value();
|
||||||
let url = document.r().url();
|
let url = document.url();
|
||||||
UrlParser::new().base_url(&url).parse(&value).map(|url| url.serialize()).ok()
|
UrlParser::new().base_url(&url).parse(&value).map(|url| url.serialize()).ok()
|
||||||
});
|
});
|
||||||
let event = ConstellationMsg::NodeStatus(status);
|
let event = ConstellationMsg::NodeStatus(status);
|
||||||
|
@ -1788,7 +1788,7 @@ impl ScriptTask {
|
||||||
KeyEvent(key, state, modifiers) => {
|
KeyEvent(key, state, modifiers) => {
|
||||||
let page = get_page(&self.root_page(), pipeline_id);
|
let page = get_page(&self.root_page(), pipeline_id);
|
||||||
let document = page.document();
|
let document = page.document();
|
||||||
document.r().dispatch_key_event(
|
document.dispatch_key_event(
|
||||||
key, state, modifiers, &mut self.compositor.borrow_mut());
|
key, state, modifiers, &mut self.compositor.borrow_mut());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1801,7 +1801,7 @@ impl ScriptTask {
|
||||||
point: Point2D<f32>) {
|
point: Point2D<f32>) {
|
||||||
let page = get_page(&self.root_page(), pipeline_id);
|
let page = get_page(&self.root_page(), pipeline_id);
|
||||||
let document = page.document();
|
let document = page.document();
|
||||||
document.r().handle_mouse_event(self.js_runtime.rt(), button, point, mouse_event_type);
|
document.handle_mouse_event(self.js_runtime.rt(), button, point, mouse_event_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_touch_event(&self,
|
fn handle_touch_event(&self,
|
||||||
|
@ -1812,7 +1812,7 @@ impl ScriptTask {
|
||||||
-> bool {
|
-> bool {
|
||||||
let page = get_page(&self.root_page(), pipeline_id);
|
let page = get_page(&self.root_page(), pipeline_id);
|
||||||
let document = page.document();
|
let document = page.document();
|
||||||
document.r().handle_touch_event(self.js_runtime.rt(), event_type, identifier, point)
|
document.handle_touch_event(self.js_runtime.rt(), event_type, identifier, point)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#navigating-across-documents
|
/// https://html.spec.whatwg.org/multipage/#navigating-across-documents
|
||||||
|
@ -1861,14 +1861,14 @@ impl ScriptTask {
|
||||||
fn handle_resize_event(&self, pipeline_id: PipelineId, new_size: WindowSizeData) {
|
fn handle_resize_event(&self, pipeline_id: PipelineId, new_size: WindowSizeData) {
|
||||||
let page = get_page(&self.root_page(), pipeline_id);
|
let page = get_page(&self.root_page(), pipeline_id);
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
window.r().set_window_size(new_size);
|
window.set_window_size(new_size);
|
||||||
window.r().force_reflow(ReflowGoal::ForDisplay,
|
window.force_reflow(ReflowGoal::ForDisplay,
|
||||||
ReflowQueryType::NoQuery,
|
ReflowQueryType::NoQuery,
|
||||||
ReflowReason::WindowResize);
|
ReflowReason::WindowResize);
|
||||||
|
|
||||||
let document = page.document();
|
let document = page.document();
|
||||||
let fragment_node = window.r().steal_fragment_name()
|
let fragment_node = window.steal_fragment_name()
|
||||||
.and_then(|name| document.r().find_fragment_node(&*name));
|
.and_then(|name| document.find_fragment_node(&*name));
|
||||||
match fragment_node {
|
match fragment_node {
|
||||||
Some(ref node) => self.scroll_fragment_point(pipeline_id, node.r()),
|
Some(ref node) => self.scroll_fragment_point(pipeline_id, node.r()),
|
||||||
None => {}
|
None => {}
|
||||||
|
@ -1931,33 +1931,33 @@ impl ScriptTask {
|
||||||
};
|
};
|
||||||
|
|
||||||
let document = page.document();
|
let document = page.document();
|
||||||
let final_url = document.r().url();
|
let final_url = document.url();
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#the-end step 1
|
// https://html.spec.whatwg.org/multipage/#the-end step 1
|
||||||
document.r().set_ready_state(DocumentReadyState::Interactive);
|
document.set_ready_state(DocumentReadyState::Interactive);
|
||||||
|
|
||||||
// TODO: Execute step 2 here.
|
// TODO: Execute step 2 here.
|
||||||
|
|
||||||
// Kick off the initial reflow of the page.
|
// Kick off the initial reflow of the page.
|
||||||
debug!("kicking off initial reflow of {:?}", final_url);
|
debug!("kicking off initial reflow of {:?}", final_url);
|
||||||
document.r().disarm_reflow_timeout();
|
document.disarm_reflow_timeout();
|
||||||
document.r().content_changed(document.upcast(),
|
document.content_changed(document.upcast(),
|
||||||
NodeDamage::OtherNodeDamage);
|
NodeDamage::OtherNodeDamage);
|
||||||
let window = window_from_node(document.r());
|
let window = window_from_node(document.r());
|
||||||
window.r().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::FirstLoad);
|
window.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::FirstLoad);
|
||||||
|
|
||||||
// No more reflow required
|
// No more reflow required
|
||||||
page.set_reflow_status(false);
|
page.set_reflow_status(false);
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#the-end steps 3-4.
|
// https://html.spec.whatwg.org/multipage/#the-end steps 3-4.
|
||||||
document.r().process_deferred_scripts();
|
document.process_deferred_scripts();
|
||||||
|
|
||||||
window.r().set_fragment_name(final_url.fragment.clone());
|
window.set_fragment_name(final_url.fragment.clone());
|
||||||
|
|
||||||
// Notify devtools that a new script global exists.
|
// Notify devtools that a new script global exists.
|
||||||
//TODO: should this happen as soon as the global is created, or at least once the first
|
//TODO: should this happen as soon as the global is created, or at least once the first
|
||||||
// script runs?
|
// script runs?
|
||||||
self.notify_devtools(document.r().Title(), (*final_url).clone(), (id, None));
|
self.notify_devtools(document.Title(), (*final_url).clone(), (id, None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1978,7 +1978,7 @@ fn shut_down_layout(page_tree: &Rc<Page>, exit_type: PipelineExitType) {
|
||||||
// processed this message.
|
// processed this message.
|
||||||
let (response_chan, response_port) = channel();
|
let (response_chan, response_port) = channel();
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
let LayoutChan(chan) = window.r().layout_chan();
|
let LayoutChan(chan) = window.layout_chan();
|
||||||
if chan.send(layout_interface::Msg::PrepareToExit(response_chan)).is_ok() {
|
if chan.send(layout_interface::Msg::PrepareToExit(response_chan)).is_ok() {
|
||||||
channels.push(chan);
|
channels.push(chan);
|
||||||
response_port.recv().unwrap();
|
response_port.recv().unwrap();
|
||||||
|
@ -1988,7 +1988,7 @@ fn shut_down_layout(page_tree: &Rc<Page>, exit_type: PipelineExitType) {
|
||||||
// Drop our references to the JSContext and DOM objects.
|
// Drop our references to the JSContext and DOM objects.
|
||||||
for page in page_tree.iter() {
|
for page in page_tree.iter() {
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
window.r().clear_js_runtime();
|
window.clear_js_runtime();
|
||||||
// Sever the connection between the global and the DOM tree
|
// Sever the connection between the global and the DOM tree
|
||||||
page.set_frame(None);
|
page.set_frame(None);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String
|
||||||
let node = document.upcast::<Node>();
|
let node = document.upcast::<Node>();
|
||||||
|
|
||||||
for candidate in node.traverse_preorder() {
|
for candidate in node.traverse_preorder() {
|
||||||
if candidate.r().get_unique_id() == node_id {
|
if candidate.get_unique_id() == node_id {
|
||||||
return Some(candidate);
|
return Some(candidate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,9 @@ pub fn handle_execute_script(page: &Rc<Page>,
|
||||||
reply: IpcSender<WebDriverJSResult>) {
|
reply: IpcSender<WebDriverJSResult>) {
|
||||||
let page = get_page(&*page, pipeline);
|
let page = get_page(&*page, pipeline);
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
let cx = window.r().get_cx();
|
let cx = window.get_cx();
|
||||||
let mut rval = RootedValue::new(cx, UndefinedValue());
|
let mut rval = RootedValue::new(cx, UndefinedValue());
|
||||||
window.r().evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
window.evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
||||||
|
|
||||||
reply.send(jsval_to_webdriver(cx, rval.handle())).unwrap();
|
reply.send(jsval_to_webdriver(cx, rval.handle())).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -77,10 +77,10 @@ pub fn handle_execute_async_script(page: &Rc<Page>,
|
||||||
reply: IpcSender<WebDriverJSResult>) {
|
reply: IpcSender<WebDriverJSResult>) {
|
||||||
let page = get_page(&*page, pipeline);
|
let page = get_page(&*page, pipeline);
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
let cx = window.r().get_cx();
|
let cx = window.get_cx();
|
||||||
window.r().set_webdriver_script_chan(Some(reply));
|
window.set_webdriver_script_chan(Some(reply));
|
||||||
let mut rval = RootedValue::new(cx, UndefinedValue());
|
let mut rval = RootedValue::new(cx, UndefinedValue());
|
||||||
window.r().evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
window.evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_get_frame_id(page: &Rc<Page>,
|
pub fn handle_get_frame_id(page: &Rc<Page>,
|
||||||
|
@ -105,17 +105,17 @@ pub fn handle_get_frame_id(page: &Rc<Page>,
|
||||||
},
|
},
|
||||||
WebDriverFrameId::Parent => {
|
WebDriverFrameId::Parent => {
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
Ok(window.r().parent())
|
Ok(window.parent())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let frame_id = window.map(|x| x.map(|x| x.r().pipeline()));
|
let frame_id = window.map(|x| x.map(|x| x.pipeline()));
|
||||||
reply.send(frame_id).unwrap()
|
reply.send(frame_id).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_find_element_css(page: &Rc<Page>, _pipeline: PipelineId, selector: String,
|
pub fn handle_find_element_css(page: &Rc<Page>, _pipeline: PipelineId, selector: String,
|
||||||
reply: IpcSender<Result<Option<String>, ()>>) {
|
reply: IpcSender<Result<Option<String>, ()>>) {
|
||||||
reply.send(match page.document().r().QuerySelector(selector) {
|
reply.send(match page.document().QuerySelector(selector) {
|
||||||
Ok(node) => {
|
Ok(node) => {
|
||||||
Ok(node.map(|x| x.upcast::<Node>().get_unique_id()))
|
Ok(node.map(|x| x.upcast::<Node>().get_unique_id()))
|
||||||
}
|
}
|
||||||
|
@ -127,12 +127,12 @@ pub fn handle_find_elements_css(page: &Rc<Page>,
|
||||||
_pipeline: PipelineId,
|
_pipeline: PipelineId,
|
||||||
selector: String,
|
selector: String,
|
||||||
reply: IpcSender<Result<Vec<String>, ()>>) {
|
reply: IpcSender<Result<Vec<String>, ()>>) {
|
||||||
reply.send(match page.document().r().QuerySelectorAll(selector) {
|
reply.send(match page.document().QuerySelectorAll(selector) {
|
||||||
Ok(ref nodes) => {
|
Ok(ref nodes) => {
|
||||||
let mut result = Vec::with_capacity(nodes.r().Length() as usize);
|
let mut result = Vec::with_capacity(nodes.Length() as usize);
|
||||||
for i in 0..nodes.r().Length() {
|
for i in 0..nodes.Length() {
|
||||||
if let Some(ref node) = nodes.r().Item(i) {
|
if let Some(ref node) = nodes.Item(i) {
|
||||||
result.push(node.r().get_unique_id());
|
result.push(node.get_unique_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
@ -146,12 +146,12 @@ pub fn handle_find_elements_css(page: &Rc<Page>,
|
||||||
pub fn handle_get_active_element(page: &Rc<Page>,
|
pub fn handle_get_active_element(page: &Rc<Page>,
|
||||||
_pipeline: PipelineId,
|
_pipeline: PipelineId,
|
||||||
reply: IpcSender<Option<String>>) {
|
reply: IpcSender<Option<String>>) {
|
||||||
reply.send(page.document().r().GetActiveElement().map(
|
reply.send(page.document().GetActiveElement().map(
|
||||||
|elem| elem.upcast::<Node>().get_unique_id())).unwrap();
|
|elem| elem.upcast::<Node>().get_unique_id())).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_get_title(page: &Rc<Page>, _pipeline: PipelineId, reply: IpcSender<String>) {
|
pub fn handle_get_title(page: &Rc<Page>, _pipeline: PipelineId, reply: IpcSender<String>) {
|
||||||
reply.send(page.document().r().Title()).unwrap();
|
reply.send(page.document().Title()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_get_text(page: &Rc<Page>,
|
pub fn handle_get_text(page: &Rc<Page>,
|
||||||
|
@ -160,7 +160,7 @@ pub fn handle_get_text(page: &Rc<Page>,
|
||||||
reply: IpcSender<Result<String, ()>>) {
|
reply: IpcSender<Result<String, ()>>) {
|
||||||
reply.send(match find_node_by_unique_id(&*page, pipeline, node_id) {
|
reply.send(match find_node_by_unique_id(&*page, pipeline, node_id) {
|
||||||
Some(ref node) => {
|
Some(ref node) => {
|
||||||
Ok(node.r().GetTextContent().unwrap_or("".to_owned()))
|
Ok(node.GetTextContent().unwrap_or("".to_owned()))
|
||||||
},
|
},
|
||||||
None => Err(())
|
None => Err(())
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
|
@ -182,6 +182,6 @@ pub fn handle_get_url(page: &Rc<Page>,
|
||||||
_pipeline: PipelineId,
|
_pipeline: PipelineId,
|
||||||
reply: IpcSender<Url>) {
|
reply: IpcSender<Url>) {
|
||||||
let document = page.document();
|
let document = page.document();
|
||||||
let url = document.r().url();
|
let url = document.url();
|
||||||
reply.send((*url).clone()).unwrap();
|
reply.send((*url).clone()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue