Implement MutNullableJS for mutable, nullable member pointers to DOM objects.

This commit is contained in:
Josh Matthews 2014-09-30 16:39:31 +02:00 committed by Ms2ger
parent f73e508821
commit 54fcab61d6
11 changed files with 171 additions and 109 deletions

View file

@ -5,7 +5,7 @@
use dom::attr::AttrHelpers;
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast};
use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::js::{MutNullableJS, JS, JSRef, Temporary};
use dom::bindings::js::OptionalRootable;
use dom::bindings::trace::{Traceable, Untraceable};
use dom::bindings::utils::GlobalStaticData;
@ -30,12 +30,14 @@ use servo_net::resource_task::ResourceTask;
use servo_util::str::DOMString;
use std::cell::{Cell, RefCell, Ref, RefMut};
use std::comm::{channel, Receiver, Empty, Disconnected};
use std::default::Default;
use std::mem::replace;
use std::rc::Rc;
use url::Url;
/// Encapsulates a handle to a frame and its associated layout information.
#[jstraceable]
#[allow(unrooted_must_root)] // FIXME(#3543) should be must_root.
pub struct Page {
/// Pipeline id associated with this page.
pub id: PipelineId,
@ -78,7 +80,7 @@ pub struct Page {
pub resize_event: Untraceable<Cell<Option<WindowSizeData>>>,
/// Pending scroll to fragment event, if any
pub fragment_node: Cell<Option<JS<Element>>>,
pub fragment_node: MutNullableJS<Element>,
/// Associated resource task for use by DOM objects like XMLHttpRequest
pub resource_task: Untraceable<ResourceTask>,
@ -152,7 +154,7 @@ impl Page {
url: Untraceable::new(RefCell::new(None)),
next_subpage_id: Traceable::new(Cell::new(SubpageId(0))),
resize_event: Untraceable::new(Cell::new(None)),
fragment_node: Cell::new(None),
fragment_node: Default::default(),
last_reflow_id: Traceable::new(Cell::new(0)),
resource_task: Untraceable::new(resource_task),
constellation_chan: Untraceable::new(constellation_chan),