[web] Fix analyzer warnings in web engine. (flutter/engine#20825)

This commit is contained in:
Ferhat
2020-08-27 14:55:43 -07:00
committed by GitHub
parent b237cb1c9c
commit 5bb7ec6611
8 changed files with 33 additions and 33 deletions

View File

@@ -261,8 +261,8 @@ mixin _WheelEventListenerMixin on _BaseAdapter {
kind: ui.PointerDeviceKind.mouse,
signalKind: ui.PointerSignalKind.scroll,
device: _mouseDeviceId,
physicalX: event.client.x * ui.window.devicePixelRatio,
physicalY: event.client.y * ui.window.devicePixelRatio,
physicalX: event.client.x.toDouble() * ui.window.devicePixelRatio,
physicalY: event.client.y.toDouble() * ui.window.devicePixelRatio,
buttons: event.buttons!,
pressure: 1.0,
pressureMin: 0.0,
@@ -526,8 +526,8 @@ class _PointerAdapter extends _BaseAdapter with _WheelEventListenerMixin {
kind: kind,
signalKind: ui.PointerSignalKind.none,
device: device,
physicalX: event.client.x * ui.window.devicePixelRatio,
physicalY: event.client.y * ui.window.devicePixelRatio,
physicalX: event.client.x.toDouble() * ui.window.devicePixelRatio,
physicalY: event.client.y.toDouble() * ui.window.devicePixelRatio,
buttons: details.buttons,
pressure: event.pressure as double,
pressureMin: 0.0,
@@ -689,8 +689,8 @@ class _TouchAdapter extends _BaseAdapter {
kind: ui.PointerDeviceKind.touch,
signalKind: ui.PointerSignalKind.none,
device: touch.identifier!,
physicalX: touch.client.x * ui.window.devicePixelRatio,
physicalY: touch.client.y * ui.window.devicePixelRatio,
physicalX: touch.client.x.toDouble() * ui.window.devicePixelRatio,
physicalY: touch.client.y.toDouble() * ui.window.devicePixelRatio,
buttons: pressed ? _kPrimaryMouseButton : 0,
pressure: 1.0,
pressureMin: 0.0,
@@ -798,8 +798,8 @@ class _MouseAdapter extends _BaseAdapter with _WheelEventListenerMixin {
kind: ui.PointerDeviceKind.mouse,
signalKind: ui.PointerSignalKind.none,
device: _mouseDeviceId,
physicalX: event.client.x * ui.window.devicePixelRatio,
physicalY: event.client.y * ui.window.devicePixelRatio,
physicalX: event.client.x.toDouble() * ui.window.devicePixelRatio,
physicalY: event.client.y.toDouble() * ui.window.devicePixelRatio,
buttons: details.buttons,
pressure: 1.0,
pressureMin: 0.0,

View File

@@ -340,12 +340,12 @@ class MobileSemanticsEnabler extends SemanticsEnabler {
final html.Rectangle<num> activatingElementRect =
domRenderer.glassPaneElement!.getBoundingClientRect();
final double midX = activatingElementRect.left +
(activatingElementRect.right - activatingElementRect.left) / 2;
final double midY = activatingElementRect.top +
(activatingElementRect.bottom - activatingElementRect.top) / 2;
final double deltaX = activationPoint.x - midX;
final double deltaY = activationPoint.y - midY;
final double midX = (activatingElementRect.left +
(activatingElementRect.right - activatingElementRect.left) / 2).toDouble();
final double midY = (activatingElementRect.top +
(activatingElementRect.bottom - activatingElementRect.top) / 2).toDouble();
final double deltaX = activationPoint.x.toDouble() - midX;
final double deltaY = activationPoint.y.toDouble() - midY;
final double deltaSquared = deltaX * deltaX + deltaY * deltaY;
if (deltaSquared < 1.0) {
safariEnableConditionPassed = true;

View File

@@ -686,7 +686,7 @@ double _measureSubstring(
final double letterSpacing = style.letterSpacing ?? 0.0;
final String sub =
start == 0 && end == text.length ? text : text.substring(start, end);
final double width = _canvasContext.measureText(sub).width! +
final double width = _canvasContext.measureText(sub).width!.toDouble() +
letterSpacing * sub.length;
// What we are doing here is we are rounding to the nearest 2nd decimal

View File

@@ -1791,7 +1791,7 @@ String? textDirectionIndexToCss(int textDirectionIndex) {
/// ```css
/// text-align: right;
/// ```
String? textAlignToCssValue(ui.TextAlign? align, ui.TextDirection textDirection) {
String textAlignToCssValue(ui.TextAlign? align, ui.TextDirection textDirection) {
switch (align) {
case ui.TextAlign.left:
return 'left';
@@ -1808,13 +1808,16 @@ String? textAlignToCssValue(ui.TextAlign? align, ui.TextDirection textDirection)
case ui.TextDirection.rtl:
return 'left';
}
default: // including ui.TextAlign.start
case ui.TextAlign.start:
switch (textDirection) {
case ui.TextDirection.ltr:
return null; // it's the default
return ''; // it's the default
case ui.TextDirection.rtl:
return 'right';
}
case null:
// If align is not specified return default.
return '';
}
}

View File

@@ -794,9 +794,9 @@ class ParagraphRuler {
}
boxes.add(ui.TextBox.fromLTRBD(
rect.left + alignOffset,
rect.left.toDouble() + alignOffset,
rect.top as double,
rect.right + alignOffset,
rect.right.toDouble() + alignOffset,
rect.bottom as double,
textDirection,
));

View File

@@ -189,11 +189,8 @@ class EngineAutofillForm {
// If a form with the same Autofill elements is already on the dom, remove
// it from DOM.
if (formsOnTheDom[formIdentifier] != null) {
final html.FormElement form =
formsOnTheDom[formIdentifier] as html.FormElement;
form.remove();
}
html.FormElement? form = formsOnTheDom[formIdentifier];
form?.remove();
// In order to submit the form when Framework sends a `TextInput.commit`
// message, we add a submit button to the form.
@@ -243,7 +240,7 @@ class EngineAutofillForm {
throw StateError(
'Autofill would not work withuot Autofill value set');
} else {
final AutofillInfo autofillInfo = items![key] as AutofillInfo;
final AutofillInfo autofillInfo = items![key]!;
_handleChange(element, autofillInfo);
}
}));
@@ -774,7 +771,7 @@ abstract class DefaultTextEditingStrategy implements TextEditingStrategy {
inputConfig.autofill?.applyToDomElement(domElement, focusedElement: true);
final String autocorrectValue = inputConfig.autocorrect! ? 'on' : 'off';
final String autocorrectValue = inputConfig.autocorrect ? 'on' : 'off';
domElement.setAttribute('autocorrect', autocorrectValue);
_setStaticStyleAttributes(domElement);

View File

@@ -73,8 +73,8 @@ class EngineWindow extends ui.Window {
double windowInnerHeight;
final html.VisualViewport? viewport = html.window.visualViewport;
if (viewport != null) {
windowInnerWidth = viewport.width! * devicePixelRatio;
windowInnerHeight = viewport.height! * devicePixelRatio;
windowInnerWidth = viewport.width!.toDouble() * devicePixelRatio;
windowInnerHeight = viewport.height!.toDouble() * devicePixelRatio;
} else {
windowInnerWidth = html.window.innerWidth! * devicePixelRatio;
windowInnerHeight = html.window.innerHeight! * devicePixelRatio;
@@ -90,7 +90,7 @@ class EngineWindow extends ui.Window {
double windowInnerHeight;
final html.VisualViewport? viewport = html.window.visualViewport;
if (viewport != null) {
windowInnerHeight = viewport.height! * devicePixelRatio;
windowInnerHeight = viewport.height!.toDouble() * devicePixelRatio;
} else {
windowInnerHeight = html.window.innerHeight! * devicePixelRatio;
}
@@ -117,8 +117,8 @@ class EngineWindow extends ui.Window {
double height = 0;
double width = 0;
if (html.window.visualViewport != null) {
height = html.window.visualViewport!.height! * devicePixelRatio;
width = html.window.visualViewport!.width! * devicePixelRatio;
height = html.window.visualViewport!.height!.toDouble() * devicePixelRatio;
width = html.window.visualViewport!.width!.toDouble() * devicePixelRatio;
} else {
height = html.window.innerHeight! * devicePixelRatio;
width = html.window.innerWidth! * devicePixelRatio;

View File

@@ -11,7 +11,7 @@ double? lerpDouble(num? a, num? b, double t) {
}
a ??= 0.0;
b ??= 0.0;
return a + (b - a) * t;
return (a + (b - a) * t).toDouble();
}
double _lerpDouble(double a, double b, double t) {