From 3afd95b5120089637cee22e29cc43b5a22e8e442 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 28 May 2019 11:48:44 -0700 Subject: [PATCH 1/3] add some missing constructors --- lib/stub_ui/lib/src/ui/compositing.dart | 6 ++ lib/stub_ui/lib/src/ui/painting.dart | 34 +++++++++- lib/stub_ui/lib/src/ui/window.dart | 4 +- web_sdk/test/api_conform_test.dart | 84 +++++++++++++++++++++++-- 4 files changed, 120 insertions(+), 8 deletions(-) diff --git a/lib/stub_ui/lib/src/ui/compositing.dart b/lib/stub_ui/lib/src/ui/compositing.dart index 840236018fddc..7f6efcda0bdf4 100644 --- a/lib/stub_ui/lib/src/ui/compositing.dart +++ b/lib/stub_ui/lib/src/ui/compositing.dart @@ -875,6 +875,12 @@ class SceneHost { /// The scene host takes ownership of the provided export token handle. SceneHost(dynamic exportTokenHandle); + SceneHost.fromViewHolderToken( + dynamic viewHolderTokenHandle, + void Function() viewConnectedCallback, + void Function() viewDisconnectedCallback, + void Function(bool) viewStateChangedCallback); + /// Releases the resources associated with the child scene host. /// /// After calling this function, the child scene host cannot be used further. diff --git a/lib/stub_ui/lib/src/ui/painting.dart b/lib/stub_ui/lib/src/ui/painting.dart index fe6c8e8938cdf..95e6fa57be8fd 100644 --- a/lib/stub_ui/lib/src/ui/painting.dart +++ b/lib/stub_ui/lib/src/ui/painting.dart @@ -962,8 +962,8 @@ class Paint { double get strokeMiterLimit { return null; } - set strokeMiterLimit(double value) { - } + + set strokeMiterLimit(double value) {} /// Whether to paint inside shapes, the edges of shapes, or both. /// @@ -1213,7 +1213,8 @@ abstract class Gradient extends Shader { List colors, [ List colorStops, TileMode tileMode = TileMode.clamp, - Float64List matrix4, // TODO(yjbanov): Implement this https://github.com/flutter/flutter/issues/32819 + Float64List + matrix4, // TODO(yjbanov): Implement this https://github.com/flutter/flutter/issues/32819 ]) => _GradientLinear(from, to, colors, colorStops, tileMode); @@ -1490,6 +1491,25 @@ class ColorFilter { : _color = color, _blendMode = blendMode; + /// Construct a color filter that transforms a color by a 4x5 matrix. The + /// matrix is in row-major order and the translation column is specified in + /// unnormalized, 0...255, space. + const ColorFilter.matrix(List matrix) + : _color = null, + _blendMode = null; + + /// Construct a color filter that applies the sRGB gamma curve to the RGB + /// channels. + const ColorFilter.linearToSrgbGamma() + : _color = null, + _blendMode = null; + + /// Creates a color filter that applies the inverse of the sRGB gamma curve + /// to the RGB channels. + const ColorFilter.srgbToLinearGamma() + : _color = null, + _blendMode = null; + final Color _color; final BlendMode _blendMode; @@ -1632,6 +1652,14 @@ class ImageFilter { ImageFilter.blur({double sigmaX = 0.0, double sigmaY = 0.0}) { _initBlur(sigmaX, sigmaY); } + + /// Creates an image filter that applies a matrix transformation. + /// + /// For example, applying a positive scale matrix (see [Matrix4.diagonal3]) + /// when used with [BackdropFilter] would magnify the background image. + ImageFilter.matrix(Float64List matrix4, + {FilterQuality filterQuality = FilterQuality.low}) {} + void _initBlur(double sigmaX, double sigmaY) { // TODO(b/128318717): Implement me. } diff --git a/lib/stub_ui/lib/src/ui/window.dart b/lib/stub_ui/lib/src/ui/window.dart index a22d2aaa3d072..a27c42fde4faa 100644 --- a/lib/stub_ui/lib/src/ui/window.dart +++ b/lib/stub_ui/lib/src/ui/window.dart @@ -1197,7 +1197,9 @@ class PluginUtilities { } } -class ImageShader {} +class ImageShader { + ImageShader(Image image, TileMode tmx, TileMode tmy, Float64List matrix4); +} class IsolateNameServer { static SendPort lookupPortByName(String name) { diff --git a/web_sdk/test/api_conform_test.dart b/web_sdk/test/api_conform_test.dart index 1dd8b850c1e0c..db51b238e101b 100644 --- a/web_sdk/test/api_conform_test.dart +++ b/web_sdk/test/api_conform_test.dart @@ -39,10 +39,62 @@ void main() { } // Next will check that the public methods exposed in each library are // identical. - final Map uiMethods = {}; - final Map webMethods = {}; + final Map uiMethods = + {}; + final Map webMethods = + {}; + final Map uiConstructors = + {}; + final Map webConstructors = + {}; _collectPublicMethods(uiClass, uiMethods); _collectPublicMethods(webClass, webMethods); + _collectPublicConstructors(uiClass, uiConstructors); + _collectPublicConstructors(webClass, webConstructors); + + for (String name in uiConstructors.keys) { + final ConstructorDeclaration uiConstructor = uiConstructors[name]; + final ConstructorDeclaration webConstructor = webConstructors[name]; + if (webConstructor == null) { + failed = true; + print( + 'Warning: lib/ui/ui.dart $className.$name is missing from lib/stub_ui/ui.dart.', + ); + continue; + } + + for (int i = 0; + i < uiConstructor.parameters.parameters.length && + i < uiConstructor.parameters.parameters.length; + i++) { + // Technically you could re-order named parameters and still be valid, + // but we enforce that they are identical. + for (int i = 0; + i < uiConstructor.parameters.parameters.length && + i < webConstructor.parameters.parameters.length; + i++) { + final FormalParameter uiParam = + uiConstructor.parameters.parameters[i]; + final FormalParameter webParam = + webConstructor.parameters.parameters[i]; + if (webParam.identifier.name != uiParam.identifier.name) { + failed = true; + print('Warning: lib/ui/ui.dart $className.$name parameter $i' + ' ${uiParam.identifier.name} has a different name in lib/stub_ui/ui.dart.'); + } + if (uiParam.isPositional && !webParam.isPositional) { + failed = true; + print('Warning: lib/ui/ui.dart $className.$name parameter $i' + '${uiParam.identifier.name} is positional, but not in lib/stub_ui/ui.dart.'); + } + if (uiParam.isNamed && !webParam.isNamed) { + failed = true; + print('Warning: lib/ui/ui.dart $className.$name parameter $i' + '${uiParam.identifier.name} is named, but not in lib/stub_ui/ui.dart.'); + } + } + } + } for (String methodName in uiMethods.keys) { final MethodDeclaration uiMethod = uiMethods[methodName]; @@ -57,7 +109,8 @@ void main() { if (uiMethod.parameters == null || webMethod.parameters == null) { continue; } - if (uiMethod.parameters.parameters.length != webMethod.parameters.parameters.length) { + if (uiMethod.parameters.parameters.length != + webMethod.parameters.parameters.length) { failed = true; print( 'Warning: lib/ui/ui.dart $className.$methodName has a different parameter ' @@ -65,7 +118,10 @@ void main() { } // Technically you could re-order named parameters and still be valid, // but we enforce that they are identical. - for (int i = 0; i < uiMethod.parameters.parameters.length && i < webMethod.parameters.parameters.length; i++) { + for (int i = 0; + i < uiMethod.parameters.parameters.length && + i < webMethod.parameters.parameters.length; + i++) { final FormalParameter uiParam = uiMethod.parameters.parameters[i]; final FormalParameter webParam = webMethod.parameters.parameters[i]; if (webParam.identifier.name != uiParam.identifier.name) { @@ -94,6 +150,8 @@ void main() { exit(0); } +void _checkParameters() {} + // Collects all public classes defined by the part files of [unit]. void _collectPublicClasses(CompilationUnit unit, Map destination, String root) { @@ -121,6 +179,24 @@ void _collectPublicClasses(CompilationUnit unit, } } +void _collectPublicConstructors(ClassDeclaration classDeclaration, + Map destination) { + for (ClassMember member in classDeclaration.members) { + if (member is! ConstructorDeclaration) { + continue; + } + final ConstructorDeclaration method = member; + if (method?.name?.name == null) { + destination['Unnamed Constructor'] = method; + continue; + } + if (method.name.name.startsWith('_')) { + continue; + } + destination[method.name.name] = method; + } +} + void _collectPublicMethods(ClassDeclaration classDeclaration, Map destination) { for (ClassMember member in classDeclaration.members) { From 333af395506d30ac937ef7c88d36f96896fe8352 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 28 May 2019 11:52:50 -0700 Subject: [PATCH 2/3] add font features --- lib/stub_ui/lib/src/ui/text.dart | 1 + web_sdk/test/api_conform_test.dart | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/stub_ui/lib/src/ui/text.dart b/lib/stub_ui/lib/src/ui/text.dart index d2612271d1447..8fd97ae82a73c 100644 --- a/lib/stub_ui/lib/src/ui/text.dart +++ b/lib/stub_ui/lib/src/ui/text.dart @@ -458,6 +458,7 @@ class TextStyle { Paint background, Paint foreground, List shadows, + List fontFeatures, }) : assert( color == null || foreground == null, 'Cannot provide both a color and a foreground\n' diff --git a/web_sdk/test/api_conform_test.dart b/web_sdk/test/api_conform_test.dart index db51b238e101b..252f45173af21 100644 --- a/web_sdk/test/api_conform_test.dart +++ b/web_sdk/test/api_conform_test.dart @@ -63,6 +63,14 @@ void main() { continue; } + if (uiConstructor.parameters.parameters.length != + webConstructor.parameters.parameters.length) { + failed = true; + print( + 'Warning: lib/ui/ui.dart $className.$name has a different parameter ' + 'length than in lib/stub_ui/ui.dart.'); + } + for (int i = 0; i < uiConstructor.parameters.parameters.length && i < uiConstructor.parameters.parameters.length; From 6e4dda6db21fc27d5e6c345da26d8b2d44e4f6b3 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 28 May 2019 12:42:07 -0700 Subject: [PATCH 3/3] address comments --- web_sdk/test/api_conform_test.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web_sdk/test/api_conform_test.dart b/web_sdk/test/api_conform_test.dart index 252f45173af21..137237bc79bd9 100644 --- a/web_sdk/test/api_conform_test.dart +++ b/web_sdk/test/api_conform_test.dart @@ -90,12 +90,12 @@ void main() { print('Warning: lib/ui/ui.dart $className.$name parameter $i' ' ${uiParam.identifier.name} has a different name in lib/stub_ui/ui.dart.'); } - if (uiParam.isPositional && !webParam.isPositional) { + if (uiParam.isPositional != webParam.isPositional) { failed = true; print('Warning: lib/ui/ui.dart $className.$name parameter $i' '${uiParam.identifier.name} is positional, but not in lib/stub_ui/ui.dart.'); } - if (uiParam.isNamed && !webParam.isNamed) { + if (uiParam.isNamed != webParam.isNamed) { failed = true; print('Warning: lib/ui/ui.dart $className.$name parameter $i' '${uiParam.identifier.name} is named, but not in lib/stub_ui/ui.dart.'); @@ -137,12 +137,12 @@ void main() { print('Warning: lib/ui/ui.dart $className.$methodName parameter $i' ' ${uiParam.identifier.name} has a different name in lib/stub_ui/ui.dart.'); } - if (uiParam.isPositional && !webParam.isPositional) { + if (uiParam.isPositional != webParam.isPositional) { failed = true; print('Warning: lib/ui/ui.dart $className.$methodName parameter $i' '${uiParam.identifier.name} is positional, but not in lib/stub_ui/ui.dart.'); } - if (uiParam.isNamed && !webParam.isNamed) { + if (uiParam.isNamed != webParam.isNamed) { failed = true; print('Warning: lib/ui/ui.dart $className.$methodName parameter $i' '${uiParam.identifier.name} is named, but not in lib/stub_ui/ui.dart.');