mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
auto merge of #3569 : andrewguertin/servo/mutnullablejs, r=Manishearth
https://github.com/servo/servo/issues/3564
This commit is contained in:
commit
d23e45fe5d
4 changed files with 41 additions and 40 deletions
|
@ -89,13 +89,13 @@ pub struct Document {
|
|||
pub is_html_document: bool,
|
||||
url: Untraceable<Url>,
|
||||
quirks_mode: Untraceable<Cell<QuirksMode>>,
|
||||
images: Cell<Option<JS<HTMLCollection>>>,
|
||||
embeds: Cell<Option<JS<HTMLCollection>>>,
|
||||
links: Cell<Option<JS<HTMLCollection>>>,
|
||||
forms: Cell<Option<JS<HTMLCollection>>>,
|
||||
scripts: Cell<Option<JS<HTMLCollection>>>,
|
||||
anchors: Cell<Option<JS<HTMLCollection>>>,
|
||||
applets: Cell<Option<JS<HTMLCollection>>>,
|
||||
images: MutNullableJS<HTMLCollection>,
|
||||
embeds: MutNullableJS<HTMLCollection>,
|
||||
links: MutNullableJS<HTMLCollection>,
|
||||
forms: MutNullableJS<HTMLCollection>,
|
||||
scripts: MutNullableJS<HTMLCollection>,
|
||||
anchors: MutNullableJS<HTMLCollection>,
|
||||
applets: MutNullableJS<HTMLCollection>,
|
||||
}
|
||||
|
||||
impl DocumentDerived for EventTarget {
|
||||
|
@ -327,13 +327,13 @@ impl Document {
|
|||
// http://dom.spec.whatwg.org/#concept-document-encoding
|
||||
encoding_name: Traceable::new(RefCell::new("utf-8".to_string())),
|
||||
is_html_document: is_html_document == HTMLDocument,
|
||||
images: Cell::new(None),
|
||||
embeds: Cell::new(None),
|
||||
links: Cell::new(None),
|
||||
forms: Cell::new(None),
|
||||
scripts: Cell::new(None),
|
||||
anchors: Cell::new(None),
|
||||
applets: Cell::new(None),
|
||||
images: Default::default(),
|
||||
embeds: Default::default(),
|
||||
links: Default::default(),
|
||||
forms: Default::default(),
|
||||
scripts: Default::default(),
|
||||
anchors: Default::default(),
|
||||
applets: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -789,7 +789,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
let filter = box ImagesFilter;
|
||||
self.images.assign(Some(HTMLCollection::create(*window, root, filter)));
|
||||
}
|
||||
Temporary::new(self.images.get().as_ref().unwrap().clone())
|
||||
self.images.get().unwrap()
|
||||
}
|
||||
|
||||
fn Embeds(self) -> Temporary<HTMLCollection> {
|
||||
|
@ -799,7 +799,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
let filter = box EmbedsFilter;
|
||||
self.embeds.assign(Some(HTMLCollection::create(*window, root, filter)));
|
||||
}
|
||||
Temporary::new(self.embeds.get().as_ref().unwrap().clone())
|
||||
self.embeds.get().unwrap()
|
||||
}
|
||||
|
||||
fn Plugins(self) -> Temporary<HTMLCollection> {
|
||||
|
@ -813,7 +813,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
let filter = box LinksFilter;
|
||||
self.links.assign(Some(HTMLCollection::create(*window, root, filter)));
|
||||
}
|
||||
Temporary::new(self.links.get().as_ref().unwrap().clone())
|
||||
self.links.get().unwrap()
|
||||
}
|
||||
|
||||
fn Forms(self) -> Temporary<HTMLCollection> {
|
||||
|
@ -823,7 +823,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
let filter = box FormsFilter;
|
||||
self.forms.assign(Some(HTMLCollection::create(*window, root, filter)));
|
||||
}
|
||||
Temporary::new(self.forms.get().as_ref().unwrap().clone())
|
||||
self.forms.get().unwrap()
|
||||
}
|
||||
|
||||
fn Scripts(self) -> Temporary<HTMLCollection> {
|
||||
|
@ -833,7 +833,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
let filter = box ScriptsFilter;
|
||||
self.scripts.assign(Some(HTMLCollection::create(*window, root, filter)));
|
||||
}
|
||||
Temporary::new(self.scripts.get().as_ref().unwrap().clone())
|
||||
self.scripts.get().unwrap()
|
||||
}
|
||||
|
||||
fn Anchors(self) -> Temporary<HTMLCollection> {
|
||||
|
@ -843,7 +843,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
let filter = box AnchorsFilter;
|
||||
self.anchors.assign(Some(HTMLCollection::create(*window, root, filter)));
|
||||
}
|
||||
Temporary::new(self.anchors.get().as_ref().unwrap().clone())
|
||||
self.anchors.get().unwrap()
|
||||
}
|
||||
|
||||
fn Applets(self) -> Temporary<HTMLCollection> {
|
||||
|
@ -854,7 +854,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
let filter = box AppletsFilter;
|
||||
self.applets.assign(Some(HTMLCollection::create(*window, root, filter)));
|
||||
}
|
||||
Temporary::new(self.applets.get().as_ref().unwrap().clone())
|
||||
self.applets.get().unwrap()
|
||||
}
|
||||
|
||||
fn Location(self) -> Temporary<Location> {
|
||||
|
|
|
@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::HTMLCanvasElemen
|
|||
use dom::bindings::codegen::InheritTypes::HTMLCanvasElementDerived;
|
||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast};
|
||||
use dom::bindings::global::Window;
|
||||
use dom::bindings::js::{JS, JSRef, Temporary, OptionalSettable};
|
||||
use dom::bindings::js::{MutNullableJS, JSRef, Temporary, OptionalSettable};
|
||||
use dom::bindings::trace::Traceable;
|
||||
use dom::bindings::utils::{Reflectable, Reflector};
|
||||
use dom::canvasrenderingcontext2d::CanvasRenderingContext2D;
|
||||
|
@ -24,6 +24,7 @@ use string_cache::Atom;
|
|||
use geom::size::Size2D;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
|
||||
static DefaultWidth: u32 = 300;
|
||||
static DefaultHeight: u32 = 150;
|
||||
|
@ -32,7 +33,7 @@ static DefaultHeight: u32 = 150;
|
|||
#[must_root]
|
||||
pub struct HTMLCanvasElement {
|
||||
pub htmlelement: HTMLElement,
|
||||
context: Traceable<Cell<Option<JS<CanvasRenderingContext2D>>>>,
|
||||
context: Traceable<MutNullableJS<CanvasRenderingContext2D>>,
|
||||
width: Traceable<Cell<u32>>,
|
||||
height: Traceable<Cell<u32>>,
|
||||
}
|
||||
|
@ -47,7 +48,7 @@ impl HTMLCanvasElement {
|
|||
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLCanvasElement {
|
||||
HTMLCanvasElement {
|
||||
htmlelement: HTMLElement::new_inherited(HTMLCanvasElementTypeId, localName, document),
|
||||
context: Traceable::new(Cell::new(None)),
|
||||
context: Traceable::new(Default::default()),
|
||||
width: Traceable::new(Cell::new(DefaultWidth)),
|
||||
height: Traceable::new(Cell::new(DefaultHeight)),
|
||||
}
|
||||
|
@ -90,7 +91,7 @@ impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> {
|
|||
let context = CanvasRenderingContext2D::new(&Window(*window), self, Size2D(w, h));
|
||||
self.context.assign(Some(context));
|
||||
}
|
||||
self.context.get().map(|context| Temporary::new(context))
|
||||
self.context.get()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
|||
use dom::bindings::codegen::InheritTypes::EventTargetCast;
|
||||
use dom::bindings::error::{Fallible, InvalidCharacter};
|
||||
use dom::bindings::global;
|
||||
use dom::bindings::js::{MutNullableJS, JS, JSRef, Temporary, OptionalSettable};
|
||||
use dom::bindings::js::{MutNullableJS, JSRef, Temporary, OptionalSettable};
|
||||
use dom::bindings::trace::{Traceable, Untraceable};
|
||||
use dom::bindings::utils::{Reflectable, Reflector};
|
||||
use dom::browsercontext::BrowserContext;
|
||||
|
@ -94,7 +94,7 @@ pub struct Window {
|
|||
performance: MutNullableJS<Performance>,
|
||||
pub navigationStart: u64,
|
||||
pub navigationStartPrecise: f64,
|
||||
screen: Cell<Option<JS<Screen>>>,
|
||||
screen: MutNullableJS<Screen>,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -338,7 +338,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
|||
let screen = Screen::new(self);
|
||||
self.screen.assign(Some(screen));
|
||||
}
|
||||
Temporary::new(self.screen.get().as_ref().unwrap().clone())
|
||||
self.screen.get().unwrap()
|
||||
}
|
||||
|
||||
fn Debug(self, message: DOMString) {
|
||||
|
@ -542,7 +542,7 @@ impl Window {
|
|||
performance: Default::default(),
|
||||
navigationStart: time::get_time().sec as u64,
|
||||
navigationStartPrecise: time::precise_time_s(),
|
||||
screen: Cell::new(None),
|
||||
screen: Default::default(),
|
||||
};
|
||||
|
||||
WindowBinding::Wrap(cx, win)
|
||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::WorkerGlobalScopeBinding::WorkerGlobalScop
|
|||
use dom::bindings::error::{ErrorResult, Fallible, Syntax, Network, FailureUnknown};
|
||||
use dom::bindings::trace::Untraceable;
|
||||
use dom::bindings::global;
|
||||
use dom::bindings::js::{JS, JSRef, Temporary, OptionalSettable};
|
||||
use dom::bindings::js::{MutNullableJS, JSRef, Temporary, OptionalSettable};
|
||||
use dom::bindings::utils::{Reflectable, Reflector};
|
||||
use dom::console::Console;
|
||||
use dom::eventtarget::{EventTarget, WorkerGlobalScopeTypeId};
|
||||
|
@ -21,7 +21,7 @@ use servo_util::str::DOMString;
|
|||
use js::jsapi::JSContext;
|
||||
use js::rust::Cx;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
use std::rc::Rc;
|
||||
use url::{Url, UrlParser};
|
||||
|
||||
|
@ -39,9 +39,9 @@ pub struct WorkerGlobalScope {
|
|||
js_context: Untraceable<Rc<Cx>>,
|
||||
resource_task: Untraceable<ResourceTask>,
|
||||
script_chan: ScriptChan,
|
||||
location: Cell<Option<JS<WorkerLocation>>>,
|
||||
navigator: Cell<Option<JS<WorkerNavigator>>>,
|
||||
console: Cell<Option<JS<Console>>>,
|
||||
location: MutNullableJS<WorkerLocation>,
|
||||
navigator: MutNullableJS<WorkerNavigator>,
|
||||
console: MutNullableJS<Console>,
|
||||
}
|
||||
|
||||
impl WorkerGlobalScope {
|
||||
|
@ -56,9 +56,9 @@ impl WorkerGlobalScope {
|
|||
js_context: Untraceable::new(cx),
|
||||
resource_task: Untraceable::new(resource_task),
|
||||
script_chan: script_chan,
|
||||
location: Cell::new(None),
|
||||
navigator: Cell::new(None),
|
||||
console: Cell::new(None),
|
||||
location: Default::default(),
|
||||
navigator: Default::default(),
|
||||
console: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ impl<'a> WorkerGlobalScopeMethods for JSRef<'a, WorkerGlobalScope> {
|
|||
let location = WorkerLocation::new(self, self.worker_url.deref().clone());
|
||||
self.location.assign(Some(location));
|
||||
}
|
||||
Temporary::new(self.location.get().as_ref().unwrap().clone())
|
||||
self.location.get().unwrap()
|
||||
}
|
||||
|
||||
fn ImportScripts(self, url_strings: Vec<DOMString>) -> ErrorResult {
|
||||
|
@ -129,7 +129,7 @@ impl<'a> WorkerGlobalScopeMethods for JSRef<'a, WorkerGlobalScope> {
|
|||
let navigator = WorkerNavigator::new(self);
|
||||
self.navigator.assign(Some(navigator));
|
||||
}
|
||||
Temporary::new(self.navigator.get().as_ref().unwrap().clone())
|
||||
self.navigator.get().unwrap()
|
||||
}
|
||||
|
||||
fn Console(self) -> Temporary<Console> {
|
||||
|
@ -137,7 +137,7 @@ impl<'a> WorkerGlobalScopeMethods for JSRef<'a, WorkerGlobalScope> {
|
|||
let console = Console::new(&global::Worker(self));
|
||||
self.console.assign(Some(console));
|
||||
}
|
||||
Temporary::new(self.console.get().as_ref().unwrap().clone())
|
||||
self.console.get().unwrap()
|
||||
}
|
||||
|
||||
fn Btoa(self, btoa: DOMString) -> Fallible<DOMString> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue