mirror of
https://github.com/servo/servo.git
synced 2025-06-06 00:25:37 +00:00
Remove ref_filter_map
dependency (#36857)
Instead, use the `filter_map` functions of `std::cell::Ref` and `accountable_refcell::Ref`, which provide the same functionality as `ref_filter_map`. Testing: Refactoring for removing dependency. No extra test is needed. Fixes: #36851 --------- Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This commit is contained in:
parent
edea2caec1
commit
1271dbf6ec
8 changed files with 15 additions and 23 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
@ -20,9 +20,9 @@ checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046"
|
|||
|
||||
[[package]]
|
||||
name = "accountable-refcell"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6e2bba6f21fcf0ae382750eb6d9387c42807761fa7329d3a05fcd1334e8c3f2"
|
||||
checksum = "6afea9052e0b2d90e38572691d87194b2e5d8d6899b9b850b22aaab17e486252"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
]
|
||||
|
@ -6060,12 +6060,6 @@ dependencies = [
|
|||
"thiserror 2.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ref_filter_map"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b5ceb840e4009da4841ed22a15eb49f64fdd00a2138945c5beacf506b2fb5ed"
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
|
@ -6337,7 +6331,6 @@ dependencies = [
|
|||
"pixels",
|
||||
"profile_traits",
|
||||
"range",
|
||||
"ref_filter_map",
|
||||
"regex",
|
||||
"script_bindings",
|
||||
"script_layout_interface",
|
||||
|
|
|
@ -16,7 +16,7 @@ publish = false
|
|||
rust-version = "1.85.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
accountable-refcell = "0.2.0"
|
||||
accountable-refcell = "0.2.2"
|
||||
aes = "0.8.4"
|
||||
aes-gcm = "0.10.3"
|
||||
aes-kw = { version = "0.2.1", features = ["alloc"] }
|
||||
|
|
|
@ -100,7 +100,6 @@ phf = "0.11"
|
|||
pixels = { path = "../pixels" }
|
||||
profile_traits = { workspace = true }
|
||||
range = { path = "../range" }
|
||||
ref_filter_map = "1.0.1"
|
||||
regex = { workspace = true }
|
||||
script_bindings = { path = "../script_bindings" }
|
||||
script_layout_interface = { workspace = true }
|
||||
|
|
|
@ -9,10 +9,8 @@ use std::cell::{BorrowError, BorrowMutError};
|
|||
pub(crate) use std::cell::{Ref, RefCell, RefMut};
|
||||
|
||||
#[cfg(feature = "refcell_backtrace")]
|
||||
pub(crate) use accountable_refcell::{Ref, RefCell, RefMut, ref_filter_map};
|
||||
pub(crate) use accountable_refcell::{Ref, RefCell, RefMut};
|
||||
use malloc_size_of::{MallocConditionalSizeOf, MallocSizeOfOps};
|
||||
#[cfg(not(feature = "refcell_backtrace"))]
|
||||
pub(crate) use ref_filter_map::ref_filter_map;
|
||||
|
||||
use crate::dom::bindings::root::{assert_in_layout, assert_in_script};
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ use xml5ever::serialize::TraversalScope::{
|
|||
use crate::conversions::Convert;
|
||||
use crate::dom::activation::Activatable;
|
||||
use crate::dom::attr::{Attr, AttrHelpersForLayout, is_relevant_attribute};
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref, RefMut, ref_filter_map};
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref, RefMut};
|
||||
use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::ElementBinding::{
|
||||
|
@ -1480,7 +1480,7 @@ impl Element {
|
|||
// is "xmlns", and local name is prefix, or if prefix is null and it has an attribute
|
||||
// whose namespace is the XMLNS namespace, namespace prefix is null, and local name is
|
||||
// "xmlns", then return its value if it is not the empty string, and null otherwise."
|
||||
let attr = ref_filter_map(self.attrs(), |attrs| {
|
||||
let attr = Ref::filter_map(self.attrs(), |attrs| {
|
||||
attrs.iter().find(|attr| {
|
||||
if attr.namespace() != &ns!(xmlns) {
|
||||
return false;
|
||||
|
@ -1493,7 +1493,8 @@ impl Element {
|
|||
_ => false,
|
||||
}
|
||||
})
|
||||
});
|
||||
})
|
||||
.ok();
|
||||
|
||||
if let Some(attr) = attr {
|
||||
return (**attr.value()).into();
|
||||
|
|
|
@ -31,7 +31,7 @@ pub(crate) use crate::canvas_context::*;
|
|||
use crate::conversions::Convert;
|
||||
use crate::dom::attr::Attr;
|
||||
use crate::dom::bindings::callback::ExceptionHandling;
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref, ref_filter_map};
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::{
|
||||
BlobCallback, HTMLCanvasElementMethods, RenderingContext as RootedRenderingContext,
|
||||
};
|
||||
|
@ -225,7 +225,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
|||
|
||||
impl HTMLCanvasElement {
|
||||
pub(crate) fn context(&self) -> Option<Ref<RenderingContext>> {
|
||||
ref_filter_map(self.context_mode.borrow(), |ctx| ctx.as_ref())
|
||||
Ref::filter_map(self.context_mode.borrow(), |ctx| ctx.as_ref()).ok()
|
||||
}
|
||||
|
||||
fn get_or_init_2d_context(&self, can_gc: CanGc) -> Option<DomRoot<CanvasRenderingContext2D>> {
|
||||
|
|
|
@ -10,7 +10,7 @@ use js::rust::{HandleObject, HandleValue};
|
|||
use snapshot::Snapshot;
|
||||
|
||||
use crate::canvas_context::{CanvasContext, OffscreenRenderingContext};
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref, ref_filter_map};
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
||||
use crate::dom::bindings::codegen::Bindings::OffscreenCanvasBinding::{
|
||||
OffscreenCanvasMethods, OffscreenRenderingContext as RootedOffscreenRenderingContext,
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ impl OffscreenCanvas {
|
|||
}
|
||||
|
||||
pub(crate) fn context(&self) -> Option<Ref<OffscreenRenderingContext>> {
|
||||
ref_filter_map(self.context.borrow(), |ctx| ctx.as_ref())
|
||||
Ref::filter_map(self.context.borrow(), |ctx| ctx.as_ref()).ok()
|
||||
}
|
||||
|
||||
pub(crate) fn get_image_data(&self) -> Option<Snapshot> {
|
||||
|
|
|
@ -8,7 +8,7 @@ use canvas_traits::webgl::{
|
|||
ActiveAttribInfo, WebGLCommand, WebGLError, WebGLResult, WebGLVersion, WebGLVertexArrayId,
|
||||
};
|
||||
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref, ref_filter_map};
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
||||
use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants2;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
|
||||
use crate::dom::bindings::root::{Dom, MutNullableDom};
|
||||
|
@ -83,9 +83,10 @@ impl VertexArrayObject {
|
|||
}
|
||||
|
||||
pub(crate) fn get_vertex_attrib(&self, index: u32) -> Option<Ref<VertexAttribData>> {
|
||||
ref_filter_map(self.vertex_attribs.borrow(), |attribs| {
|
||||
Ref::filter_map(self.vertex_attribs.borrow(), |attribs| {
|
||||
attribs.get(index as usize)
|
||||
})
|
||||
.ok()
|
||||
}
|
||||
|
||||
pub(crate) fn set_vertex_attrib_type(&self, index: u32, type_: u32) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue