Rename Root<T> to DomRoot<T>

In a later PR, DomRoot<T> will become a type alias of Root<Dom<T>>,
where Root<T> will be able to handle all the things that need to be
rooted that have a stable traceable address that doesn't move for the
whole lifetime of the root. Stay tuned.
This commit is contained in:
Anthony Ramine 2017-09-26 01:53:40 +02:00
parent 577370746e
commit f87c2a8d76
291 changed files with 1774 additions and 1770 deletions

View file

@ -20,7 +20,7 @@ use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, ToJSVal
use dom::bindings::error::{Error, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{Dom, LayoutDom, MutNullableDom, Root};
use dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom};
use dom::bindings::str::DOMString;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::htmlcanvaselement::HTMLCanvasElement;
@ -207,7 +207,7 @@ impl WebGLRenderingContext {
#[allow(unrooted_must_root)]
pub fn new(window: &Window, canvas: &HTMLCanvasElement, size: Size2D<i32>, attrs: GLContextAttributes)
-> Option<Root<WebGLRenderingContext>> {
-> Option<DomRoot<WebGLRenderingContext>> {
match WebGLRenderingContext::new_inherited(window, canvas, size, attrs) {
Ok(ctx) => Some(reflect_dom_object(box ctx, window, WebGLRenderingContextBinding::Wrap)),
Err(msg) => {
@ -227,7 +227,7 @@ impl WebGLRenderingContext {
&self.limits
}
pub fn bound_texture_for_target(&self, target: &TexImageTarget) -> Option<Root<WebGLTexture>> {
pub fn bound_texture_for_target(&self, target: &TexImageTarget) -> Option<DomRoot<WebGLTexture>> {
match *target {
TexImageTarget::Texture2D => self.bound_texture_2d.get(),
TexImageTarget::CubeMapPositiveX |
@ -247,7 +247,7 @@ impl WebGLRenderingContext {
*self.bound_attrib_buffers.borrow_mut() = FnvHashMap::from_iter(iter.map(|(k,v)| (k, Dom::from_ref(v))));
}
pub fn bound_buffer_element_array(&self) -> Option<Root<WebGLBuffer>> {
pub fn bound_buffer_element_array(&self) -> Option<DomRoot<WebGLBuffer>> {
self.bound_buffer_element_array.get()
}
@ -992,7 +992,7 @@ impl WebGLRenderingContext {
}
fn tex_sub_image_2d(&self,
texture: Root<WebGLTexture>,
texture: DomRoot<WebGLTexture>,
target: TexImageTarget,
level: u32,
xoffset: i32,
@ -1133,8 +1133,8 @@ unsafe fn fallible_array_buffer_view_to_vec(cx: *mut JSContext, abv: *mut JSObje
impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.1
fn Canvas(&self) -> Root<HTMLCanvasElement> {
Root::from_ref(&*self.canvas)
fn Canvas(&self) -> DomRoot<HTMLCanvasElement> {
DomRoot::from_ref(&*self.canvas)
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11
@ -1840,32 +1840,32 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// TODO(emilio): Probably in the future we should keep track of the
// generated objects, either here or in the webgl thread
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
fn CreateBuffer(&self) -> Option<Root<WebGLBuffer>> {
fn CreateBuffer(&self) -> Option<DomRoot<WebGLBuffer>> {
WebGLBuffer::maybe_new(self.global().as_window(), self.webgl_sender.clone())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
fn CreateFramebuffer(&self) -> Option<Root<WebGLFramebuffer>> {
fn CreateFramebuffer(&self) -> Option<DomRoot<WebGLFramebuffer>> {
WebGLFramebuffer::maybe_new(self.global().as_window(), self.webgl_sender.clone())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
fn CreateRenderbuffer(&self) -> Option<Root<WebGLRenderbuffer>> {
fn CreateRenderbuffer(&self) -> Option<DomRoot<WebGLRenderbuffer>> {
WebGLRenderbuffer::maybe_new(self.global().as_window(), self.webgl_sender.clone())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
fn CreateTexture(&self) -> Option<Root<WebGLTexture>> {
fn CreateTexture(&self) -> Option<DomRoot<WebGLTexture>> {
WebGLTexture::maybe_new(self.global().as_window(), self.webgl_sender.clone())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn CreateProgram(&self) -> Option<Root<WebGLProgram>> {
fn CreateProgram(&self) -> Option<DomRoot<WebGLProgram>> {
WebGLProgram::maybe_new(self.global().as_window(), self.webgl_sender.clone())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn CreateShader(&self, shader_type: u32) -> Option<Root<WebGLShader>> {
fn CreateShader(&self, shader_type: u32) -> Option<DomRoot<WebGLShader>> {
match shader_type {
constants::VERTEX_SHADER | constants::FRAGMENT_SHADER => {},
_ => {
@ -2087,7 +2087,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn GetActiveUniform(&self, program: Option<&WebGLProgram>, index: u32) -> Option<Root<WebGLActiveInfo>> {
fn GetActiveUniform(&self, program: Option<&WebGLProgram>, index: u32) -> Option<DomRoot<WebGLActiveInfo>> {
let program = match program {
Some(program) => program,
None => {
@ -2114,7 +2114,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn GetActiveAttrib(&self, program: Option<&WebGLProgram>, index: u32) -> Option<Root<WebGLActiveInfo>> {
fn GetActiveAttrib(&self, program: Option<&WebGLProgram>, index: u32) -> Option<DomRoot<WebGLActiveInfo>> {
let program = match program {
Some(program) => program,
None => {
@ -2212,7 +2212,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
fn GetShaderPrecisionFormat(&self,
shader_type: u32,
precision_type: u32)
-> Option<Root<WebGLShaderPrecisionFormat>> {
-> Option<DomRoot<WebGLShaderPrecisionFormat>> {
let (sender, receiver) = webgl_channel().unwrap();
self.send_command(WebGLCommand::GetShaderPrecisionFormat(shader_type,
precision_type,
@ -2232,7 +2232,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn GetUniformLocation(&self,
program: Option<&WebGLProgram>,
name: DOMString) -> Option<Root<WebGLUniformLocation>> {
name: DOMString) -> Option<DomRoot<WebGLUniformLocation>> {
program.and_then(|p| {
handle_potential_webgl_error!(self, p.get_uniform_location(name), None)
.map(|location| WebGLUniformLocation::new(self.global().as_window(), location, p.id()))