Skip to content

Commit

Permalink
Auto merge of #25547 - kunalmohan:25531-SnakeCase, r=jdm
Browse files Browse the repository at this point in the history
Modify `script` to prevent further violations of snake_case

<!-- Please describe your changes on the following line: -->
Remove `#![allow(non_snake_case)]` from `script/lib.rs` and add `#[allow(non_snake_case)]` at each instance of violation.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25531  (GitHub issue number if applicable)

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
  • Loading branch information
bors-servo committed Jan 20, 2020
2 parents 544c41b + f7db4b7 commit 74d1f02
Show file tree
Hide file tree
Showing 135 changed files with 205 additions and 54 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions components/script/dom/analysernode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ impl AnalyserNode {
}

/// https://webaudio.github.io/web-audio-api/#dom-analysernode-analysernode
#[allow(non_snake_case)]
pub fn Constructor(
window: &Window,
context: &BaseAudioContext,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/audiobuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl AudioBuffer {
}

// https://webaudio.github.io/web-audio-api/#dom-audiobuffer-audiobuffer
#[allow(non_snake_case)]
pub fn Constructor(
window: &Window,
options: &AudioBufferOptions,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/audiobuffersourcenode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl AudioBufferSourceNode {
))
}

#[allow(non_snake_case)]
pub fn Constructor(
window: &Window,
context: &BaseAudioContext,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/audiocontext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ impl AudioContext {
}

// https://webaudio.github.io/web-audio-api/#AudioContext-constructors
#[allow(non_snake_case)]
pub fn Constructor(
window: &Window,
options: &AudioContextOptions,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/audiolistener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ impl AudioListener {
}
}

#[allow(non_snake_case)]
impl AudioListenerMethods for AudioListener {
// https://webaudio.github.io/web-audio-api/#dom-audiolistener-positionx
fn PositionX(&self) -> DomRoot<AudioParam> {
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/biquadfilternode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl BiquadFilterNode {
))
}

#[allow(non_snake_case)]
pub fn Constructor(
window: &Window,
context: &BaseAudioContext,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ impl Blob {
}

// https://w3c.github.io/FileAPI/#constructorBlob
#[allow(non_snake_case)]
pub fn Constructor(
global: &GlobalScope,
blobParts: Option<Vec<ArrayBufferOrArrayBufferViewOrBlobOrString>>,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/bluetooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const BT_DESC_CONVERSION_ERROR: &'static str =
"Can't convert to an IDL value of type BluetoothPermissionDescriptor";

#[derive(JSTraceable, MallocSizeOf)]
#[allow(non_snake_case)]
pub struct AllowedBluetoothDevice {
pub deviceId: DOMString,
pub mayUseGATT: bool,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/bluetoothadvertisingevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct BluetoothAdvertisingEvent {
rssi: Option<i8>,
}

#[allow(non_snake_case)]
impl BluetoothAdvertisingEvent {
pub fn new_inherited(
device: &BluetoothDevice,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/bluetoothcharacteristicproperties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct BluetoothCharacteristicProperties {
writable_auxiliaries: bool,
}

#[allow(non_snake_case)]
impl BluetoothCharacteristicProperties {
pub fn new_inherited(
broadcast: bool,
Expand Down
7 changes: 5 additions & 2 deletions components/script/dom/bluetoothremotegattcharacteristic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ impl BluetoothRemoteGATTCharacteristic {
service: &BluetoothRemoteGATTService,
uuid: DOMString,
properties: &BluetoothCharacteristicProperties,
instanceID: String,
instance_id: String,
) -> DomRoot<BluetoothRemoteGATTCharacteristic> {
reflect_dom_object(
Box::new(BluetoothRemoteGATTCharacteristic::new_inherited(
service, uuid, properties, instanceID,
service,
uuid,
properties,
instance_id,
)),
global,
BluetoothRemoteGATTCharacteristicBinding::Wrap,
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/bluetoothremotegattdescriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ impl BluetoothRemoteGATTDescriptor {
global: &GlobalScope,
characteristic: &BluetoothRemoteGATTCharacteristic,
uuid: DOMString,
instanceID: String,
instance_id: String,
) -> DomRoot<BluetoothRemoteGATTDescriptor> {
reflect_dom_object(
Box::new(BluetoothRemoteGATTDescriptor::new_inherited(
characteristic,
uuid,
instanceID,
instance_id,
)),
global,
BluetoothRemoteGATTDescriptorBinding::Wrap,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/bluetoothremotegattservice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl BluetoothRemoteGATTService {
}
}

#[allow(non_snake_case)]
pub fn new(
global: &GlobalScope,
device: &BluetoothDevice,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/bluetoothuuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ const DESCRIPTOR_ERROR_MESSAGE: &'static str =
"https://developer.bluetooth.org/gatt/descriptors/Pages/\
DescriptorsHomePage.aspx\ne.g. 'gatt.characteristic_presentation_format'.";

#[allow(non_snake_case)]
impl BluetoothUUID {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-canonicaluuid
pub fn CanonicalUUID(_: &Window, alias: u32) -> UUID {
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/channelmergernode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl ChannelMergerNode {
))
}

#[allow(non_snake_case)]
pub fn Constructor(
window: &Window,
context: &BaseAudioContext,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/channelsplitternode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl ChannelSplitterNode {
))
}

#[allow(non_snake_case)]
pub fn Constructor(
window: &Window,
context: &BaseAudioContext,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/closeevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct CloseEvent {
reason: DOMString,
}

#[allow(non_snake_case)]
impl CloseEvent {
pub fn new_inherited(was_clean: bool, code: u16, reason: DOMString) -> CloseEvent {
CloseEvent {
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl Comment {
)
}

#[allow(non_snake_case)]
pub fn Constructor(window: &Window, data: DOMString) -> Fallible<DomRoot<Comment>> {
let document = window.Document();
Ok(Comment::new(data, &document))
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/compositionevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ impl CompositionEvent {
ev
}

#[allow(non_snake_case)]
pub fn Constructor(
window: &Window,
type_: DOMString,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ where
f()
}

#[allow(non_snake_case)]
impl Console {
// https://developer.mozilla.org/en-US/docs/Web/API/Console/log
pub fn Log(global: &GlobalScope, messages: Vec<DOMString>) {
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/constantsourcenode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ impl ConstantSourceNode {
))
}

#[allow(non_snake_case)]
pub fn Constructor(
window: &Window,
context: &BaseAudioContext,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/css.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct CSS {
reflector_: Reflector,
}

#[allow(non_snake_case)]
impl CSS {
/// <http://dev.w3.org/csswg/cssom/#serialize-an-identifier>
pub fn Escape(_: &Window, ident: DOMString) -> Fallible<DOMString> {
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/customevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl CustomEvent {
ev
}

#[allow(unsafe_code)]
#[allow(unsafe_code, non_snake_case)]
pub fn Constructor(
global: &GlobalScope,
type_: DOMString,
Expand Down
2 changes: 2 additions & 0 deletions components/script/dom/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ impl CollectionFilter for AnchorsFilter {
}
}

#[allow(non_snake_case)]
impl Document {
#[inline]
pub fn loader(&self) -> Ref<DocumentLoader> {
Expand Down Expand Up @@ -2899,6 +2900,7 @@ impl Document {
}

// https://dom.spec.whatwg.org/#dom-document-document
#[allow(non_snake_case)]
pub fn Constructor(window: &Window) -> Fallible<DomRoot<Document>> {
let doc = window.Document();
let docloader = DocumentLoader::new(&*doc.loader());
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/documentfragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl DocumentFragment {
)
}

#[allow(non_snake_case)]
pub fn Constructor(window: &Window) -> Fallible<DomRoot<DocumentFragment>> {
let document = window.Document();

Expand Down
1 change: 1 addition & 0 deletions components/script/dom/domexception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl DOMException {
)
}

#[allow(non_snake_case)]
pub fn Constructor(
global: &GlobalScope,
message: DOMString,
Expand Down
4 changes: 3 additions & 1 deletion components/script/dom/dommatrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct DOMMatrix {
parent: DOMMatrixReadOnly,
}

#[allow(non_snake_case)]
impl DOMMatrix {
#[allow(unrooted_must_root)]
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
Expand Down Expand Up @@ -74,7 +75,7 @@ impl DOMMatrix {
}

pub fn from_readonly(global: &GlobalScope, ro: &DOMMatrixReadOnly) -> DomRoot<Self> {
Self::new(global, ro.is_2d(), ro.matrix().clone())
Self::new(global, ro.is2D(), ro.matrix().clone())
}

// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-fromfloat32array
Expand Down Expand Up @@ -102,6 +103,7 @@ impl DOMMatrix {
}
}

#[allow(non_snake_case)]
impl DOMMatrixMethods for DOMMatrix {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m11
fn M11(&self) -> f64 {
Expand Down
17 changes: 10 additions & 7 deletions components/script/dom/dommatrixreadonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ use std::ptr::NonNull;
use style::parser::ParserContext;

#[dom_struct]
#[allow(non_snake_case)]
pub struct DOMMatrixReadOnly {
reflector_: Reflector,
matrix: DomRefCell<Transform3D<f64>>,
is2D: Cell<bool>,
}

#[allow(non_snake_case)]
impl DOMMatrixReadOnly {
#[allow(unrooted_must_root)]
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
Expand Down Expand Up @@ -91,7 +93,7 @@ impl DOMMatrixReadOnly {
self.matrix.borrow()
}

pub fn is_2d(&self) -> bool {
pub fn is2D(&self) -> bool {
self.is2D.get()
}

Expand Down Expand Up @@ -421,6 +423,7 @@ impl DOMMatrixReadOnly {
}
}

#[allow(non_snake_case)]
impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m11
fn M11(&self) -> f64 {
Expand Down Expand Up @@ -761,7 +764,7 @@ pub fn dommatrixinit_to_matrix(dict: &DOMMatrixInit) -> Fallible<(bool, Transfor
{
Err(error::Error::Type("Invalid matrix initializer.".to_owned()))
} else {
let mut is2D = dict.is2D;
let mut is_2d = dict.is2D;
// Step 2.
let m11 = dict.m11.unwrap_or(dict.a.unwrap_or(1.0));
// Step 3.
Expand All @@ -775,7 +778,7 @@ pub fn dommatrixinit_to_matrix(dict: &DOMMatrixInit) -> Fallible<(bool, Transfor
// Step 7.
let m42 = dict.m42.unwrap_or(dict.f.unwrap_or(0.0));
// Step 8.
if is2D.is_none() &&
if is_2d.is_none() &&
(dict.m31 != 0.0 ||
dict.m32 != 0.0 ||
dict.m13 != 0.0 ||
Expand All @@ -787,17 +790,17 @@ pub fn dommatrixinit_to_matrix(dict: &DOMMatrixInit) -> Fallible<(bool, Transfor
dict.m33 != 1.0 ||
dict.m44 != 1.0)
{
is2D = Some(false);
is_2d = Some(false);
}
// Step 9.
if is2D.is_none() {
is2D = Some(true);
if is_2d.is_none() {
is_2d = Some(true);
}
let matrix = Transform3D::row_major(
m11, m12, dict.m13, dict.m14, m21, m22, dict.m23, dict.m24, dict.m31, dict.m32,
dict.m33, dict.m34, m41, m42, dict.m43, dict.m44,
);
Ok((is2D.unwrap(), matrix))
Ok((is_2d.unwrap(), matrix))
}
}

Expand Down
1 change: 1 addition & 0 deletions components/script/dom/domparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl DOMParser {
)
}

#[allow(non_snake_case)]
pub fn Constructor(window: &Window) -> Fallible<DomRoot<DOMParser>> {
Ok(DOMParser::new(window))
}
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/dompoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct DOMPoint {
point: DOMPointReadOnly,
}

#[allow(non_snake_case)]
impl DOMPoint {
fn new_inherited(x: f64, y: f64, z: f64, w: f64) -> DOMPoint {
DOMPoint {
Expand Down
3 changes: 3 additions & 0 deletions components/script/dom/dompointreadonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct DOMPointReadOnly {
w: Cell<f64>,
}

#[allow(non_snake_case)]
impl DOMPointReadOnly {
pub fn new_inherited(x: f64, y: f64, z: f64, w: f64) -> DOMPointReadOnly {
DOMPointReadOnly {
Expand Down Expand Up @@ -58,6 +59,7 @@ impl DOMPointReadOnly {
}
}

#[allow(non_snake_case)]
impl DOMPointReadOnlyMethods for DOMPointReadOnly {
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
fn X(&self) -> f64 {
Expand All @@ -80,6 +82,7 @@ impl DOMPointReadOnlyMethods for DOMPointReadOnly {
}
}

#[allow(non_snake_case)]
pub trait DOMPointWriteMethods {
fn SetX(&self, value: f64);
fn SetY(&self, value: f64);
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/domquad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct DOMQuad {
p4: Dom<DOMPoint>,
}

#[allow(non_snake_case)]
impl DOMQuad {
fn new_inherited(p1: &DOMPoint, p2: &DOMPoint, p3: &DOMPoint, p4: &DOMPoint) -> DOMQuad {
DOMQuad {
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/domrect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl DOMRect {
)
}

#[allow(non_snake_case)]
pub fn Constructor(
global: &GlobalScope,
x: f64,
Expand Down
Loading

0 comments on commit 74d1f02

Please sign in to comment.