Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions lib/web_ui/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ analyzer:

linter:
rules:
always_declare_return_types: true
always_put_control_body_on_new_line: true
always_specify_types: false
annotate_overrides: false
avoid_classes_with_only_static_members: false
Expand Down Expand Up @@ -88,14 +86,8 @@ linter:
prefer_final_in_for_each: false
avoid_single_cascade_in_expression_statements: false
unnecessary_string_interpolations: false
unnecessary_string_escapes: false
cast_nullable_to_non_nullable: false
flutter_style_todos: false
avoid_unused_constructor_parameters: false
avoid_void_async: false
prefer_if_elements_to_conditional_expressions: false
unnecessary_await_in_return: false
avoid_bool_literals_in_conditional_expressions: false
unnecessary_statements: false
# We have some legitimate use-cases for this (preserve tear-off identity)
prefer_function_declarations_over_variables: false
4 changes: 2 additions & 2 deletions lib/web_ui/dev/edge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'edge_installation.dart';
class EdgeEnvironment implements BrowserEnvironment {
@override
Browser launchBrowserInstance(Uri url, {bool debug = false}) {
return Edge(url, debug: debug);
return Edge(url);
}

@override
Expand Down Expand Up @@ -46,7 +46,7 @@ class Edge extends Browser {

/// Starts a new instance of Safari open to the given [url], which may be a
/// [Uri] or a [String].
factory Edge(Uri url, {bool debug = false}) {
factory Edge(Uri url) {
final String version = EdgeArgParser.instance.version;

return Edge._(() async {
Expand Down
5 changes: 3 additions & 2 deletions lib/web_ui/dev/firefox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ user_pref("dom.max_script_run_time", 0);
'--headless',
'-width $kMaxScreenshotWidth',
'-height $kMaxScreenshotHeight',
isMac ? '--new-window' : '-new-window',
isMac ? '--new-instance' : '-new-instance',
// On Mac Firefox uses the -- option prefix, while elsewhere it uses the - prefix.
'${isMac ? '-' : ''}-new-window',
'${isMac ? '-' : ''}-new-instance',
'--start-debugger-server $kDevtoolsPort',
];

Expand Down
4 changes: 2 additions & 2 deletions lib/web_ui/dev/firefox_installer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ Future<String> _findSystemFirefoxExecutable() async {

/// Fetches the latest available Firefox build version on Linux.
Future<String> fetchLatestFirefoxVersionLinux() async {
final RegExp forFirefoxVersion = RegExp("firefox-[0-9.]\+[0-9]");
final RegExp forFirefoxVersion = RegExp("firefox-[0-9.]+[0-9]");
final io.HttpClientRequest request = await io.HttpClient()
.getUrl(Uri.parse(PlatformBinding.instance.getFirefoxLatestVersionUrl()));
request.followRedirects = false;
Expand All @@ -333,7 +333,7 @@ Future<String> fetchLatestFirefoxVersionLinux() async {

/// Fetches the latest available Firefox build version on Mac OS.
Future<String> fetchLatestFirefoxVersionMacOS() async {
final RegExp forFirefoxVersion = RegExp("firefox\/releases\/[0-9.]\+[0-9]");
final RegExp forFirefoxVersion = RegExp("firefox/releases/[0-9.]+[0-9]");
final io.HttpClientRequest request = await io.HttpClient()
.getUrl(Uri.parse(PlatformBinding.instance.getFirefoxLatestVersionUrl()));
request.followRedirects = false;
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/dev/safari_installation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SafariArgParser extends BrowserArgParser {
_version = argResults['safari-version'] as String;
assert(_version == 'system');
final String browser = argResults['browser'] as String;
_isMobileBrowser = browser == 'ios-safari' ? true : false;
_isMobileBrowser = (browser == 'ios-safari');
}

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/dev/test_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ class BrowserManager {
sink.close();
}));

return await _pool.withResource<RunnerSuite>(() async {
return _pool.withResource<RunnerSuite>(() async {
_channel.sink.add({
'command': 'loadSuite',
'url': url.toString(),
Expand Down
5 changes: 2 additions & 3 deletions lib/web_ui/lib/src/engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,8 @@ void initializeEngine() {

_engineInitialized = true;

// Calling this getter to force the DOM renderer to initialize before we
// initialize framework bindings.
domRenderer;
// Initialize the DomRenderer before initializing framework bindings.
ensureDomRendererInitialized();

WebExperiments.ensureInitialized();

Expand Down
6 changes: 2 additions & 4 deletions lib/web_ui/lib/src/engine/canvaskit/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -859,11 +859,9 @@ class CkParagraphBuilder implements ui.ParagraphBuilder {
ui.TextBaseline? baseline,
}) {
// Require a baseline to be specified if using a baseline-based alignment.
assert((alignment == ui.PlaceholderAlignment.aboveBaseline ||
assert(!(alignment == ui.PlaceholderAlignment.aboveBaseline ||
alignment == ui.PlaceholderAlignment.belowBaseline ||
alignment == ui.PlaceholderAlignment.baseline)
? baseline != null
: true);
alignment == ui.PlaceholderAlignment.baseline) || baseline != null);

_placeholderCount++;
_placeholderScales.add(scale);
Expand Down
9 changes: 5 additions & 4 deletions lib/web_ui/lib/src/engine/dom_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,9 @@ Frame statistics:
}
}

// TODO(yjbanov): Replace this with an explicit initialization function. The
// lazy initialization of statics makes it very unpredictable, as
// the constructor has side-effects.
/// Singleton DOM renderer.
final DomRenderer domRenderer = DomRenderer();
DomRenderer get domRenderer => ensureDomRendererInitialized();

/// Initializes the [DomRenderer], if it's not already initialized.
DomRenderer ensureDomRendererInitialized() => _domRenderer ??= DomRenderer();
DomRenderer? _domRenderer;
4 changes: 1 addition & 3 deletions lib/web_ui/lib/src/engine/html/path/path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ class SurfacePath implements ui.Path {
/// and last point.
bool get isLastContourClosed {
int verbCount = pathRef.countVerbs();
return verbCount == 0
? false
: (pathRef.atVerb(verbCount - 1) == SPathVerb.kClose);
return verbCount > 0 && (pathRef.atVerb(verbCount - 1) == SPathVerb.kClose);
}

/// Returns true for finite SkPoint array values between negative SK_ScalarMax
Expand Down
4 changes: 2 additions & 2 deletions lib/web_ui/lib/src/engine/html/shaders/image_shader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class EngineImageShader implements ui.ImageShader {
}
js_util.callMethod(renderContext, 'drawImage', <dynamic>[
image.imgElement,
x == 0 ? 0 : -2 * imageWidth,
y == 0 ? 0 : -2 * imageHeight
if (x == 0) 0 else -2 * imageWidth,
if (y == 0) 0 else -2 * imageHeight,
]);
if (flipX != 1 || flipY != 1) {
/// Restore transform. This is faster than save/restore on context.
Expand Down
6 changes: 2 additions & 4 deletions lib/web_ui/lib/src/engine/text/canvas_paragraph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -671,11 +671,9 @@ class CanvasParagraphBuilder implements ui.ParagraphBuilder {
// - https://github.com/flutter/engine/blob/c0f7e8acf9318d264ad6a235facd097de597ffcc/third_party/txt/src/txt/paragraph_txt.cc#L325-L350

// Require a baseline to be specified if using a baseline-based alignment.
assert((alignment == ui.PlaceholderAlignment.aboveBaseline ||
assert(!(alignment == ui.PlaceholderAlignment.aboveBaseline ||
alignment == ui.PlaceholderAlignment.belowBaseline ||
alignment == ui.PlaceholderAlignment.baseline)
? baseline != null
: true);
alignment == ui.PlaceholderAlignment.baseline) || baseline != null);

_placeholderCount++;
_placeholderScales.add(scale);
Expand Down
24 changes: 18 additions & 6 deletions lib/web_ui/lib/src/engine/text/line_break_properties.dart

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions lib/web_ui/lib/src/engine/text/paragraph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1278,11 +1278,9 @@ class DomParagraphBuilder implements ui.ParagraphBuilder {
ui.TextBaseline? baseline,
}) {
// Require a baseline to be specified if using a baseline-based alignment.
assert((alignment == ui.PlaceholderAlignment.aboveBaseline ||
assert(!(alignment == ui.PlaceholderAlignment.aboveBaseline ||
alignment == ui.PlaceholderAlignment.belowBaseline ||
alignment == ui.PlaceholderAlignment.baseline)
? baseline != null
: true);
alignment == ui.PlaceholderAlignment.baseline) || baseline != null);

_placeholderCount++;
_placeholderScales.add(scale);
Expand Down
10 changes: 3 additions & 7 deletions lib/web_ui/lib/src/engine/text_editing/text_editing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ class EngineAutofillForm {

void handleChange(html.Element domElement, AutofillInfo autofillInfo) {
EditingState newEditingState = EditingState.fromDomElement(
domElement as html.HtmlElement?,
textCapitalization: autofillInfo.textCapitalization);
domElement as html.HtmlElement?);

_sendAutofillEditingState(autofillInfo.uniqueIdentifier, newEditingState);
}
Expand Down Expand Up @@ -439,9 +438,7 @@ class EditingState {
///
/// [domElement] can be a [InputElement] or a [TextAreaElement] depending on
/// the [InputType] of the text field.
factory EditingState.fromDomElement(html.HtmlElement? domElement,
{TextCapitalizationConfig textCapitalization =
const TextCapitalizationConfig.defaultCapitalization()}) {
factory EditingState.fromDomElement(html.HtmlElement? domElement) {
if (domElement is html.InputElement) {
html.InputElement element = domElement;
return EditingState(
Expand Down Expand Up @@ -978,8 +975,7 @@ abstract class DefaultTextEditingStrategy implements TextEditingStrategy {
void handleChange(html.Event event) {
assert(isEnabled);

EditingState newEditingState = EditingState.fromDomElement(activeDomElement,
textCapitalization: inputConfiguration.textCapitalization);
EditingState newEditingState = EditingState.fromDomElement(activeDomElement);

if (newEditingState != lastEditingState) {
lastEditingState = newEditingState;
Expand Down
7 changes: 4 additions & 3 deletions lib/web_ui/lib/src/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,9 @@ class ImageFilter {
return engine.EngineImageFilter.matrix(matrix: matrix4, filterQuality: filterQuality);
}

// TODO(flutter_web): add implementation and remove the "ignore".
// ignore: avoid_unused_constructor_parameters
ImageFilter.compose({required ImageFilter outer, required ImageFilter inner}) {
// TODO(flutter_web): add implementation.
throw UnimplementedError(
'ImageFilter.compose not implemented for web platform.');
}
Expand Down Expand Up @@ -770,14 +771,14 @@ class ImageDescriptor {
throw StateError('Object is disposed');
}
if (_width == null) {
return await instantiateImageCodec(
return instantiateImageCodec(
_data!,
targetWidth: targetWidth,
targetHeight: targetHeight,
allowUpscaling: false,
);
}

return await _createBmp(_data!, width, height, _rowBytes ?? width, _format!);
return _createBmp(_data!, width, height, _rowBytes ?? width, _format!);
}
}
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/ui/test_embedding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Future<void>? _platformInitializedFuture;

Future<void> webOnlyInitializeTestDomRenderer({double devicePixelRatio = 3.0}) {
// Force-initialize DomRenderer so it doesn't overwrite test pixel ratio.
engine.domRenderer;
engine.ensureDomRendererInitialized();

// The following parameters are hard-coded in Flutter's test embedder. Since
// we don't have an embedder yet this is the lowest-most layer we can put
Expand Down
5 changes: 2 additions & 3 deletions lib/web_ui/test/engine/pointer_binding_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';
import 'package:ui/src/engine.dart' show domRenderer, window;
import 'package:ui/src/engine/browser_detection.dart';
import 'package:ui/src/engine/dom_renderer.dart';
import 'package:ui/src/engine/pointer_binding.dart';
import 'package:ui/ui.dart' as ui;

Expand Down Expand Up @@ -49,9 +50,7 @@ void testMain() {
double dpi = 1.0;

setUp(() {
// Touching domRenderer creates PointerBinding.instance.
domRenderer;

ensureDomRendererInitialized();
ui.window.onPointerDataPacket = null;
dpi = window.devicePixelRatio;
});
Expand Down
3 changes: 1 addition & 2 deletions lib/web_ui/test/engine/window_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,7 @@ void testMain() {
localeChangedCount += 1;
};

// Cause DomRenderer to initialize itself.
domRenderer;
ensureDomRendererInitialized();

// We populate the initial list of locales automatically (only test that we
// got some locales; some contributors may be in different locales, so we
Expand Down
8 changes: 4 additions & 4 deletions lib/web_ui/test/text/font_collection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void testMain() {
expect(fontFamilyList, contains('/Ahem'));
} else {
expect(fontFamilyList.length, equals(1));
expect(fontFamilyList.first, '\"/Ahem\"');
expect(fontFamilyList.first, '"/Ahem"');
}
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/50770
Expand All @@ -129,7 +129,7 @@ void testMain() {
expect(fontFamilyList, contains('Ahem!!ahem'));
} else {
expect(fontFamilyList.length, equals(1));
expect(fontFamilyList.first, '\"Ahem!!ahem\"');
expect(fontFamilyList.first, '"Ahem!!ahem"');
}
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/50770
Expand All @@ -155,7 +155,7 @@ void testMain() {
expect(fontFamilyList, contains('Ahem ,ahem'));
} else {
expect(fontFamilyList.length, equals(1));
expect(fontFamilyList.first, '\"Ahem ,ahem\"');
expect(fontFamilyList.first, '"Ahem ,ahem"');
}
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/50770
Expand All @@ -182,7 +182,7 @@ void testMain() {
expect(fontFamilyList, contains('\'Ahem 1998\''));
} else {
expect(fontFamilyList.length, equals(1));
expect(fontFamilyList.first, '\"Ahem 1998\"');
expect(fontFamilyList.first, '"Ahem 1998"');
}
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/50770
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/test/text/word_breaker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void testMain() {
expectWords("Students' grades", <String>['Students', "'", ' ', 'grades']);
expectWords(
'Joe said: "I\'m here"',
<String>['Joe', ' ', 'said', ':', ' ', '"', "I\'m", ' ', 'here', '"'],
<String>['Joe', ' ', 'said', ':', ' ', '"', "I'm", ' ', 'here', '"'],
);
});

Expand Down