mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
auto merge of #2640 : Ms2ger/servo/derefmut, r=jdm
This commit is contained in:
commit
897e39dcf3
8 changed files with 88 additions and 89 deletions
|
@ -10,7 +10,7 @@ use dom::bindings::codegen::InheritTypes::EventTargetCast;
|
||||||
use dom::bindings::codegen::Bindings::DocumentBinding;
|
use dom::bindings::codegen::Bindings::DocumentBinding;
|
||||||
use dom::bindings::js::{JS, JSRef, Temporary, OptionalSettable, TemporaryPushable};
|
use dom::bindings::js::{JS, JSRef, Temporary, OptionalSettable, TemporaryPushable};
|
||||||
use dom::bindings::js::OptionalRootable;
|
use dom::bindings::js::OptionalRootable;
|
||||||
use dom::bindings::trace::Untraceable;
|
use dom::bindings::trace::{Traceable, Untraceable};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::error::{ErrorResult, Fallible, NotSupported, InvalidCharacter};
|
use dom::bindings::error::{ErrorResult, Fallible, NotSupported, InvalidCharacter};
|
||||||
use dom::bindings::error::{HierarchyRequest, NamespaceError};
|
use dom::bindings::error::{HierarchyRequest, NamespaceError};
|
||||||
|
@ -63,7 +63,7 @@ pub struct Document {
|
||||||
pub node: Node,
|
pub node: Node,
|
||||||
pub reflector_: Reflector,
|
pub reflector_: Reflector,
|
||||||
pub window: JS<Window>,
|
pub window: JS<Window>,
|
||||||
pub idmap: HashMap<DOMString, Vec<JS<Element>>>,
|
idmap: Traceable<RefCell<HashMap<DOMString, Vec<JS<Element>>>>>,
|
||||||
pub implementation: Cell<Option<JS<DOMImplementation>>>,
|
pub implementation: Cell<Option<JS<DOMImplementation>>>,
|
||||||
pub content_type: DOMString,
|
pub content_type: DOMString,
|
||||||
pub encoding_name: Untraceable<RefCell<DOMString>>,
|
pub encoding_name: Untraceable<RefCell<DOMString>>,
|
||||||
|
@ -86,8 +86,8 @@ pub trait DocumentHelpers {
|
||||||
fn content_changed(&self);
|
fn content_changed(&self);
|
||||||
fn damage_and_reflow(&self, damage: DocumentDamageLevel);
|
fn damage_and_reflow(&self, damage: DocumentDamageLevel);
|
||||||
fn wait_until_safe_to_modify_dom(&self);
|
fn wait_until_safe_to_modify_dom(&self);
|
||||||
fn unregister_named_element(&mut self, to_unregister: &JSRef<Element>, id: DOMString);
|
fn unregister_named_element(&self, to_unregister: &JSRef<Element>, id: DOMString);
|
||||||
fn register_named_element(&mut self, element: &JSRef<Element>, id: DOMString);
|
fn register_named_element(&self, element: &JSRef<Element>, id: DOMString);
|
||||||
fn load_anchor_href(&self, href: DOMString);
|
fn load_anchor_href(&self, href: DOMString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,28 +122,28 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> {
|
||||||
|
|
||||||
|
|
||||||
/// Remove any existing association between the provided id and any elements in this document.
|
/// Remove any existing association between the provided id and any elements in this document.
|
||||||
fn unregister_named_element(&mut self,
|
fn unregister_named_element(&self,
|
||||||
to_unregister: &JSRef<Element>,
|
to_unregister: &JSRef<Element>,
|
||||||
id: DOMString) {
|
id: DOMString) {
|
||||||
let mut is_empty = false;
|
let mut idmap = self.idmap.deref().borrow_mut();
|
||||||
match self.idmap.find_mut(&id) {
|
let is_empty = match idmap.find_mut(&id) {
|
||||||
None => {},
|
None => false,
|
||||||
Some(elements) => {
|
Some(elements) => {
|
||||||
let position = elements.iter()
|
let position = elements.iter()
|
||||||
.map(|elem| elem.root())
|
.map(|elem| elem.root())
|
||||||
.position(|element| &*element == to_unregister)
|
.position(|element| &*element == to_unregister)
|
||||||
.expect("This element should be in registered.");
|
.expect("This element should be in registered.");
|
||||||
elements.remove(position);
|
elements.remove(position);
|
||||||
is_empty = elements.is_empty();
|
elements.is_empty()
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
if is_empty {
|
if is_empty {
|
||||||
self.idmap.remove(&id);
|
idmap.remove(&id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Associate an element present in this document with the provided id.
|
/// Associate an element present in this document with the provided id.
|
||||||
fn register_named_element(&mut self,
|
fn register_named_element(&self,
|
||||||
element: &JSRef<Element>,
|
element: &JSRef<Element>,
|
||||||
id: DOMString) {
|
id: DOMString) {
|
||||||
assert!({
|
assert!({
|
||||||
|
@ -151,10 +151,12 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> {
|
||||||
node.is_in_doc()
|
node.is_in_doc()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let mut idmap = self.idmap.deref().borrow_mut();
|
||||||
|
|
||||||
// FIXME https://github.com/mozilla/rust/issues/13195
|
// FIXME https://github.com/mozilla/rust/issues/13195
|
||||||
// Use mangle() when it exists again.
|
// Use mangle() when it exists again.
|
||||||
let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root();
|
let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root();
|
||||||
match self.idmap.find_mut(&id) {
|
match idmap.find_mut(&id) {
|
||||||
Some(elements) => {
|
Some(elements) => {
|
||||||
let new_node: &JSRef<Node> = NodeCast::from_ref(element);
|
let new_node: &JSRef<Node> = NodeCast::from_ref(element);
|
||||||
let mut head : uint = 0u;
|
let mut head : uint = 0u;
|
||||||
|
@ -180,7 +182,7 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> {
|
||||||
}
|
}
|
||||||
let mut elements = vec!();
|
let mut elements = vec!();
|
||||||
elements.push_unrooted(element);
|
elements.push_unrooted(element);
|
||||||
self.idmap.insert(id, elements);
|
idmap.insert(id, elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_anchor_href(&self, href: DOMString) {
|
fn load_anchor_href(&self, href: DOMString) {
|
||||||
|
@ -214,7 +216,7 @@ impl Document {
|
||||||
node: Node::new_without_doc(DocumentNodeTypeId),
|
node: Node::new_without_doc(DocumentNodeTypeId),
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
window: window.unrooted(),
|
window: window.unrooted(),
|
||||||
idmap: HashMap::new(),
|
idmap: Traceable::new(RefCell::new(HashMap::new())),
|
||||||
implementation: Cell::new(None),
|
implementation: Cell::new(None),
|
||||||
content_type: match content_type {
|
content_type: match content_type {
|
||||||
Some(string) => string.clone(),
|
Some(string) => string.clone(),
|
||||||
|
@ -418,7 +420,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
||||||
fn GetElementById(&self, id: DOMString) -> Option<Temporary<Element>> {
|
fn GetElementById(&self, id: DOMString) -> Option<Temporary<Element>> {
|
||||||
match self.idmap.find_equiv(&id) {
|
match self.idmap.deref().borrow().find_equiv(&id) {
|
||||||
None => None,
|
None => None,
|
||||||
Some(ref elements) => Some(Temporary::new(elements.get(0).clone())),
|
Some(ref elements) => Some(Temporary::new(elements.get(0).clone())),
|
||||||
}
|
}
|
||||||
|
|
|
@ -803,8 +803,8 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||||
|
|
||||||
match self.get_attribute(Null, "id").root() {
|
match self.get_attribute(Null, "id").root() {
|
||||||
Some(attr) => {
|
Some(attr) => {
|
||||||
let mut doc = document_from_node(self).root();
|
let doc = document_from_node(self).root();
|
||||||
doc.register_named_element(self, attr.deref().Value());
|
doc.deref().register_named_element(self, attr.deref().Value());
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
@ -818,8 +818,8 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||||
|
|
||||||
match self.get_attribute(Null, "id").root() {
|
match self.get_attribute(Null, "id").root() {
|
||||||
Some(attr) => {
|
Some(attr) => {
|
||||||
let mut doc = document_from_node(self).root();
|
let doc = document_from_node(self).root();
|
||||||
doc.unregister_named_element(self, attr.deref().Value());
|
doc.deref().unregister_named_element(self, attr.deref().Value());
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,10 +111,10 @@ pub fn dispatch_event<'a, 'b>(target: &JSRef<'a, EventTarget>,
|
||||||
/* default action */
|
/* default action */
|
||||||
let target = event.GetTarget().root();
|
let target = event.GetTarget().root();
|
||||||
match target {
|
match target {
|
||||||
Some(mut target) => {
|
Some(target) => {
|
||||||
let node: Option<&JSRef<Node>> = NodeCast::to_ref(&mut *target);
|
let node: Option<&JSRef<Node>> = NodeCast::to_ref(&*target);
|
||||||
match node {
|
match node {
|
||||||
Some(node) =>{
|
Some(node) => {
|
||||||
let vtable = vtable_for(node);
|
let vtable = vtable_for(node);
|
||||||
vtable.handle_event(event);
|
vtable.handle_event(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl HTMLBodyElement {
|
||||||
|
|
||||||
pub trait HTMLBodyElementMethods {
|
pub trait HTMLBodyElementMethods {
|
||||||
fn GetOnunload(&self) -> Option<EventHandlerNonNull>;
|
fn GetOnunload(&self) -> Option<EventHandlerNonNull>;
|
||||||
fn SetOnunload(&mut self, listener: Option<EventHandlerNonNull>);
|
fn SetOnunload(&self, listener: Option<EventHandlerNonNull>);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> {
|
impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> {
|
||||||
|
@ -52,9 +52,9 @@ impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> {
|
||||||
win.deref().GetOnunload()
|
win.deref().GetOnunload()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetOnunload(&mut self, listener: Option<EventHandlerNonNull>) {
|
fn SetOnunload(&self, listener: Option<EventHandlerNonNull>) {
|
||||||
let mut win = window_from_node(self).root();
|
let win = window_from_node(self).root();
|
||||||
win.SetOnunload(listener)
|
win.deref().SetOnunload(listener)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::MouseEventBinding;
|
use dom::bindings::codegen::Bindings::MouseEventBinding;
|
||||||
use dom::bindings::codegen::InheritTypes::{UIEventCast, MouseEventDerived};
|
use dom::bindings::codegen::InheritTypes::{UIEventCast, MouseEventDerived};
|
||||||
use dom::bindings::js::{JS, JSRef, RootedReference, Temporary, OptionalSettable};
|
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
|
use dom::bindings::js::{JS, JSRef, RootedReference, Temporary, OptionalSettable};
|
||||||
|
use dom::bindings::trace::Traceable;
|
||||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::event::{Event, MouseEventTypeId};
|
use dom::event::{Event, MouseEventTypeId};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
@ -17,15 +18,15 @@ use std::cell::Cell;
|
||||||
#[deriving(Encodable)]
|
#[deriving(Encodable)]
|
||||||
pub struct MouseEvent {
|
pub struct MouseEvent {
|
||||||
pub mouseevent: UIEvent,
|
pub mouseevent: UIEvent,
|
||||||
pub screen_x: i32,
|
pub screen_x: Traceable<Cell<i32>>,
|
||||||
pub screen_y: i32,
|
pub screen_y: Traceable<Cell<i32>>,
|
||||||
pub client_x: i32,
|
pub client_x: Traceable<Cell<i32>>,
|
||||||
pub client_y: i32,
|
pub client_y: Traceable<Cell<i32>>,
|
||||||
pub ctrl_key: bool,
|
pub ctrl_key: Traceable<Cell<bool>>,
|
||||||
pub shift_key: bool,
|
pub shift_key: Traceable<Cell<bool>>,
|
||||||
pub alt_key: bool,
|
pub alt_key: Traceable<Cell<bool>>,
|
||||||
pub meta_key: bool,
|
pub meta_key: Traceable<Cell<bool>>,
|
||||||
pub button: i16,
|
pub button: Traceable<Cell<i16>>,
|
||||||
pub related_target: Cell<Option<JS<EventTarget>>>
|
pub related_target: Cell<Option<JS<EventTarget>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,15 +40,15 @@ impl MouseEvent {
|
||||||
pub fn new_inherited() -> MouseEvent {
|
pub fn new_inherited() -> MouseEvent {
|
||||||
MouseEvent {
|
MouseEvent {
|
||||||
mouseevent: UIEvent::new_inherited(MouseEventTypeId),
|
mouseevent: UIEvent::new_inherited(MouseEventTypeId),
|
||||||
screen_x: 0,
|
screen_x: Traceable::new(Cell::new(0)),
|
||||||
screen_y: 0,
|
screen_y: Traceable::new(Cell::new(0)),
|
||||||
client_x: 0,
|
client_x: Traceable::new(Cell::new(0)),
|
||||||
client_y: 0,
|
client_y: Traceable::new(Cell::new(0)),
|
||||||
ctrl_key: false,
|
ctrl_key: Traceable::new(Cell::new(false)),
|
||||||
shift_key: false,
|
shift_key: Traceable::new(Cell::new(false)),
|
||||||
alt_key: false,
|
alt_key: Traceable::new(Cell::new(false)),
|
||||||
meta_key: false,
|
meta_key: Traceable::new(Cell::new(false)),
|
||||||
button: 0,
|
button: Traceable::new(Cell::new(0)),
|
||||||
related_target: Cell::new(None)
|
related_target: Cell::new(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,11 +75,11 @@ impl MouseEvent {
|
||||||
metaKey: bool,
|
metaKey: bool,
|
||||||
button: i16,
|
button: i16,
|
||||||
relatedTarget: Option<JSRef<EventTarget>>) -> Temporary<MouseEvent> {
|
relatedTarget: Option<JSRef<EventTarget>>) -> Temporary<MouseEvent> {
|
||||||
let mut ev = MouseEvent::new_uninitialized(window).root();
|
let ev = MouseEvent::new_uninitialized(window).root();
|
||||||
ev.InitMouseEvent(type_, canBubble, cancelable, view, detail,
|
ev.deref().InitMouseEvent(type_, canBubble, cancelable, view, detail,
|
||||||
screenX, screenY, clientX, clientY,
|
screenX, screenY, clientX, clientY,
|
||||||
ctrlKey, altKey, shiftKey, metaKey,
|
ctrlKey, altKey, shiftKey, metaKey,
|
||||||
button, relatedTarget);
|
button, relatedTarget);
|
||||||
Temporary::from_rooted(&*ev)
|
Temporary::from_rooted(&*ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +109,7 @@ pub trait MouseEventMethods {
|
||||||
fn MetaKey(&self) -> bool;
|
fn MetaKey(&self) -> bool;
|
||||||
fn Button(&self) -> i16;
|
fn Button(&self) -> i16;
|
||||||
fn GetRelatedTarget(&self) -> Option<Temporary<EventTarget>>;
|
fn GetRelatedTarget(&self) -> Option<Temporary<EventTarget>>;
|
||||||
fn InitMouseEvent(&mut self,
|
fn InitMouseEvent(&self,
|
||||||
typeArg: DOMString,
|
typeArg: DOMString,
|
||||||
canBubbleArg: bool,
|
canBubbleArg: bool,
|
||||||
cancelableArg: bool,
|
cancelableArg: bool,
|
||||||
|
@ -128,46 +129,46 @@ pub trait MouseEventMethods {
|
||||||
|
|
||||||
impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> {
|
impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> {
|
||||||
fn ScreenX(&self) -> i32 {
|
fn ScreenX(&self) -> i32 {
|
||||||
self.screen_x
|
self.screen_x.deref().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ScreenY(&self) -> i32 {
|
fn ScreenY(&self) -> i32 {
|
||||||
self.screen_y
|
self.screen_y.deref().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ClientX(&self) -> i32 {
|
fn ClientX(&self) -> i32 {
|
||||||
self.client_x
|
self.client_x.deref().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ClientY(&self) -> i32 {
|
fn ClientY(&self) -> i32 {
|
||||||
self.client_y
|
self.client_y.deref().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn CtrlKey(&self) -> bool {
|
fn CtrlKey(&self) -> bool {
|
||||||
self.ctrl_key
|
self.ctrl_key.deref().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ShiftKey(&self) -> bool {
|
fn ShiftKey(&self) -> bool {
|
||||||
self.shift_key
|
self.shift_key.deref().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn AltKey(&self) -> bool {
|
fn AltKey(&self) -> bool {
|
||||||
self.alt_key
|
self.alt_key.deref().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn MetaKey(&self) -> bool {
|
fn MetaKey(&self) -> bool {
|
||||||
self.meta_key
|
self.meta_key.deref().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Button(&self) -> i16 {
|
fn Button(&self) -> i16 {
|
||||||
self.button
|
self.button.deref().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetRelatedTarget(&self) -> Option<Temporary<EventTarget>> {
|
fn GetRelatedTarget(&self) -> Option<Temporary<EventTarget>> {
|
||||||
self.related_target.get().clone().map(|target| Temporary::new(target))
|
self.related_target.get().clone().map(|target| Temporary::new(target))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn InitMouseEvent(&mut self,
|
fn InitMouseEvent(&self,
|
||||||
typeArg: DOMString,
|
typeArg: DOMString,
|
||||||
canBubbleArg: bool,
|
canBubbleArg: bool,
|
||||||
cancelableArg: bool,
|
cancelableArg: bool,
|
||||||
|
@ -183,19 +184,17 @@ impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> {
|
||||||
metaKeyArg: bool,
|
metaKeyArg: bool,
|
||||||
buttonArg: i16,
|
buttonArg: i16,
|
||||||
relatedTargetArg: Option<JSRef<EventTarget>>) {
|
relatedTargetArg: Option<JSRef<EventTarget>>) {
|
||||||
{
|
let uievent: &JSRef<UIEvent> = UIEventCast::from_ref(self);
|
||||||
let uievent: &mut JSRef<UIEvent> = UIEventCast::from_mut_ref(self);
|
uievent.InitUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg);
|
||||||
uievent.InitUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg);
|
self.screen_x.deref().set(screenXArg);
|
||||||
}
|
self.screen_y.deref().set(screenYArg);
|
||||||
self.screen_x = screenXArg;
|
self.client_x.deref().set(clientXArg);
|
||||||
self.screen_y = screenYArg;
|
self.client_y.deref().set(clientYArg);
|
||||||
self.client_x = clientXArg;
|
self.ctrl_key.deref().set(ctrlKeyArg);
|
||||||
self.client_y = clientYArg;
|
self.alt_key.deref().set(altKeyArg);
|
||||||
self.ctrl_key = ctrlKeyArg;
|
self.shift_key.deref().set(shiftKeyArg);
|
||||||
self.alt_key = altKeyArg;
|
self.meta_key.deref().set(metaKeyArg);
|
||||||
self.shift_key = shiftKeyArg;
|
self.button.deref().set(buttonArg);
|
||||||
self.meta_key = metaKeyArg;
|
|
||||||
self.button = buttonArg;
|
|
||||||
self.related_target.assign(relatedTargetArg);
|
self.related_target.assign(relatedTargetArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1376,9 +1376,9 @@ pub trait NodeMethods {
|
||||||
fn GetPreviousSibling(&self) -> Option<Temporary<Node>>;
|
fn GetPreviousSibling(&self) -> Option<Temporary<Node>>;
|
||||||
fn GetNextSibling(&self) -> Option<Temporary<Node>>;
|
fn GetNextSibling(&self) -> Option<Temporary<Node>>;
|
||||||
fn GetNodeValue(&self) -> Option<DOMString>;
|
fn GetNodeValue(&self) -> Option<DOMString>;
|
||||||
fn SetNodeValue(&mut self, val: Option<DOMString>) -> ErrorResult;
|
fn SetNodeValue(&self, val: Option<DOMString>) -> ErrorResult;
|
||||||
fn GetTextContent(&self) -> Option<DOMString>;
|
fn GetTextContent(&self) -> Option<DOMString>;
|
||||||
fn SetTextContent(&mut self, value: Option<DOMString>) -> ErrorResult;
|
fn SetTextContent(&self, value: Option<DOMString>) -> ErrorResult;
|
||||||
fn InsertBefore(&self, node: &JSRef<Node>, child: Option<JSRef<Node>>) -> Fallible<Temporary<Node>>;
|
fn InsertBefore(&self, node: &JSRef<Node>, child: Option<JSRef<Node>>) -> Fallible<Temporary<Node>>;
|
||||||
fn AppendChild(&self, node: &JSRef<Node>) -> Fallible<Temporary<Node>>;
|
fn AppendChild(&self, node: &JSRef<Node>) -> Fallible<Temporary<Node>>;
|
||||||
fn ReplaceChild(&self, node: &JSRef<Node>, child: &JSRef<Node>) -> Fallible<Temporary<Node>>;
|
fn ReplaceChild(&self, node: &JSRef<Node>, child: &JSRef<Node>) -> Fallible<Temporary<Node>>;
|
||||||
|
@ -1520,8 +1520,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-node-nodevalue
|
// http://dom.spec.whatwg.org/#dom-node-nodevalue
|
||||||
fn SetNodeValue(&mut self, val: Option<DOMString>)
|
fn SetNodeValue(&self, val: Option<DOMString>) -> ErrorResult {
|
||||||
-> ErrorResult {
|
|
||||||
match self.type_id {
|
match self.type_id {
|
||||||
CommentNodeTypeId |
|
CommentNodeTypeId |
|
||||||
TextNodeTypeId |
|
TextNodeTypeId |
|
||||||
|
@ -1560,8 +1559,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-node-textcontent
|
// http://dom.spec.whatwg.org/#dom-node-textcontent
|
||||||
fn SetTextContent(&mut self, value: Option<DOMString>)
|
fn SetTextContent(&self, value: Option<DOMString>) -> ErrorResult {
|
||||||
-> ErrorResult {
|
|
||||||
let value = null_str_as_empty(&value);
|
let value = null_str_as_empty(&value);
|
||||||
match self.type_id {
|
match self.type_id {
|
||||||
DocumentFragmentNodeTypeId |
|
DocumentFragmentNodeTypeId |
|
||||||
|
|
|
@ -291,7 +291,7 @@ pub fn build_element_from_tag(tag: DOMString, ns: Namespace, document: &JSRef<Do
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_html(page: &Page,
|
pub fn parse_html(page: &Page,
|
||||||
document: &mut JSRef<Document>,
|
document: &JSRef<Document>,
|
||||||
url: Url,
|
url: Url,
|
||||||
resource_task: ResourceTask)
|
resource_task: ResourceTask)
|
||||||
-> HtmlParserResult {
|
-> HtmlParserResult {
|
||||||
|
@ -485,15 +485,15 @@ pub fn parse_html(page: &Page,
|
||||||
set_quirks_mode: |mode| {
|
set_quirks_mode: |mode| {
|
||||||
debug!("set quirks mode");
|
debug!("set quirks mode");
|
||||||
// NOTE: tmp vars are workaround for lifetime issues. Both required.
|
// NOTE: tmp vars are workaround for lifetime issues. Both required.
|
||||||
let mut tmp_borrow = doc_cell.borrow_mut();
|
let tmp_borrow = doc_cell.borrow_mut();
|
||||||
let tmp = &mut *tmp_borrow;
|
let tmp = &*tmp_borrow;
|
||||||
tmp.set_quirks_mode(mode);
|
tmp.set_quirks_mode(mode);
|
||||||
},
|
},
|
||||||
encoding_change: |encname| {
|
encoding_change: |encname| {
|
||||||
debug!("encoding change");
|
debug!("encoding change");
|
||||||
// NOTE: tmp vars are workaround for lifetime issues. Both required.
|
// NOTE: tmp vars are workaround for lifetime issues. Both required.
|
||||||
let mut tmp_borrow = doc_cell.borrow_mut();
|
let tmp_borrow = doc_cell.borrow_mut();
|
||||||
let tmp = &mut *tmp_borrow;
|
let tmp = &*tmp_borrow;
|
||||||
tmp.set_encoding_name(encname);
|
tmp.set_encoding_name(encname);
|
||||||
},
|
},
|
||||||
complete_script: |script| {
|
complete_script: |script| {
|
||||||
|
|
|
@ -947,7 +947,7 @@ impl ScriptTask {
|
||||||
self.chan.clone(),
|
self.chan.clone(),
|
||||||
self.compositor.dup(),
|
self.compositor.dup(),
|
||||||
self.image_cache_task.clone()).root();
|
self.image_cache_task.clone()).root();
|
||||||
let mut document = Document::new(&*window, Some(url.clone()), HTMLDocument, None).root();
|
let document = Document::new(&*window, Some(url.clone()), HTMLDocument, None).root();
|
||||||
window.deref().init_browser_context(&*document);
|
window.deref().init_browser_context(&*document);
|
||||||
|
|
||||||
with_compartment((**cx).ptr, window.reflector().get_jsobject(), || {
|
with_compartment((**cx).ptr, window.reflector().get_jsobject(), || {
|
||||||
|
@ -960,7 +960,7 @@ impl ScriptTask {
|
||||||
//
|
//
|
||||||
// Note: We can parse the next document in parallel with any previous documents.
|
// Note: We can parse the next document in parallel with any previous documents.
|
||||||
let html_parsing_result = hubbub_html_parser::parse_html(&*page,
|
let html_parsing_result = hubbub_html_parser::parse_html(&*page,
|
||||||
&mut *document,
|
&*document,
|
||||||
url.clone(),
|
url.clone(),
|
||||||
self.resource_task.clone());
|
self.resource_task.clone());
|
||||||
|
|
||||||
|
@ -998,7 +998,7 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kick off the initial reflow of the page.
|
// Kick off the initial reflow of the page.
|
||||||
document.content_changed();
|
document.deref().content_changed();
|
||||||
|
|
||||||
let fragment = url.fragment.as_ref().map(|ref fragment| fragment.to_string());
|
let fragment = url.fragment.as_ref().map(|ref fragment| fragment.to_string());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue