mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
clippy: Fix all errors in components/script
(#31911)
* clippy: Fix errors in components/script/dom * clippy: fixed remaining errors in components/script
This commit is contained in:
parent
eccb60e548
commit
f183170786
8 changed files with 57 additions and 57 deletions
|
@ -114,8 +114,8 @@ impl AudioBuffer {
|
||||||
proto: Option<HandleObject>,
|
proto: Option<HandleObject>,
|
||||||
options: &AudioBufferOptions,
|
options: &AudioBufferOptions,
|
||||||
) -> Fallible<DomRoot<AudioBuffer>> {
|
) -> Fallible<DomRoot<AudioBuffer>> {
|
||||||
if options.length <= 0 ||
|
if options.length == 0 ||
|
||||||
options.numberOfChannels <= 0 ||
|
options.numberOfChannels == 0 ||
|
||||||
options.numberOfChannels > MAX_CHANNEL_COUNT ||
|
options.numberOfChannels > MAX_CHANNEL_COUNT ||
|
||||||
*options.sampleRate < MIN_SAMPLE_RATE ||
|
*options.sampleRate < MIN_SAMPLE_RATE ||
|
||||||
*options.sampleRate > MAX_SAMPLE_RATE
|
*options.sampleRate > MAX_SAMPLE_RATE
|
||||||
|
|
|
@ -404,9 +404,9 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
||||||
length: u32,
|
length: u32,
|
||||||
sample_rate: Finite<f32>,
|
sample_rate: Finite<f32>,
|
||||||
) -> Fallible<DomRoot<AudioBuffer>> {
|
) -> Fallible<DomRoot<AudioBuffer>> {
|
||||||
if number_of_channels <= 0 ||
|
if number_of_channels == 0 ||
|
||||||
number_of_channels > MAX_CHANNEL_COUNT ||
|
number_of_channels > MAX_CHANNEL_COUNT ||
|
||||||
length <= 0 ||
|
length == 0 ||
|
||||||
*sample_rate <= 0.
|
*sample_rate <= 0.
|
||||||
{
|
{
|
||||||
return Err(Error::NotSupported);
|
return Err(Error::NotSupported);
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl<T> DomRefCell<T> {
|
||||||
|
|
||||||
/// Borrow the contents for the purpose of script deallocation.
|
/// 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 {
|
pub unsafe fn borrow_for_script_deallocation(&self) -> &mut T {
|
||||||
assert_in_script();
|
assert_in_script();
|
||||||
&mut *self.value.as_ptr()
|
&mut *self.value.as_ptr()
|
||||||
|
@ -49,7 +49,7 @@ impl<T> DomRefCell<T> {
|
||||||
|
|
||||||
/// Mutably borrow a cell for layout. Ideally this would use
|
/// Mutably borrow a cell for layout. Ideally this would use
|
||||||
/// `RefCell::try_borrow_mut_unguarded` but that doesn't exist yet.
|
/// `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 {
|
pub unsafe fn borrow_mut_for_layout(&self) -> &mut T {
|
||||||
assert_in_layout();
|
assert_in_layout();
|
||||||
&mut *self.value.as_ptr()
|
&mut *self.value.as_ptr()
|
||||||
|
|
|
@ -1049,9 +1049,9 @@ impl HTMLFormElement {
|
||||||
validatable
|
validatable
|
||||||
.validity_state()
|
.validity_state()
|
||||||
.perform_validation_and_update(ValidationFlags::all());
|
.perform_validation_and_update(ValidationFlags::all());
|
||||||
if !validatable.is_instance_validatable() {
|
if !validatable.is_instance_validatable() ||
|
||||||
None
|
validatable.validity_state().invalid_flags().is_empty()
|
||||||
} else if validatable.validity_state().invalid_flags().is_empty() {
|
{
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(DomRoot::from_ref(el))
|
Some(DomRoot::from_ref(el))
|
||||||
|
|
|
@ -79,8 +79,8 @@ impl OfflineAudioContext {
|
||||||
sample_rate: f32,
|
sample_rate: f32,
|
||||||
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
||||||
if channel_count > MAX_CHANNEL_COUNT ||
|
if channel_count > MAX_CHANNEL_COUNT ||
|
||||||
channel_count <= 0 ||
|
channel_count == 0 ||
|
||||||
length <= 0 ||
|
length == 0 ||
|
||||||
sample_rate < MIN_SAMPLE_RATE ||
|
sample_rate < MIN_SAMPLE_RATE ||
|
||||||
sample_rate > MAX_SAMPLE_RATE
|
sample_rate > MAX_SAMPLE_RATE
|
||||||
{
|
{
|
||||||
|
|
|
@ -519,6 +519,7 @@ impl WorkerGlobalScope {
|
||||||
/// Process a single event as if it were the next event
|
/// Process a single event as if it were the next event
|
||||||
/// in the queue for this worker event-loop.
|
/// in the queue for this worker event-loop.
|
||||||
/// Returns a boolean indicating whether further events should be processed.
|
/// Returns a boolean indicating whether further events should be processed.
|
||||||
|
#[allow(unsafe_code)]
|
||||||
pub fn process_event(&self, msg: CommonScriptMsg) -> bool {
|
pub fn process_event(&self, msg: CommonScriptMsg) -> bool {
|
||||||
if self.is_closing() {
|
if self.is_closing() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -528,7 +529,7 @@ impl WorkerGlobalScope {
|
||||||
CommonScriptMsg::CollectReports(reports_chan) => {
|
CommonScriptMsg::CollectReports(reports_chan) => {
|
||||||
let cx = self.get_cx();
|
let cx = self.get_cx();
|
||||||
let path_seg = format!("url({})", self.get_url());
|
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);
|
reports_chan.send(reports);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -691,60 +691,59 @@ unsafe extern "C" fn get_size(obj: *mut JSObject) -> usize {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[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![];
|
let mut reports = vec![];
|
||||||
|
|
||||||
unsafe {
|
let mut stats = ::std::mem::zeroed();
|
||||||
let mut stats = ::std::mem::zeroed();
|
if CollectServoSizes(cx, &mut stats, Some(get_size)) {
|
||||||
if CollectServoSizes(cx, &mut stats, Some(get_size)) {
|
let mut report = |mut path_suffix, kind, size| {
|
||||||
let mut report = |mut path_suffix, kind, size| {
|
let mut path = path![path_seg, "js"];
|
||||||
let mut path = path![path_seg, "js"];
|
path.append(&mut path_suffix);
|
||||||
path.append(&mut path_suffix);
|
reports.push(Report { path, kind, size })
|
||||||
reports.push(Report { path, kind, size })
|
};
|
||||||
};
|
|
||||||
|
|
||||||
// A note about possibly confusing terminology: the JS GC "heap" is allocated via
|
// 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
|
// mmap/VirtualAlloc, which means it's not on the malloc "heap", so we use
|
||||||
// `ExplicitNonHeapSize` as its kind.
|
// `ExplicitNonHeapSize` as its kind.
|
||||||
|
|
||||||
report(
|
report(
|
||||||
path!["gc-heap", "used"],
|
path!["gc-heap", "used"],
|
||||||
ReportKind::ExplicitNonHeapSize,
|
ReportKind::ExplicitNonHeapSize,
|
||||||
stats.gcHeapUsed,
|
stats.gcHeapUsed,
|
||||||
);
|
);
|
||||||
|
|
||||||
report(
|
report(
|
||||||
path!["gc-heap", "unused"],
|
path!["gc-heap", "unused"],
|
||||||
ReportKind::ExplicitNonHeapSize,
|
ReportKind::ExplicitNonHeapSize,
|
||||||
stats.gcHeapUnused,
|
stats.gcHeapUnused,
|
||||||
);
|
);
|
||||||
|
|
||||||
report(
|
report(
|
||||||
path!["gc-heap", "admin"],
|
path!["gc-heap", "admin"],
|
||||||
ReportKind::ExplicitNonHeapSize,
|
ReportKind::ExplicitNonHeapSize,
|
||||||
stats.gcHeapAdmin,
|
stats.gcHeapAdmin,
|
||||||
);
|
);
|
||||||
|
|
||||||
report(
|
report(
|
||||||
path!["gc-heap", "decommitted"],
|
path!["gc-heap", "decommitted"],
|
||||||
ReportKind::ExplicitNonHeapSize,
|
ReportKind::ExplicitNonHeapSize,
|
||||||
stats.gcHeapDecommitted,
|
stats.gcHeapDecommitted,
|
||||||
);
|
);
|
||||||
|
|
||||||
// SpiderMonkey uses the system heap, not jemalloc.
|
// SpiderMonkey uses the system heap, not jemalloc.
|
||||||
report(
|
report(
|
||||||
path!["malloc-heap"],
|
path!["malloc-heap"],
|
||||||
ReportKind::ExplicitSystemHeapSize,
|
ReportKind::ExplicitSystemHeapSize,
|
||||||
stats.mallocHeap,
|
stats.mallocHeap,
|
||||||
);
|
);
|
||||||
|
|
||||||
report(
|
report(
|
||||||
path!["non-heap"],
|
path!["non-heap"],
|
||||||
ReportKind::ExplicitNonHeapSize,
|
ReportKind::ExplicitNonHeapSize,
|
||||||
stats.nonHeap,
|
stats.nonHeap,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reports
|
reports
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2548,7 +2548,7 @@ impl ScriptThread {
|
||||||
let path_seg = format!("url({})", urls);
|
let path_seg = format!("url({})", urls);
|
||||||
|
|
||||||
let mut reports = vec![];
|
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);
|
reports_chan.send(reports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue