aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/audiobuffer.rs4
-rw-r--r--components/script/dom/baseaudiocontext.rs4
-rw-r--r--components/script/dom/bindings/cell.rs4
-rw-r--r--components/script/dom/htmlformelement.rs6
-rw-r--r--components/script/dom/offlineaudiocontext.rs4
-rw-r--r--components/script/dom/workerglobalscope.rs3
-rw-r--r--components/script/script_runtime.rs87
-rw-r--r--components/script/script_thread.rs2
8 files changed, 57 insertions, 57 deletions
diff --git a/components/script/dom/audiobuffer.rs b/components/script/dom/audiobuffer.rs
index 1b6fbfd0e48..2572041bdba 100644
--- a/components/script/dom/audiobuffer.rs
+++ b/components/script/dom/audiobuffer.rs
@@ -114,8 +114,8 @@ impl AudioBuffer {
proto: Option<HandleObject>,
options: &AudioBufferOptions,
) -> Fallible<DomRoot<AudioBuffer>> {
- if options.length <= 0 ||
- options.numberOfChannels <= 0 ||
+ if options.length == 0 ||
+ options.numberOfChannels == 0 ||
options.numberOfChannels > MAX_CHANNEL_COUNT ||
*options.sampleRate < MIN_SAMPLE_RATE ||
*options.sampleRate > MAX_SAMPLE_RATE
diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs
index d0cfc8ab203..462274bb685 100644
--- a/components/script/dom/baseaudiocontext.rs
+++ b/components/script/dom/baseaudiocontext.rs
@@ -404,9 +404,9 @@ impl BaseAudioContextMethods for BaseAudioContext {
length: u32,
sample_rate: Finite<f32>,
) -> Fallible<DomRoot<AudioBuffer>> {
- if number_of_channels <= 0 ||
+ if number_of_channels == 0 ||
number_of_channels > MAX_CHANNEL_COUNT ||
- length <= 0 ||
+ length == 0 ||
*sample_rate <= 0.
{
return Err(Error::NotSupported);
diff --git a/components/script/dom/bindings/cell.rs b/components/script/dom/bindings/cell.rs
index a9fb9b9b9d3..d56465594ca 100644
--- a/components/script/dom/bindings/cell.rs
+++ b/components/script/dom/bindings/cell.rs
@@ -41,7 +41,7 @@ impl<T> DomRefCell<T> {
/// Borrow the contents for the purpose of script deallocation.
///
- #[allow(unsafe_code)]
+ #[allow(unsafe_code, clippy::mut_from_ref)]
pub unsafe fn borrow_for_script_deallocation(&self) -> &mut T {
assert_in_script();
&mut *self.value.as_ptr()
@@ -49,7 +49,7 @@ impl<T> DomRefCell<T> {
/// Mutably borrow a cell for layout. Ideally this would use
/// `RefCell::try_borrow_mut_unguarded` but that doesn't exist yet.
- #[allow(unsafe_code)]
+ #[allow(unsafe_code, clippy::mut_from_ref)]
pub unsafe fn borrow_mut_for_layout(&self) -> &mut T {
assert_in_layout();
&mut *self.value.as_ptr()
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index 43f2f6df72b..307fbb78cd0 100644
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -1049,9 +1049,9 @@ impl HTMLFormElement {
validatable
.validity_state()
.perform_validation_and_update(ValidationFlags::all());
- if !validatable.is_instance_validatable() {
- None
- } else if validatable.validity_state().invalid_flags().is_empty() {
+ if !validatable.is_instance_validatable() ||
+ validatable.validity_state().invalid_flags().is_empty()
+ {
None
} else {
Some(DomRoot::from_ref(el))
diff --git a/components/script/dom/offlineaudiocontext.rs b/components/script/dom/offlineaudiocontext.rs
index 88186bde5ee..072f19d80da 100644
--- a/components/script/dom/offlineaudiocontext.rs
+++ b/components/script/dom/offlineaudiocontext.rs
@@ -79,8 +79,8 @@ impl OfflineAudioContext {
sample_rate: f32,
) -> Fallible<DomRoot<OfflineAudioContext>> {
if channel_count > MAX_CHANNEL_COUNT ||
- channel_count <= 0 ||
- length <= 0 ||
+ channel_count == 0 ||
+ length == 0 ||
sample_rate < MIN_SAMPLE_RATE ||
sample_rate > MAX_SAMPLE_RATE
{
diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs
index 76f5770bbc1..0ab01a38c59 100644
--- a/components/script/dom/workerglobalscope.rs
+++ b/components/script/dom/workerglobalscope.rs
@@ -519,6 +519,7 @@ impl WorkerGlobalScope {
/// Process a single event as if it were the next event
/// in the queue for this worker event-loop.
/// Returns a boolean indicating whether further events should be processed.
+ #[allow(unsafe_code)]
pub fn process_event(&self, msg: CommonScriptMsg) -> bool {
if self.is_closing() {
return false;
@@ -528,7 +529,7 @@ impl WorkerGlobalScope {
CommonScriptMsg::CollectReports(reports_chan) => {
let cx = self.get_cx();
let path_seg = format!("url({})", self.get_url());
- let reports = get_reports(*cx, path_seg);
+ let reports = unsafe { get_reports(*cx, path_seg) };
reports_chan.send(reports);
},
}
diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs
index 591b4adece6..fc62991149b 100644
--- a/components/script/script_runtime.rs
+++ b/components/script/script_runtime.rs
@@ -691,60 +691,59 @@ unsafe extern "C" fn get_size(obj: *mut JSObject) -> usize {
}
#[allow(unsafe_code)]
-pub fn get_reports(cx: *mut RawJSContext, path_seg: String) -> Vec<Report> {
+pub unsafe fn get_reports(cx: *mut RawJSContext, path_seg: String) -> Vec<Report> {
let mut reports = vec![];
- unsafe {
- let mut stats = ::std::mem::zeroed();
- if CollectServoSizes(cx, &mut stats, Some(get_size)) {
- let mut report = |mut path_suffix, kind, size| {
- let mut path = path![path_seg, "js"];
- path.append(&mut path_suffix);
- reports.push(Report { path, kind, size })
- };
+ let mut stats = ::std::mem::zeroed();
+ if CollectServoSizes(cx, &mut stats, Some(get_size)) {
+ let mut report = |mut path_suffix, kind, size| {
+ let mut path = path![path_seg, "js"];
+ path.append(&mut path_suffix);
+ reports.push(Report { path, kind, size })
+ };
- // A note about possibly confusing terminology: the JS GC "heap" is allocated via
- // mmap/VirtualAlloc, which means it's not on the malloc "heap", so we use
- // `ExplicitNonHeapSize` as its kind.
+ // A note about possibly confusing terminology: the JS GC "heap" is allocated via
+ // mmap/VirtualAlloc, which means it's not on the malloc "heap", so we use
+ // `ExplicitNonHeapSize` as its kind.
- report(
- path!["gc-heap", "used"],
- ReportKind::ExplicitNonHeapSize,
- stats.gcHeapUsed,
- );
+ report(
+ path!["gc-heap", "used"],
+ ReportKind::ExplicitNonHeapSize,
+ stats.gcHeapUsed,
+ );
- report(
- path!["gc-heap", "unused"],
- ReportKind::ExplicitNonHeapSize,
- stats.gcHeapUnused,
- );
+ report(
+ path!["gc-heap", "unused"],
+ ReportKind::ExplicitNonHeapSize,
+ stats.gcHeapUnused,
+ );
- report(
- path!["gc-heap", "admin"],
- ReportKind::ExplicitNonHeapSize,
- stats.gcHeapAdmin,
- );
+ report(
+ path!["gc-heap", "admin"],
+ ReportKind::ExplicitNonHeapSize,
+ stats.gcHeapAdmin,
+ );
- report(
- path!["gc-heap", "decommitted"],
- ReportKind::ExplicitNonHeapSize,
- stats.gcHeapDecommitted,
- );
+ report(
+ path!["gc-heap", "decommitted"],
+ ReportKind::ExplicitNonHeapSize,
+ stats.gcHeapDecommitted,
+ );
- // SpiderMonkey uses the system heap, not jemalloc.
- report(
- path!["malloc-heap"],
- ReportKind::ExplicitSystemHeapSize,
- stats.mallocHeap,
- );
+ // SpiderMonkey uses the system heap, not jemalloc.
+ report(
+ path!["malloc-heap"],
+ ReportKind::ExplicitSystemHeapSize,
+ stats.mallocHeap,
+ );
- report(
- path!["non-heap"],
- ReportKind::ExplicitNonHeapSize,
- stats.nonHeap,
- );
- }
+ report(
+ path!["non-heap"],
+ ReportKind::ExplicitNonHeapSize,
+ stats.nonHeap,
+ );
}
+
reports
}
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 960eb8a2e01..965e899c0f2 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -2548,7 +2548,7 @@ impl ScriptThread {
let path_seg = format!("url({})", urls);
let mut reports = vec![];
- reports.extend(get_reports(*self.get_cx(), path_seg));
+ reports.extend(unsafe { get_reports(*self.get_cx(), path_seg) });
reports_chan.send(reports);
}