mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
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:
parent
236cae9ce5
commit
7df30f3788
51 changed files with 165 additions and 171 deletions
|
@ -329,7 +329,7 @@ impl BluetoothManager {
|
||||||
let adapter_valid = self
|
let adapter_valid = self
|
||||||
.adapter
|
.adapter
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |a| a.get_address().is_ok());
|
.is_some_and(|a| a.get_address().is_ok());
|
||||||
if !adapter_valid {
|
if !adapter_valid {
|
||||||
self.adapter = BluetoothAdapter::new().ok();
|
self.adapter = BluetoothAdapter::new().ok();
|
||||||
}
|
}
|
||||||
|
@ -471,9 +471,9 @@ impl BluetoothManager {
|
||||||
|
|
||||||
services.retain(|s| {
|
services.retain(|s| {
|
||||||
!uuid_is_blocklisted(&s.get_uuid().unwrap_or_default(), Blocklist::All) &&
|
!uuid_is_blocklisted(&s.get_uuid().unwrap_or_default(), Blocklist::All) &&
|
||||||
self.allowed_services.get(device_id).map_or(false, |uuids| {
|
self.allowed_services
|
||||||
uuids.contains(&s.get_uuid().unwrap_or_default())
|
.get(device_id)
|
||||||
})
|
.is_some_and(|uuids| uuids.contains(&s.get_uuid().unwrap_or_default()))
|
||||||
});
|
});
|
||||||
for service in &services {
|
for service in &services {
|
||||||
self.cached_services
|
self.cached_services
|
||||||
|
@ -727,7 +727,7 @@ impl BluetoothManager {
|
||||||
if !self
|
if !self
|
||||||
.allowed_services
|
.allowed_services
|
||||||
.get(&id)
|
.get(&id)
|
||||||
.map_or(false, |s| s.contains(uuid))
|
.is_some_and(|s| s.contains(uuid))
|
||||||
{
|
{
|
||||||
return Err(BluetoothError::Security);
|
return Err(BluetoothError::Security);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4858,7 +4858,7 @@ where
|
||||||
.webviews
|
.webviews
|
||||||
.focused_webview()
|
.focused_webview()
|
||||||
.map(|(_, webview)| webview.focused_browsing_context_id);
|
.map(|(_, webview)| webview.focused_browsing_context_id);
|
||||||
focused_browsing_context_id.map_or(false, |focus_ctx_id| {
|
focused_browsing_context_id.is_some_and(|focus_ctx_id| {
|
||||||
focus_ctx_id == browsing_context_id ||
|
focus_ctx_id == browsing_context_id ||
|
||||||
self.fully_active_descendant_browsing_contexts_iter(browsing_context_id)
|
self.fully_active_descendant_browsing_contexts_iter(browsing_context_id)
|
||||||
.any(|nested_ctx| nested_ctx.id == focus_ctx_id)
|
.any(|nested_ctx| nested_ctx.id == focus_ctx_id)
|
||||||
|
|
|
@ -215,9 +215,10 @@ impl SimpleFamily {
|
||||||
|
|
||||||
fn remove_templates_for_stylesheet(&mut self, stylesheet: &DocumentStyleSheet) {
|
fn remove_templates_for_stylesheet(&mut self, stylesheet: &DocumentStyleSheet) {
|
||||||
let remove_if_template_matches = |template: &mut Option<FontTemplateRef>| {
|
let remove_if_template_matches = |template: &mut Option<FontTemplateRef>| {
|
||||||
if template.as_ref().map_or(false, |template| {
|
if template
|
||||||
template.borrow().stylesheet.as_ref() == Some(stylesheet)
|
.as_ref()
|
||||||
}) {
|
.is_some_and(|template| template.borrow().stylesheet.as_ref() == Some(stylesheet))
|
||||||
|
{
|
||||||
*template = None;
|
*template = None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -505,9 +505,10 @@ impl<'a> DisplayListBuildState<'a> {
|
||||||
// Properly order display items that make up a stacking context. "Steps" here
|
// Properly order display items that make up a stacking context. "Steps" here
|
||||||
// refer to the steps in CSS 2.1 Appendix E.
|
// refer to the steps in CSS 2.1 Appendix E.
|
||||||
// Steps 1 and 2: Borders and background for the root.
|
// Steps 1 and 2: Borders and background for the root.
|
||||||
while child_items.last().map_or(false, |child| {
|
while child_items
|
||||||
child.section() == DisplayListSection::BackgroundAndBorders
|
.last()
|
||||||
}) {
|
.is_some_and(|child| child.section() == DisplayListSection::BackgroundAndBorders)
|
||||||
|
{
|
||||||
list.push(child_items.pop().unwrap());
|
list.push(child_items.pop().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,31 +516,34 @@ impl<'a> DisplayListBuildState<'a> {
|
||||||
let mut child_stacking_contexts = child_stacking_contexts.into_iter().peekable();
|
let mut child_stacking_contexts = child_stacking_contexts.into_iter().peekable();
|
||||||
while child_stacking_contexts
|
while child_stacking_contexts
|
||||||
.peek()
|
.peek()
|
||||||
.map_or(false, |child| child.z_index < 0)
|
.is_some_and(|child| child.z_index < 0)
|
||||||
{
|
{
|
||||||
let context = child_stacking_contexts.next().unwrap();
|
let context = child_stacking_contexts.next().unwrap();
|
||||||
self.move_to_display_list_for_stacking_context(list, context);
|
self.move_to_display_list_for_stacking_context(list, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 4: Block backgrounds and borders.
|
// Step 4: Block backgrounds and borders.
|
||||||
while child_items.last().map_or(false, |child| {
|
while child_items
|
||||||
child.section() == DisplayListSection::BlockBackgroundsAndBorders
|
.last()
|
||||||
}) {
|
.is_some_and(|child| child.section() == DisplayListSection::BlockBackgroundsAndBorders)
|
||||||
|
{
|
||||||
list.push(child_items.pop().unwrap());
|
list.push(child_items.pop().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 5: Floats.
|
// Step 5: Floats.
|
||||||
while child_stacking_contexts.peek().map_or(false, |child| {
|
while child_stacking_contexts
|
||||||
child.context_type == StackingContextType::PseudoFloat
|
.peek()
|
||||||
}) {
|
.is_some_and(|child| child.context_type == StackingContextType::PseudoFloat)
|
||||||
|
{
|
||||||
let context = child_stacking_contexts.next().unwrap();
|
let context = child_stacking_contexts.next().unwrap();
|
||||||
self.move_to_display_list_for_stacking_context(list, context);
|
self.move_to_display_list_for_stacking_context(list, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6 & 7: Content and inlines that generate stacking contexts.
|
// Step 6 & 7: Content and inlines that generate stacking contexts.
|
||||||
while child_items.last().map_or(false, |child| {
|
while child_items
|
||||||
child.section() == DisplayListSection::Content
|
.last()
|
||||||
}) {
|
.is_some_and(|child| child.section() == DisplayListSection::Content)
|
||||||
|
{
|
||||||
list.push(child_items.pop().unwrap());
|
list.push(child_items.pop().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -868,7 +868,7 @@ impl Fragment {
|
||||||
node_address == self.node ||
|
node_address == self.node ||
|
||||||
self.inline_context
|
self.inline_context
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |ctx| ctx.contains_node(node_address))
|
.is_some_and(|ctx| ctx.contains_node(node_address))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a style to the inline context for this fragment. If the inline context doesn't exist
|
/// Adds a style to the inline context for this fragment. If the inline context doesn't exist
|
||||||
|
@ -2750,9 +2750,7 @@ impl Fragment {
|
||||||
/// Returns true if this fragment has a transform applied that causes it to take up no space.
|
/// Returns true if this fragment has a transform applied that causes it to take up no space.
|
||||||
pub fn has_non_invertible_transform_or_zero_scale(&self) -> bool {
|
pub fn has_non_invertible_transform_or_zero_scale(&self) -> bool {
|
||||||
self.transform_matrix(&Rect::default())
|
self.transform_matrix(&Rect::default())
|
||||||
.map_or(false, |matrix| {
|
.is_some_and(|matrix| !matrix.is_invertible() || matrix.m11 == 0. || matrix.m22 == 0.)
|
||||||
!matrix.is_invertible() || matrix.m11 == 0. || matrix.m22 == 0.
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if this fragment establishes a new stacking context and false otherwise.
|
/// Returns true if this fragment establishes a new stacking context and false otherwise.
|
||||||
|
|
|
@ -228,7 +228,7 @@ impl<'a> TextRun {
|
||||||
// Split off any trailing whitespace into a separate glyph run.
|
// Split off any trailing whitespace into a separate glyph run.
|
||||||
let mut whitespace = slice.end..slice.end;
|
let mut whitespace = slice.end..slice.end;
|
||||||
let mut rev_char_indices = word.char_indices().rev().peekable();
|
let mut rev_char_indices = word.char_indices().rev().peekable();
|
||||||
let ends_with_newline = rev_char_indices.peek().map_or(false, |&(_, c)| c == '\n');
|
let ends_with_newline = rev_char_indices.peek().is_some_and(|&(_, c)| c == '\n');
|
||||||
if let Some((i, _)) = rev_char_indices
|
if let Some((i, _)) = rev_char_indices
|
||||||
.take_while(|&(_, c)| char_is_whitespace(c))
|
.take_while(|&(_, c)| char_is_whitespace(c))
|
||||||
.last()
|
.last()
|
||||||
|
|
|
@ -219,7 +219,7 @@ fn construct_flows_at<'dom>(context: &LayoutContext, node: impl LayoutNode<'dom>
|
||||||
if nonincremental_layout ||
|
if nonincremental_layout ||
|
||||||
tnode.restyle_damage() != RestyleDamage::empty() ||
|
tnode.restyle_damage() != RestyleDamage::empty() ||
|
||||||
node.as_element()
|
node.as_element()
|
||||||
.map_or(false, |el| el.has_dirty_descendants())
|
.is_some_and(|el| el.has_dirty_descendants())
|
||||||
{
|
{
|
||||||
let mut flow_constructor = FlowConstructor::new(context);
|
let mut flow_constructor = FlowConstructor::new(context);
|
||||||
if nonincremental_layout || !flow_constructor.repair_if_possible(&tnode) {
|
if nonincremental_layout || !flow_constructor.repair_if_possible(&tnode) {
|
||||||
|
|
|
@ -678,7 +678,7 @@ impl StackingContext {
|
||||||
|
|
||||||
// Steps 1 and 2: Borders and background for the root
|
// Steps 1 and 2: Borders and background for the root
|
||||||
let mut contents = self.contents.iter().enumerate().peekable();
|
let mut contents = self.contents.iter().enumerate().peekable();
|
||||||
while contents.peek().map_or(false, |(_, child)| {
|
while contents.peek().is_some_and(|(_, child)| {
|
||||||
child.section() == StackingContextSection::OwnBackgroundsAndBorders
|
child.section() == StackingContextSection::OwnBackgroundsAndBorders
|
||||||
}) {
|
}) {
|
||||||
let (i, child) = contents.next().unwrap();
|
let (i, child) = contents.next().unwrap();
|
||||||
|
@ -694,7 +694,7 @@ impl StackingContext {
|
||||||
.peekable();
|
.peekable();
|
||||||
while real_stacking_contexts_and_positioned_stacking_containers
|
while real_stacking_contexts_and_positioned_stacking_containers
|
||||||
.peek()
|
.peek()
|
||||||
.map_or(false, |(_, child)| child.z_index() < 0)
|
.is_some_and(|(_, child)| child.z_index() < 0)
|
||||||
{
|
{
|
||||||
let (i, child) = real_stacking_contexts_and_positioned_stacking_containers
|
let (i, child) = real_stacking_contexts_and_positioned_stacking_containers
|
||||||
.next()
|
.next()
|
||||||
|
@ -707,7 +707,7 @@ impl StackingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 4: Block backgrounds and borders
|
// Step 4: Block backgrounds and borders
|
||||||
while contents.peek().map_or(false, |(_, child)| {
|
while contents.peek().is_some_and(|(_, child)| {
|
||||||
child.section() == StackingContextSection::DescendantBackgroundsAndBorders
|
child.section() == StackingContextSection::DescendantBackgroundsAndBorders
|
||||||
}) {
|
}) {
|
||||||
let (i, child) = contents.next().unwrap();
|
let (i, child) = contents.next().unwrap();
|
||||||
|
@ -722,9 +722,10 @@ impl StackingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Steps 6 and 7: Fragments and inline stacking containers
|
// Steps 6 and 7: Fragments and inline stacking containers
|
||||||
while contents.peek().map_or(false, |(_, child)| {
|
while contents
|
||||||
child.section() == StackingContextSection::Foreground
|
.peek()
|
||||||
}) {
|
.is_some_and(|(_, child)| child.section() == StackingContextSection::Foreground)
|
||||||
|
{
|
||||||
let (i, child) = contents.next().unwrap();
|
let (i, child) = contents.next().unwrap();
|
||||||
self.debug_push_print_item(DebugPrintField::Contents, i);
|
self.debug_push_print_item(DebugPrintField::Contents, i);
|
||||||
child.build_display_list(builder, &self.atomic_inline_stacking_containers);
|
child.build_display_list(builder, &self.atomic_inline_stacking_containers);
|
||||||
|
@ -741,9 +742,10 @@ impl StackingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 10: Outline
|
// Step 10: Outline
|
||||||
while contents.peek().map_or(false, |(_, child)| {
|
while contents
|
||||||
child.section() == StackingContextSection::Outline
|
.peek()
|
||||||
}) {
|
.is_some_and(|(_, child)| child.section() == StackingContextSection::Outline)
|
||||||
|
{
|
||||||
let (i, child) = contents.next().unwrap();
|
let (i, child) = contents.next().unwrap();
|
||||||
self.debug_push_print_item(DebugPrintField::Contents, i);
|
self.debug_push_print_item(DebugPrintField::Contents, i);
|
||||||
child.build_display_list(builder, &self.atomic_inline_stacking_containers);
|
child.build_display_list(builder, &self.atomic_inline_stacking_containers);
|
||||||
|
|
|
@ -56,7 +56,7 @@ impl<'dom, Node: NodeExt<'dom>> NodeAndStyleInfo<Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn is_single_line_text_input(&self) -> bool {
|
pub(crate) fn is_single_line_text_input(&self) -> bool {
|
||||||
self.node.map_or(false, |node| {
|
self.node.is_some_and(|node| {
|
||||||
node.type_id() == LayoutNodeType::Element(LayoutElementType::HTMLInputElement)
|
node.type_id() == LayoutNodeType::Element(LayoutElementType::HTMLInputElement)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,7 +230,7 @@ impl TextRunSegment {
|
||||||
let mut ends_with_whitespace = false;
|
let mut ends_with_whitespace = false;
|
||||||
let ends_with_newline = rev_char_indices
|
let ends_with_newline = rev_char_indices
|
||||||
.peek()
|
.peek()
|
||||||
.map_or(false, |&(_, character)| character == '\n');
|
.is_some_and(|&(_, character)| character == '\n');
|
||||||
if let Some((first_white_space_index, first_white_space_character)) = rev_char_indices
|
if let Some((first_white_space_index, first_white_space_character)) = rev_char_indices
|
||||||
.take_while(|&(_, character)| char_is_whitespace(character))
|
.take_while(|&(_, character)| char_is_whitespace(character))
|
||||||
.last()
|
.last()
|
||||||
|
|
|
@ -70,9 +70,11 @@ impl BoxTree {
|
||||||
let mut root_overflow = root_style.effective_overflow().y;
|
let mut root_overflow = root_style.effective_overflow().y;
|
||||||
if root_overflow == Overflow::Visible && !root_style.get_box().display.is_none() {
|
if root_overflow == Overflow::Visible && !root_style.get_box().display.is_none() {
|
||||||
for child in iter_child_nodes(root_element) {
|
for child in iter_child_nodes(root_element) {
|
||||||
if !child.to_threadsafe().as_element().map_or(false, |element| {
|
if !child
|
||||||
element.is_body_element_of_html_element_root()
|
.to_threadsafe()
|
||||||
}) {
|
.as_element()
|
||||||
|
.is_some_and(|element| element.is_body_element_of_html_element_root())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -245,9 +245,9 @@ fn resolved_size_should_be_used_value(fragment: &Fragment) -> bool {
|
||||||
match fragment {
|
match fragment {
|
||||||
Fragment::Box(box_fragment) => {
|
Fragment::Box(box_fragment) => {
|
||||||
!box_fragment.style.get_box().display.is_inline_flow() ||
|
!box_fragment.style.get_box().display.is_inline_flow() ||
|
||||||
fragment.base().map_or(false, |base| {
|
fragment
|
||||||
base.flags.contains(FragmentFlags::IS_REPLACED)
|
.base()
|
||||||
})
|
.is_some_and(|base| base.flags.contains(FragmentFlags::IS_REPLACED))
|
||||||
},
|
},
|
||||||
Fragment::Float(_) |
|
Fragment::Float(_) |
|
||||||
Fragment::Positioning(_) |
|
Fragment::Positioning(_) |
|
||||||
|
|
|
@ -1209,9 +1209,9 @@ impl<'a> TableLayout<'a> {
|
||||||
// configuration for whatever PositioningContext the contents are ultimately added to.
|
// configuration for whatever PositioningContext the contents are ultimately added to.
|
||||||
let collect_for_nearest_positioned_ancestor = parent_positioning_context
|
let collect_for_nearest_positioned_ancestor = parent_positioning_context
|
||||||
.collects_for_nearest_positioned_ancestor() ||
|
.collects_for_nearest_positioned_ancestor() ||
|
||||||
self.table.rows.get(row_index).map_or(false, |row| {
|
self.table.rows.get(row_index).is_some_and(|row| {
|
||||||
let row_group_collects_for_nearest_positioned_ancestor =
|
let row_group_collects_for_nearest_positioned_ancestor =
|
||||||
row.group_index.map_or(false, |group_index| {
|
row.group_index.is_some_and(|group_index| {
|
||||||
self.table.row_groups[group_index]
|
self.table.row_groups[group_index]
|
||||||
.style
|
.style
|
||||||
.establishes_containing_block_for_absolute_descendants(
|
.establishes_containing_block_for_absolute_descendants(
|
||||||
|
|
|
@ -93,7 +93,7 @@ impl HstsList {
|
||||||
|
|
||||||
pub fn is_host_secure(&self, host: &str) -> bool {
|
pub fn is_host_secure(&self, host: &str) -> bool {
|
||||||
let base_domain = reg_suffix(host);
|
let base_domain = reg_suffix(host);
|
||||||
self.entries_map.get(base_domain).map_or(false, |entries| {
|
self.entries_map.get(base_domain).is_some_and(|entries| {
|
||||||
entries.iter().any(|e| {
|
entries.iter().any(|e| {
|
||||||
if e.include_subdomains {
|
if e.include_subdomains {
|
||||||
e.matches_subdomain(host) || e.matches_domain(host)
|
e.matches_subdomain(host) || e.matches_domain(host)
|
||||||
|
@ -105,15 +105,15 @@ impl HstsList {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_domain(&self, host: &str, base_domain: &str) -> bool {
|
fn has_domain(&self, host: &str, base_domain: &str) -> bool {
|
||||||
self.entries_map.get(base_domain).map_or(false, |entries| {
|
self.entries_map
|
||||||
entries.iter().any(|e| e.matches_domain(host))
|
.get(base_domain)
|
||||||
})
|
.is_some_and(|entries| entries.iter().any(|e| e.matches_domain(host)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_subdomain(&self, host: &str, base_domain: &str) -> bool {
|
fn has_subdomain(&self, host: &str, base_domain: &str) -> bool {
|
||||||
self.entries_map.get(base_domain).map_or(false, |entries| {
|
self.entries_map
|
||||||
entries.iter().any(|e| e.matches_subdomain(host))
|
.get(base_domain)
|
||||||
})
|
.is_some_and(|entries| entries.iter().any(|e| e.matches_subdomain(host)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push(&mut self, entry: HstsEntry) {
|
pub fn push(&mut self, entry: HstsEntry) {
|
||||||
|
@ -153,16 +153,16 @@ impl HstsList {
|
||||||
}) ||
|
}) ||
|
||||||
(!pref!(network.enforce_tls.onion) &&
|
(!pref!(network.enforce_tls.onion) &&
|
||||||
url.domain()
|
url.domain()
|
||||||
.map_or(false, |domain| domain.ends_with(".onion")))
|
.is_some_and(|domain| domain.ends_with(".onion")))
|
||||||
{
|
{
|
||||||
url.domain()
|
url.domain()
|
||||||
.map_or(false, |domain| self.is_host_secure(domain))
|
.is_some_and(|domain| self.is_host_secure(domain))
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
url.domain()
|
url.domain()
|
||||||
.map_or(false, |domain| self.is_host_secure(domain))
|
.is_some_and(|domain| self.is_host_secure(domain))
|
||||||
};
|
};
|
||||||
|
|
||||||
if upgrade_scheme {
|
if upgrade_scheme {
|
||||||
|
|
|
@ -802,7 +802,7 @@ pub async fn http_fetch(
|
||||||
.actual_response()
|
.actual_response()
|
||||||
.status
|
.status
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, is_redirect_status)
|
.is_some_and(is_redirect_status)
|
||||||
{
|
{
|
||||||
// Substep 1.
|
// Substep 1.
|
||||||
if response
|
if response
|
||||||
|
@ -992,7 +992,7 @@ pub async fn http_redirect_fetch(
|
||||||
.status
|
.status
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |s| s.0 != StatusCode::SEE_OTHER) &&
|
.map_or(true, |s| s.0 != StatusCode::SEE_OTHER) &&
|
||||||
request.body.as_ref().map_or(false, |b| b.source_is_null())
|
request.body.as_ref().is_some_and(|b| b.source_is_null())
|
||||||
{
|
{
|
||||||
return Response::network_error(NetworkError::Internal("Request body is not done".into()));
|
return Response::network_error(NetworkError::Internal("Request body is not done".into()));
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1007,7 @@ pub async fn http_redirect_fetch(
|
||||||
.actual_response()
|
.actual_response()
|
||||||
.status
|
.status
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |(code, _)| {
|
.is_some_and(|(code, _)| {
|
||||||
((*code == StatusCode::MOVED_PERMANENTLY || *code == StatusCode::FOUND) &&
|
((*code == StatusCode::MOVED_PERMANENTLY || *code == StatusCode::FOUND) &&
|
||||||
request.method == Method::POST) ||
|
request.method == Method::POST) ||
|
||||||
(*code == StatusCode::SEE_OTHER &&
|
(*code == StatusCode::SEE_OTHER &&
|
||||||
|
@ -1450,7 +1450,7 @@ async fn http_network_or_cache_fetch(
|
||||||
forward_response
|
forward_response
|
||||||
.status
|
.status
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |s| s.0 == StatusCode::NOT_MODIFIED)
|
.is_some_and(|s| s.0 == StatusCode::NOT_MODIFIED)
|
||||||
{
|
{
|
||||||
if let Ok(mut http_cache) = context.state.http_cache.write() {
|
if let Ok(mut http_cache) = context.state.http_cache.write() {
|
||||||
// Ensure done_chan is None,
|
// Ensure done_chan is None,
|
||||||
|
@ -1989,7 +1989,7 @@ async fn cors_preflight_fetch(
|
||||||
response
|
response
|
||||||
.status
|
.status
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |(status, _)| status.is_success())
|
.is_some_and(|(status, _)| status.is_success())
|
||||||
{
|
{
|
||||||
// Substep 1
|
// Substep 1
|
||||||
let mut methods = if response
|
let mut methods = if response
|
||||||
|
|
|
@ -258,7 +258,7 @@ impl StorageManager {
|
||||||
sender
|
sender
|
||||||
.send(
|
.send(
|
||||||
data.get_mut(&origin)
|
data.get_mut(&origin)
|
||||||
.map_or(false, |&mut (ref mut total, ref mut entry)| {
|
.is_some_and(|&mut (ref mut total, ref mut entry)| {
|
||||||
if !entry.is_empty() {
|
if !entry.is_empty() {
|
||||||
entry.clear();
|
entry.clear();
|
||||||
*total = 0;
|
*total = 0;
|
||||||
|
|
|
@ -1005,7 +1005,7 @@ impl CanvasState {
|
||||||
if !x.is_finite() || !y.is_finite() {
|
if !x.is_finite() || !y.is_finite() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if max_width.map_or(false, |max_width| !max_width.is_finite() || max_width <= 0.) {
|
if max_width.is_some_and(|max_width| !max_width.is_finite() || max_width <= 0.) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if self.state.borrow().font_style.is_none() {
|
if self.state.borrow().font_style.is_none() {
|
||||||
|
|
|
@ -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
|
// 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
|
// use `ensure_cross_origin_property_holder`. We'll need `_proxy` to
|
||||||
// do that.
|
// 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| {
|
cross_origin_properties.keys().any(|defined_key| {
|
||||||
let defined_key = CStr::from_ptr(defined_key);
|
let defined_key = CStr::from_ptr(defined_key);
|
||||||
defined_key.to_bytes() == key.as_bytes()
|
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 {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1266,7 +1266,7 @@ pub fn is_valid_custom_element_name(name: &str) -> bool {
|
||||||
// PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)*
|
// PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)*
|
||||||
|
|
||||||
let mut chars = name.chars();
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3595,7 +3595,7 @@ impl Document {
|
||||||
if element.namespace() != &ns!(html) {
|
if element.namespace() != &ns!(html) {
|
||||||
return false;
|
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 {
|
fn count_node_list<F: Fn(&Node) -> bool>(&self, callback: F) -> u32 {
|
||||||
|
@ -3935,9 +3935,9 @@ impl Document {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
// Step 3
|
// Step 3
|
||||||
window.GetFrameElement().map_or(false, |el| {
|
window
|
||||||
el.has_attribute(&local_name!("allowfullscreen"))
|
.GetFrameElement()
|
||||||
})
|
.is_some_and(|el| el.has_attribute(&local_name!("allowfullscreen")))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -5064,7 +5064,7 @@ impl DocumentMethods for Document {
|
||||||
HTMLElementTypeId::HTMLFormElement | HTMLElementTypeId::HTMLIFrameElement => {
|
HTMLElementTypeId::HTMLFormElement | HTMLElementTypeId::HTMLIFrameElement => {
|
||||||
elem.get_name().as_ref() == Some(&self.name)
|
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 == *self.name ||
|
||||||
!name.is_empty() && elem.get_id().as_ref() == Some(&self.name)
|
!name.is_empty() && elem.get_id().as_ref() == Some(&self.name)
|
||||||
}),
|
}),
|
||||||
|
@ -5217,7 +5217,7 @@ impl DocumentMethods for Document {
|
||||||
// Step 5
|
// Step 5
|
||||||
if self
|
if self
|
||||||
.get_current_parser()
|
.get_current_parser()
|
||||||
.map_or(false, |parser| parser.is_active())
|
.is_some_and(|parser| parser.is_active())
|
||||||
{
|
{
|
||||||
return Ok(DomRoot::from_ref(self));
|
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
|
// TODO handle <embed> and <object>; these depend on whether the element is
|
||||||
// “exposed”, a concept that doesn’t fully make sense until embed/object
|
// “exposed”, a concept that doesn’t fully make sense until embed/object
|
||||||
// behaviour is actually implemented
|
// 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())
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ impl DOMTokenListMethods for DOMTokenList {
|
||||||
/// <https://dom.spec.whatwg.org/#dom-domtokenlist-contains>
|
/// <https://dom.spec.whatwg.org/#dom-domtokenlist-contains>
|
||||||
fn Contains(&self, token: DOMString) -> bool {
|
fn Contains(&self, token: DOMString) -> bool {
|
||||||
let token = Atom::from(token);
|
let token = Atom::from(token);
|
||||||
self.attribute().map_or(false, |attr| {
|
self.attribute().is_some_and(|attr| {
|
||||||
attr.value()
|
attr.value()
|
||||||
.as_tokens()
|
.as_tokens()
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -430,7 +430,7 @@ impl Element {
|
||||||
// https://drafts.csswg.org/cssom-view/#css-layout-box
|
// https://drafts.csswg.org/cssom-view/#css-layout-box
|
||||||
pub fn has_css_layout_box(&self) -> bool {
|
pub fn has_css_layout_box(&self) -> bool {
|
||||||
self.style()
|
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
|
// https://drafts.csswg.org/cssom-view/#potentially-scrollable
|
||||||
|
@ -477,7 +477,7 @@ impl Element {
|
||||||
fn has_scrolling_box(&self) -> bool {
|
fn has_scrolling_box(&self) -> bool {
|
||||||
// TODO: scrolling mechanism, such as scrollbar (We don't have scrollbar yet)
|
// TODO: scrolling mechanism, such as scrollbar (We don't have scrollbar yet)
|
||||||
// self.has_scrolling_mechanism()
|
// 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_x().is_scrollable() ||
|
||||||
style.get_box().clone_overflow_y().is_scrollable()
|
style.get_box().clone_overflow_y().is_scrollable()
|
||||||
})
|
})
|
||||||
|
@ -658,7 +658,7 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn has_class_for_layout(self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool {
|
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()
|
attr.to_tokens()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -1651,7 +1651,7 @@ impl Element {
|
||||||
|
|
||||||
pub fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
|
pub fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
|
||||||
self.get_attribute(&ns!(), &local_name!("class"))
|
self.get_attribute(&ns!(), &local_name!("class"))
|
||||||
.map_or(false, |attr| {
|
.is_some_and(|attr| {
|
||||||
attr.value()
|
attr.value()
|
||||||
.as_tokens()
|
.as_tokens()
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -3652,7 +3652,7 @@ impl SelectorsElement for DomRoot<Element> {
|
||||||
match *ns {
|
match *ns {
|
||||||
NamespaceConstraint::Specific(ns) => self
|
NamespaceConstraint::Specific(ns) => self
|
||||||
.get_attribute(ns, local_name)
|
.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| {
|
NamespaceConstraint::Any => self.attrs.borrow().iter().any(|attr| {
|
||||||
*attr.local_name() == **local_name && attr.value().eval_selector(operation)
|
*attr.local_name() == **local_name && attr.value().eval_selector(operation)
|
||||||
}),
|
}),
|
||||||
|
@ -3765,7 +3765,7 @@ impl SelectorsElement for DomRoot<Element> {
|
||||||
self.id_attribute
|
self.id_attribute
|
||||||
.borrow()
|
.borrow()
|
||||||
.as_ref()
|
.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 {
|
fn is_part(&self, _name: &AtomIdent) -> bool {
|
||||||
|
|
|
@ -2836,12 +2836,12 @@ impl GlobalScope {
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
let in_realm_proof = AlreadyInRealm::assert();
|
let in_realm_proof = AlreadyInRealm::assert();
|
||||||
let p = Promise::new_in_current_realm(InRealm::Already(&in_realm_proof));
|
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);
|
p.reject_error(Error::InvalidState);
|
||||||
return p;
|
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);
|
p.reject_error(Error::InvalidState);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
|
@ -620,7 +620,7 @@ pub fn get_element_noopener(subject: &Element, target_attribute_value: Option<DO
|
||||||
}
|
}
|
||||||
let target_is_blank = target_attribute_value
|
let target_is_blank = target_attribute_value
|
||||||
.as_ref()
|
.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")) {
|
let link_types = match subject.get_attribute(&ns!(), &local_name!("rel")) {
|
||||||
Some(rel) => rel.Value(),
|
Some(rel) => rel.Value(),
|
||||||
None => return target_is_blank,
|
None => return target_is_blank,
|
||||||
|
|
|
@ -383,8 +383,8 @@ impl HTMLCollectionMethods for HTMLCollection {
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
self.elements_iter().find(|elem| {
|
self.elements_iter().find(|elem| {
|
||||||
elem.get_id().map_or(false, |id| id == key) ||
|
elem.get_id().is_some_and(|id| id == key) ||
|
||||||
(elem.namespace() == &ns!(html) && elem.get_name().map_or(false, |id| id == key))
|
(elem.namespace() == &ns!(html) && elem.get_name().is_some_and(|id| id == key))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -673,7 +673,7 @@ impl HTMLElement {
|
||||||
.chars()
|
.chars()
|
||||||
.skip_while(|&ch| ch != '\u{2d}')
|
.skip_while(|&ch| ch != '\u{2d}')
|
||||||
.nth(1)
|
.nth(1)
|
||||||
.map_or(false, |ch| ch.is_ascii_lowercase())
|
.is_some_and(|ch| ch.is_ascii_lowercase())
|
||||||
{
|
{
|
||||||
return Err(Error::Syntax);
|
return Err(Error::Syntax);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl HTMLFieldSetElementMethods for HTMLFieldSetElement {
|
||||||
impl CollectionFilter for ElementsFilter {
|
impl CollectionFilter for ElementsFilter {
|
||||||
fn filter<'a>(&self, elem: &'a Element, _root: &'a Node) -> bool {
|
fn filter<'a>(&self, elem: &'a Element, _root: &'a Node) -> bool {
|
||||||
elem.downcast::<HTMLElement>()
|
elem.downcast::<HTMLElement>()
|
||||||
.map_or(false, HTMLElement::is_listed_element)
|
.is_some_and(HTMLElement::is_listed_element)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let filter = Box::new(ElementsFilter);
|
let filter = Box::new(ElementsFilter);
|
||||||
|
@ -210,7 +210,7 @@ impl VirtualMethods for HTMLFieldSetElement {
|
||||||
element.set_enabled_state(false);
|
element.set_enabled_state(false);
|
||||||
if element
|
if element
|
||||||
.downcast::<HTMLElement>()
|
.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(
|
ScriptThread::enqueue_callback_reaction(
|
||||||
element,
|
element,
|
||||||
|
@ -231,7 +231,7 @@ impl VirtualMethods for HTMLFieldSetElement {
|
||||||
if element.enabled_state() &&
|
if element.enabled_state() &&
|
||||||
element
|
element
|
||||||
.downcast::<HTMLElement>()
|
.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(
|
ScriptThread::enqueue_callback_reaction(
|
||||||
element,
|
element,
|
||||||
|
|
|
@ -70,8 +70,8 @@ impl HTMLFormControlsCollectionMethods for HTMLFormControlsCollection {
|
||||||
let name = Atom::from(name);
|
let name = Atom::from(name);
|
||||||
|
|
||||||
let mut filter_map = self.collection.elements_iter().filter_map(|elem| {
|
let mut filter_map = self.collection.elements_iter().filter_map(|elem| {
|
||||||
if elem.get_name().map_or(false, |n| n == name) ||
|
if elem.get_name().is_some_and(|n| n == name) ||
|
||||||
elem.get_id().map_or(false, |i| i == name)
|
elem.get_id().is_some_and(|i| i == name)
|
||||||
{
|
{
|
||||||
Some(elem)
|
Some(elem)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -144,9 +144,9 @@ impl HTMLFormElement {
|
||||||
RadioListMode::ControlsExceptImageInputs => {
|
RadioListMode::ControlsExceptImageInputs => {
|
||||||
if child
|
if child
|
||||||
.downcast::<HTMLElement>()
|
.downcast::<HTMLElement>()
|
||||||
.map_or(false, |c| c.is_listed_element()) &&
|
.is_some_and(|c| c.is_listed_element()) &&
|
||||||
(child.get_id().map_or(false, |i| i == *name) ||
|
(child.get_id().is_some_and(|i| i == *name) ||
|
||||||
child.get_name().map_or(false, |n| n == *name))
|
child.get_name().is_some_and(|n| n == *name))
|
||||||
{
|
{
|
||||||
if let Some(inp) = child.downcast::<HTMLInputElement>() {
|
if let Some(inp) = child.downcast::<HTMLInputElement>() {
|
||||||
// input, only return it if it's not image-button state
|
// input, only return it if it's not image-button state
|
||||||
|
@ -160,8 +160,8 @@ impl HTMLFormElement {
|
||||||
},
|
},
|
||||||
RadioListMode::Images => {
|
RadioListMode::Images => {
|
||||||
return child.is::<HTMLImageElement>() &&
|
return child.is::<HTMLImageElement>() &&
|
||||||
(child.get_id().map_or(false, |i| i == *name) ||
|
(child.get_id().is_some_and(|i| i == *name) ||
|
||||||
child.get_name().map_or(false, |n| n == *name));
|
child.get_name().is_some_and(|n| n == *name));
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -511,7 +511,7 @@ impl HTMLFormElementMethods for HTMLFormElement {
|
||||||
for child in controls.iter() {
|
for child in controls.iter() {
|
||||||
if child
|
if child
|
||||||
.downcast::<HTMLElement>()
|
.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() {
|
if let Some(id_atom) = child.get_id() {
|
||||||
let entry = SourcedName {
|
let entry = SourcedName {
|
||||||
|
@ -1147,13 +1147,11 @@ impl HTMLFormElement {
|
||||||
// An element can only have a dirname attribute if it is a textarea element
|
// 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
|
// 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 child_element = child.downcast::<Element>().unwrap();
|
||||||
let input_matches =
|
let input_matches = child_element
|
||||||
child_element
|
.downcast::<HTMLInputElement>()
|
||||||
.downcast::<HTMLInputElement>()
|
.is_some_and(|input| {
|
||||||
.map_or(false, |input| {
|
matches!(input.input_type(), InputType::Text | InputType::Search)
|
||||||
input.input_type() == InputType::Text ||
|
});
|
||||||
input.input_type() == InputType::Search
|
|
||||||
});
|
|
||||||
let textarea_matches = child_element.is::<HTMLTextAreaElement>();
|
let textarea_matches = child_element.is::<HTMLTextAreaElement>();
|
||||||
let dirname = child_element.get_string_attribute(&local_name!("dirname"));
|
let dirname = child_element.get_string_attribute(&local_name!("dirname"));
|
||||||
if (input_matches || textarea_matches) && !dirname.is_empty() {
|
if (input_matches || textarea_matches) && !dirname.is_empty() {
|
||||||
|
@ -1642,7 +1640,7 @@ pub trait FormControl: DomObject {
|
||||||
if self.to_element().has_attribute(attr) {
|
if self.to_element().has_attribute(attr) {
|
||||||
input(self)
|
input(self)
|
||||||
} else {
|
} else {
|
||||||
self.form_owner().map_or(false, |t| owner(&t))
|
self.form_owner().is_some_and(|t| owner(&t))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -975,7 +975,7 @@ impl HTMLImageElement {
|
||||||
let is_parent_picture = elem
|
let is_parent_picture = elem
|
||||||
.upcast::<Node>()
|
.upcast::<Node>()
|
||||||
.GetParentElement()
|
.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() {
|
if src_set.is_empty() && !is_parent_picture && !src.is_empty() {
|
||||||
selected_source = Some(src.clone());
|
selected_source = Some(src.clone());
|
||||||
pixel_density = Some(1_f64);
|
pixel_density = Some(1_f64);
|
||||||
|
@ -1295,7 +1295,7 @@ impl HTMLImageElement {
|
||||||
let is_parent_picture = elem
|
let is_parent_picture = elem
|
||||||
.upcast::<Node>()
|
.upcast::<Node>()
|
||||||
.GetParentElement()
|
.GetParentElement()
|
||||||
.map_or(false, |p| p.is::<HTMLPictureElement>());
|
.is_some_and(|p| p.is::<HTMLPictureElement>());
|
||||||
has_src || is_parent_picture
|
has_src || is_parent_picture
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1405,7 +1405,7 @@ impl HTMLImageElement {
|
||||||
.find(|n| {
|
.find(|n| {
|
||||||
n.upcast::<Element>()
|
n.upcast::<Element>()
|
||||||
.get_name()
|
.get_name()
|
||||||
.map_or(false, |n| *n == *last)
|
.is_some_and(|n| *n == *last)
|
||||||
});
|
});
|
||||||
|
|
||||||
useMapElements.map(|mapElem| mapElem.get_area_elements())
|
useMapElements.map(|mapElem| mapElem.get_area_elements())
|
||||||
|
@ -1420,9 +1420,7 @@ impl HTMLImageElement {
|
||||||
.borrow()
|
.borrow()
|
||||||
.final_url
|
.final_url
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |url| {
|
.is_some_and(|url| url.scheme() == "data" || url.origin().same_origin(origin))
|
||||||
url.scheme() == "data" || url.origin().same_origin(origin)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -756,7 +756,7 @@ impl HTMLInputElement {
|
||||||
.traverse_preorder(ShadowIncluding::No)
|
.traverse_preorder(ShadowIncluding::No)
|
||||||
.find(|node| {
|
.find(|node| {
|
||||||
node.downcast::<Element>()
|
node.downcast::<Element>()
|
||||||
.map_or(false, |e| e.Id() == list_string)
|
.is_some_and(|e| e.Id() == list_string)
|
||||||
});
|
});
|
||||||
first_with_id
|
first_with_id
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
|
@ -2187,7 +2187,7 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
|
||||||
if self
|
if self
|
||||||
.error
|
.error
|
||||||
.get()
|
.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);
|
promise.reject_error(Error::NotSupported);
|
||||||
return promise;
|
return promise;
|
||||||
|
|
|
@ -825,7 +825,7 @@ impl HTMLScriptElement {
|
||||||
ScriptType::Classic => {
|
ScriptType::Classic => {
|
||||||
if was_parser_inserted &&
|
if was_parser_inserted &&
|
||||||
doc.get_current_parser()
|
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
|
doc.get_script_blocking_stylesheets_count() > 0
|
||||||
{
|
{
|
||||||
// Step 27.h: classic, has no src, was parser-inserted, is blocked on stylesheet.
|
// Step 27.h: classic, has no src, was parser-inserted, is blocked on stylesheet.
|
||||||
|
|
|
@ -283,7 +283,7 @@ impl HTMLStyleElementMethods for HTMLStyleElement {
|
||||||
/// <https://html.spec.whatwg.org/multipage/#dom-style-disabled>
|
/// <https://html.spec.whatwg.org/multipage/#dom-style-disabled>
|
||||||
fn Disabled(&self) -> bool {
|
fn Disabled(&self) -> bool {
|
||||||
self.get_cssom_stylesheet()
|
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>
|
/// <https://html.spec.whatwg.org/multipage/#dom-style-disabled>
|
||||||
|
|
|
@ -98,7 +98,7 @@ impl ImageData {
|
||||||
}
|
}
|
||||||
|
|
||||||
let height = len / width;
|
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);
|
return Err(Error::IndexSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -783,7 +783,7 @@ impl Node {
|
||||||
child
|
child
|
||||||
.parent_node
|
.parent_node
|
||||||
.get()
|
.get()
|
||||||
.map_or(false, |parent| &*parent == self)
|
.is_some_and(|parent| &*parent == self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_trusted_node_address(&self) -> TrustedNodeAddress {
|
pub fn to_trusted_node_address(&self) -> TrustedNodeAddress {
|
||||||
|
@ -825,10 +825,10 @@ impl Node {
|
||||||
let viewport = Size2D::new(window.InnerWidth(), window.InnerHeight());
|
let viewport = Size2D::new(window.InnerWidth(), window.InnerHeight());
|
||||||
|
|
||||||
let in_quirks_mode = document.quirks_mode() == QuirksMode::Quirks;
|
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
|
let is_body_element = self
|
||||||
.downcast::<HTMLBodyElement>()
|
.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
|
// "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)."
|
// return max(viewport scrolling area width/height, viewport width/height)."
|
||||||
|
@ -2180,7 +2180,7 @@ impl Node {
|
||||||
parent.owner_doc().add_script_and_layout_blocker();
|
parent.owner_doc().add_script_and_layout_blocker();
|
||||||
assert!(node
|
assert!(node
|
||||||
.GetParentNode()
|
.GetParentNode()
|
||||||
.map_or(false, |node_parent| &*node_parent == parent));
|
.is_some_and(|node_parent| &*node_parent == parent));
|
||||||
let cached_index = {
|
let cached_index = {
|
||||||
if parent.ranges.is_empty() {
|
if parent.ranges.is_empty() {
|
||||||
None
|
None
|
||||||
|
@ -2809,7 +2809,7 @@ impl NodeMethods for Node {
|
||||||
}
|
}
|
||||||
while children
|
while children
|
||||||
.peek()
|
.peek()
|
||||||
.map_or(false, |(_, sibling)| sibling.is::<Text>())
|
.is_some_and(|(_, sibling)| sibling.is::<Text>())
|
||||||
{
|
{
|
||||||
let (index, sibling) = children.next().unwrap();
|
let (index, sibling) = children.next().unwrap();
|
||||||
sibling
|
sibling
|
||||||
|
|
|
@ -97,8 +97,7 @@ impl PerformanceEntryList {
|
||||||
entry_type: DOMString,
|
entry_type: DOMString,
|
||||||
) {
|
) {
|
||||||
self.entries.retain(|e| {
|
self.entries.retain(|e| {
|
||||||
*e.entry_type() != *entry_type ||
|
*e.entry_type() != *entry_type || name.as_ref().is_some_and(|name_| *e.name() != *name_)
|
||||||
name.as_ref().map_or(false, |name_| *e.name() != *name_)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -653,12 +653,12 @@ impl BodyMixin for Request {
|
||||||
let body_stream = self.body_stream.get();
|
let body_stream = self.body_stream.get();
|
||||||
body_stream
|
body_stream
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |stream| stream.is_disturbed())
|
.is_some_and(|stream| stream.is_disturbed())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_locked(&self) -> bool {
|
fn is_locked(&self) -> bool {
|
||||||
let body_stream = self.body_stream.get();
|
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>> {
|
fn body(&self) -> Option<DomRoot<ReadableStream>> {
|
||||||
|
|
|
@ -235,13 +235,13 @@ impl BodyMixin for Response {
|
||||||
fn is_disturbed(&self) -> bool {
|
fn is_disturbed(&self) -> bool {
|
||||||
self.body_stream
|
self.body_stream
|
||||||
.get()
|
.get()
|
||||||
.map_or(false, |stream| stream.is_disturbed())
|
.is_some_and(|stream| stream.is_disturbed())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_locked(&self) -> bool {
|
fn is_locked(&self) -> bool {
|
||||||
self.body_stream
|
self.body_stream
|
||||||
.get()
|
.get()
|
||||||
.map_or(false, |stream| stream.is_locked())
|
.is_some_and(|stream| stream.is_locked())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn body(&self) -> Option<DomRoot<ReadableStream>> {
|
fn body(&self) -> Option<DomRoot<ReadableStream>> {
|
||||||
|
|
|
@ -159,7 +159,7 @@ struct SerializationIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rev_children_iter(n: &Node) -> impl Iterator<Item = DomRoot<Node>> {
|
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();
|
return Node::new_document_node().rev_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1294,7 +1294,7 @@ impl TreeSink for Sink {
|
||||||
fn is_mathml_annotation_xml_integration_point(&self, handle: &Dom<Node>) -> bool {
|
fn is_mathml_annotation_xml_integration_point(&self, handle: &Dom<Node>) -> bool {
|
||||||
let elem = handle.downcast::<Element>().unwrap();
|
let elem = handle.downcast::<Element>().unwrap();
|
||||||
elem.get_attribute(&ns!(), &local_name!("encoding"))
|
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("text/html") ||
|
||||||
attr.value().eq_ignore_ascii_case("application/xhtml+xml")
|
attr.value().eq_ignore_ascii_case("application/xhtml+xml")
|
||||||
})
|
})
|
||||||
|
|
|
@ -194,7 +194,7 @@ impl VertexArrayObject {
|
||||||
if self
|
if self
|
||||||
.element_array_buffer
|
.element_array_buffer
|
||||||
.get()
|
.get()
|
||||||
.map_or(false, |b| buffer == &*b)
|
.is_some_and(|b| buffer == &*b)
|
||||||
{
|
{
|
||||||
buffer.decrement_attached_counter(Operation::Infallible);
|
buffer.decrement_attached_counter(Operation::Infallible);
|
||||||
self.element_array_buffer.set(None);
|
self.element_array_buffer.set(None);
|
||||||
|
@ -239,7 +239,7 @@ impl VertexArrayObject {
|
||||||
}
|
}
|
||||||
} else if max_vertices
|
} else if max_vertices
|
||||||
.checked_mul(attrib.divisor)
|
.checked_mul(attrib.divisor)
|
||||||
.map_or(false, |v| v < instance_count)
|
.is_some_and(|v| v < instance_count)
|
||||||
{
|
{
|
||||||
return Err(WebGLError::InvalidOperation);
|
return Err(WebGLError::InvalidOperation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,7 +350,7 @@ impl WebGL2RenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unbind_from(&self, slot: &MutNullableDom<WebGLBuffer>, buffer: &WebGLBuffer) {
|
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);
|
buffer.decrement_attached_counter(Operation::Infallible);
|
||||||
slot.set(None);
|
slot.set(None);
|
||||||
}
|
}
|
||||||
|
@ -1452,10 +1452,10 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
||||||
}
|
}
|
||||||
let src_is_elemarray = read_buffer
|
let src_is_elemarray = read_buffer
|
||||||
.target()
|
.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
|
let dst_is_elemarray = write_buffer
|
||||||
.target()
|
.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 {
|
if src_is_elemarray != dst_is_elemarray {
|
||||||
return self.base.webgl_error(InvalidOperation);
|
return self.base.webgl_error(InvalidOperation);
|
||||||
}
|
}
|
||||||
|
@ -3424,7 +3424,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
||||||
if let Some(sampler) = sampler {
|
if let Some(sampler) = sampler {
|
||||||
handle_potential_webgl_error!(self.base, self.base.validate_ownership(sampler), return);
|
handle_potential_webgl_error!(self.base, self.base.validate_ownership(sampler), return);
|
||||||
for slot in self.samplers.iter() {
|
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);
|
slot.set(None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,7 @@ impl WebGLExtensions {
|
||||||
self.extensions
|
self.extensions
|
||||||
.borrow()
|
.borrow()
|
||||||
.get(&name)
|
.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 {
|
pub fn supports_gl_extension(&self, name: &str) -> bool {
|
||||||
|
|
|
@ -430,7 +430,7 @@ impl WebGLFramebuffer {
|
||||||
self.size.set(fb_size);
|
self.size.set(fb_size);
|
||||||
|
|
||||||
if has_c || has_z || has_zs || has_s {
|
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);
|
self.status.set(constants::FRAMEBUFFER_COMPLETE);
|
||||||
} else {
|
} else {
|
||||||
self.status
|
self.status
|
||||||
|
|
|
@ -1208,7 +1208,7 @@ impl WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_vertex_array(&self, vao: Option<&WebGLVertexArrayObjectOES>) -> bool {
|
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.
|
// The default vertex array has no id and should never be passed around.
|
||||||
assert!(vao.id().is_some());
|
assert!(vao.id().is_some());
|
||||||
self.validate_ownership(vao).is_ok() && vao.ever_bound() && !vao.is_deleted()
|
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 {
|
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.
|
// The default vertex array has no id and should never be passed around.
|
||||||
assert!(vao.id().is_some());
|
assert!(vao.id().is_some());
|
||||||
self.validate_ownership(vao).is_ok() && vao.ever_bound() && !vao.is_deleted()
|
self.validate_ownership(vao).is_ok() && vao.ever_bound() && !vao.is_deleted()
|
||||||
|
@ -2913,11 +2913,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.current_vao().unbind_buffer(buffer);
|
self.current_vao().unbind_buffer(buffer);
|
||||||
if self
|
if self.bound_buffer_array.get().is_some_and(|b| buffer == &*b) {
|
||||||
.bound_buffer_array
|
|
||||||
.get()
|
|
||||||
.map_or(false, |b| buffer == &*b)
|
|
||||||
{
|
|
||||||
self.bound_buffer_array.set(None);
|
self.bound_buffer_array.set(None);
|
||||||
buffer.decrement_attached_counter(Operation::Infallible);
|
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
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
||||||
fn IsBuffer(&self, buffer: Option<&WebGLBuffer>) -> bool {
|
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()
|
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
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
||||||
fn IsFramebuffer(&self, frame_buffer: Option<&WebGLFramebuffer>) -> bool {
|
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()
|
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
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn IsProgram(&self, program: Option<&WebGLProgram>) -> bool {
|
fn IsProgram(&self, program: Option<&WebGLProgram>) -> bool {
|
||||||
program.map_or(false, |p| {
|
program.is_some_and(|p| self.validate_ownership(p).is_ok() && !p.is_deleted())
|
||||||
self.validate_ownership(p).is_ok() && !p.is_deleted()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
||||||
fn IsRenderbuffer(&self, render_buffer: Option<&WebGLRenderbuffer>) -> bool {
|
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()
|
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
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||||
fn IsShader(&self, shader: Option<&WebGLShader>) -> bool {
|
fn IsShader(&self, shader: Option<&WebGLShader>) -> bool {
|
||||||
shader.map_or(false, |s| {
|
shader.is_some_and(|s| self.validate_ownership(s).is_ok() && !s.is_deleted())
|
||||||
self.validate_ownership(s).is_ok() && !s.is_deleted()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
||||||
fn IsTexture(&self, texture: Option<&WebGLTexture>) -> bool {
|
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()
|
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),
|
(&self.tex_3d, WebGL2RenderingContextConstants::TEXTURE_3D),
|
||||||
];
|
];
|
||||||
for &(slot, target) in &fields {
|
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);
|
slot.set(None);
|
||||||
return Some(target);
|
return Some(target);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2020,7 +2020,7 @@ impl Window {
|
||||||
// See http://testthewebforward.org/docs/reftests.html
|
// See http://testthewebforward.org/docs/reftests.html
|
||||||
// and https://web-platform-tests.org/writing-tests/crashtest.html
|
// and https://web-platform-tests.org/writing-tests/crashtest.html
|
||||||
let html_element = document.GetDocumentElement();
|
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!("reftest-wait"), CaseSensitivity::CaseSensitive) ||
|
||||||
elem.has_class(&Atom::from("test-wait"), CaseSensitivity::CaseSensitive)
|
elem.has_class(&Atom::from("test-wait"), CaseSensitivity::CaseSensitive)
|
||||||
});
|
});
|
||||||
|
@ -2516,7 +2516,7 @@ impl Window {
|
||||||
.get()
|
.get()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|nav| nav.xr())
|
.and_then(|nav| nav.xr())
|
||||||
.map_or(false, |xr| xr.pending_or_active_session())
|
.is_some_and(|xr| xr.pending_or_active_session())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -507,7 +507,7 @@ impl<'dom> ::selectors::Element for ServoLayoutElement<'dom> {
|
||||||
match *ns {
|
match *ns {
|
||||||
NamespaceConstraint::Specific(ns) => self
|
NamespaceConstraint::Specific(ns) => self
|
||||||
.get_attr_enum(ns, local_name)
|
.get_attr_enum(ns, local_name)
|
||||||
.map_or(false, |value| value.eval_selector(operation)),
|
.is_some_and(|value| value.eval_selector(operation)),
|
||||||
NamespaceConstraint::Any => self
|
NamespaceConstraint::Any => self
|
||||||
.element
|
.element
|
||||||
.get_attr_vals_for_layout(local_name)
|
.get_attr_vals_for_layout(local_name)
|
||||||
|
@ -637,7 +637,7 @@ impl<'dom> ::selectors::Element for ServoLayoutElement<'dom> {
|
||||||
unsafe {
|
unsafe {
|
||||||
(*self.element.id_attribute())
|
(*self.element.id_attribute())
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |atom| case_sensitivity.eq_atom(atom, id))
|
.is_some_and(|atom| case_sensitivity.eq_atom(atom, id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -851,7 +851,7 @@ impl<'dom> ::selectors::Element for ServoThreadSafeLayoutElement<'dom> {
|
||||||
match *ns {
|
match *ns {
|
||||||
NamespaceConstraint::Specific(ns) => self
|
NamespaceConstraint::Specific(ns) => self
|
||||||
.get_attr_enum(ns, local_name)
|
.get_attr_enum(ns, local_name)
|
||||||
.map_or(false, |value| value.eval_selector(operation)),
|
.is_some_and(|value| value.eval_selector(operation)),
|
||||||
NamespaceConstraint::Any => self
|
NamespaceConstraint::Any => self
|
||||||
.element
|
.element
|
||||||
.element
|
.element
|
||||||
|
|
|
@ -1097,7 +1097,7 @@ impl ScriptThread {
|
||||||
|
|
||||||
pub fn is_user_interacting() -> bool {
|
pub fn is_user_interacting() -> bool {
|
||||||
SCRIPT_THREAD_ROOT.with(|root| {
|
SCRIPT_THREAD_ROOT.with(|root| {
|
||||||
root.get().map_or(false, |script_thread| {
|
root.get().is_some_and(|script_thread| {
|
||||||
let script_thread = unsafe { &*script_thread };
|
let script_thread = unsafe { &*script_thread };
|
||||||
script_thread.is_user_interacting.get()
|
script_thread.is_user_interacting.get()
|
||||||
})
|
})
|
||||||
|
|
|
@ -128,7 +128,7 @@ impl FetchResponseListener for StylesheetContext {
|
||||||
Some(meta) => meta,
|
Some(meta) => meta,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
let is_css = metadata.content_type.map_or(false, |ct| {
|
let is_css = metadata.content_type.is_some_and(|ct| {
|
||||||
let mime: Mime = ct.into_inner().into();
|
let mime: Mime = ct.into_inner().into();
|
||||||
mime.type_() == mime::TEXT && mime.subtype() == mime::CSS
|
mime.type_() == mime::TEXT && mime.subtype() == mime::CSS
|
||||||
});
|
});
|
||||||
|
@ -202,7 +202,7 @@ impl FetchResponseListener for StylesheetContext {
|
||||||
|
|
||||||
// FIXME: Revisit once consensus is reached at:
|
// FIXME: Revisit once consensus is reached at:
|
||||||
// https://github.com/whatwg/html/issues/1142
|
// https://github.com/whatwg/html/issues/1142
|
||||||
successful = metadata.status.map_or(false, |(code, _)| code == 200);
|
successful = metadata.status.is_some_and(|(code, _)| code == 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
let owner = elem
|
let owner = elem
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl BluetoothBlocklist {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#blocklisted
|
// https://webbluetoothcg.github.io/web-bluetooth/#blocklisted
|
||||||
pub fn is_blocklisted(&self, uuid: &str) -> bool {
|
pub fn is_blocklisted(&self, uuid: &str) -> bool {
|
||||||
match self.0 {
|
match self.0 {
|
||||||
Some(ref map) => map.get(uuid).map_or(false, |et| et.eq(&Blocklist::All)),
|
Some(ref map) => map.get(uuid).is_some_and(|et| et.eq(&Blocklist::All)),
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,9 @@ impl BluetoothBlocklist {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#blocklisted-for-reads
|
// https://webbluetoothcg.github.io/web-bluetooth/#blocklisted-for-reads
|
||||||
pub fn is_blocklisted_for_reads(&self, uuid: &str) -> bool {
|
pub fn is_blocklisted_for_reads(&self, uuid: &str) -> bool {
|
||||||
match self.0 {
|
match self.0 {
|
||||||
Some(ref map) => map.get(uuid).map_or(false, |et| {
|
Some(ref map) => map
|
||||||
et.eq(&Blocklist::All) || et.eq(&Blocklist::Reads)
|
.get(uuid)
|
||||||
}),
|
.is_some_and(|et| et.eq(&Blocklist::All) || et.eq(&Blocklist::Reads)),
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,9 @@ impl BluetoothBlocklist {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#blocklisted-for-writes
|
// https://webbluetoothcg.github.io/web-bluetooth/#blocklisted-for-writes
|
||||||
pub fn is_blocklisted_for_writes(&self, uuid: &str) -> bool {
|
pub fn is_blocklisted_for_writes(&self, uuid: &str) -> bool {
|
||||||
match self.0 {
|
match self.0 {
|
||||||
Some(ref map) => map.get(uuid).map_or(false, |et| {
|
Some(ref map) => map
|
||||||
et.eq(&Blocklist::All) || et.eq(&Blocklist::Writes)
|
.get(uuid)
|
||||||
}),
|
.is_some_and(|et| et.eq(&Blocklist::All) || et.eq(&Blocklist::Writes)),
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue