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>,
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
}
|
||||
|
|
|
@ -691,10 +691,9 @@ 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| {
|
||||
|
@ -744,7 +743,7 @@ pub fn get_reports(cx: *mut RawJSContext, path_seg: String) -> Vec<Report> {
|
|||
stats.nonHeap,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
reports
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue