Reland "Post 3.0 lint sync (#40394)" (flutter/engine#40688)

Reland "Post 3.0 lint sync (#40394)"
This commit is contained in:
Michael Goderbauer 2023-03-27 20:25:02 -07:00 committed by GitHub
parent d4586d760f
commit a508065bbc
75 changed files with 70 additions and 376 deletions

View File

@ -1,7 +1,7 @@
# Specify analysis options.
#
# This file is a copy of analysis_options.yaml from flutter repo
# as of 2022-07-27, but with some modifications marked with
# as of 2023-03-22, but with some modifications marked with
# "DIFFERENT FROM FLUTTER/FLUTTER" below.
analyzer:
@ -23,7 +23,6 @@ linter:
- always_declare_return_types
- always_put_control_body_on_new_line
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
- always_require_non_null_named_parameters
- always_specify_types
# - always_use_package_imports # we do this commonly
- annotate_overrides
@ -52,8 +51,6 @@ linter:
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
- avoid_returning_null
- avoid_returning_null_for_future
- avoid_returning_null_for_void
# - avoid_returning_this # there are enough valid reasons to return `this` that this lint ends up with too many false positives
- avoid_setters_without_getters
@ -74,17 +71,19 @@ linter:
# - cascade_invocations # doesn't match the typical style of this repo
- cast_nullable_to_non_nullable
# - close_sinks # not reliable enough
- collection_methods_unrelated_type
- combinators_ordering
# - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
- conditional_uri_does_not_exist
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
- control_flow_in_finally
- curly_braces_in_flow_control_structures
- dangling_library_doc_comments
- depend_on_referenced_packages
- deprecated_consistency
# - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
- directives_ordering
# - discarded_futures # not yet tested
# - discarded_futures # too many false positives, similar to unawaited_futures
# - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
- empty_catches
- empty_constructor_bodies
@ -95,10 +94,12 @@ linter:
- flutter_style_todos
- hash_and_equals
- implementation_imports
- implicit_call_tearoffs
- invalid_case_patterns
- iterable_contains_unrelated_type
# - join_return_with_assignment # not required by flutter style
- leading_newlines_in_multiline_strings
- library_annotations
- library_names
- library_prefixes
- library_private_types_in_public_api
@ -137,7 +138,6 @@ linter:
# - prefer_constructors_over_static_methods # far too many false positives
- prefer_contains
# - prefer_double_quotes # opposite of prefer_single_quotes
- prefer_equal_for_default_values
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
- prefer_final_fields
- prefer_final_in_for_each
@ -157,7 +157,7 @@ linter:
- prefer_is_not_empty
- prefer_is_not_operator
- prefer_iterable_whereType
# - prefer_mixin # Has false positives, see https://github.com/dart-lang/linter/issues/3018
- prefer_mixin
# - prefer_null_aware_method_calls # "call()" is confusing to people new to the language since it's not documented anywhere
- prefer_null_aware_operators
- prefer_relative_imports
@ -168,10 +168,10 @@ linter:
- provide_deprecation_message
- public_member_api_docs # DIFFERENT FROM FLUTTER/FLUTTER
- recursive_getters
# - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
# - require_trailing_commas # would be nice, but requires a lot of manual work: 10,000+ code locations would need to be reformatted by hand after bulk fix is applied
- secure_pubspec_urls
- sized_box_for_whitespace
# - sized_box_shrink_expand # not yet tested
- sized_box_shrink_expand
- slash_for_doc_comments
- sort_child_properties_last
- sort_constructors_first
@ -185,12 +185,14 @@ linter:
# - unawaited_futures # too many false positives, especially with the way AnimationController works
- unnecessary_await_in_return
- unnecessary_brace_in_string_interps
- unnecessary_breaks
- unnecessary_const
- unnecessary_constructor_name
# - unnecessary_final # conflicts with prefer_final_locals
- unnecessary_getters_setters
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
- unnecessary_late
- unnecessary_library_directive
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_aware_operator_on_extension_on_nullable
@ -205,12 +207,13 @@ linter:
- unnecessary_string_interpolations
- unnecessary_this
- unnecessary_to_list_in_spreads
# - unreachable_from_main # Do not enable this rule until it is un-marked as "experimental" and carefully re-evaluated.
- unrelated_type_equality_checks
- unsafe_html
- use_build_context_synchronously
# - use_colored_box # not yet tested
# - use_decorated_box # not yet tested
# - use_enums # not yet tested
- use_colored_box
# - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding)
- use_enums
- use_full_hex_values_for_flutter_colors
- use_function_type_syntax_for_parameters
- use_if_null_to_convert_nulls_to_bools
@ -222,6 +225,7 @@ linter:
- use_rethrow_when_possible
- use_setters_to_change_properties
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
# - use_string_in_part_of_directives # DIFFERENT FROM FLUTTER/FLUTTER (needs to be evaluated, dart:ui does this frequently)
- use_super_parameters
- use_test_throws_matchers
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review

View File

@ -968,13 +968,10 @@ Future<int> main(List<String> arguments) async {
switch (type) {
case MessageType.message:
stderr.writeln(message);
break;
case MessageType.error:
stderr.writeln('ERROR: $message');
break;
case MessageType.warning:
stderr.writeln('WARNING: $message');
break;
}
}

View File

@ -1,2 +1,2 @@
Signature: 90df0faca032ae220230aef5e61ca020
Signature: 61adfda2905179c8e8b7d754d8660a7f

View File

@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library frontend_server;
import 'dart:io';

View File

@ -4,7 +4,6 @@
// ignore_for_file: avoid_print
library flutter_frontend_server;
import 'dart:async';
import 'dart:io' hide FileSystemEntity;

View File

@ -468,7 +468,6 @@ class ChannelBuffers {
}
index += 1;
resize(channelName, data.getUint32(index, Endian.host));
break;
case 'overflow':
if (bytes[index] != 0x0C) { // 12 = value code for list
throw Exception("Invalid arguments for 'overflow' method sent to $kControlChannelName (arguments must be a two-element list, channel name and flag state)");
@ -493,7 +492,6 @@ class ChannelBuffers {
throw Exception("Invalid arguments for 'overflow' method sent to $kControlChannelName (second argument must be a boolean)");
}
allowOverflow(channelName, bytes[index] == 0x01);
break;
default:
throw Exception("Unrecognized method '$methodName' sent to $kControlChannelName");
}

View File

@ -2831,10 +2831,8 @@ class Paragraph extends NativeFieldWrapperClass1 {
switch (position.affinity) {
case TextAffinity.upstream:
characterPosition = position.offset - 1;
break;
case TextAffinity.downstream:
characterPosition = position.offset;
break;
}
final List<int> boundary = _getWordBoundary(characterPosition);
return TextRange(start: boundary[0], end: boundary[1]);

View File

@ -1020,11 +1020,9 @@ class BrowserManager {
case 'restart':
_onRestartController.add(null);
break;
case 'resume':
_pauseCompleter?.complete();
break;
default:
// Unreachable.

View File

@ -199,7 +199,6 @@ class ChannelBuffers {
}
index += 1;
resize(channelName, data.getUint32(index, Endian.host));
break;
case 'overflow':
if (bytes[index] != 0x0C) {
throw Exception("Invalid arguments for 'overflow' method sent to $kControlChannelName (arguments must be a two-element list, channel name and flag state)");
@ -224,7 +223,6 @@ class ChannelBuffers {
throw Exception("Invalid arguments for 'overflow' method sent to $kControlChannelName (second argument must be a boolean)");
}
allowOverflow(channelName, bytes[index] == 0x01);
break;
default:
throw Exception("Unrecognized method '$methodName' sent to $kControlChannelName");
}

View File

@ -559,10 +559,8 @@ Future<Codec> createBmp(
switch (format) {
case PixelFormat.bgra8888:
swapRedBlue = true;
break;
case PixelFormat.rgba8888:
swapRedBlue = false;
break;
}
// See https://en.wikipedia.org/wiki/BMP_file_format for format examples.

View File

@ -12,7 +12,7 @@
// The code that performs the transformations lives in:
//
// - https://github.com/flutter/engine/blob/main/web_sdk/sdk_rewriter.dart
// ignore: unnecessary_library_directive
library engine;
export 'engine/alarm_clock.dart';

View File

@ -592,7 +592,6 @@ class CanvasPool extends _SaveStackTracking {
ctx.arc(x, y, radius, 0, 2.0 * math.pi);
ctx.fill();
}
break;
case ui.PointMode.lines:
ctx.beginPath();
for (int i = 0; i < (len - 2); i += 4) {
@ -600,7 +599,6 @@ class CanvasPool extends _SaveStackTracking {
ctx.lineTo(points[i + 2] + offsetX, points[i + 3] + offsetY);
ctx.stroke();
}
break;
case ui.PointMode.polygon:
ctx.beginPath();
ctx.moveTo(points[0] + offsetX, points[1] + offsetY);
@ -608,7 +606,6 @@ class CanvasPool extends _SaveStackTracking {
ctx.lineTo(points[i] + offsetX, points[i + 1] + offsetY);
}
ctx.stroke();
break;
}
}
@ -625,16 +622,12 @@ class CanvasPool extends _SaveStackTracking {
switch (verb) {
case SPath.kMoveVerb:
ctx.moveTo(p[0], p[1]);
break;
case SPath.kLineVerb:
ctx.lineTo(p[2], p[3]);
break;
case SPath.kCubicVerb:
ctx.bezierCurveTo(p[2], p[3], p[4], p[5], p[6], p[7]);
break;
case SPath.kQuadVerb:
ctx.quadraticCurveTo(p[2], p[3], p[4], p[5]);
break;
case SPath.kConicVerb:
final double w = iter.conicWeight;
final Conic conic = Conic(p[0], p[1], p[2], p[3], p[4], p[5], w);
@ -647,10 +640,8 @@ class CanvasPool extends _SaveStackTracking {
final double p2y = points[i + 1].dy;
ctx.quadraticCurveTo(p1x, p1y, p2x, p2y);
}
break;
case SPath.kCloseVerb:
ctx.closePath();
break;
default:
throw UnimplementedError('Unknown path verb $verb');
}
@ -683,18 +674,14 @@ class CanvasPool extends _SaveStackTracking {
switch (verb) {
case SPath.kMoveVerb:
ctx.moveTo(p[0] + offsetX, p[1] + offsetY);
break;
case SPath.kLineVerb:
ctx.lineTo(p[2] + offsetX, p[3] + offsetY);
break;
case SPath.kCubicVerb:
ctx.bezierCurveTo(p[2] + offsetX, p[3] + offsetY,
p[4] + offsetX, p[5] + offsetY, p[6] + offsetX, p[7] + offsetY);
break;
case SPath.kQuadVerb:
ctx.quadraticCurveTo(p[2] + offsetX, p[3] + offsetY,
p[4] + offsetX, p[5] + offsetY);
break;
case SPath.kConicVerb:
final double w = iter.conicWeight;
final Conic conic = Conic(p[0], p[1], p[2], p[3], p[4], p[5], w);
@ -708,10 +695,8 @@ class CanvasPool extends _SaveStackTracking {
ctx.quadraticCurveTo(p1x + offsetX, p1y + offsetY,
p2x + offsetX, p2y + offsetY);
}
break;
case SPath.kCloseVerb:
ctx.closePath();
break;
default:
throw UnimplementedError('Unknown path verb $verb');
}

View File

@ -302,7 +302,6 @@ class HtmlViewEmbedder {
headTransform = mutator.matrix!.multiplied(headTransform);
head.style.transform =
float64ListToCssTransform(headTransform.storage);
break;
case MutatorType.clipRect:
case MutatorType.clipRRect:
case MutatorType.clipPath:
@ -359,10 +358,8 @@ class HtmlViewEmbedder {
}
_resetAnchor(clipView);
head = clipView;
break;
case MutatorType.opacity:
embeddedOpacity *= mutator.alphaFloat;
break;
}
}

View File

@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Uses the `ImageDecoder` class supplied by the browser.
///
/// See also:
///
/// * `image_wasm_codecs.dart`, which uses codecs supplied by the CanvasKit WASM bundle.
// Uses the `ImageDecoder` class supplied by the browser.
//
// See also:
//
// * `image_wasm_codecs.dart`, which uses codecs supplied by the CanvasKit WASM bundle.
import 'dart:async';
import 'dart:convert' show base64;

View File

@ -64,13 +64,10 @@ class PrerollContext {
switch (m.type) {
case MutatorType.clipRect:
clipRect = m.rect!;
break;
case MutatorType.clipRRect:
clipRect = m.rrect!.outerRect;
break;
case MutatorType.clipPath:
clipRect = m.path!.getBounds();
break;
default:
continue;
}
@ -527,14 +524,11 @@ class PhysicalShapeEngineLayer extends ContainerLayer
switch (_clipBehavior) {
case ui.Clip.hardEdge:
paintContext.internalNodesCanvas.clipPath(_path, false);
break;
case ui.Clip.antiAlias:
paintContext.internalNodesCanvas.clipPath(_path, true);
break;
case ui.Clip.antiAliasWithSaveLayer:
paintContext.internalNodesCanvas.clipPath(_path, true);
paintContext.internalNodesCanvas.saveLayer(paintBounds, null);
break;
case ui.Clip.none:
break;
}

View File

@ -115,10 +115,8 @@ class CkParagraphStyle implements ui.ParagraphStyle {
break;
case ui.TextLeadingDistribution.even:
skStrutStyle.halfLeading = true;
break;
case ui.TextLeadingDistribution.proportional:
skStrutStyle.halfLeading = false;
break;
}
if (style._leading != null) {
@ -420,10 +418,8 @@ class CkTextStyle implements ui.TextStyle {
break;
case ui.TextLeadingDistribution.even:
properties.halfLeading = true;
break;
case ui.TextLeadingDistribution.proportional:
properties.halfLeading = false;
break;
}
if (locale != null) {
@ -604,16 +600,12 @@ class CkParagraph extends SkiaObject<SkParagraph> implements ui.Paragraph {
switch (command.type) {
case _ParagraphCommandType.addText:
builder.addText(command.text!);
break;
case _ParagraphCommandType.pop:
builder.pop();
break;
case _ParagraphCommandType.pushStyle:
builder.pushStyle(command.style!);
break;
case _ParagraphCommandType.addPlaceholder:
builder._addPlaceholder(command.placeholderStyle!);
break;
}
}
paragraph = builder._buildSkParagraph();
@ -786,10 +778,8 @@ class CkParagraph extends SkiaObject<SkParagraph> implements ui.Paragraph {
switch (position.affinity) {
case ui.TextAffinity.upstream:
characterPosition = position.offset - 1;
break;
case ui.TextAffinity.downstream:
characterPosition = position.offset;
break;
}
final SkTextRange skRange = paragraph.getWordBoundary(characterPosition.toDouble());
return ui.TextRange(start: skRange.start.toInt(), end: skRange.end.toInt());

View File

@ -804,19 +804,16 @@ class BitmapCanvas extends EngineCanvas {
case ui.BlendMode.clear:
case ui.BlendMode.dstOut:
style.position = 'absolute';
break;
case ui.BlendMode.src:
case ui.BlendMode.srcOver:
style
..position = 'absolute'
..backgroundColor = colorToCssString(filterColor)!;
break;
case ui.BlendMode.dst:
case ui.BlendMode.dstIn:
style
..position = 'absolute'
..backgroundImage = "url('${image.imgElement.src}')";
break;
default:
style
..position = 'absolute'

View File

@ -121,24 +121,18 @@ SvgFilter svgFilterFromBlendMode(
case ui.BlendMode.srcIn:
case ui.BlendMode.srcATop:
svgFilter = _srcInColorFilterToSvg(filterColor);
break;
case ui.BlendMode.srcOut:
svgFilter = _srcOutColorFilterToSvg(filterColor);
break;
case ui.BlendMode.dstATop:
svgFilter = _dstATopColorFilterToSvg(filterColor);
break;
case ui.BlendMode.xor:
svgFilter = _xorColorFilterToSvg(filterColor);
break;
case ui.BlendMode.plus:
// Porter duff source + destination.
svgFilter = _compositeColorFilterToSvg(filterColor, 0, 1, 1, 0);
break;
case ui.BlendMode.modulate:
// Porter duff source * destination but preserves alpha.
svgFilter = _modulateColorFilterToSvg(filterColor!);
break;
case ui.BlendMode.overlay:
// Since overlay is the same as hard-light by swapping layers,
// pass hard-light blend function.
@ -147,7 +141,6 @@ SvgFilter svgFilterFromBlendMode(
blendModeToSvgEnum(ui.BlendMode.hardLight)!,
swapLayers: true,
);
break;
// Several of the filters below (although supported) do not render the
// same (close but not exact) as native flutter when used as blend mode
// for a background-image with a background color. They only look
@ -175,7 +168,6 @@ SvgFilter svgFilterFromBlendMode(
case ui.BlendMode.exclusion:
svgFilter = _blendColorFilterToSvg(
filterColor, blendModeToSvgEnum(colorFilterBlendMode)!);
break;
case ui.BlendMode.src:
case ui.BlendMode.dst:
case ui.BlendMode.dstIn:

View File

@ -1135,24 +1135,18 @@ class SurfacePath implements ui.Path {
} else {
moveTo(outPts[0], outPts[1]);
}
break;
case SPath.kLineVerb:
lineTo(outPts[2], outPts[3]);
break;
case SPath.kQuadVerb:
_quadTo(outPts[2], outPts[3], outPts[4], outPts[5]);
break;
case SPath.kConicVerb:
conicTo(
outPts[2], outPts[3], outPts[4], outPts[5], iter.conicWeight);
break;
case SPath.kCubicVerb:
cubicTo(outPts[2], outPts[3], outPts[4], outPts[5], outPts[6],
outPts[7]);
break;
case SPath.kCloseVerb:
close();
break;
}
firstVerb = false;
}
@ -1248,19 +1242,14 @@ class SurfacePath implements ui.Path {
break;
case SPath.kLineVerb:
tangentLine(buffer, x, y, tangents);
break;
case SPath.kQuadVerb:
tangentQuad(buffer, x, y, tangents);
break;
case SPath.kConicVerb:
tangentConic(buffer, x, y, iter.conicWeight, tangents);
break;
case SPath.kCubicVerb:
tangentCubic(buffer, x, y, tangents);
break;
case SPath.kDoneVerb:
done = true;
break;
}
if (tangents.length > oldCount) {
final int last = tangents.length - 1;
@ -1392,19 +1381,14 @@ class SurfacePath implements ui.Path {
}
state.setMovePt(pts[0], pts[1]);
count = 0;
break;
case SPath.kLineVerb:
count = 1;
break;
case SPath.kQuadVerb:
count = 2;
break;
case SPath.kConicVerb:
count = 2;
break;
case SPath.kCubicVerb:
count = 3;
break;
case SPath.kCloseVerb:
if (!state.close()) {
if (!state.isFinite) {
@ -1413,7 +1397,6 @@ class SurfacePath implements ui.Path {
return _setComputedConvexity(SPathConvexityType.kConcave);
}
count = 0;
break;
default:
return _setComputedConvexity(SPathConvexityType.kConcave);
}
@ -1479,11 +1462,9 @@ class SurfacePath implements ui.Path {
case SPath.kMoveVerb:
minX = maxX = points[pIndex];
minY = maxY = points[pIndex + 1];
break;
case SPath.kLineVerb:
minX = maxX = points[pIndex + 2];
minY = maxY = points[pIndex + 3];
break;
case SPath.kQuadVerb:
quadBounds ??= QuadBounds();
quadBounds.calculateBounds(points, pIndex);
@ -1491,7 +1472,6 @@ class SurfacePath implements ui.Path {
minY = quadBounds.minY;
maxX = quadBounds.maxX;
maxY = quadBounds.maxY;
break;
case SPath.kConicVerb:
conicBounds ??= ConicBounds();
conicBounds.calculateBounds(points, iter.conicWeight, pIndex);
@ -1499,7 +1479,6 @@ class SurfacePath implements ui.Path {
minY = conicBounds.minY;
maxX = conicBounds.maxX;
maxY = conicBounds.maxY;
break;
case SPath.kCubicVerb:
cubicBounds ??= CubicBounds();
cubicBounds.calculateBounds(points, pIndex);
@ -1507,7 +1486,6 @@ class SurfacePath implements ui.Path {
minY = cubicBounds.minY;
maxX = cubicBounds.maxX;
maxY = cubicBounds.maxY;
break;
}
if (!ltrbInitialized) {
left = minX;
@ -1591,26 +1569,20 @@ class SurfacePath implements ui.Path {
switch (verb) {
case SPath.kMoveVerb:
sb.write('MoveTo(${points[pIndex]}, ${points[pIndex + 1]})');
break;
case SPath.kLineVerb:
sb.write('LineTo(${points[pIndex + 2]}, ${points[pIndex + 3]})');
break;
case SPath.kQuadVerb:
sb.write('Quad(${points[pIndex + 2]}, ${points[pIndex + 3]},'
' ${points[pIndex + 3]}, ${points[pIndex + 4]})');
break;
case SPath.kConicVerb:
sb.write('Conic(${points[pIndex + 2]}, ${points[pIndex + 3]},'
' ${points[pIndex + 3]}, ${points[pIndex + 4]}, w = ${iter.conicWeight})');
break;
case SPath.kCubicVerb:
sb.write('Cubic(${points[pIndex + 2]}, ${points[pIndex + 3]},'
' ${points[pIndex + 3]}, ${points[pIndex + 4]}, '
' ${points[pIndex + 5]}, ${points[pIndex + 6]})');
break;
case SPath.kCloseVerb:
sb.write('Close()');
break;
}
if (iter.peek() != SPath.kDoneVerb) {
sb.write(' ');

View File

@ -153,7 +153,6 @@ class PathIterator {
_lastPointX = _moveToX;
_lastPointY = _moveToY;
_needClose = _forceClose;
break;
case SPath.kLineVerb:
final ui.Offset start = _constructMoveTo();
final double offsetX = pathRef.points[_pointIndex++];
@ -164,7 +163,6 @@ class PathIterator {
outPts[3] = offsetY;
_lastPointX = offsetX;
_lastPointY = offsetY;
break;
case SPath.kConicVerb:
_conicWeightIndex++;
final ui.Offset start = _constructMoveTo();
@ -174,7 +172,6 @@ class PathIterator {
outPts[3] = pathRef.points[_pointIndex++];
_lastPointX = outPts[4] = pathRef.points[_pointIndex++];
_lastPointY = outPts[5] = pathRef.points[_pointIndex++];
break;
case SPath.kQuadVerb:
final ui.Offset start = _constructMoveTo();
outPts[0] = start.dx;
@ -183,7 +180,6 @@ class PathIterator {
outPts[3] = pathRef.points[_pointIndex++];
_lastPointX = outPts[4] = pathRef.points[_pointIndex++];
_lastPointY = outPts[5] = pathRef.points[_pointIndex++];
break;
case SPath.kCubicVerb:
final ui.Offset start = _constructMoveTo();
outPts[0] = start.dx;
@ -194,7 +190,6 @@ class PathIterator {
outPts[5] = pathRef.points[_pointIndex++];
_lastPointX = outPts[6] = pathRef.points[_pointIndex++];
_lastPointY = outPts[7] = pathRef.points[_pointIndex++];
break;
case SPath.kCloseVerb:
verb = _autoClose(outPts);
if (verb == SPath.kLineVerb) {
@ -206,10 +201,8 @@ class PathIterator {
}
_lastPointX = _moveToX;
_lastPointY = _moveToY;
break;
case SPath.kDoneVerb:
assert(_verbIndex == pathRef.countVerbs());
break;
default:
throw FormatException('Unsupport Path verb $verb');
}

View File

@ -258,16 +258,13 @@ class _PathContourMeasure {
final double toX = (points[2] * stopT) + (points[0] * (1.0 - stopT));
final double toY = (points[3] * stopT) + (points[1] * (1.0 - stopT));
path.lineTo(toX, toY);
break;
case SPath.kCubicVerb:
chopCubicBetweenT(points, startT, stopT, _buffer);
path.cubicTo(_buffer[2], _buffer[3], _buffer[4], _buffer[5], _buffer[6],
_buffer[7]);
break;
case SPath.kQuadVerb:
_chopQuadBetweenT(points, startT, stopT, _buffer);
path.quadraticBezierTo(_buffer[2], _buffer[3], _buffer[4], _buffer[5]);
break;
case SPath.kConicVerb:
// Implement this once we start writing out conic segments.
throw UnimplementedError();
@ -309,11 +306,9 @@ class _PathContourMeasure {
switch (verb) {
case SPath.kMoveVerb:
haveSeenMoveTo = true;
break;
case SPath.kLineVerb:
assert(haveSeenMoveTo);
lineToHandler(points[0], points[1], points[2], points[3]);
break;
case SPath.kCubicVerb:
assert(haveSeenMoveTo);
// Compute cubic curve distance.
@ -330,7 +325,6 @@ class _PathContourMeasure {
0,
_kMaxTValue,
_segments);
break;
case SPath.kConicVerb:
assert(haveSeenMoveTo);
final double w = iter.conicWeight;
@ -350,13 +344,11 @@ class _PathContourMeasure {
startX = p2x;
startY = p2y;
}
break;
case SPath.kQuadVerb:
assert(haveSeenMoveTo);
// Compute quad curve distance.
distance = _computeQuadSegments(points[0], points[1], points[2],
points[3], points[4], points[5], distance, 0, _kMaxTValue);
break;
case SPath.kCloseVerb:
_contourLength = distance;
return iter.pathVerbIndex;

View File

@ -532,16 +532,12 @@ class PathRef {
switch (verbs[i]) {
case SPath.kLineVerb:
mask |= SPath.kLineSegmentMask;
break;
case SPath.kQuadVerb:
mask |= SPath.kQuadSegmentMask;
break;
case SPath.kConicVerb:
mask |= SPath.kConicSegmentMask;
break;
case SPath.kCubicVerb:
mask |= SPath.kCubicSegmentMask;
break;
default:
break;
}
@ -641,32 +637,25 @@ class PathRef {
switch (verb) {
case SPath.kMoveVerb:
pCnt = 1;
break;
case SPath.kLineVerb:
mask = SPath.kLineSegmentMask;
pCnt = 1;
break;
case SPath.kQuadVerb:
mask = SPath.kQuadSegmentMask;
pCnt = 2;
break;
case SPath.kConicVerb:
mask = SPath.kConicSegmentMask;
pCnt = 2;
break;
case SPath.kCubicVerb:
mask = SPath.kCubicSegmentMask;
pCnt = 3;
break;
case SPath.kCloseVerb:
pCnt = 0;
break;
case SPath.kDoneVerb:
if (assertionsEnabled) {
throw Exception('growForVerb called for kDone');
}
pCnt = 0;
break;
default:
if (assertionsEnabled) {
throw Exception('default is not reached');
@ -708,32 +697,25 @@ class PathRef {
switch (verb) {
case SPath.kMoveVerb:
pCnt = numVbs;
break;
case SPath.kLineVerb:
mask = SPath.kLineSegmentMask;
pCnt = numVbs;
break;
case SPath.kQuadVerb:
mask = SPath.kQuadSegmentMask;
pCnt = 2 * numVbs;
break;
case SPath.kConicVerb:
mask = SPath.kConicSegmentMask;
pCnt = 2 * numVbs;
break;
case SPath.kCubicVerb:
mask = SPath.kCubicSegmentMask;
pCnt = 3 * numVbs;
break;
case SPath.kCloseVerb:
pCnt = 0;
break;
case SPath.kDoneVerb:
if (assertionsEnabled) {
throw Exception('growForVerb called for kDone');
}
pCnt = 0;
break;
default:
if (assertionsEnabled) {
throw Exception('default is not reached');
@ -999,29 +981,23 @@ class PathRefIterator {
case SPath.kMoveVerb:
iterIndex = _pointIndex;
_pointIndex += 2;
break;
case SPath.kLineVerb:
iterIndex = _pointIndex - 2;
_pointIndex += 2;
break;
case SPath.kConicVerb:
_conicWeightIndex++;
iterIndex = _pointIndex - 2;
_pointIndex += 4;
break;
case SPath.kQuadVerb:
iterIndex = _pointIndex - 2;
_pointIndex += 4;
break;
case SPath.kCubicVerb:
iterIndex = _pointIndex - 2;
_pointIndex += 6;
break;
case SPath.kCloseVerb:
break;
case SPath.kDoneVerb:
assert(_verbIndex == pathRef.countVerbs());
break;
default:
throw FormatException('Unsupport Path verb $verb');
}
@ -1040,13 +1016,11 @@ class PathRefIterator {
case SPath.kMoveVerb:
outPts[0] = points[pointIndex++];
outPts[1] = points[pointIndex++];
break;
case SPath.kLineVerb:
outPts[0] = points[pointIndex - 2];
outPts[1] = points[pointIndex - 1];
outPts[2] = points[pointIndex++];
outPts[3] = points[pointIndex++];
break;
case SPath.kConicVerb:
_conicWeightIndex++;
outPts[0] = points[pointIndex - 2];
@ -1055,7 +1029,6 @@ class PathRefIterator {
outPts[3] = points[pointIndex++];
outPts[4] = points[pointIndex++];
outPts[5] = points[pointIndex++];
break;
case SPath.kQuadVerb:
outPts[0] = points[pointIndex - 2];
outPts[1] = points[pointIndex - 1];
@ -1063,7 +1036,6 @@ class PathRefIterator {
outPts[3] = points[pointIndex++];
outPts[4] = points[pointIndex++];
outPts[5] = points[pointIndex++];
break;
case SPath.kCubicVerb:
outPts[0] = points[pointIndex - 2];
outPts[1] = points[pointIndex - 1];
@ -1073,12 +1045,10 @@ class PathRefIterator {
outPts[5] = points[pointIndex++];
outPts[6] = points[pointIndex++];
outPts[7] = points[pointIndex++];
break;
case SPath.kCloseVerb:
break;
case SPath.kDoneVerb:
assert(_verbIndex == pathRef.countVerbs());
break;
default:
throw FormatException('Unsupport Path verb $verb');
}

View File

@ -21,18 +21,14 @@ String pathToSvg(PathRef pathRef, {double offsetX = 0, double offsetY = 0}) {
switch (verb) {
case SPath.kMoveVerb:
buffer.write('M ${outPts[0] + offsetX} ${outPts[1] + offsetY}');
break;
case SPath.kLineVerb:
buffer.write('L ${outPts[2] + offsetX} ${outPts[3] + offsetY}');
break;
case SPath.kCubicVerb:
buffer.write('C ${outPts[2] + offsetX} ${outPts[3] + offsetY} '
'${outPts[4] + offsetX} ${outPts[5] + offsetY} ${outPts[6] + offsetX} ${outPts[7] + offsetY}');
break;
case SPath.kQuadVerb:
buffer.write('Q ${outPts[2] + offsetX} ${outPts[3] + offsetY} '
'${outPts[4] + offsetX} ${outPts[5] + offsetY}');
break;
case SPath.kConicVerb:
final double w = iter.conicWeight;
final Conic conic = Conic(outPts[0], outPts[1], outPts[2], outPts[3],
@ -47,10 +43,8 @@ String pathToSvg(PathRef pathRef, {double offsetX = 0, double offsetY = 0}) {
buffer.write('Q ${p1x + offsetX} ${p1y + offsetY} '
'${p2x + offsetX} ${p2y + offsetY}');
}
break;
case SPath.kCloseVerb:
buffer.write('Z');
break;
default:
throw UnimplementedError('Unknown path verb $verb');
}

View File

@ -41,16 +41,12 @@ class PathWinding {
break;
case SPath.kLineVerb:
_computeLineWinding();
break;
case SPath.kQuadVerb:
_computeQuadWinding();
break;
case SPath.kConicVerb:
_computeConicWinding(pathRef.conicWeights![iter.conicWeightIndex]);
break;
case SPath.kCubicVerb:
_computeCubicWinding();
break;
}
}
}

View File

@ -281,7 +281,6 @@ class RecordingCanvas {
switch (clipOp) {
case ui.ClipOp.intersect:
_paintBounds.clipRect(rect, command);
break;
case ui.ClipOp.difference:
// Since this refers to inverse, can't shrink paintBounds.
break;

View File

@ -466,10 +466,8 @@ class _WebGlRenderer implements GlRenderer {
switch (triangleVertexIndex) {
case 0:
ctx.moveTo(dx, dy);
break;
case 1:
ctx.lineTo(dx, dy);
break;
case 2:
ctx.lineTo(dx, dy);
ctx.closePath();

View File

@ -132,7 +132,6 @@ class PersistedShaderMask extends PersistedContainerSurface
// Since we don't have a size, we can't use background color.
// Use svg filter srcIn instead.
blendModeTemp = ui.BlendMode.srcIn;
break;
case ui.BlendMode.src:
case ui.BlendMode.dstOver:
case ui.BlendMode.srcIn:
@ -188,25 +187,19 @@ SvgFilter svgMaskFilterFromImageAndBlendMode(
switch (blendMode) {
case ui.BlendMode.src:
svgFilter = _srcImageToSvg(imageUrl, width, height);
break;
case ui.BlendMode.srcIn:
case ui.BlendMode.srcATop:
svgFilter = _srcInImageToSvg(imageUrl, width, height);
break;
case ui.BlendMode.srcOut:
svgFilter = _srcOutImageToSvg(imageUrl, width, height);
break;
case ui.BlendMode.xor:
svgFilter = _xorImageToSvg(imageUrl, width, height);
break;
case ui.BlendMode.plus:
// Porter duff source + destination.
svgFilter = _compositeImageToSvg(imageUrl, 0, 1, 1, 0, width, height);
break;
case ui.BlendMode.modulate:
// Porter duff source * destination but preserves alpha.
svgFilter = _modulateImageToSvg(imageUrl, width, height);
break;
case ui.BlendMode.overlay:
// Since overlay is the same as hard-light by swapping layers,
// pass hard-light blend function.
@ -217,7 +210,6 @@ SvgFilter svgMaskFilterFromImageAndBlendMode(
height,
swapLayers: true,
);
break;
// Several of the filters below (although supported) do not render the
// same (close but not exact) as native flutter when used as blend mode
// for a background-image with a background color. They only look
@ -245,7 +237,6 @@ SvgFilter svgMaskFilterFromImageAndBlendMode(
case ui.BlendMode.exclusion:
svgFilter = _blendImageToSvg(
imageUrl, blendModeToSvgEnum(blendMode)!, width, height);
break;
case ui.BlendMode.dst:
case ui.BlendMode.dstATop:
case ui.BlendMode.dstIn:

View File

@ -444,7 +444,6 @@ String _writeSharedGradientShader(ShaderBuilder builder, ShaderMethod method,
case ui.TileMode.clamp:
method.addStatement('float tiled_st = clamp(st, 0.0, 1.0);');
probeName = 'tiled_st';
break;
case ui.TileMode.decal:
break;
case ui.TileMode.repeated:
@ -453,13 +452,11 @@ String _writeSharedGradientShader(ShaderBuilder builder, ShaderMethod method,
// pattern center is at origin.
method.addStatement('float tiled_st = fract(st);');
probeName = 'tiled_st';
break;
case ui.TileMode.mirror:
method.addStatement('float t_1 = (st - 1.0);');
method.addStatement(
'float tiled_st = abs((t_1 - 2.0 * floor(t_1 * 0.5)) - 1.0);');
probeName = 'tiled_st';
break;
}
writeUnrolledBinarySearch(method, 0, gradient.thresholdCount - 1,
probe: probeName,
@ -812,7 +809,6 @@ class ModeHtmlColorFilter extends EngineHtmlColorFilter {
// Since we don't have a size, we can't use background color.
// Use svg filter srcIn instead.
blendMode = ui.BlendMode.srcIn;
break;
case ui.BlendMode.dstOver:
case ui.BlendMode.srcIn:
case ui.BlendMode.srcATop:

View File

@ -132,17 +132,13 @@ class ShaderBuilder {
switch (variable.storage) {
case ShaderStorageQualifier.kConst:
_buffer.write('const ');
break;
case ShaderStorageQualifier.kAttribute:
_buffer.write(isWebGl2 ? 'in '
: _isFragmentShader ? 'varying ' : 'attribute ');
break;
case ShaderStorageQualifier.kUniform:
_buffer.write('uniform ');
break;
case ShaderStorageQualifier.kVarying:
_buffer.write(isWebGl2 ? 'out ' : 'varying ');
break;
}
_buffer.write('${typeToString(variable.dataType)} ${variable.name}');
if (variable.storage == ShaderStorageQualifier.kConst) {
@ -277,17 +273,14 @@ class ShaderMethod {
switch(tileMode) {
case ui.TileMode.repeated:
addStatement('float $destination = fract($source);');
break;
case ui.TileMode.mirror:
addStatement('float $destination = ($source - 1.0);');
addStatement(
'$destination = '
'abs(($destination - 2.0 * floor($destination * 0.5)) - 1.0);');
break;
case ui.TileMode.clamp:
case ui.TileMode.decal:
addStatement('float $destination = $source;');
break;
}
}

View File

@ -500,15 +500,12 @@ class KeyboardConverter {
case ui.KeyEventType.down:
assert(lastLogicalRecord == null);
nextLogicalRecord = logicalKey();
break;
case ui.KeyEventType.up:
assert(lastLogicalRecord != null);
nextLogicalRecord = null;
break;
case ui.KeyEventType.repeat:
assert(lastLogicalRecord != null);
nextLogicalRecord = lastLogicalRecord;
break;
}
if (nextLogicalRecord == null) {
_pressingRecords.remove(physicalKey);

View File

@ -484,7 +484,6 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
// CanvasKit vs HTML before invoking this method.
replyToPlatformMessage(
callback, codec.encodeSuccessEnvelope(<bool>[true]));
break;
}
return;
@ -541,7 +540,6 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
ClipboardMessageHandler().getDataMethodCall(callback);
return;
}
break;
// Dispatched by the bindings to delay service worker initialization.
case 'flutter/service_worker':

View File

@ -437,11 +437,9 @@ mixin _WheelEventListenerMixin on _BaseAdapter {
_defaultScrollLineHeight ??= _computeDefaultScrollLineHeight();
deltaX *= _defaultScrollLineHeight!;
deltaY *= _defaultScrollLineHeight!;
break;
case domDeltaPage:
deltaX *= ui.window.physicalSize.width;
deltaY *= ui.window.physicalSize.height;
break;
case domDeltaPixel:
if (operatingSystem == OperatingSystem.macOs && (isSafari || isFirefox)) {
// Safari and Firefox seem to report delta in logical pixels while
@ -449,7 +447,6 @@ mixin _WheelEventListenerMixin on _BaseAdapter {
deltaX *= ui.window.devicePixelRatio;
deltaY *= ui.window.devicePixelRatio;
}
break;
default:
break;
}

View File

@ -281,7 +281,6 @@ class PointerDataConverter {
scale: scale,
)
);
break;
case ui.PointerChange.hover:
final bool alreadyAdded = _pointers.containsKey(device);
_ensureStateForPointer(device, physicalX, physicalY);
@ -347,7 +346,6 @@ class PointerDataConverter {
)
);
_activeButtons = buttons;
break;
case ui.PointerChange.down:
final bool alreadyAdded = _pointers.containsKey(device);
final _PointerState state = _ensureStateForPointer(
@ -448,7 +446,6 @@ class PointerDataConverter {
)
);
_activeButtons = buttons;
break;
case ui.PointerChange.move:
assert(_pointers.containsKey(device));
assert(isDown);
@ -482,7 +479,6 @@ class PointerDataConverter {
)
);
_activeButtons = buttons;
break;
case ui.PointerChange.up:
case ui.PointerChange.cancel:
assert(_pointers.containsKey(device));
@ -592,7 +588,6 @@ class PointerDataConverter {
);
_pointers.remove(device);
}
break;
case ui.PointerChange.remove:
assert(_pointers.containsKey(device));
final _PointerState state = _pointers[device]!;
@ -627,13 +622,11 @@ class PointerDataConverter {
)
);
_pointers.remove(device);
break;
case ui.PointerChange.panZoomStart:
case ui.PointerChange.panZoomUpdate:
case ui.PointerChange.panZoomEnd:
// Pointer pan/zoom events are not generated on web.
assert(false);
break;
}
} else {
switch (signalKind) {
@ -767,10 +760,8 @@ class PointerDataConverter {
scale: scale,
)
);
break;
case ui.PointerSignalKind.none:
assert(false); // This branch should already have 'none' filtered out.
break;
case ui.PointerSignalKind.unknown:
// Ignore unknown signals.
break;

View File

@ -62,13 +62,10 @@ class Checkable extends RoleManager {
switch (_kind) {
case _CheckableKind.checkbox:
semanticsObject.setAriaRole('checkbox', true);
break;
case _CheckableKind.radio:
semanticsObject.setAriaRole('radio', true);
break;
case _CheckableKind.toggle:
semanticsObject.setAriaRole('switch', true);
break;
}
/// Adding disabled and aria-disabled attribute to notify the assistive
@ -90,13 +87,10 @@ class Checkable extends RoleManager {
switch (_kind) {
case _CheckableKind.checkbox:
semanticsObject.setAriaRole('checkbox', false);
break;
case _CheckableKind.radio:
semanticsObject.setAriaRole('radio', false);
break;
case _CheckableKind.toggle:
semanticsObject.setAriaRole('switch', false);
break;
}
_removeDisabledAttribute();
}

View File

@ -80,10 +80,8 @@ class Incrementable extends RoleManager {
case GestureMode.browserGestures:
_enableBrowserGestureHandling();
_updateInputValues();
break;
case GestureMode.pointerEvents:
_disableBrowserGestureHandling();
break;
}
}

View File

@ -209,7 +209,6 @@ class Scrollable extends RoleManager {
assert(semanticsObject.isHorizontalScrollContainer);
element.style.overflowX = 'scroll';
}
break;
case GestureMode.pointerEvents:
// We use "hidden" instead of "scroll" so that the browser does
// not "steal" pointer events. Flutter gesture recognizers need
@ -220,7 +219,6 @@ class Scrollable extends RoleManager {
assert(semanticsObject.isHorizontalScrollContainer);
element.style.overflowX = 'hidden';
}
break;
}
}

View File

@ -327,17 +327,14 @@ class MobileSemanticsEnabler extends SemanticsEnabler {
case 'click':
final DomMouseEvent click = event as DomMouseEvent;
activationPoint = click.offset;
break;
case 'touchstart':
case 'touchend':
final DomTouchEvent touchEvent = event as DomTouchEvent;
activationPoint = touchEvent.changedTouches.first.client;
break;
case 'pointerdown':
case 'pointerup':
final DomPointerEvent touch = event as DomPointerEvent;
activationPoint = touch.client;
break;
default:
// The event is not relevant, forward to framework as normal.
return true;

View File

@ -286,10 +286,8 @@ class TextField extends RoleManager {
case BrowserEngine.blink:
case BrowserEngine.firefox:
_initializeForBlink();
break;
case BrowserEngine.webkit:
_initializeForWebkit();
break;
}
}

View File

@ -378,19 +378,14 @@ class StandardMessageCodec implements MessageCodec<dynamic> {
switch (type) {
case _valueNull:
result = null;
break;
case _valueTrue:
result = true;
break;
case _valueFalse:
result = false;
break;
case _valueInt32:
result = buffer.getInt32();
break;
case _valueInt64:
result = buffer.getInt64();
break;
case _valueLargeInt:
// Flutter Engine APIs to use large ints have been deprecated on
// 2018-01-09 and will be made unavailable.
@ -398,44 +393,35 @@ class StandardMessageCodec implements MessageCodec<dynamic> {
final int length = readSize(buffer);
final String hex = utf8.decoder.convert(buffer.getUint8List(length));
result = int.parse(hex, radix: 16);
break;
case _valueFloat64:
result = buffer.getFloat64();
break;
case _valueString:
final int length = readSize(buffer);
result = utf8.decoder.convert(buffer.getUint8List(length));
break;
case _valueUint8List:
final int length = readSize(buffer);
result = buffer.getUint8List(length);
break;
case _valueInt32List:
final int length = readSize(buffer);
result = buffer.getInt32List(length);
break;
case _valueInt64List:
final int length = readSize(buffer);
result = buffer.getInt64List(length);
break;
case _valueFloat64List:
final int length = readSize(buffer);
result = buffer.getFloat64List(length);
break;
case _valueList:
final int length = readSize(buffer);
result = <dynamic>[];
for (int i = 0; i < length; i++) {
result.add(readValue(buffer));
}
break;
case _valueMap:
final int length = readSize(buffer);
result = <dynamic, dynamic>{};
for (int i = 0; i < length; i++) {
result[readValue(buffer)] = readValue(buffer);
}
break;
default:
throw const FormatException('Message corrupted');
}

View File

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The web_sdk/sdk_rewriter.dart uses this directive.
// ignore: unnecessary_library_directive
library skwasm_impl;
export 'skwasm_impl/canvas.dart';

View File

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The web_sdk/sdk_rewriter.dart uses this directive.
// ignore: unnecessary_library_directive
library skwasm_stub;
export 'skwasm_stub/renderer.dart';

View File

@ -214,10 +214,8 @@ class CanvasParagraph implements ui.Paragraph {
switch (position.affinity) {
case ui.TextAffinity.upstream:
characterPosition = position.offset - 1;
break;
case ui.TextAffinity.downstream:
characterPosition = position.offset;
break;
}
final int start = WordBreaker.prevBreakIndex(plainText, characterPosition + 1);
final int end = WordBreaker.nextBreakIndex(plainText, characterPosition);

View File

@ -210,7 +210,6 @@ class TextLayoutService {
case LineBreakType.opportunity:
minIntrinsicWidth = math.max(minIntrinsicWidth, runningMinIntrinsicWidth);
runningMinIntrinsicWidth = 0;
break;
case LineBreakType.mandatory:
case LineBreakType.endOfText:
@ -218,7 +217,6 @@ class TextLayoutService {
maxIntrinsicWidth = math.max(maxIntrinsicWidth, runningMaxIntrinsicWidth);
runningMinIntrinsicWidth = 0;
runningMaxIntrinsicWidth = 0;
break;
}
}
}
@ -640,14 +638,12 @@ class LineBuilder {
// `descent` enough to fit the placeholder.
ascent = this.ascent;
descent = placeholder.height - this.ascent;
break;
case ui.PlaceholderAlignment.bottom:
// The opposite of `top`. The `descent` is the same, but we extend the
// `ascent`.
ascent = placeholder.height - this.descent;
descent = this.descent;
break;
case ui.PlaceholderAlignment.middle:
final double textMidPoint = height / 2;
@ -655,22 +651,18 @@ class LineBuilder {
final double diff = placeholderMidPoint - textMidPoint;
ascent = this.ascent + diff;
descent = this.descent + diff;
break;
case ui.PlaceholderAlignment.aboveBaseline:
ascent = placeholder.height;
descent = 0.0;
break;
case ui.PlaceholderAlignment.belowBaseline:
ascent = 0.0;
descent = placeholder.height;
break;
case ui.PlaceholderAlignment.baseline:
ascent = placeholder.baselineOffset;
descent = placeholder.height - ascent;
break;
}
// Update the metrics of the fragment to reflect the calculated ascent and

View File

@ -170,10 +170,8 @@ class UnicodePropertyLookup<P> {
switch (range.compare(value)) {
case _ComparisonResult.higher:
min = mid + 1;
break;
case _ComparisonResult.lower:
max = mid;
break;
case _ComparisonResult.inside:
return mid;
}

View File

@ -5,11 +5,11 @@
import '../util.dart';
import 'word_break_properties.dart';
class _FindBreakDirection {
const _FindBreakDirection({required this.step});
enum _FindBreakDirection {
forward(step: 1),
backward(step: -1);
static const _FindBreakDirection forward = _FindBreakDirection(step: 1);
static const _FindBreakDirection backward = _FindBreakDirection(step: -1);
const _FindBreakDirection({required this.step});
final int step;
}

View File

@ -69,13 +69,10 @@ class TextCapitalizationConfig {
} else {
autocapitalize = 'words';
}
break;
case TextCapitalization.characters:
autocapitalize = 'characters';
break;
case TextCapitalization.sentences:
autocapitalize = 'sentences';
break;
case TextCapitalization.none:
default:
autocapitalize = 'off';

View File

@ -2048,7 +2048,6 @@ class TextEditingChannel {
clientId: call.arguments[0] as int,
configuration: InputConfiguration.fromFrameworkMessage(call.arguments[1] as Map<String, dynamic>),
);
break;
case 'TextInput.updateConfig':
// Set configuration eagerly because it contains data about the text
@ -2058,7 +2057,6 @@ class TextEditingChannel {
call.arguments as Map<String, dynamic>
);
command = const TextInputUpdateConfig();
break;
case 'TextInput.setEditingState':
command = TextInputSetEditingState(
@ -2066,11 +2064,9 @@ class TextEditingChannel {
call.arguments as Map<String, dynamic>
),
);
break;
case 'TextInput.show':
command = const TextInputShow();
break;
case 'TextInput.setEditableSizeAndTransform':
command = TextInputSetEditableSizeAndTransform(
@ -2078,7 +2074,6 @@ class TextEditingChannel {
call.arguments as Map<String, dynamic>
),
);
break;
case 'TextInput.setStyle':
command = TextInputSetStyle(
@ -2086,36 +2081,29 @@ class TextEditingChannel {
call.arguments as Map<String, dynamic>,
),
);
break;
case 'TextInput.clearClient':
command = const TextInputClearClient();
break;
case 'TextInput.hide':
command = const TextInputHide();
break;
case 'TextInput.requestAutofill':
// There's no API to request autofill on the web. Instead we let the
// browser show autofill options automatically, if available. We
// therefore simply ignore this message.
command = const TextInputRequestAutofill();
break;
case 'TextInput.finishAutofillContext':
command = TextInputFinishAutofillContext(
saveForm: call.arguments as bool,
);
break;
case 'TextInput.setMarkedTextRect':
command = const TextInputSetMarkedTextRect();
break;
case 'TextInput.setCaretRect':
command = const TextInputSetCaretRect();
break;
default:
EnginePlatformDispatcher.instance.replyToPlatformMessage(callback, null);

View File

@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library util;
import 'dart:async';
import 'dart:math' as math;

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('chrome || safari || firefox')
library;
import 'dart:async';

View File

@ -255,53 +255,38 @@ String canonicalizeHtml(
switch (replacementTag) {
case 'flt-scene':
replacementTag = 's';
break;
case 'flt-transform':
replacementTag = 't';
break;
case 'flt-opacity':
replacementTag = 'o';
break;
case 'flt-clip':
final String? clipType = original.attributes['clip-type'];
switch (clipType) {
case 'rect':
replacementTag = 'clip';
break;
case 'rrect':
replacementTag = 'rclip';
break;
case 'physical-shape':
replacementTag = 'pshape';
break;
default:
throw Exception('Unknown clip type: $clipType');
}
break;
case 'flt-clip-interior':
replacementTag = 'clip-i';
break;
case 'flt-picture':
replacementTag = 'pic';
break;
case 'flt-canvas':
replacementTag = 'c';
break;
case 'flt-dom-canvas':
replacementTag = 'd';
break;
case 'flt-semantics':
replacementTag = 'sem';
break;
case 'flt-semantics-container':
replacementTag = 'sem-c';
break;
case 'flt-semantics-img':
replacementTag = 'sem-img';
break;
case 'flt-semantics-text-field':
replacementTag = 'sem-tf';
break;
}
final html_package.Element replacement =

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('browser')
library;
import 'dart:js_util';

View File

@ -126,13 +126,10 @@ void testMain() {
switch (counter) {
case 0:
expect(drainedData, equals(two));
break;
case 1:
expect(drainedData, equals(three));
break;
case 2:
expect(drainedData, equals(four));
break;
}
counter += 1;
return Future<void>.value();

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('browser')
library;
import 'package:js/js_util.dart' as js_util;

View File

@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@TestOn('!safari')
// TODO(mdebbar): https://github.com/flutter/flutter/issues/51169
@TestOn('!safari')
library;
import 'dart:async';

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('chrome || safari || firefox')
library;
import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('chrome || safari || firefox')
library;
import 'dart:async';
import 'dart:typed_data';

View File

@ -3,6 +3,8 @@
// found in the LICENSE file.
@TestOn('chrome || safari || firefox')
library;
import 'dart:typed_data';
import 'package:test/bootstrap/browser.dart';

View File

@ -113,19 +113,15 @@ void testMain() {
switch (index % 13) {
case 0:
path.lineTo(nonFinitePts[i].dx, nonFinitePts[i].dy);
break;
case 1:
path.quadraticBezierTo(nonFinitePts[i].dx, nonFinitePts[i].dy,
nonFinitePts[i].dx, nonFinitePts[i].dy);
break;
case 2:
path.quadraticBezierTo(nonFinitePts[i].dx, nonFinitePts[i].dy,
axisAlignedPts[f].dx, axisAlignedPts[f].dy);
break;
case 3:
path.quadraticBezierTo(axisAlignedPts[f].dx, axisAlignedPts[f].dy,
nonFinitePts[i].dx, nonFinitePts[i].dy);
break;
case 4:
path.cubicTo(
nonFinitePts[i].dx,
@ -134,7 +130,6 @@ void testMain() {
axisAlignedPts[f].dy,
axisAlignedPts[f].dx,
axisAlignedPts[f].dy);
break;
case 5:
path.cubicTo(
axisAlignedPts[f].dx,
@ -143,7 +138,6 @@ void testMain() {
nonFinitePts[i].dy,
axisAlignedPts[f].dx,
axisAlignedPts[f].dy);
break;
case 6:
path.cubicTo(
axisAlignedPts[f].dx,
@ -152,7 +146,6 @@ void testMain() {
axisAlignedPts[f].dy,
nonFinitePts[i].dx,
nonFinitePts[i].dy);
break;
case 7:
path.cubicTo(
nonFinitePts[i].dx,
@ -161,7 +154,6 @@ void testMain() {
nonFinitePts[i].dy,
axisAlignedPts[f].dx,
axisAlignedPts[f].dy);
break;
case 8:
path.cubicTo(
nonFinitePts[i].dx,
@ -170,7 +162,6 @@ void testMain() {
axisAlignedPts[f].dy,
nonFinitePts[i].dx,
nonFinitePts[i].dy);
break;
case 9:
path.cubicTo(
axisAlignedPts[f].dx,
@ -179,7 +170,6 @@ void testMain() {
nonFinitePts[i].dy,
nonFinitePts[i].dx,
nonFinitePts[i].dy);
break;
case 10:
path.cubicTo(
nonFinitePts[i].dx,
@ -188,7 +178,6 @@ void testMain() {
nonFinitePts[i].dy,
nonFinitePts[i].dx,
nonFinitePts[i].dy);
break;
case 11:
path.cubicTo(
nonFinitePts[i].dx,
@ -197,10 +186,8 @@ void testMain() {
axisAlignedPts[f].dy,
axisAlignedPts[g].dx,
axisAlignedPts[g].dy);
break;
case 12:
path.moveTo(nonFinitePts[i].dx, nonFinitePts[i].dy);
break;
}
expect(path.convexityType, SPathConvexityType.kUnknown);
}
@ -213,22 +200,17 @@ void testMain() {
switch (curveSelect) {
case 0:
path.moveTo(axisAlignedPts[f].dx, axisAlignedPts[f].dy);
break;
case 1:
path.lineTo(axisAlignedPts[f].dx, axisAlignedPts[f].dy);
break;
case 2:
path.quadraticBezierTo(axisAlignedPts[f].dx, axisAlignedPts[f].dy,
axisAlignedPts[f].dx, axisAlignedPts[f].dy);
break;
case 3:
path.quadraticBezierTo(axisAlignedPts[f].dx, axisAlignedPts[f].dy,
axisAlignedPts[g].dx, axisAlignedPts[g].dy);
break;
case 4:
path.quadraticBezierTo(axisAlignedPts[g].dx, axisAlignedPts[g].dy,
axisAlignedPts[f].dx, axisAlignedPts[f].dy);
break;
case 5:
path.cubicTo(
axisAlignedPts[f].dx,
@ -237,7 +219,6 @@ void testMain() {
axisAlignedPts[f].dy,
axisAlignedPts[f].dx,
axisAlignedPts[f].dy);
break;
case 6:
path.cubicTo(
axisAlignedPts[f].dx,
@ -246,7 +227,6 @@ void testMain() {
axisAlignedPts[f].dy,
axisAlignedPts[g].dx,
axisAlignedPts[g].dy);
break;
case 7:
path.cubicTo(
axisAlignedPts[f].dx,
@ -255,7 +235,6 @@ void testMain() {
axisAlignedPts[g].dy,
axisAlignedPts[f].dx,
axisAlignedPts[f].dy);
break;
case 8:
path.cubicTo(
axisAlignedPts[f].dx,
@ -264,7 +243,6 @@ void testMain() {
axisAlignedPts[g].dy,
axisAlignedPts[g].dx,
axisAlignedPts[g].dy);
break;
case 9:
path.cubicTo(
axisAlignedPts[g].dx,
@ -273,7 +251,6 @@ void testMain() {
axisAlignedPts[f].dy,
axisAlignedPts[f].dx,
axisAlignedPts[f].dy);
break;
case 10:
path.cubicTo(
axisAlignedPts[g].dx,
@ -282,7 +259,6 @@ void testMain() {
axisAlignedPts[f].dy,
axisAlignedPts[g].dx,
axisAlignedPts[g].dy);
break;
}
if (curveSelect != 7 && curveSelect != 10) {
final int result = path.convexityType;

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('chrome || firefox')
library;
import 'dart:async';
import 'dart:js_interop';

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('browser')
library;
import 'dart:async';

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('browser')
library;
import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('browser')
library;
import 'dart:async';

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('browser')
library;
import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('browser')
library;
import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('browser')
library;
import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('browser')
library;
import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
@TestOn('chrome || safari || firefox')
library;
import 'dart:async';

View File

@ -111,13 +111,10 @@ void main() {
switch (counter) {
case 0:
expect(drainedData, equals(two));
break;
case 1:
expect(drainedData, equals(three));
break;
case 2:
expect(drainedData, equals(four));
break;
}
counter += 1;
});

View File

@ -110,12 +110,10 @@ void main() {
break;
case kCloseCode:
receivePort.close();
break;
case kDeletedCode:
expect(IsolateNameServer.lookupPortByName(portName), isNull);
// Test is done, close the last ReceivePort.
testReceivePort.close();
break;
case kErrorCode:
throw message;
default:

View File

@ -38,7 +38,6 @@ void _handleDriverMessage(Map<String, dynamic> call) {
case 'set_scenario':
assert(call['args'] != null);
loadScenario(call['args'] as Map<String, dynamic>, _view);
break;
default:
throw 'Unimplemented method: $methodName.';
}
@ -55,11 +54,9 @@ Future<void> _handlePlatformMessage(
switch (name) {
case 'driver':
_handleDriverMessage(json.decode(utf8.decode(data!.buffer.asUint8List())) as Map<String, dynamic>);
break;
case 'write_timeline':
final String timelineData = await _getTimelineData();
callback!(Uint8List.fromList(utf8.encode(timelineData)).buffer.asByteData());
break;
default:
currentScenario?.onPlatformMessage(name, data, callback);
}

View File

@ -299,24 +299,19 @@ class ClangTidy {
switch (action) {
case LintAction.skipNoLint:
_outSink.writeln('🔷 ignoring $relativePath (FLUTTER_NOLINT)');
break;
case LintAction.failMalformedNoLint:
_errSink.writeln('❌ malformed opt-out $relativePath');
_errSink.writeln(
' Required format: // FLUTTER_NOLINT: $issueUrlPrefix/ISSUE_ID',
);
sawMalformed = true;
break;
case LintAction.lint:
_outSink.writeln('🔶 linting $relativePath');
jobs.add(command.createLintJob(options));
break;
case LintAction.skipThirdParty:
_outSink.writeln('🔷 ignoring $relativePath (third_party)');
break;
case LintAction.skipMissing:
_outSink.writeln('🔷 ignoring $relativePath (missing)');
break;
}
}
return _ComputeJobsResult(jobs, sawMalformed);

View File

@ -524,13 +524,13 @@ class FileSystemDirectory extends IoNode implements Directory {
final io.File fileEntity = entity as io.File;
if (fileEntity.lengthSync() > 0) {
switch (identifyFile(fileEntity.path, () => _readBytes(fileEntity))) {
case FileType.binary: yield FileSystemFile(fileEntity); break;
case FileType.zip: yield FileSystemZipFile(fileEntity); break;
case FileType.tar: yield FileSystemTarFile(fileEntity); break;
case FileType.gz: yield FileSystemGZipFile(fileEntity); break;
case FileType.bzip2: yield FileSystemBZip2File(fileEntity); break;
case FileType.text: yield FileSystemUTF8TextFile(fileEntity); break;
case FileType.latin1Text: yield FileSystemLatin1TextFile(fileEntity); break;
case FileType.binary: yield FileSystemFile(fileEntity);
case FileType.zip: yield FileSystemZipFile(fileEntity);
case FileType.tar: yield FileSystemTarFile(fileEntity);
case FileType.gz: yield FileSystemGZipFile(fileEntity);
case FileType.bzip2: yield FileSystemBZip2File(fileEntity);
case FileType.text: yield FileSystemUTF8TextFile(fileEntity);
case FileType.latin1Text: yield FileSystemLatin1TextFile(fileEntity);
case FileType.notPartOfBuild: break; // ignore this file
}
}
@ -618,13 +618,13 @@ class ArchiveDirectory extends IoNode implements Directory {
if (entry.size > 0) {
final String entryFullName = '$fullName/${path.basename(entry.name)}';
switch (identifyFile(entry.name, () => entry.content as List<int>)) {
case FileType.binary: _files.add(ArchiveFile(entryFullName, entry)); break;
case FileType.zip: _files.add(ArchiveZipFile(entryFullName, entry)); break;
case FileType.tar: _files.add(ArchiveTarFile(entryFullName, entry)); break;
case FileType.gz: _files.add(ArchiveGZipFile(entryFullName, entry)); break;
case FileType.bzip2: _files.add(ArchiveBZip2File(entryFullName, entry)); break;
case FileType.text: _files.add(ArchiveUTF8TextFile(entryFullName, entry)); break;
case FileType.latin1Text: _files.add(ArchiveLatin1TextFile(entryFullName, entry)); break;
case FileType.binary: _files.add(ArchiveFile(entryFullName, entry));
case FileType.zip: _files.add(ArchiveZipFile(entryFullName, entry));
case FileType.tar: _files.add(ArchiveTarFile(entryFullName, entry));
case FileType.gz: _files.add(ArchiveGZipFile(entryFullName, entry));
case FileType.bzip2: _files.add(ArchiveBZip2File(entryFullName, entry));
case FileType.text: _files.add(ArchiveUTF8TextFile(entryFullName, entry));
case FileType.latin1Text: _files.add(ArchiveLatin1TextFile(entryFullName, entry));
case FileType.notPartOfBuild: break; // ignore this file
}
}

View File

@ -344,7 +344,6 @@ abstract class License {
case LicenseType.bsd:
case LicenseType.mit:
result = TemplateLicense._autosplit(body, type, origin: origin);
break;
case LicenseType.apache:
case LicenseType.freetype:
case LicenseType.ijg:
@ -356,19 +355,15 @@ abstract class License {
case LicenseType.vulkan:
case LicenseType.zlib:
result = MessageLicense._(body, type, origin: origin);
break;
case LicenseType.apacheNotice:
result = UniqueLicense._(body, type, origin: origin);
break;
case LicenseType.mpl:
result = MozillaLicense._(body, type, origin: origin);
break;
// The exception in the license of Bison allows redistributing larger
// works "under terms of your choice"; we choose terms that don't require
// any notice in the binary distribution.
case LicenseType.bison:
result = BlankLicense._(body, type, origin: origin);
break;
case LicenseType.icu:
case LicenseType.openssl:
throw 'Use License.fromMultipleBlocks rather than License.fromBodyAndType for the ICU and OpenSSL licenses.';
@ -378,7 +373,6 @@ abstract class License {
case LicenseType.gpl:
case LicenseType.lgpl:
result = DisallowedLicense._(body, type, origin: origin);
break;
case LicenseType.defaultTemplate:
throw 'should not be creating a LicenseType.defaultTemplate license, it is not a real type';
}
@ -423,62 +417,49 @@ abstract class License {
// https://github.com/abseil/abseil-cpp/pull/270/files#r793181143
body = system.File('data/apache-license-2.0').readAsStringSync();
type = LicenseType.apache;
break;
case 'Apache-2.0 WITH LLVM-exception': // SPDX ID
case 'https://llvm.org/LICENSE.txt':
body = system.File('data/apache-license-2.0-with-llvm-exception').readAsStringSync();
type = LicenseType.llvm;
break;
case 'https://developers.google.com/open-source/licenses/bsd':
body = system.File('data/google-bsd').readAsStringSync();
type = LicenseType.bsd;
break;
case 'http://polymer.github.io/LICENSE.txt':
body = system.File('data/polymer-bsd').readAsStringSync();
type = LicenseType.bsd;
break;
case 'http://www.eclipse.org/legal/epl-v10.html':
body = system.File('data/eclipse-1.0').readAsStringSync();
type = LicenseType.eclipse;
break;
case 'COPYING3:3':
body = system.File('data/gpl-3.0').readAsStringSync();
type = LicenseType.gpl;
break;
case 'COPYING.LIB:2':
case 'COPYING.LIother.m_:2': // blame hyatt
body = system.File('data/library-gpl-2.0').readAsStringSync();
type = LicenseType.lgpl;
break;
case 'GNU Lesser:2':
// there has never been such a license, but the authors said they meant the LGPL2.1
case 'GNU Lesser:2.1':
body = system.File('data/lesser-gpl-2.1').readAsStringSync();
type = LicenseType.lgpl;
break;
case 'COPYING.RUNTIME:3.1':
case 'GCC Runtime Library Exception:3.1':
body = system.File('data/gpl-gcc-exception-3.1').readAsStringSync();
break;
case 'Academic Free License:3.0':
body = system.File('data/academic-3.0').readAsStringSync();
type = LicenseType.afl;
break;
case 'Mozilla Public License:1.1':
body = system.File('data/mozilla-1.1').readAsStringSync();
type = LicenseType.mpl;
break;
case 'http://mozilla.org/MPL/2.0/:2.0':
body = system.File('data/mozilla-2.0').readAsStringSync();
type = LicenseType.mpl;
break;
case 'MIT': // SPDX ID
case 'http://opensource->org/licenses/MIT': // i don't even
case 'http://opensource.org/licenses/MIT':
case 'https://opensource.org/licenses/MIT':
body = system.File('data/mit').readAsStringSync();
type = LicenseType.mit;
break;
case 'Unicode-DFS-2016': // SPDX ID
case 'http://unicode.org/copyright.html#Exhibit1':
case 'http://www.unicode.org/copyright.html#License':
@ -488,11 +469,9 @@ abstract class License {
case 'https://www.unicode.org/terms_of_use.html': // redirects to copyright.html
body = system.File('data/unicode').readAsStringSync();
type = LicenseType.unicode;
break;
case 'http://www.ietf.org/rfc/rfc3454.txt':
body = system.File('data/ietf').readAsStringSync();
type = LicenseType.ietf;
break;
default: throw 'unknown identifyingReference $identifyingReference';
}
return License.fromBodyAndType(body, type, origin: '$identifyingReference referenced by $referencer');
@ -513,7 +492,6 @@ abstract class License {
case LicenseType.lgpl:
// We do not want this kind of license in our build.
assert(this is DisallowedLicense);
break;
case LicenseType.apache:
case LicenseType.freetype:
case LicenseType.ijg:
@ -524,30 +502,22 @@ abstract class License {
case LicenseType.vulkan:
case LicenseType.zlib:
assert(this is MessageLicense);
break;
case LicenseType.apacheNotice:
assert(this is UniqueLicense);
break;
case LicenseType.bison:
assert(this is BlankLicense);
break;
case LicenseType.bsd:
case LicenseType.mit:
assert(this is TemplateLicense);
break;
case LicenseType.icu:
case LicenseType.openssl:
assert(this is MultiLicense);
break;
case LicenseType.mpl:
assert(this is MozillaLicense);
break;
case LicenseType.unknown:
assert(this is MessageLicense || this is UniqueLicense);
break;
case LicenseType.defaultTemplate:
assert(false, 'should not be creating LicenseType.defaultTemplate license');
break;
}
} on AssertionError {
throw 'incorrectly created a $runtimeType for a $type';

View File

@ -171,16 +171,12 @@ class Path implements PathProxy {
switch (verb) {
case PathVerb.moveTo:
proxy.moveTo(points[index++], points[index++]);
break;
case PathVerb.lineTo:
proxy.lineTo(points[index++], points[index++]);
break;
case PathVerb._quadTo:
assert(false);
break;
case PathVerb._conicTo:
assert(false);
break;
case PathVerb.cubicTo:
proxy.cubicTo(
points[index++],
@ -190,10 +186,8 @@ class Path implements PathProxy {
points[index++],
points[index++],
);
break;
case PathVerb.close:
proxy.close();
break;
}
}
assert(index == points.length);

View File

@ -4,13 +4,13 @@
// ignore_for_file: avoid_print
/// Checks that JavaScript API is accessed properly.
///
/// JavaScript access needs to be audited to make sure it follows security best
/// practices. To do that, all JavaScript access is consolidated into a small
/// number of libraries that change infrequently. These libraries are manually
/// audited on every change. All other code accesses JavaScript through these
/// libraries and does not require audit.
// Checks that JavaScript API is accessed properly.
//
// JavaScript access needs to be audited to make sure it follows security best
// practices. To do that, all JavaScript access is consolidated into a small
// number of libraries that change infrequently. These libraries are manually
// audited on every change. All other code accesses JavaScript through these
// libraries and does not require audit.
import 'dart:io';