Replace .map_or(false with Option::is_some_and (#33468)

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2024-09-16 12:03:52 +02:00 committed by GitHub
parent 236cae9ce5
commit 7df30f3788
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
51 changed files with 165 additions and 171 deletions

View file

@ -598,7 +598,7 @@ pub unsafe fn cross_origin_has_own(
// TODO: Once we have the slot for the holder, it'd be more efficient to
// use `ensure_cross_origin_property_holder`. We'll need `_proxy` to
// do that.
*bp = jsid_to_string(*cx, Handle::from_raw(id)).map_or(false, |key| {
*bp = jsid_to_string(*cx, Handle::from_raw(id)).is_some_and(|key| {
cross_origin_properties.keys().any(|defined_key| {
let defined_key = CStr::from_ptr(defined_key);
defined_key.to_bytes() == key.as_bytes()
@ -674,7 +674,7 @@ const ALLOWLISTED_SYMBOL_CODES: &[SymbolCode] = &[
];
unsafe fn is_cross_origin_allowlisted_prop(cx: SafeJSContext, id: RawHandleId) -> bool {
if jsid_to_string(*cx, Handle::from_raw(id)).map_or(false, |st| st == "then") {
if jsid_to_string(*cx, Handle::from_raw(id)).is_some_and(|st| st == "then") {
return true;
}

View file

@ -1266,7 +1266,7 @@ pub fn is_valid_custom_element_name(name: &str) -> bool {
// PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)*
let mut chars = name.chars();
if !chars.next().map_or(false, |c| c.is_ascii_lowercase()) {
if !chars.next().is_some_and(|c| c.is_ascii_lowercase()) {
return false;
}

View file

@ -3595,7 +3595,7 @@ impl Document {
if element.namespace() != &ns!(html) {
return false;
}
element.get_name().map_or(false, |n| *n == **name)
element.get_name().is_some_and(|n| *n == **name)
}
fn count_node_list<F: Fn(&Node) -> bool>(&self, callback: F) -> u32 {
@ -3935,9 +3935,9 @@ impl Document {
true
} else {
// Step 3
window.GetFrameElement().map_or(false, |el| {
el.has_attribute(&local_name!("allowfullscreen"))
})
window
.GetFrameElement()
.is_some_and(|el| el.has_attribute(&local_name!("allowfullscreen")))
}
},
}
@ -5064,7 +5064,7 @@ impl DocumentMethods for Document {
HTMLElementTypeId::HTMLFormElement | HTMLElementTypeId::HTMLIFrameElement => {
elem.get_name().as_ref() == Some(&self.name)
},
HTMLElementTypeId::HTMLImageElement => elem.get_name().map_or(false, |name| {
HTMLElementTypeId::HTMLImageElement => elem.get_name().is_some_and(|name| {
name == *self.name ||
!name.is_empty() && elem.get_id().as_ref() == Some(&self.name)
}),
@ -5217,7 +5217,7 @@ impl DocumentMethods for Document {
// Step 5
if self
.get_current_parser()
.map_or(false, |parser| parser.is_active())
.is_some_and(|parser| parser.is_active())
{
return Ok(DomRoot::from_ref(self));
}
@ -5650,5 +5650,5 @@ fn is_named_element_with_id_attribute(elem: &Element) -> bool {
// TODO handle <embed> and <object>; these depend on whether the element is
// “exposed”, a concept that doesnt fully make sense until embed/object
// behaviour is actually implemented
elem.is::<HTMLImageElement>() && elem.get_name().map_or(false, |name| !name.is_empty())
elem.is::<HTMLImageElement>() && elem.get_name().is_some_and(|name| !name.is_empty())
}

View file

@ -121,7 +121,7 @@ impl DOMTokenListMethods for DOMTokenList {
/// <https://dom.spec.whatwg.org/#dom-domtokenlist-contains>
fn Contains(&self, token: DOMString) -> bool {
let token = Atom::from(token);
self.attribute().map_or(false, |attr| {
self.attribute().is_some_and(|attr| {
attr.value()
.as_tokens()
.iter()

View file

@ -430,7 +430,7 @@ impl Element {
// https://drafts.csswg.org/cssom-view/#css-layout-box
pub fn has_css_layout_box(&self) -> bool {
self.style()
.map_or(false, |s| !s.get_box().clone_display().is_none())
.is_some_and(|s| !s.get_box().clone_display().is_none())
}
// https://drafts.csswg.org/cssom-view/#potentially-scrollable
@ -477,7 +477,7 @@ impl Element {
fn has_scrolling_box(&self) -> bool {
// TODO: scrolling mechanism, such as scrollbar (We don't have scrollbar yet)
// self.has_scrolling_mechanism()
self.style().map_or(false, |style| {
self.style().is_some_and(|style| {
style.get_box().clone_overflow_x().is_scrollable() ||
style.get_box().clone_overflow_y().is_scrollable()
})
@ -658,7 +658,7 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
#[inline]
fn has_class_for_layout(self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool {
get_attr_for_layout(self, &ns!(), &local_name!("class")).map_or(false, |attr| {
get_attr_for_layout(self, &ns!(), &local_name!("class")).is_some_and(|attr| {
attr.to_tokens()
.unwrap()
.iter()
@ -1651,7 +1651,7 @@ impl Element {
pub fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
self.get_attribute(&ns!(), &local_name!("class"))
.map_or(false, |attr| {
.is_some_and(|attr| {
attr.value()
.as_tokens()
.iter()
@ -3652,7 +3652,7 @@ impl SelectorsElement for DomRoot<Element> {
match *ns {
NamespaceConstraint::Specific(ns) => self
.get_attribute(ns, local_name)
.map_or(false, |attr| attr.value().eval_selector(operation)),
.is_some_and(|attr| attr.value().eval_selector(operation)),
NamespaceConstraint::Any => self.attrs.borrow().iter().any(|attr| {
*attr.local_name() == **local_name && attr.value().eval_selector(operation)
}),
@ -3765,7 +3765,7 @@ impl SelectorsElement for DomRoot<Element> {
self.id_attribute
.borrow()
.as_ref()
.map_or(false, |atom| case_sensitivity.eq_atom(id, atom))
.is_some_and(|atom| case_sensitivity.eq_atom(id, atom))
}
fn is_part(&self, _name: &AtomIdent) -> bool {

View file

@ -2836,12 +2836,12 @@ impl GlobalScope {
) -> Rc<Promise> {
let in_realm_proof = AlreadyInRealm::assert();
let p = Promise::new_in_current_realm(InRealm::Already(&in_realm_proof));
if options.resizeWidth.map_or(false, |w| w == 0) {
if options.resizeWidth.is_some_and(|w| w == 0) {
p.reject_error(Error::InvalidState);
return p;
}
if options.resizeHeight.map_or(false, |w| w == 0) {
if options.resizeHeight.is_some_and(|w| w == 0) {
p.reject_error(Error::InvalidState);
return p;
}

View file

@ -620,7 +620,7 @@ pub fn get_element_noopener(subject: &Element, target_attribute_value: Option<DO
}
let target_is_blank = target_attribute_value
.as_ref()
.map_or(false, |target| target.to_lowercase() == "_blank");
.is_some_and(|target| target.to_lowercase() == "_blank");
let link_types = match subject.get_attribute(&ns!(), &local_name!("rel")) {
Some(rel) => rel.Value(),
None => return target_is_blank,

View file

@ -383,8 +383,8 @@ impl HTMLCollectionMethods for HTMLCollection {
// Step 2.
self.elements_iter().find(|elem| {
elem.get_id().map_or(false, |id| id == key) ||
(elem.namespace() == &ns!(html) && elem.get_name().map_or(false, |id| id == key))
elem.get_id().is_some_and(|id| id == key) ||
(elem.namespace() == &ns!(html) && elem.get_name().is_some_and(|id| id == key))
})
}

View file

@ -673,7 +673,7 @@ impl HTMLElement {
.chars()
.skip_while(|&ch| ch != '\u{2d}')
.nth(1)
.map_or(false, |ch| ch.is_ascii_lowercase())
.is_some_and(|ch| ch.is_ascii_lowercase())
{
return Err(Error::Syntax);
}

View file

@ -90,7 +90,7 @@ impl HTMLFieldSetElementMethods for HTMLFieldSetElement {
impl CollectionFilter for ElementsFilter {
fn filter<'a>(&self, elem: &'a Element, _root: &'a Node) -> bool {
elem.downcast::<HTMLElement>()
.map_or(false, HTMLElement::is_listed_element)
.is_some_and(HTMLElement::is_listed_element)
}
}
let filter = Box::new(ElementsFilter);
@ -210,7 +210,7 @@ impl VirtualMethods for HTMLFieldSetElement {
element.set_enabled_state(false);
if element
.downcast::<HTMLElement>()
.map_or(false, |h| h.is_form_associated_custom_element())
.is_some_and(|h| h.is_form_associated_custom_element())
{
ScriptThread::enqueue_callback_reaction(
element,
@ -231,7 +231,7 @@ impl VirtualMethods for HTMLFieldSetElement {
if element.enabled_state() &&
element
.downcast::<HTMLElement>()
.map_or(false, |h| h.is_form_associated_custom_element())
.is_some_and(|h| h.is_form_associated_custom_element())
{
ScriptThread::enqueue_callback_reaction(
element,

View file

@ -70,8 +70,8 @@ impl HTMLFormControlsCollectionMethods for HTMLFormControlsCollection {
let name = Atom::from(name);
let mut filter_map = self.collection.elements_iter().filter_map(|elem| {
if elem.get_name().map_or(false, |n| n == name) ||
elem.get_id().map_or(false, |i| i == name)
if elem.get_name().is_some_and(|n| n == name) ||
elem.get_id().is_some_and(|i| i == name)
{
Some(elem)
} else {

View file

@ -144,9 +144,9 @@ impl HTMLFormElement {
RadioListMode::ControlsExceptImageInputs => {
if child
.downcast::<HTMLElement>()
.map_or(false, |c| c.is_listed_element()) &&
(child.get_id().map_or(false, |i| i == *name) ||
child.get_name().map_or(false, |n| n == *name))
.is_some_and(|c| c.is_listed_element()) &&
(child.get_id().is_some_and(|i| i == *name) ||
child.get_name().is_some_and(|n| n == *name))
{
if let Some(inp) = child.downcast::<HTMLInputElement>() {
// input, only return it if it's not image-button state
@ -160,8 +160,8 @@ impl HTMLFormElement {
},
RadioListMode::Images => {
return child.is::<HTMLImageElement>() &&
(child.get_id().map_or(false, |i| i == *name) ||
child.get_name().map_or(false, |n| n == *name));
(child.get_id().is_some_and(|i| i == *name) ||
child.get_name().is_some_and(|n| n == *name));
},
}
}
@ -511,7 +511,7 @@ impl HTMLFormElementMethods for HTMLFormElement {
for child in controls.iter() {
if child
.downcast::<HTMLElement>()
.map_or(false, |c| c.is_listed_element())
.is_some_and(|c| c.is_listed_element())
{
if let Some(id_atom) = child.get_id() {
let entry = SourcedName {
@ -1147,13 +1147,11 @@ impl HTMLFormElement {
// An element can only have a dirname attribute if it is a textarea element
// or an input element whose type attribute is in either the Text state or the Search state
let child_element = child.downcast::<Element>().unwrap();
let input_matches =
child_element
.downcast::<HTMLInputElement>()
.map_or(false, |input| {
input.input_type() == InputType::Text ||
input.input_type() == InputType::Search
});
let input_matches = child_element
.downcast::<HTMLInputElement>()
.is_some_and(|input| {
matches!(input.input_type(), InputType::Text | InputType::Search)
});
let textarea_matches = child_element.is::<HTMLTextAreaElement>();
let dirname = child_element.get_string_attribute(&local_name!("dirname"));
if (input_matches || textarea_matches) && !dirname.is_empty() {
@ -1642,7 +1640,7 @@ pub trait FormControl: DomObject {
if self.to_element().has_attribute(attr) {
input(self)
} else {
self.form_owner().map_or(false, |t| owner(&t))
self.form_owner().is_some_and(|t| owner(&t))
}
}

View file

@ -975,7 +975,7 @@ impl HTMLImageElement {
let is_parent_picture = elem
.upcast::<Node>()
.GetParentElement()
.map_or(false, |p| p.is::<HTMLPictureElement>());
.is_some_and(|p| p.is::<HTMLPictureElement>());
if src_set.is_empty() && !is_parent_picture && !src.is_empty() {
selected_source = Some(src.clone());
pixel_density = Some(1_f64);
@ -1295,7 +1295,7 @@ impl HTMLImageElement {
let is_parent_picture = elem
.upcast::<Node>()
.GetParentElement()
.map_or(false, |p| p.is::<HTMLPictureElement>());
.is_some_and(|p| p.is::<HTMLPictureElement>());
has_src || is_parent_picture
}
@ -1405,7 +1405,7 @@ impl HTMLImageElement {
.find(|n| {
n.upcast::<Element>()
.get_name()
.map_or(false, |n| *n == *last)
.is_some_and(|n| *n == *last)
});
useMapElements.map(|mapElem| mapElem.get_area_elements())
@ -1420,9 +1420,7 @@ impl HTMLImageElement {
.borrow()
.final_url
.as_ref()
.map_or(false, |url| {
url.scheme() == "data" || url.origin().same_origin(origin)
})
.is_some_and(|url| url.scheme() == "data" || url.origin().same_origin(origin))
}
}

View file

@ -756,7 +756,7 @@ impl HTMLInputElement {
.traverse_preorder(ShadowIncluding::No)
.find(|node| {
node.downcast::<Element>()
.map_or(false, |e| e.Id() == list_string)
.is_some_and(|e| e.Id() == list_string)
});
first_with_id
.as_ref()

View file

@ -2187,7 +2187,7 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
if self
.error
.get()
.map_or(false, |e| e.Code() == MEDIA_ERR_SRC_NOT_SUPPORTED)
.is_some_and(|e| e.Code() == MEDIA_ERR_SRC_NOT_SUPPORTED)
{
promise.reject_error(Error::NotSupported);
return promise;

View file

@ -825,7 +825,7 @@ impl HTMLScriptElement {
ScriptType::Classic => {
if was_parser_inserted &&
doc.get_current_parser()
.map_or(false, |parser| parser.script_nesting_level() <= 1) &&
.is_some_and(|parser| parser.script_nesting_level() <= 1) &&
doc.get_script_blocking_stylesheets_count() > 0
{
// Step 27.h: classic, has no src, was parser-inserted, is blocked on stylesheet.

View file

@ -283,7 +283,7 @@ impl HTMLStyleElementMethods for HTMLStyleElement {
/// <https://html.spec.whatwg.org/multipage/#dom-style-disabled>
fn Disabled(&self) -> bool {
self.get_cssom_stylesheet()
.map_or(false, |sheet| sheet.disabled())
.is_some_and(|sheet| sheet.disabled())
}
/// <https://html.spec.whatwg.org/multipage/#dom-style-disabled>

View file

@ -98,7 +98,7 @@ impl ImageData {
}
let height = len / width;
if opt_height.map_or(false, |x| height != x) {
if opt_height.is_some_and(|x| height != x) {
return Err(Error::IndexSize);
}

View file

@ -783,7 +783,7 @@ impl Node {
child
.parent_node
.get()
.map_or(false, |parent| &*parent == self)
.is_some_and(|parent| &*parent == self)
}
pub fn to_trusted_node_address(&self) -> TrustedNodeAddress {
@ -825,10 +825,10 @@ impl Node {
let viewport = Size2D::new(window.InnerWidth(), window.InnerHeight());
let in_quirks_mode = document.quirks_mode() == QuirksMode::Quirks;
let is_root = self.downcast::<Element>().map_or(false, |e| e.is_root());
let is_root = self.downcast::<Element>().is_some_and(|e| e.is_root());
let is_body_element = self
.downcast::<HTMLBodyElement>()
.map_or(false, |e| e.is_the_html_body_element());
.is_some_and(|e| e.is_the_html_body_element());
// "4. If the element is the root element and document is not in quirks mode
// return max(viewport scrolling area width/height, viewport width/height)."
@ -2180,7 +2180,7 @@ impl Node {
parent.owner_doc().add_script_and_layout_blocker();
assert!(node
.GetParentNode()
.map_or(false, |node_parent| &*node_parent == parent));
.is_some_and(|node_parent| &*node_parent == parent));
let cached_index = {
if parent.ranges.is_empty() {
None
@ -2809,7 +2809,7 @@ impl NodeMethods for Node {
}
while children
.peek()
.map_or(false, |(_, sibling)| sibling.is::<Text>())
.is_some_and(|(_, sibling)| sibling.is::<Text>())
{
let (index, sibling) = children.next().unwrap();
sibling

View file

@ -97,8 +97,7 @@ impl PerformanceEntryList {
entry_type: DOMString,
) {
self.entries.retain(|e| {
*e.entry_type() != *entry_type ||
name.as_ref().map_or(false, |name_| *e.name() != *name_)
*e.entry_type() != *entry_type || name.as_ref().is_some_and(|name_| *e.name() != *name_)
});
}

View file

@ -653,12 +653,12 @@ impl BodyMixin for Request {
let body_stream = self.body_stream.get();
body_stream
.as_ref()
.map_or(false, |stream| stream.is_disturbed())
.is_some_and(|stream| stream.is_disturbed())
}
fn is_locked(&self) -> bool {
let body_stream = self.body_stream.get();
body_stream.map_or(false, |stream| stream.is_locked())
body_stream.is_some_and(|stream| stream.is_locked())
}
fn body(&self) -> Option<DomRoot<ReadableStream>> {

View file

@ -235,13 +235,13 @@ impl BodyMixin for Response {
fn is_disturbed(&self) -> bool {
self.body_stream
.get()
.map_or(false, |stream| stream.is_disturbed())
.is_some_and(|stream| stream.is_disturbed())
}
fn is_locked(&self) -> bool {
self.body_stream
.get()
.map_or(false, |stream| stream.is_locked())
.is_some_and(|stream| stream.is_locked())
}
fn body(&self) -> Option<DomRoot<ReadableStream>> {

View file

@ -159,7 +159,7 @@ struct SerializationIterator {
}
fn rev_children_iter(n: &Node) -> impl Iterator<Item = DomRoot<Node>> {
if n.downcast::<Element>().map_or(false, |e| e.is_void()) {
if n.downcast::<Element>().is_some_and(|e| e.is_void()) {
return Node::new_document_node().rev_children();
}

View file

@ -1294,7 +1294,7 @@ impl TreeSink for Sink {
fn is_mathml_annotation_xml_integration_point(&self, handle: &Dom<Node>) -> bool {
let elem = handle.downcast::<Element>().unwrap();
elem.get_attribute(&ns!(), &local_name!("encoding"))
.map_or(false, |attr| {
.is_some_and(|attr| {
attr.value().eq_ignore_ascii_case("text/html") ||
attr.value().eq_ignore_ascii_case("application/xhtml+xml")
})

View file

@ -194,7 +194,7 @@ impl VertexArrayObject {
if self
.element_array_buffer
.get()
.map_or(false, |b| buffer == &*b)
.is_some_and(|b| buffer == &*b)
{
buffer.decrement_attached_counter(Operation::Infallible);
self.element_array_buffer.set(None);
@ -239,7 +239,7 @@ impl VertexArrayObject {
}
} else if max_vertices
.checked_mul(attrib.divisor)
.map_or(false, |v| v < instance_count)
.is_some_and(|v| v < instance_count)
{
return Err(WebGLError::InvalidOperation);
}

View file

@ -350,7 +350,7 @@ impl WebGL2RenderingContext {
}
fn unbind_from(&self, slot: &MutNullableDom<WebGLBuffer>, buffer: &WebGLBuffer) {
if slot.get().map_or(false, |b| buffer == &*b) {
if slot.get().is_some_and(|b| buffer == &*b) {
buffer.decrement_attached_counter(Operation::Infallible);
slot.set(None);
}
@ -1452,10 +1452,10 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
let src_is_elemarray = read_buffer
.target()
.map_or(false, |t| t == constants::ELEMENT_ARRAY_BUFFER);
.is_some_and(|t| t == constants::ELEMENT_ARRAY_BUFFER);
let dst_is_elemarray = write_buffer
.target()
.map_or(false, |t| t == constants::ELEMENT_ARRAY_BUFFER);
.is_some_and(|t| t == constants::ELEMENT_ARRAY_BUFFER);
if src_is_elemarray != dst_is_elemarray {
return self.base.webgl_error(InvalidOperation);
}
@ -3424,7 +3424,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
if let Some(sampler) = sampler {
handle_potential_webgl_error!(self.base, self.base.validate_ownership(sampler), return);
for slot in self.samplers.iter() {
if slot.get().map_or(false, |s| sampler == &*s) {
if slot.get().is_some_and(|s| sampler == &*s) {
slot.set(None);
}
}

View file

@ -250,7 +250,7 @@ impl WebGLExtensions {
self.extensions
.borrow()
.get(&name)
.map_or(false, |ext| ext.is_enabled())
.is_some_and(|ext| ext.is_enabled())
}
pub fn supports_gl_extension(&self, name: &str) -> bool {

View file

@ -430,7 +430,7 @@ impl WebGLFramebuffer {
self.size.set(fb_size);
if has_c || has_z || has_zs || has_s {
if self.size.get().map_or(false, |(w, h)| w != 0 && h != 0) {
if self.size.get().is_some_and(|(w, h)| w != 0 && h != 0) {
self.status.set(constants::FRAMEBUFFER_COMPLETE);
} else {
self.status

View file

@ -1208,7 +1208,7 @@ impl WebGLRenderingContext {
}
pub fn is_vertex_array(&self, vao: Option<&WebGLVertexArrayObjectOES>) -> bool {
vao.map_or(false, |vao| {
vao.is_some_and(|vao| {
// The default vertex array has no id and should never be passed around.
assert!(vao.id().is_some());
self.validate_ownership(vao).is_ok() && vao.ever_bound() && !vao.is_deleted()
@ -1216,7 +1216,7 @@ impl WebGLRenderingContext {
}
pub fn is_vertex_array_webgl2(&self, vao: Option<&WebGLVertexArrayObject>) -> bool {
vao.map_or(false, |vao| {
vao.is_some_and(|vao| {
// The default vertex array has no id and should never be passed around.
assert!(vao.id().is_some());
self.validate_ownership(vao).is_ok() && vao.ever_bound() && !vao.is_deleted()
@ -2913,11 +2913,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
return;
}
self.current_vao().unbind_buffer(buffer);
if self
.bound_buffer_array
.get()
.map_or(false, |b| buffer == &*b)
{
if self.bound_buffer_array.get().is_some_and(|b| buffer == &*b) {
self.bound_buffer_array.set(None);
buffer.decrement_attached_counter(Operation::Infallible);
}
@ -3517,7 +3513,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
fn IsBuffer(&self, buffer: Option<&WebGLBuffer>) -> bool {
buffer.map_or(false, |buf| {
buffer.is_some_and(|buf| {
self.validate_ownership(buf).is_ok() && buf.target().is_some() && !buf.is_deleted()
})
}
@ -3529,35 +3525,31 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
fn IsFramebuffer(&self, frame_buffer: Option<&WebGLFramebuffer>) -> bool {
frame_buffer.map_or(false, |buf| {
frame_buffer.is_some_and(|buf| {
self.validate_ownership(buf).is_ok() && buf.target().is_some() && !buf.is_deleted()
})
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn IsProgram(&self, program: Option<&WebGLProgram>) -> bool {
program.map_or(false, |p| {
self.validate_ownership(p).is_ok() && !p.is_deleted()
})
program.is_some_and(|p| self.validate_ownership(p).is_ok() && !p.is_deleted())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
fn IsRenderbuffer(&self, render_buffer: Option<&WebGLRenderbuffer>) -> bool {
render_buffer.map_or(false, |buf| {
render_buffer.is_some_and(|buf| {
self.validate_ownership(buf).is_ok() && buf.ever_bound() && !buf.is_deleted()
})
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn IsShader(&self, shader: Option<&WebGLShader>) -> bool {
shader.map_or(false, |s| {
self.validate_ownership(s).is_ok() && !s.is_deleted()
})
shader.is_some_and(|s| self.validate_ownership(s).is_ok() && !s.is_deleted())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
fn IsTexture(&self, texture: Option<&WebGLTexture>) -> bool {
texture.map_or(false, |tex| {
texture.is_some_and(|tex| {
self.validate_ownership(tex).is_ok() && tex.target().is_some() && !tex.is_invalid()
})
}
@ -4850,7 +4842,7 @@ impl TextureUnit {
(&self.tex_3d, WebGL2RenderingContextConstants::TEXTURE_3D),
];
for &(slot, target) in &fields {
if slot.get().map_or(false, |t| texture == &*t) {
if slot.get().is_some_and(|t| texture == &*t) {
slot.set(None);
return Some(target);
}

View file

@ -2020,7 +2020,7 @@ impl Window {
// See http://testthewebforward.org/docs/reftests.html
// and https://web-platform-tests.org/writing-tests/crashtest.html
let html_element = document.GetDocumentElement();
let reftest_wait = html_element.map_or(false, |elem| {
let reftest_wait = html_element.is_some_and(|elem| {
elem.has_class(&atom!("reftest-wait"), CaseSensitivity::CaseSensitive) ||
elem.has_class(&Atom::from("test-wait"), CaseSensitivity::CaseSensitive)
});
@ -2516,7 +2516,7 @@ impl Window {
.get()
.as_ref()
.and_then(|nav| nav.xr())
.map_or(false, |xr| xr.pending_or_active_session())
.is_some_and(|xr| xr.pending_or_active_session())
}
}