mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
Script: Change the rest of script to not rely on Deref<str> for DOMString (#39481)
This is part of the future work of implementing LazyDOMString as outlined in issue #39479. We use str() method or direct implementations on DOMString for these methods. We also change some types. This is independent of https://github.com/servo/servo/pull/39480 Signed-off-by: Narfinger Narfinger@users.noreply.github.com Testing: This is essentially just renaming a method and a type and should not change functionality. Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
parent
9713bb9e1b
commit
1e471b9b41
50 changed files with 219 additions and 132 deletions
|
@ -10,6 +10,7 @@ use canvas_traits::webgl::{GlType, TexFormat, WebGLSLVersion, WebGLVersion};
|
|||
use js::jsapi::JSObject;
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use script_bindings::str::DOMString;
|
||||
type GLenum = u32;
|
||||
|
||||
use super::wrapper::{TypedWebGLExtensionWrapper, WebGLExtensionWrapper};
|
||||
|
@ -229,7 +230,7 @@ impl WebGLExtensions {
|
|||
|
||||
pub(crate) fn get_or_init_extension(
|
||||
&self,
|
||||
name: &str,
|
||||
name: &DOMString,
|
||||
ctx: &WebGLRenderingContext,
|
||||
) -> Option<NonNull<JSObject>> {
|
||||
let name = name.to_uppercase();
|
||||
|
|
|
@ -309,7 +309,7 @@ impl WebGLProgram {
|
|||
if !validate_glsl_name(&name)? {
|
||||
return Ok(());
|
||||
}
|
||||
if name.starts_with("gl_") {
|
||||
if name.starts_with_str("gl_") {
|
||||
return Err(WebGLError::InvalidOperation);
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ impl WebGLProgram {
|
|||
if !validate_glsl_name(&name)? {
|
||||
return Ok(-1);
|
||||
}
|
||||
if name.starts_with("gl_") {
|
||||
if name.starts_with_str("gl_") {
|
||||
return Ok(-1);
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,7 @@ impl WebGLProgram {
|
|||
.active_attribs
|
||||
.borrow()
|
||||
.iter()
|
||||
.find(|attrib| attrib.name == *name)
|
||||
.find(|attrib| *attrib.name == *name)
|
||||
.and_then(|attrib| attrib.location.map(|l| l as i32))
|
||||
.unwrap_or(-1);
|
||||
Ok(location)
|
||||
|
@ -398,7 +398,7 @@ impl WebGLProgram {
|
|||
if !validate_glsl_name(&name)? {
|
||||
return Ok(-1);
|
||||
}
|
||||
if name.starts_with("gl_") {
|
||||
if name.starts_with_str("gl_") {
|
||||
return Ok(-1);
|
||||
}
|
||||
|
||||
|
@ -426,7 +426,7 @@ impl WebGLProgram {
|
|||
if !validate_glsl_name(&name)? {
|
||||
return Ok(None);
|
||||
}
|
||||
if name.starts_with("gl_") {
|
||||
if name.starts_with_str("gl_") {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
|
@ -499,10 +499,7 @@ impl WebGLProgram {
|
|||
return Err(WebGLError::InvalidOperation);
|
||||
}
|
||||
|
||||
let validation_errors = names
|
||||
.iter()
|
||||
.map(|name| validate_glsl_name(name))
|
||||
.collect::<Vec<_>>();
|
||||
let validation_errors = names.iter().map(validate_glsl_name).collect::<Vec<_>>();
|
||||
let first_validation_error = validation_errors.iter().find(|result| result.is_err());
|
||||
if let Some(error) = first_validation_error {
|
||||
return Err(error.unwrap_err());
|
||||
|
@ -679,7 +676,7 @@ impl Drop for WebGLProgram {
|
|||
}
|
||||
}
|
||||
|
||||
fn validate_glsl_name(name: &str) -> WebGLResult<bool> {
|
||||
fn validate_glsl_name(name: &DOMString) -> WebGLResult<bool> {
|
||||
if name.is_empty() {
|
||||
return Ok(false);
|
||||
}
|
||||
|
@ -689,7 +686,7 @@ fn validate_glsl_name(name: &str) -> WebGLResult<bool> {
|
|||
for c in name.chars() {
|
||||
validate_glsl_char(c)?;
|
||||
}
|
||||
if name.starts_with("webgl_") || name.starts_with("_webgl_") {
|
||||
if name.starts_with_str("webgl_") || name.starts_with_str("_webgl_") {
|
||||
return Err(WebGLError::InvalidOperation);
|
||||
}
|
||||
Ok(true)
|
||||
|
@ -735,7 +732,8 @@ fn validate_glsl_char(c: char) -> WebGLResult<()> {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_uniform_name(name: &str) -> Option<(&str, Option<i32>)> {
|
||||
fn parse_uniform_name(name: &DOMString) -> Option<(&str, Option<i32>)> {
|
||||
let name = name.str();
|
||||
if !name.ends_with(']') {
|
||||
return Some((name, None));
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ impl WebGLShader {
|
|||
options.set_clampIndirectArrayBounds(1);
|
||||
}
|
||||
|
||||
match validator.compile(&[&source], options) {
|
||||
match validator.compile(&[source.str()], options) {
|
||||
Ok(()) => {
|
||||
let translated_source = validator.object_code();
|
||||
debug!("Shader translated: {}", translated_source);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue