From e2c4b27600b328d0d75da48a60bbb6c35e8aab48 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 9 Mar 2018 13:11:21 -0800 Subject: [PATCH] Use Dart 2 camel case constants in the engine Dart libraries (#4766) --- lib/ui/geometry.dart | 22 +++++++++++----------- lib/ui/hooks.dart | 10 +++++----- lib/ui/natives.dart | 2 +- lib/ui/painting.dart | 4 ++-- lib/ui/pointer.dart | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/ui/geometry.dart b/lib/ui/geometry.dart index 5478ff34943..005a0764505 100644 --- a/lib/ui/geometry.dart +++ b/lib/ui/geometry.dart @@ -17,16 +17,16 @@ abstract class OffsetBase { final double _dx; final double _dy; - /// Returns true if either component is [double.INFINITY], and false if both + /// Returns true if either component is [double.infinity], and false if both /// are finite (or negative infinity, or NaN). /// /// This is different than comparing for equality with an instance that has - /// _both_ components set to [double.INFINITY]. + /// _both_ components set to [double.infinity]. /// /// See also: /// /// * [isFinite], which is true if both components are finite (and not NaN). - bool get isInfinite => _dx >= double.INFINITY || _dy >= double.INFINITY; + bool get isInfinite => _dx >= double.infinity || _dy >= double.infinity; /// Whether both components are finite (neither infinite nor NaN). /// @@ -183,7 +183,7 @@ class Offset extends OffsetBase { /// * [isInfinite], which checks whether either component is infinite. /// * [isFinite], which checks whether both components are finite. // This is included for completeness, because [Size.infinite] exists. - static const Offset infinite = const Offset(double.INFINITY, double.INFINITY); + static const Offset infinite = const Offset(double.infinity, double.infinity); /// Returns a new offset with the x component scaled by `scaleX` and the y /// component scaled by `scaleY`. @@ -352,10 +352,10 @@ class Size extends OffsetBase { const Size.square(double dimension) : super(dimension, dimension); /// Creates a [Size] with the given [width] and an infinite [height]. - const Size.fromWidth(double width) : super(width, double.INFINITY); + const Size.fromWidth(double width) : super(width, double.infinity); /// Creates a [Size] with the given [height] and an infinite [width]. - const Size.fromHeight(double height) : super(double.INFINITY, height); + const Size.fromHeight(double height) : super(double.infinity, height); /// Creates a square [Size] whose [width] and [height] are twice the given /// dimension. @@ -382,7 +382,7 @@ class Size extends OffsetBase { /// /// * [isInfinite], which checks whether either dimension is infinite. /// * [isFinite], which checks whether both dimensions are finite. - static const Size infinite = const Size(double.INFINITY, double.INFINITY); + static const Size infinite = const Size(double.infinity, double.infinity); /// Whether this size encloses a non-zero area. /// @@ -670,10 +670,10 @@ class Rect { /// Whether any of the coordinates of this rectangle are equal to positive infinity. // included for consistency with Offset and Size bool get isInfinite { - return left >= double.INFINITY - || top >= double.INFINITY - || right >= double.INFINITY - || bottom >= double.INFINITY; + return left >= double.infinity + || top >= double.infinity + || right >= double.infinity + || bottom >= double.infinity; } /// Whether all coordinates of this rectangle are finite. diff --git a/lib/ui/hooks.dart b/lib/ui/hooks.dart index a11ebd5a2c7..57b18d1773f 100644 --- a/lib/ui/hooks.dart +++ b/lib/ui/hooks.dart @@ -5,11 +5,11 @@ part of dart.ui; String _decodeUTF8(ByteData message) { - return message != null ? UTF8.decoder.convert(message.buffer.asUint8List()) : null; + return message != null ? utf8.decoder.convert(message.buffer.asUint8List()) : null; } dynamic _decodeJSON(String message) { - return message != null ? JSON.decode(message) : null; + return message != null ? json.decode(message) : null; } void _updateWindowMetrics(double devicePixelRatio, @@ -50,8 +50,8 @@ void _updateLocale(String languageCode, String countryCode) { _invoke(window.onLocaleChanged, window._onLocaleChangedZone); } -void _updateUserSettingsData(String json) { - final Map data = JSON.decode(json); +void _updateUserSettingsData(String jsonData) { + final Map data = json.decode(jsonData); _updateTextScaleFactor(data['textScaleFactor'].toDouble()); _updateAlwaysUse24HourFormat(data['alwaysUse24HourFormat']); } @@ -174,7 +174,7 @@ void _invoke3(void callback(A1 a1, A2 a2, A3 a3), Zone zone, A1 arg1 const int _kPointerDataFieldCount = 19; PointerDataPacket _unpackPointerDataPacket(ByteData packet) { - const int kStride = Int64List.BYTES_PER_ELEMENT; + const int kStride = Int64List.bytesPerElement; const int kBytesPerPointerData = _kPointerDataFieldCount * kStride; final int length = packet.lengthInBytes ~/ kBytesPerPointerData; assert(length * kBytesPerPointerData == packet.lengthInBytes); diff --git a/lib/ui/natives.dart b/lib/ui/natives.dart index 92c790aee3c..380a44d1d03 100644 --- a/lib/ui/natives.dart +++ b/lib/ui/natives.dart @@ -22,7 +22,7 @@ Future _scheduleFrame( // Schedule the frame. window.scheduleFrame(); // Always succeed. - return new developer.ServiceExtensionResponse.result(JSON.encode({ + return new developer.ServiceExtensionResponse.result(json.encode({ 'type': 'Success', })); } diff --git a/lib/ui/painting.dart b/lib/ui/painting.dart index 4b041a27df3..2412101c5bd 100644 --- a/lib/ui/painting.dart +++ b/lib/ui/painting.dart @@ -838,9 +838,9 @@ enum PaintingStyle { } // If we actually run on big endian machines, we'll need to do something smarter -// here. We don't use [Endianness.HOST_ENDIAN] because it's not a compile-time +// here. We don't use [Endian.Host] because it's not a compile-time // constant and can't propagate into the set/get calls. -const Endianness _kFakeHostEndian = Endianness.LITTLE_ENDIAN; +const Endian _kFakeHostEndian = Endian.little; /// A description of the style to use when drawing on a [Canvas]. /// diff --git a/lib/ui/pointer.dart b/lib/ui/pointer.dart index c9295dbe187..77eda837e47 100644 --- a/lib/ui/pointer.dart +++ b/lib/ui/pointer.dart @@ -55,7 +55,7 @@ enum PointerDeviceKind { class PointerData { /// Creates an object that represents the state of a pointer. const PointerData({ - this.timeStamp: Duration.ZERO, + this.timeStamp: Duration.zero, this.change: PointerChange.cancel, this.kind: PointerDeviceKind.touch, this.device: 0,