forked from firka/flutter
[web] Cleanup assertionsEnabled (flutter/engine#41829)
For consistency with the rest of the flutter code, this PR explores the possibility of removing our proprietary `assertionsEnabled`.
This commit is contained in:
@@ -12,14 +12,14 @@ class DartPluginRegistrant {
|
||||
/// isolate. This can safely be executed multiple times on the same isolate,
|
||||
/// but should not be called on the Root isolate.
|
||||
static void ensureInitialized() {
|
||||
throw UnimplementedError('`ensureInitialized` is not implemented on the web.');
|
||||
throw UnimplementedError(
|
||||
'`ensureInitialized` is not implemented on the web.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<int> saveCompilationTrace() {
|
||||
if (engine.assertionsEnabled) {
|
||||
throw UnimplementedError('saveCompilationTrace is not implemented on the web.');
|
||||
}
|
||||
assert(
|
||||
throw UnimplementedError('saveCompilationTrace is not implemented on the web.'),
|
||||
);
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@@ -963,10 +963,12 @@ class ContextStateHandle {
|
||||
///
|
||||
/// [tearDownPaint] must be called after calling this method.
|
||||
void setUpPaint(SurfacePaintData paint, ui.Rect? shaderBounds) {
|
||||
if (assertionsEnabled) {
|
||||
assert(!_debugIsPaintSetUp);
|
||||
assert(() {
|
||||
final bool wasPaintSetUp = _debugIsPaintSetUp;
|
||||
_debugIsPaintSetUp = true;
|
||||
}
|
||||
// When setting up paint, the previous paint must be torn down.
|
||||
return !wasPaintSetUp;
|
||||
}());
|
||||
|
||||
_lastUsedPaint = paint;
|
||||
lineWidth = paint.strokeWidth ?? 1.0;
|
||||
@@ -1059,10 +1061,12 @@ class ContextStateHandle {
|
||||
///
|
||||
/// Must be called after calling [setUpPaint].
|
||||
void tearDownPaint() {
|
||||
if (assertionsEnabled) {
|
||||
assert(_debugIsPaintSetUp);
|
||||
assert(() {
|
||||
final bool wasPaintSetUp = _debugIsPaintSetUp;
|
||||
_debugIsPaintSetUp = false;
|
||||
}
|
||||
// When tearing down paint, we expect that it was set up before.
|
||||
return wasPaintSetUp;
|
||||
}());
|
||||
|
||||
final ui.MaskFilter? maskFilter = _lastUsedPaint?.maskFilter;
|
||||
if (maskFilter != null && _renderMaskFilterForWebkit) {
|
||||
|
||||
@@ -464,13 +464,19 @@ class HtmlViewEmbedder {
|
||||
}
|
||||
|
||||
for (final int viewId in diffResult.viewsToAdd) {
|
||||
if (assertionsEnabled) {
|
||||
if (!platformViewManager.knowsViewId(viewId)) {
|
||||
bool isViewInvalid = false;
|
||||
assert(() {
|
||||
isViewInvalid = !platformViewManager.knowsViewId(viewId);
|
||||
if (isViewInvalid) {
|
||||
debugInvalidViewIds ??= <int>[];
|
||||
debugInvalidViewIds.add(viewId);
|
||||
continue;
|
||||
debugInvalidViewIds!.add(viewId);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
if (isViewInvalid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (diffResult.addToBeginning) {
|
||||
final DomElement platformViewRoot = _viewClipChains[viewId]!.root;
|
||||
skiaSceneHost.insertBefore(platformViewRoot, elementToInsertBefore);
|
||||
@@ -511,12 +517,17 @@ class HtmlViewEmbedder {
|
||||
for (int i = 0; i < _compositionOrder.length; i++) {
|
||||
final int viewId = _compositionOrder[i];
|
||||
|
||||
if (assertionsEnabled) {
|
||||
if (!platformViewManager.knowsViewId(viewId)) {
|
||||
bool isViewInvalid = false;
|
||||
assert(() {
|
||||
isViewInvalid = !platformViewManager.knowsViewId(viewId);
|
||||
if (isViewInvalid) {
|
||||
debugInvalidViewIds ??= <int>[];
|
||||
debugInvalidViewIds.add(viewId);
|
||||
continue;
|
||||
debugInvalidViewIds!.add(viewId);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
if (isViewInvalid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final DomElement platformViewRoot = _viewClipChains[viewId]!.root;
|
||||
@@ -534,14 +545,11 @@ class HtmlViewEmbedder {
|
||||
|
||||
disposeViews(unusedViews);
|
||||
|
||||
if (assertionsEnabled) {
|
||||
if (debugInvalidViewIds != null && debugInvalidViewIds.isNotEmpty) {
|
||||
throw AssertionError(
|
||||
'Cannot render platform views: ${debugInvalidViewIds.join(', ')}. '
|
||||
'These views have not been created, or they have been deleted.',
|
||||
);
|
||||
}
|
||||
}
|
||||
assert(
|
||||
debugInvalidViewIds == null || debugInvalidViewIds!.isEmpty,
|
||||
'Cannot render platform views: ${debugInvalidViewIds!.join(', ')}. '
|
||||
'These views have not been created, or they have been deleted.',
|
||||
);
|
||||
}
|
||||
|
||||
void disposeViews(Set<int> viewsToDispose) {
|
||||
|
||||
@@ -36,10 +36,12 @@ class SkiaFontCollection implements FlutterFontCollection {
|
||||
///
|
||||
/// This should only be used in tests.
|
||||
List<RegisteredFont>? get debugRegisteredFonts {
|
||||
if (!assertionsEnabled) {
|
||||
return null;
|
||||
}
|
||||
return _registeredFonts;
|
||||
List<RegisteredFont>? result;
|
||||
assert(() {
|
||||
result = _registeredFonts;
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
|
||||
final Map<String, List<SkFont>> familyToFontMap = <String, List<SkFont>>{};
|
||||
|
||||
@@ -226,9 +226,10 @@ class CkImage implements ui.Image, StackTraceDebugger {
|
||||
}
|
||||
|
||||
void _init() {
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
_debugStackTrace = StackTrace.current;
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
ui.Image.onCreate?.call(this);
|
||||
}
|
||||
|
||||
@@ -274,9 +275,16 @@ class CkImage implements ui.Image, StackTraceDebugger {
|
||||
|
||||
@override
|
||||
bool get debugDisposed {
|
||||
if (assertionsEnabled) {
|
||||
return _disposed;
|
||||
bool? result;
|
||||
assert(() {
|
||||
result = _disposed;
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (result != null) {
|
||||
return result!;
|
||||
}
|
||||
|
||||
throw StateError(
|
||||
'Image.debugDisposed is only available when asserts are enabled.');
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'dart:js_interop';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../../engine.dart' show Instrumentation;
|
||||
import '../util.dart';
|
||||
import 'canvaskit_api.dart';
|
||||
|
||||
/// Collects native objects that weren't explicitly disposed of using
|
||||
@@ -130,9 +129,10 @@ class CountedRef<R extends StackTraceDebugger, T extends Object> {
|
||||
/// Creates a counted reference.
|
||||
CountedRef(T nativeObject, R debugReferrer, String debugLabel) {
|
||||
_ref = UniqueRef<T>(this, nativeObject, debugLabel);
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
debugReferrers.add(debugReferrer);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
assert(refCount == debugReferrers.length);
|
||||
}
|
||||
|
||||
@@ -170,11 +170,18 @@ class CountedRef<R extends StackTraceDebugger, T extends Object> {
|
||||
/// If asserts are enabled, the [StackTrace]s representing when a reference
|
||||
/// was created.
|
||||
List<StackTrace> debugGetStackTraces() {
|
||||
if (assertionsEnabled) {
|
||||
return debugReferrers
|
||||
List<StackTrace>? result;
|
||||
assert(() {
|
||||
result = debugReferrers
|
||||
.map<StackTrace>((R referrer) => referrer.debugStackTrace)
|
||||
.toList();
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (result != null) {
|
||||
return result!;
|
||||
}
|
||||
|
||||
throw UnsupportedError('');
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import '../util.dart';
|
||||
import 'canvas.dart';
|
||||
import 'canvaskit_api.dart';
|
||||
import 'image.dart';
|
||||
@@ -30,9 +29,16 @@ class CkPicture implements ui.Picture {
|
||||
|
||||
@override
|
||||
bool get debugDisposed {
|
||||
if (assertionsEnabled) {
|
||||
return _isDisposed;
|
||||
bool? result;
|
||||
assert(() {
|
||||
result = _isDisposed;
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (result != null) {
|
||||
return result!;
|
||||
}
|
||||
|
||||
throw StateError('Picture.debugDisposed is only available when asserts are enabled.');
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'dart:typed_data';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import '../util.dart';
|
||||
import '../validators.dart';
|
||||
import 'canvaskit_api.dart';
|
||||
import 'image.dart';
|
||||
@@ -105,10 +104,12 @@ class CkGradientLinear extends SimpleCkShader implements ui.Gradient {
|
||||
) : assert(offsetIsValid(from)),
|
||||
assert(offsetIsValid(to)),
|
||||
matrix4 = matrix {
|
||||
if (assertionsEnabled) {
|
||||
assert(matrix4 == null || matrix4IsValid(matrix4!));
|
||||
assert(matrix4 == null || matrix4IsValid(matrix4!));
|
||||
// ignore: prefer_asserts_in_initializer_lists
|
||||
assert(() {
|
||||
validateColorStops(colors, colorStops);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
final ui.Offset from;
|
||||
|
||||
@@ -11,14 +11,15 @@ import '../../engine.dart';
|
||||
class SurfaceFactory {
|
||||
SurfaceFactory(int maximumSurfaces)
|
||||
: maximumSurfaces = math.max(maximumSurfaces, 1) {
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
if (maximumSurfaces < 1) {
|
||||
printWarning('Attempted to create a $SurfaceFactory with '
|
||||
'$maximumSurfaces maximum surfaces. At least 1 surface is required '
|
||||
'for rendering.');
|
||||
}
|
||||
registerHotRestartListener(debugClear);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
/// The lazy-initialized singleton surface factory.
|
||||
|
||||
@@ -734,9 +734,16 @@ class CkParagraph implements ui.Paragraph {
|
||||
|
||||
@override
|
||||
bool get debugDisposed {
|
||||
if (assertionsEnabled) {
|
||||
return _disposed;
|
||||
bool? result;
|
||||
assert(() {
|
||||
result = _disposed;
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (result != null) {
|
||||
return result!;
|
||||
}
|
||||
|
||||
throw StateError('Paragraph.debugDisposed is only available when asserts are enabled.');
|
||||
}
|
||||
}
|
||||
@@ -888,12 +895,13 @@ class CkParagraphBuilder implements ui.ParagraphBuilder {
|
||||
void pop() {
|
||||
if (_styleStack.length <= 1) {
|
||||
// The top-level text style is paragraph-level. We don't pop it off.
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
printWarning(
|
||||
'Cannot pop text style in ParagraphBuilder. '
|
||||
'Already popped all text styles from the style stack.',
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
return;
|
||||
}
|
||||
_styleStack.removeLast();
|
||||
|
||||
@@ -81,11 +81,17 @@ class FontFallbackManager {
|
||||
bool _scheduledCodePointCheck = false;
|
||||
|
||||
Future<void> debugWhenIdle() {
|
||||
if (assertionsEnabled) {
|
||||
return _idleFuture;
|
||||
} else {
|
||||
throw UnimplementedError();
|
||||
Future<void>? result;
|
||||
assert(() {
|
||||
result = _idleFuture;
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (result != null) {
|
||||
return result!;
|
||||
}
|
||||
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
/// Determines if the given [text] contains any code points which are not
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import '../dom.dart';
|
||||
import '../util.dart';
|
||||
|
||||
DomHTMLElement _createContainer() {
|
||||
final DomHTMLElement container = createDomHTMLDivElement();
|
||||
@@ -77,9 +76,10 @@ class DebugCanvasReuseOverlay {
|
||||
if (_instance == null) {
|
||||
// Only call the constructor when assertions are enabled to guard against
|
||||
// mistakingly including this class in a release build.
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
_instance = DebugCanvasReuseOverlay._();
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
return _instance!;
|
||||
}
|
||||
|
||||
@@ -249,9 +249,8 @@ class SurfacePaintData {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (!assertionsEnabled) {
|
||||
return super.toString();
|
||||
} else {
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
final StringBuffer buffer = StringBuffer('SurfacePaintData(');
|
||||
if (blendMode != null) {
|
||||
buffer.write('blendMode = $blendMode; ');
|
||||
@@ -282,8 +281,12 @@ class SurfacePaintData {
|
||||
buffer.write('colorFilter = $colorFilter; ');
|
||||
}
|
||||
buffer.write('isAntiAlias = $isAntiAlias)');
|
||||
return buffer.toString();
|
||||
}
|
||||
result = buffer.toString();
|
||||
|
||||
return true;
|
||||
}());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import 'dart:math' as math;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import '../../util.dart';
|
||||
import 'path_utils.dart';
|
||||
|
||||
/// Chops cubic at Y extrema points and writes result to [dest].
|
||||
@@ -45,7 +44,7 @@ QuadRoots _findCubicExtrema(double a, double b, double c, double d) {
|
||||
/// Subdivides cubic curve for a list of t values.
|
||||
void _chopCubicAt(
|
||||
List<double> tValues, Float32List points, Float32List outPts) {
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
for (int i = 0; i < tValues.length - 1; i++) {
|
||||
final double tValue = tValues[i];
|
||||
assert(tValue > 0 && tValue < 1,
|
||||
@@ -57,7 +56,8 @@ void _chopCubicAt(
|
||||
assert(
|
||||
nextTValue > tValue, 'Expecting t value to monotonically increase');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
final int rootCount = tValues.length;
|
||||
if (0 == rootCount) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import '../../util.dart';
|
||||
import '../../validators.dart';
|
||||
import '../../vector_math.dart';
|
||||
import 'conic.dart';
|
||||
@@ -1558,7 +1557,8 @@ class SurfacePath implements ui.Path {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
final StringBuffer sb = StringBuffer();
|
||||
sb.write('Path(');
|
||||
final PathRefIterator iter = PathRefIterator(pathRef);
|
||||
@@ -1589,10 +1589,10 @@ class SurfacePath implements ui.Path {
|
||||
}
|
||||
}
|
||||
sb.write(')');
|
||||
return sb.toString();
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
result = sb.toString();
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import '../../util.dart';
|
||||
import 'path_utils.dart';
|
||||
|
||||
/// Stores the path verbs, points and conic weights.
|
||||
@@ -304,7 +303,7 @@ class PathRef {
|
||||
dx = vector1_0x.abs();
|
||||
dy = vector1_0y.abs();
|
||||
}
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
final int checkCornerIndex = SPath.nearlyEqual(controlPx, bounds.left)
|
||||
? (SPath.nearlyEqual(controlPy, bounds.top)
|
||||
? _Corner.kUpperLeft
|
||||
@@ -312,12 +311,12 @@ class PathRef {
|
||||
: (SPath.nearlyEqual(controlPy, bounds.top)
|
||||
? _Corner.kUpperRight
|
||||
: _Corner.kLowerRight);
|
||||
assert(checkCornerIndex == cornerIndex);
|
||||
}
|
||||
return checkCornerIndex == cornerIndex;
|
||||
}());
|
||||
radii.add(ui.Radius.elliptical(dx, dy));
|
||||
++cornerIndex;
|
||||
} else {
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
if (verb == SPath.kLineVerb) {
|
||||
final bool isVerticalOrHorizontal =
|
||||
SPath.nearlyEqual(pts[2], pts[0]) ||
|
||||
@@ -329,7 +328,8 @@ class PathRef {
|
||||
} else {
|
||||
assert(verb == SPath.kCloseVerb);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
}
|
||||
return ui.RRect.fromRectAndCorners(bounds,
|
||||
@@ -634,6 +634,7 @@ class PathRef {
|
||||
debugValidate();
|
||||
int pCnt;
|
||||
int mask = 0;
|
||||
String? throwError;
|
||||
switch (verb) {
|
||||
case SPath.kMoveVerb:
|
||||
pCnt = 1;
|
||||
@@ -652,16 +653,21 @@ class PathRef {
|
||||
case SPath.kCloseVerb:
|
||||
pCnt = 0;
|
||||
case SPath.kDoneVerb:
|
||||
if (assertionsEnabled) {
|
||||
throw Exception('growForVerb called for kDone');
|
||||
}
|
||||
assert(() {
|
||||
throwError = 'growForVerb called for kDone';
|
||||
return true;
|
||||
}());
|
||||
pCnt = 0;
|
||||
default:
|
||||
if (assertionsEnabled) {
|
||||
throw Exception('default is not reached');
|
||||
}
|
||||
assert(() {
|
||||
throwError = 'growForVerb called for unknown verb';
|
||||
return true;
|
||||
}());
|
||||
pCnt = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (throwError != null) {
|
||||
throw Exception(throwError);
|
||||
}
|
||||
|
||||
fSegmentMask |= mask;
|
||||
@@ -694,6 +700,7 @@ class PathRef {
|
||||
startEdit();
|
||||
int pCnt;
|
||||
int mask = 0;
|
||||
String? throwError;
|
||||
switch (verb) {
|
||||
case SPath.kMoveVerb:
|
||||
pCnt = numVbs;
|
||||
@@ -712,16 +719,21 @@ class PathRef {
|
||||
case SPath.kCloseVerb:
|
||||
pCnt = 0;
|
||||
case SPath.kDoneVerb:
|
||||
if (assertionsEnabled) {
|
||||
throw Exception('growForVerb called for kDone');
|
||||
}
|
||||
assert(() {
|
||||
throwError = 'growForVerb called for kDone';
|
||||
return true;
|
||||
}());
|
||||
pCnt = 0;
|
||||
default:
|
||||
if (assertionsEnabled) {
|
||||
throw Exception('default is not reached');
|
||||
}
|
||||
assert(() {
|
||||
throwError = 'growForVerb called for unknown verb';
|
||||
return true;
|
||||
}());
|
||||
pCnt = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (throwError != null) {
|
||||
throw Exception(throwError);
|
||||
}
|
||||
|
||||
fSegmentMask |= mask;
|
||||
|
||||
@@ -55,9 +55,16 @@ class RecordingCanvas {
|
||||
|
||||
/// In debug mode returns the list of recorded paint commands for testing.
|
||||
List<PaintCommand> get debugPaintCommands {
|
||||
if (assertionsEnabled) {
|
||||
return _commands;
|
||||
List<PaintCommand>? result;
|
||||
assert(() {
|
||||
result = _commands;
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (result != null) {
|
||||
return result!;
|
||||
}
|
||||
|
||||
throw UnsupportedError('For debugging only.');
|
||||
}
|
||||
|
||||
@@ -184,15 +191,17 @@ class RecordingCanvas {
|
||||
|
||||
/// Prints recorded commands.
|
||||
String? debugPrintCommands() {
|
||||
if (assertionsEnabled) {
|
||||
String? result;
|
||||
assert(() {
|
||||
final StringBuffer debugBuf = StringBuffer();
|
||||
for (int i = 0; i < _commands.length; i++) {
|
||||
final PaintCommand command = _commands[i];
|
||||
debugBuf.writeln('ctx.$command;');
|
||||
}
|
||||
return debugBuf.toString();
|
||||
}
|
||||
return null;
|
||||
result = debugBuf.toString();
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
|
||||
void save() {
|
||||
@@ -729,11 +738,12 @@ class PaintSave extends PaintCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'save()';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'save()';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -747,11 +757,12 @@ class PaintRestore extends PaintCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'restore()';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'restore()';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -768,11 +779,12 @@ class PaintTranslate extends PaintCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'translate($dx, $dy)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'translate($dx, $dy)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -789,11 +801,12 @@ class PaintScale extends PaintCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'scale($sx, $sy)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'scale($sx, $sy)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,11 +822,12 @@ class PaintRotate extends PaintCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'rotate($radians)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'rotate($radians)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,11 +843,12 @@ class PaintTransform extends PaintCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'transform(Matrix4.fromFloat32List(Float32List.fromList(<double>[${matrix4.join(', ')}])))';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'transform(Matrix4.fromFloat32List(Float32List.fromList(<double>[${matrix4.join(', ')}])))';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -850,11 +865,12 @@ class PaintSkew extends PaintCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'skew($sx, $sy)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'skew($sx, $sy)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -871,11 +887,12 @@ class PaintClipRect extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'clipRect($rect)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'clipRect($rect)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,11 +908,12 @@ class PaintClipRRect extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'clipRRect($rrect)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'clipRRect($rrect)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -911,11 +929,12 @@ class PaintClipPath extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'clipPath($path)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'clipPath($path)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -932,11 +951,12 @@ class PaintDrawColor extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawColor($color, $blendMode)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawColor($color, $blendMode)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -954,11 +974,12 @@ class PaintDrawLine extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawLine($p1, $p2, $paint)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawLine($p1, $p2, $paint)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -974,11 +995,12 @@ class PaintDrawPaint extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawPaint($paint)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawPaint($paint)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -996,11 +1018,12 @@ class PaintDrawVertices extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawVertices($vertices, $blendMode, $paint)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawVertices($vertices, $blendMode, $paint)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1018,11 +1041,12 @@ class PaintDrawPoints extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawPoints($pointMode, $points, $paint)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawPoints($pointMode, $points, $paint)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1039,11 +1063,12 @@ class PaintDrawRect extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawRect($rect, $paint)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawRect($rect, $paint)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1060,11 +1085,12 @@ class PaintDrawRRect extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawRRect($rrect, $paint)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawRRect($rrect, $paint)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1090,11 +1116,12 @@ class PaintDrawDRRect extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawDRRect($outer, $inner, $paint)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawDRRect($outer, $inner, $paint)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,11 +1138,12 @@ class PaintDrawOval extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawOval($rect, $paint)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawOval($rect, $paint)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1133,11 +1161,12 @@ class PaintDrawCircle extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawCircle($c, $radius, $paint)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawCircle($c, $radius, $paint)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1154,11 +1183,12 @@ class PaintDrawPath extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawPath($path, $paint)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawPath($path, $paint)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1178,11 +1208,12 @@ class PaintDrawShadow extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawShadow($path, $color, $elevation, $transparentOccluder)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawShadow($path, $color, $elevation, $transparentOccluder)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1200,11 +1231,12 @@ class PaintDrawImage extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawImage($image, $offset, $paint)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawImage($image, $offset, $paint)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1223,11 +1255,12 @@ class PaintDrawImageRect extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'drawImageRect($image, $src, $dst, $paint)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'drawImageRect($image, $src, $dst, $paint)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1244,11 +1277,12 @@ class PaintDrawParagraph extends DrawCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'DrawParagraph(${paragraph.plainText}, $offset)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'DrawParagraph(${paragraph.plainText}, $offset)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1276,11 +1310,12 @@ class Subpath {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'Subpath(${commands.join(', ')})';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'Subpath(${commands.join(', ')})';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1317,11 +1352,12 @@ class MoveTo extends PathCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'MoveTo($x, $y)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'MoveTo($x, $y)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1344,11 +1380,12 @@ class LineTo extends PathCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'LineTo($x, $y)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'LineTo($x, $y)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1476,11 +1513,12 @@ class Ellipse extends PathCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'Ellipse($x, $y, $radiusX, $radiusY)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'Ellipse($x, $y, $radiusX, $radiusY)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1516,11 +1554,12 @@ class QuadraticCurveTo extends PathCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'QuadraticCurveTo($x1, $y1, $x2, $y2)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'QuadraticCurveTo($x1, $y1, $x2, $y2)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1560,11 +1599,12 @@ class BezierCurveTo extends PathCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'BezierCurveTo($x1, $y1, $x2, $y2, $x3, $y3)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'BezierCurveTo($x1, $y1, $x2, $y2, $x3, $y3)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1617,11 +1657,12 @@ class RectCommand extends PathCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'Rect($x, $y, $width, $height)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'Rect($x, $y, $width, $height)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1644,11 +1685,12 @@ class RRectCommand extends PathCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return '$rrect';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = '$rrect';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1665,11 +1707,12 @@ class CloseCommand extends PathCommand {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'Close()';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'Close()';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1997,12 +2040,13 @@ class _PaintBounds {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
final ui.Rect bounds = computeBounds();
|
||||
return '_PaintBounds($bounds of size ${bounds.size})';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
result = '_PaintBounds($bounds of size ${bounds.size})';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,9 +64,16 @@ class SurfaceVertices implements ui.Vertices {
|
||||
|
||||
@override
|
||||
bool get debugDisposed {
|
||||
if (assertionsEnabled) {
|
||||
return _disposed;
|
||||
bool? result;
|
||||
assert(() {
|
||||
result = _disposed;
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (result != null) {
|
||||
return result!;
|
||||
}
|
||||
|
||||
throw StateError('Vertices.debugDisposed is only available when asserts are enabled.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +63,10 @@ class SurfaceSceneBuilder implements ui.SceneBuilder {
|
||||
///
|
||||
/// This is used by tests.
|
||||
void debugAddSurface(PersistedSurface surface) {
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
_addSurface(surface);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
void _addSurface(PersistedSurface surface) {
|
||||
@@ -275,10 +276,10 @@ class SurfaceSceneBuilder implements ui.SceneBuilder {
|
||||
void addRetained(ui.EngineLayer retainedLayer) {
|
||||
final PersistedContainerSurface retainedSurface =
|
||||
retainedLayer as PersistedContainerSurface;
|
||||
if (assertionsEnabled) {
|
||||
assert(debugAssertSurfaceState(retainedSurface,
|
||||
PersistedSurfaceState.active, PersistedSurfaceState.released));
|
||||
}
|
||||
assert(debugAssertSurfaceState(retainedSurface,
|
||||
PersistedSurfaceState.active,
|
||||
PersistedSurfaceState.released,
|
||||
));
|
||||
retainedSurface.tryRetain();
|
||||
_adoptSurface(retainedSurface);
|
||||
}
|
||||
|
||||
@@ -186,9 +186,11 @@ class GradientLinear extends EngineGradient {
|
||||
assert(offsetIsValid(to)),
|
||||
matrix4 = matrix == null ? null : FastMatrix32(matrix),
|
||||
super._() {
|
||||
if (assertionsEnabled) {
|
||||
// ignore: prefer_asserts_in_initializer_lists
|
||||
assert(() {
|
||||
validateColorStops(colors, colorStops);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
final ui.Offset from;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import '../../browser_detection.dart';
|
||||
import '../../util.dart';
|
||||
|
||||
/// Creates shader program for target webgl version.
|
||||
///
|
||||
@@ -250,11 +249,12 @@ class ShaderMethod {
|
||||
}
|
||||
|
||||
void addStatement(String statement) {
|
||||
if (assertionsEnabled) {
|
||||
_statements.add(' ' * _indentLevel + statement);
|
||||
} else {
|
||||
_statements.add(statement);
|
||||
}
|
||||
String itemToAdd = statement;
|
||||
assert(() {
|
||||
itemToAdd = ' ' * _indentLevel + statement;
|
||||
return true;
|
||||
}());
|
||||
_statements.add(itemToAdd);
|
||||
}
|
||||
|
||||
/// Adds statements to compute tiling in 0..1 coordinate space.
|
||||
|
||||
@@ -166,10 +166,12 @@ class PersistedSurfaceException implements Exception {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return '${surface.runtimeType}: $message';
|
||||
}
|
||||
return super.toString();
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = '${surface.runtimeType}: $message';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +358,7 @@ abstract class PersistedSurface implements ui.EngineLayer {
|
||||
/// such as on the very first frame.
|
||||
@mustCallSuper
|
||||
void build() {
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
final DomElement? existingElement = rootElement;
|
||||
if (existingElement != null) {
|
||||
throw PersistedSurfaceException(
|
||||
@@ -365,7 +367,8 @@ abstract class PersistedSurface implements ui.EngineLayer {
|
||||
'element ${existingElement.tagName}.',
|
||||
);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
assert(debugAssertSurfaceState(this, PersistedSurfaceState.created));
|
||||
rootElement = createElement();
|
||||
assert(rootElement != null);
|
||||
@@ -420,9 +423,10 @@ abstract class PersistedSurface implements ui.EngineLayer {
|
||||
|
||||
adoptElements(oldSurface);
|
||||
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
rootElement!.setAttribute('flt-layer-state', 'updated');
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
state = PersistedSurfaceState.active;
|
||||
assert(rootElement != null);
|
||||
}
|
||||
@@ -444,9 +448,10 @@ abstract class PersistedSurface implements ui.EngineLayer {
|
||||
// this surface's DOM elements.
|
||||
retainedSurfaces.add(this);
|
||||
}
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
rootElement!.setAttribute('flt-layer-state', 'retained');
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
if (debugExplainSurfaceStats) {
|
||||
surfaceStatsFor(this).retainSurfaceCount++;
|
||||
}
|
||||
@@ -503,9 +508,10 @@ abstract class PersistedSurface implements ui.EngineLayer {
|
||||
DomElement defaultCreateElement(String tagName) {
|
||||
final DomElement element = createDomElement(tagName);
|
||||
element.style.position = 'absolute';
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
element.setAttribute('flt-layer-state', 'new');
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -595,13 +601,14 @@ abstract class PersistedSurface implements ui.EngineLayer {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
final StringBuffer log = StringBuffer();
|
||||
debugPrint(log, 0);
|
||||
return log.toString();
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
result = log.toString();
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -720,9 +727,10 @@ abstract class PersistedContainerSurface extends PersistedSurface {
|
||||
_updateManyToMany(oldSurface);
|
||||
}
|
||||
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
_debugValidateContainerUpdate(oldSurface);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
// Children should override if they are performing clipping.
|
||||
@@ -1212,11 +1220,12 @@ class _PersistedSurfaceMatch {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return '_PersistedSurfaceMatch(${newChild!.runtimeType}#${newChild!.hashCode}: $oldChildIndex, quality: $matchQuality)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = '_PersistedSurfaceMatch(${newChild!.runtimeType}#${newChild!.hashCode}: $oldChildIndex, quality: $matchQuality)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import 'package:ui/ui.dart' as ui;
|
||||
import 'browser_detection.dart';
|
||||
import 'dom.dart';
|
||||
import 'safe_browser_api.dart';
|
||||
import 'util.dart';
|
||||
|
||||
Object? get _jsImageDecodeFunction => getJsProperty<Object?>(
|
||||
getJsProperty<Object>(
|
||||
@@ -151,17 +150,25 @@ class HtmlImage implements ui.Image {
|
||||
ui.Image.onDispose?.call(this);
|
||||
// Do nothing. The codec that owns this image should take care of
|
||||
// releasing the object url.
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
_disposed = true;
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
@override
|
||||
bool get debugDisposed {
|
||||
if (assertionsEnabled) {
|
||||
return _disposed;
|
||||
bool? result;
|
||||
assert(() {
|
||||
result = _disposed;
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (result != null) {
|
||||
return result!;
|
||||
}
|
||||
return throw StateError('Image.debugDisposed is only available when asserts are enabled.');
|
||||
|
||||
throw StateError('Image.debugDisposed is only available when asserts are enabled.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import 'dom.dart';
|
||||
import 'html/bitmap_canvas.dart';
|
||||
import 'html/recording_canvas.dart';
|
||||
import 'html_image_codec.dart';
|
||||
import 'util.dart';
|
||||
|
||||
/// An implementation of [ui.PictureRecorder] backed by a [RecordingCanvas].
|
||||
class EnginePictureRecorder implements ui.PictureRecorder {
|
||||
@@ -106,9 +105,16 @@ class EnginePicture implements ui.Picture {
|
||||
|
||||
@override
|
||||
bool get debugDisposed {
|
||||
if (assertionsEnabled) {
|
||||
return _disposed;
|
||||
bool? result;
|
||||
assert(() {
|
||||
result = _disposed;
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (result != null) {
|
||||
return result!;
|
||||
}
|
||||
|
||||
throw StateError('Picture.debugDisposed is only available when asserts are enabled.');
|
||||
}
|
||||
|
||||
|
||||
@@ -452,7 +452,15 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
|
||||
ui.PlatformMessageResponseCallback? callback,
|
||||
) {
|
||||
// In widget tests we want to bypass processing of platform messages.
|
||||
if (assertionsEnabled && ui.debugEmulateFlutterTesterEnvironment) {
|
||||
bool returnImmediately = false;
|
||||
assert(() {
|
||||
if (ui.debugEmulateFlutterTesterEnvironment) {
|
||||
returnImmediately = true;
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (returnImmediately) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -460,7 +468,13 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
|
||||
print('Sent platform message on channel: "$name"');
|
||||
}
|
||||
|
||||
if (assertionsEnabled && name == 'flutter/debug-echo') {
|
||||
bool allowDebugEcho = false;
|
||||
assert(() {
|
||||
allowDebugEcho = true;
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (allowDebugEcho && name == 'flutter/debug-echo') {
|
||||
// Echoes back the data unchanged. Used for testing purposes.
|
||||
replyToPlatformMessage(callback, data);
|
||||
return;
|
||||
|
||||
@@ -1512,15 +1512,16 @@ class SemanticsObject {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
final String children = _childrenInTraversalOrder != null &&
|
||||
_childrenInTraversalOrder!.isNotEmpty
|
||||
? '[${_childrenInTraversalOrder!.join(', ')}]'
|
||||
: '<empty>';
|
||||
return '$runtimeType(#$id, children: $children)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
result = '$runtimeType(#$id, children: $children)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import '../dom.dart';
|
||||
import '../embedder.dart';
|
||||
import '../html/bitmap_canvas.dart';
|
||||
import '../profiler.dart';
|
||||
import '../util.dart';
|
||||
import 'layout_fragmenter.dart';
|
||||
import 'layout_service.dart';
|
||||
import 'paint_service.dart';
|
||||
@@ -253,9 +252,16 @@ class CanvasParagraph implements ui.Paragraph {
|
||||
|
||||
@override
|
||||
bool get debugDisposed {
|
||||
if (assertionsEnabled) {
|
||||
return _disposed;
|
||||
bool? result;
|
||||
assert(() {
|
||||
result = _disposed;
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (result != null) {
|
||||
return result!;
|
||||
}
|
||||
|
||||
throw StateError('Paragraph.debugDisposed is only avialalbe when asserts are enabled.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,8 +89,9 @@ class EngineLineMetrics implements ui.LineMetrics {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
return 'LineMetrics(hardBreak: $hardBreak, '
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'LineMetrics(hardBreak: $hardBreak, '
|
||||
'ascent: $ascent, '
|
||||
'descent: $descent, '
|
||||
'unscaledAscent: $unscaledAscent, '
|
||||
@@ -99,9 +100,9 @@ class EngineLineMetrics implements ui.LineMetrics {
|
||||
'left: $left, '
|
||||
'baseline: $baseline, '
|
||||
'lineNumber: $lineNumber)';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,10 +344,11 @@ class EngineParagraphStyle implements ui.ParagraphStyle {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
final double? fontSize = this.fontSize;
|
||||
final double? height = this.height;
|
||||
return 'ParagraphStyle('
|
||||
result = 'ParagraphStyle('
|
||||
'textAlign: ${textAlign ?? "unspecified"}, '
|
||||
'textDirection: ${textDirection ?? "unspecified"}, '
|
||||
'fontWeight: ${fontWeight ?? "unspecified"}, '
|
||||
@@ -359,9 +361,9 @@ class EngineParagraphStyle implements ui.ParagraphStyle {
|
||||
'ellipsis: ${ellipsis != null ? '"$ellipsis"' : "unspecified"}, '
|
||||
'locale: ${locale ?? "unspecified"}'
|
||||
')';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,9 +471,14 @@ class EngineTextStyle implements ui.TextStyle {
|
||||
final String fontFamily = this.fontFamily.isEmpty ? FlutterViewEmbedder.defaultFontFamily : this.fontFamily;
|
||||
// In the flutter tester environment, we use predictable-size test fonts.
|
||||
// This makes widget tests predictable and less flaky.
|
||||
return assertionsEnabled && ui.debugEmulateFlutterTesterEnvironment && !_testFonts.contains(fontFamily)
|
||||
? _testFonts.first
|
||||
: fontFamily;
|
||||
String result = fontFamily;
|
||||
assert(() {
|
||||
if (ui.debugEmulateFlutterTesterEnvironment && !_testFonts.contains(fontFamily)) {
|
||||
result = _testFonts.first;
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
|
||||
String? _cssFontString;
|
||||
@@ -600,11 +607,12 @@ class EngineTextStyle implements ui.TextStyle {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
final List<String>? fontFamilyFallback = this.fontFamilyFallback;
|
||||
final double? fontSize = this.fontSize;
|
||||
final double? height = this.height;
|
||||
return 'TextStyle('
|
||||
result = 'TextStyle('
|
||||
'color: ${color ?? "unspecified"}, '
|
||||
'decoration: ${decoration ?? "unspecified"}, '
|
||||
'decorationColor: ${decorationColor ?? "unspecified"}, '
|
||||
@@ -626,9 +634,9 @@ class EngineTextStyle implements ui.TextStyle {
|
||||
'fontFeatures: ${fontFeatures ?? "unspecified"}, '
|
||||
'fontVariations: ${fontVariations ?? "unspecified"}'
|
||||
')';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -197,9 +197,10 @@ class TextHeightRuler {
|
||||
..border = '0'
|
||||
..padding = '0';
|
||||
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
host.setAttribute('data-ruler', 'line-height');
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
|
||||
_dimensions.applyHeightStyle(textHeightStyle);
|
||||
|
||||
|
||||
@@ -813,9 +813,12 @@ class EditingState {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return assertionsEnabled
|
||||
? 'EditingState("$text", base:$baseOffset, extent:$extentOffset, composingBase:$composingBaseOffset, composingExtent:$composingExtentOffset)'
|
||||
: super.toString();
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
result = 'EditingState("$text", base:$baseOffset, extent:$extentOffset, composingBase:$composingBaseOffset, composingExtent:$composingExtentOffset)';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Sets the selection values of a DOM element using this [EditingState].
|
||||
|
||||
@@ -217,12 +217,6 @@ String float64ListToCssTransform3d(List<double> matrix) {
|
||||
}
|
||||
}
|
||||
|
||||
bool get assertionsEnabled {
|
||||
bool k = false;
|
||||
assert(k = true);
|
||||
return k;
|
||||
}
|
||||
|
||||
final Float32List _tempRectData = Float32List(4);
|
||||
|
||||
/// Transforms a [ui.Rect] given the effective [transform].
|
||||
|
||||
@@ -1047,18 +1047,19 @@ class Matrix4 {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (assertionsEnabled) {
|
||||
String result = super.toString();
|
||||
assert(() {
|
||||
String fmt(int index) {
|
||||
return storage[index].toStringAsFixed(2);
|
||||
}
|
||||
|
||||
return '[${fmt(0)}, ${fmt(4)}, ${fmt(8)}, ${fmt(12)}]\n'
|
||||
'[${fmt(1)}, ${fmt(5)}, ${fmt(9)}, ${fmt(13)}]\n'
|
||||
'[${fmt(2)}, ${fmt(6)}, ${fmt(10)}, ${fmt(14)}]\n'
|
||||
'[${fmt(3)}, ${fmt(7)}, ${fmt(11)}, ${fmt(15)}]';
|
||||
} else {
|
||||
return super.toString();
|
||||
}
|
||||
result = '[${fmt(0)}, ${fmt(4)}, ${fmt(8)}, ${fmt(12)}]\n'
|
||||
'[${fmt(1)}, ${fmt(5)}, ${fmt(9)}, ${fmt(13)}]\n'
|
||||
'[${fmt(2)}, ${fmt(6)}, ${fmt(10)}, ${fmt(14)}]\n'
|
||||
'[${fmt(3)}, ${fmt(7)}, ${fmt(11)}, ${fmt(15)}]';
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:ui/src/engine/dom.dart';
|
||||
import 'package:ui/src/engine/util.dart' show assertionsEnabled, setElementStyle;
|
||||
import 'package:ui/src/engine/util.dart' show setElementStyle;
|
||||
|
||||
import 'embedding_strategy.dart';
|
||||
|
||||
@@ -84,7 +84,7 @@ class FullPageEmbeddingStrategy extends EmbeddingStrategy {
|
||||
void _applyViewportMeta() {
|
||||
for (final DomElement viewportMeta
|
||||
in domDocument.head!.querySelectorAll('meta[name="viewport"]')) {
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
// Filter out the meta tag that the engine placed on the page. This is
|
||||
// to avoid UI flicker during hot restart. Hot restart will clean up the
|
||||
// old meta tag synchronously with the first post-restart frame.
|
||||
@@ -95,7 +95,8 @@ class FullPageEmbeddingStrategy extends EmbeddingStrategy {
|
||||
'with Flutter. This tag will be replaced.',
|
||||
);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
viewportMeta.remove();
|
||||
}
|
||||
|
||||
|
||||
@@ -252,17 +252,19 @@ class TestJsConstructor implements JsConstructor {
|
||||
|
||||
class TestCountedRefOwner implements StackTraceDebugger {
|
||||
TestCountedRefOwner(TestSkDeletable nativeObject) {
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
_debugStackTrace = StackTrace.current;
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
ref = CountedRef<TestCountedRefOwner, TestSkDeletable>(
|
||||
nativeObject, this, 'TestCountedRefOwner');
|
||||
}
|
||||
|
||||
TestCountedRefOwner.cloneOf(this.ref) {
|
||||
if (assertionsEnabled) {
|
||||
assert(() {
|
||||
_debugStackTrace = StackTrace.current;
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
ref.ref(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,13 @@ const List<String> _auditedLibraries = <String>[
|
||||
];
|
||||
|
||||
Future<void> main(List<String> args) async {
|
||||
bool areAssertionsEnabled = false;
|
||||
bool shouldThrow = true;
|
||||
assert(() {
|
||||
areAssertionsEnabled = true;
|
||||
shouldThrow = false;
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (!areAssertionsEnabled) {
|
||||
if (shouldThrow) {
|
||||
throw ArgumentError(
|
||||
'This test must run with --enable-asserts',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user