diff options
author | chansuke <chansuke@georepublic.de> | 2018-09-18 23:24:15 +0900 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2018-09-19 17:40:47 -0400 |
commit | c37a345dc9f4dda6ea29c42f96f6c7201c42cbac (patch) | |
tree | 1f05b49bac02318455a59d5b143c186fd872bdb9 /components/script/dom/webgl_extensions/wrapper.rs | |
parent | 2ca7a134736bb4759ff209c1bc0b6dc3cc1984c9 (diff) | |
download | servo-c37a345dc9f4dda6ea29c42f96f6c7201c42cbac.tar.gz servo-c37a345dc9f4dda6ea29c42f96f6c7201c42cbac.zip |
Format script component
Diffstat (limited to 'components/script/dom/webgl_extensions/wrapper.rs')
-rw-r--r-- | components/script/dom/webgl_extensions/wrapper.rs | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/components/script/dom/webgl_extensions/wrapper.rs b/components/script/dom/webgl_extensions/wrapper.rs index b5166327381..f45d3ff8045 100644 --- a/components/script/dom/webgl_extensions/wrapper.rs +++ b/components/script/dom/webgl_extensions/wrapper.rs @@ -15,10 +15,11 @@ use super::{WebGLExtension, WebGLExtensions, WebGLExtensionSpec}; /// Trait used internally by WebGLExtensions to store and /// handle the different WebGL extensions in a common list. pub trait WebGLExtensionWrapper: JSTraceable + MallocSizeOf { - fn instance_or_init(&self, - ctx: &WebGLRenderingContext, - ext: &WebGLExtensions) - -> NonNull<JSObject>; + fn instance_or_init( + &self, + ctx: &WebGLRenderingContext, + ext: &WebGLExtensions, + ) -> NonNull<JSObject>; fn spec(&self) -> WebGLExtensionSpec; fn is_supported(&self, &WebGLExtensions) -> bool; fn is_enabled(&self) -> bool; @@ -30,7 +31,7 @@ pub trait WebGLExtensionWrapper: JSTraceable + MallocSizeOf { #[must_root] #[derive(JSTraceable, MallocSizeOf)] pub struct TypedWebGLExtensionWrapper<T: WebGLExtension> { - extension: MutNullableDom<T::Extension> + extension: MutNullableDom<T::Extension>, } /// Typed WebGL Extension implementation. @@ -38,18 +39,21 @@ pub struct TypedWebGLExtensionWrapper<T: WebGLExtension> { impl<T: WebGLExtension> TypedWebGLExtensionWrapper<T> { pub fn new() -> TypedWebGLExtensionWrapper<T> { TypedWebGLExtensionWrapper { - extension: MutNullableDom::new(None) + extension: MutNullableDom::new(None), } } } impl<T> WebGLExtensionWrapper for TypedWebGLExtensionWrapper<T> - where T: WebGLExtension + JSTraceable + MallocSizeOf + 'static { +where + T: WebGLExtension + JSTraceable + MallocSizeOf + 'static, +{ #[allow(unsafe_code)] - fn instance_or_init(&self, - ctx: &WebGLRenderingContext, - ext: &WebGLExtensions) - -> NonNull<JSObject> { + fn instance_or_init( + &self, + ctx: &WebGLRenderingContext, + ext: &WebGLExtensions, + ) -> NonNull<JSObject> { let mut enabled = true; let extension = self.extension.or_init(|| { enabled = false; @@ -58,13 +62,11 @@ impl<T> WebGLExtensionWrapper for TypedWebGLExtensionWrapper<T> if !enabled { self.enable(ext); } - unsafe { - NonNull::new_unchecked(extension.reflector().get_jsobject().get()) - } + unsafe { NonNull::new_unchecked(extension.reflector().get_jsobject().get()) } } fn spec(&self) -> WebGLExtensionSpec { - T::spec() + T::spec() } fn is_supported(&self, ext: &WebGLExtensions) -> bool { |