Skip to content

Commit

Permalink
Update script to work with lint changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Oct 15, 2015
1 parent 9a3c145 commit 894c242
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions components/script/dom/bindings/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ impl GlobalRoot {

impl GlobalField {
/// Create a new `GlobalField` from a rooted reference.
#[allow(unrooted_must_root)]
pub fn from_rooted(global: &GlobalRef) -> GlobalField {
match *global {
GlobalRef::Window(window) => GlobalField::Window(JS::from_ref(window)),
Expand Down
4 changes: 4 additions & 0 deletions components/script/dom/bindings/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ impl<T: Reflectable> JS<T> {
}
/// Create a JS<T> from a Root<T>
/// XXX Not a great API. Should be a call on Root<T> instead
#[allow(unrooted_must_root)]
pub fn from_rooted(root: &Root<T>) -> JS<T> {
JS {
ptr: unsafe { NonZero::new(&**root) }
}
}
/// Create a JS<T> from a &T
#[allow(unrooted_must_root)]
pub fn from_ref(obj: &T) -> JS<T> {
JS {
ptr: unsafe { NonZero::new(&*obj) }
Expand Down Expand Up @@ -125,6 +127,7 @@ impl<T> PartialEq for LayoutJS<T> {

impl <T> Clone for JS<T> {
#[inline]
#[allow(unrooted_must_root)]
fn clone(&self) -> JS<T> {
JS {
ptr: self.ptr.clone()
Expand Down Expand Up @@ -288,6 +291,7 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
}

impl<T: HeapGCValue + Copy> Default for MutNullableHeap<T> {
#[allow(unrooted_must_root)]
fn default() -> MutNullableHeap<T> {
MutNullableHeap {
ptr: Cell::new(None)
Expand Down
2 changes: 2 additions & 0 deletions components/script/dom/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1371,10 +1371,12 @@ impl Node {
Node::new_(type_id, Some(doc.clone()))
}

#[allow(unrooted_must_root)]
pub fn new_without_doc(type_id: NodeTypeId) -> Node {
Node::new_(type_id, None)
}

#[allow(unrooted_must_root)]
fn new_(type_id: NodeTypeId, doc: Option<&Document>) -> Node {
Node {
eventtarget: EventTarget::new_inherited(),
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/servohtmlparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub struct Sink {
}

impl Sink {
#[allow(unrooted_must_root)] // method is only run at parse time
pub fn get_or_create(&self, child: NodeOrText<JS<Node>>) -> Root<Node> {
match child {
NodeOrText::AppendNode(n) => n.root(),
Expand Down
8 changes: 3 additions & 5 deletions components/script/dom/webglrenderingcontext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ impl WebGLRenderingContext {
}
}

pub fn bound_texture_for(&self, target: u32) -> Option<JS<WebGLTexture>> {
pub fn bound_texture_for(&self, target: u32) -> Option<Root<WebGLTexture>> {
match target {
constants::TEXTURE_2D => self.bound_texture_2d.get(),
constants::TEXTURE_CUBE_MAP => self.bound_texture_cube_map.get(),
constants::TEXTURE_2D => self.bound_texture_2d.get().map(|t| t.root()),
constants::TEXTURE_CUBE_MAP => self.bound_texture_cube_map.get().map(|t| t.root()),

_ => unreachable!(),
}
Expand Down Expand Up @@ -906,7 +906,6 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
constants::TEXTURE_2D |
constants::TEXTURE_CUBE_MAP => {
if let Some(texture) = self.bound_texture_for(target) {
let texture = texture.root();
let result = texture.r().tex_parameter(target, name, TexParameterValue::Float(value));
handle_potential_webgl_error!(self, result);
} else {
Expand All @@ -924,7 +923,6 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
constants::TEXTURE_2D |
constants::TEXTURE_CUBE_MAP => {
if let Some(texture) = self.bound_texture_for(target) {
let texture = texture.root();
let result = texture.r().tex_parameter(target, name, TexParameterValue::Int(value));
handle_potential_webgl_error!(self, result);
} else {
Expand Down
1 change: 1 addition & 0 deletions components/script/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ impl Page {
old
}

#[allow(unrooted_must_root)]
pub fn set_frame(&self, frame: Option<Frame>) {
*self.frame.borrow_mut() = frame;
}
Expand Down

0 comments on commit 894c242

Please sign in to comment.