Truly independent web browser
LibWeb: Build Rust bindings' arrays and rect lists from rooted lists
Shannon Booth9a8264b01b2c
diff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_rect_list.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_rect_list.rsindex de3f9d76396..88c86991e9d 100644--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_rect_list.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_rect_list.rs@@ -21,8 +21,8 @@ pub(crate) struct DOMRectList {impl Wrappable for DOMRectList {}impl DOMRectList {- pub(crate) fn new(rects: Vec<Ref<DOMRect>>) -> Self {- Self { rects }+ pub(crate) fn new(rects: &[Ref<DOMRect>]) -> Self {+ Self { rects: rects.to_vec() }}/// https://drafts.fxtf.org/geometry/#dom-domrectlist-lengthdiff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rsindex fd8d9e0103a..b187dd1e0c8 100644--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs@@ -115,7 +115,7 @@ pub extern "C" fn web_dom_rect_list_create(vm: &Vm, rects: ak::Span<'_, [f64; 4]for &[x, y, width, height] in rects.as_slice() {created.push(allocate(vm, DOMRect::new(x, y, width, height)));}- let list = DOMRectList::new(created.to_vec());+ let list = DOMRectList::new(&created.values());cell_into_abi(allocate(vm, list))}diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/values.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/values.rsindex cb3e1879639..0774bf771a5 100644--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/values.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/values.rs@@ -6,7 +6,8 @@use ak::Utf16String;use libjs_rust::api::{- Array, ArrayBuffer, ArrayBufferShared, PrimitiveString, TypedArrayKind, Value, create_typed_array_on_buffer,+ Array, ArrayBuffer, ArrayBufferShared, MarkedVec, PrimitiveString, TypedArrayKind, Value,+ create_typed_array_on_buffer,};use super::proxy::recorder::bytes_of;@@ -41,8 +42,11 @@ impl ContextState {/// A `sequence<GLboolean>` returned as `any` is a JS array.pub(crate) fn boolean_array(&self, cx: &CallContext, booleans: &[bool]) -> Value {- let elements: Vec<Value> = booleans.iter().map(|&boolean| Value::from_bool(boolean)).collect();- Value::from_object(Array::create_from(cx.vm(), self.realm(), &elements))+ let elements = MarkedVec::with_capacity(cx.vm(), booleans.len());+ for &boolean in booleans {+ elements.push(Value::from_bool(boolean));+ }+ Value::from_object(Array::create_from_list(cx.vm(), self.realm(), &elements))}}diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl2_rendering_context_base.rs b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl2_rendering_context_base.rsindex 679e19a9a37..28b2e862e77 100644--- a/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl2_rendering_context_base.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/web_gl/web_gl2_rendering_context_base.rs@@ -7,7 +7,7 @@//! https://registry.khronos.org/webgl/specs/latest/2.0/#3.7use ak::Utf16String;-use libjs_rust::api::{Array, Gc, TypedArrayBase, Value};+use libjs_rust::api::{Array, Gc, MarkedVec, TypedArrayBase, Value};use super::buffer_kind::BufferKind;use super::buffer_source::{@@ -1505,7 +1505,7 @@ impl RenderingContext<WebGL2> {&mut params,);- let mut params_as_values = Vec::with_capacity(params.len());+ let params_as_values = MarkedVec::with_capacity(cx.vm(), params.len());for param in params {params_as_values.push(match pname {GL_UNIFORM_TYPE | GL_UNIFORM_SIZE => Value::from_f64(f64::from(param.cast_unsigned())),@@ -1519,7 +1519,7 @@ impl RenderingContext<WebGL2> {}});}- Ok(Value::from_object(Array::create_from(+ Ok(Value::from_object(Array::create_from_list(cx.vm(),self.realm(),¶ms_as_values,