From 27b25e869bc6d8d1b42da655895c27dc3c08f211 Mon Sep 17 00:00:00 2001 From: tanishka <109246904+taniishkaaa@users.noreply.github.com> Date: Fri, 11 Oct 2024 21:10:39 +0530 Subject: [PATCH] content: Replace uses of `downcast`+`is_some`/`is_none` with `is` (#33804) * content: Replace uses of downcast+is_some/is_none with is Signed-off-by: taniishkaaa * Remove ! to return correct logic Signed-off-by: taniishkaaa --------- Signed-off-by: taniishkaaa --- components/script/dom/dommatrix.rs | 2 +- components/script/dom/dommatrixreadonly.rs | 2 +- components/script/dom/globalscope.rs | 2 +- components/script/dom/htmlformelement.rs | 5 +---- components/script/fetch.rs | 2 +- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/components/script/dom/dommatrix.rs b/components/script/dom/dommatrix.rs index 66455e459de..2acdadf489f 100644 --- a/components/script/dom/dommatrix.rs +++ b/components/script/dom/dommatrix.rs @@ -76,7 +76,7 @@ impl DOMMatrixMethods for DOMMatrix { } match init.unwrap() { StringOrUnrestrictedDoubleSequence::String(ref s) => { - if global.downcast::().is_none() { + if !global.is::() { return Err(error::Error::Type( "String constructor is only supported in the main thread.".to_owned(), )); diff --git a/components/script/dom/dommatrixreadonly.rs b/components/script/dom/dommatrixreadonly.rs index 1362615022c..5fa5da52ce6 100644 --- a/components/script/dom/dommatrixreadonly.rs +++ b/components/script/dom/dommatrixreadonly.rs @@ -447,7 +447,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly { } match init.unwrap() { StringOrUnrestrictedDoubleSequence::String(ref s) => { - if global.downcast::().is_none() { + if !global.is::() { return Err(error::Error::Type( "String constructor is only supported in the main thread.".to_owned(), )); diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 9991ae6c103..e98e73e5da6 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -2909,7 +2909,7 @@ impl GlobalScope { /// Returns a boolean indicating whether the event-loop /// where this global is running on can continue running JS. pub fn can_continue_running(&self) -> bool { - if self.downcast::().is_some() { + if self.is::() { return ScriptThread::can_continue_running(); } if let Some(worker) = self.downcast::() { diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index c4ef948df56..9125a14deec 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -1102,10 +1102,7 @@ impl HTMLFormElement { let child = child.upcast::(); // Step 5.1: The field element has a datalist element ancestor. - if child - .ancestors() - .any(|a| DomRoot::downcast::(a).is_some()) - { + if child.ancestors().any(|a| a.is::()) { continue; } if let NodeTypeId::Element(ElementTypeId::HTMLElement(element)) = child.type_id() { diff --git a/components/script/fetch.rs b/components/script/fetch.rs index 2b545e3daaf..d39dafe5e80 100644 --- a/components/script/fetch.rs +++ b/components/script/fetch.rs @@ -181,7 +181,7 @@ pub fn Fetch( // Step 6. If globalObject is a ServiceWorkerGlobalScope object, then set request’s // service-workers mode to "none". - if global.downcast::().is_some() { + if global.is::() { request_init.service_workers_mode = ServiceWorkersMode::None; }