浏览代码

Revert "Revert "Merge branch 'shiyun/skia' of https://github.com/Unity-Technologies/com.unity.uiwidgets into shiyun/skia""

This reverts commit bd57e3f8ce7b16769f9517144a7aafd0d7d0abba.
/siyaoH-1.17-PlatformMessage
guanghuispark 4 年前
当前提交
c779330e
共有 30 个文件被更改,包括 1627 次插入563 次删除
  1. 128
      com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.gen.cs
  2. 30
      com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.njk
  3. 23
      com.unity.uiwidgets/Runtime/cupertino/app.cs
  4. 381
      com.unity.uiwidgets/Runtime/foundation/assertions.cs
  5. 9
      com.unity.uiwidgets/Runtime/foundation/binding.cs
  6. 15
      com.unity.uiwidgets/Runtime/foundation/change_notifier.cs
  7. 891
      com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
  8. 4
      com.unity.uiwidgets/Runtime/foundation/object.cs
  9. 16
      com.unity.uiwidgets/Runtime/foundation/observer_list.cs
  10. 6
      com.unity.uiwidgets/Runtime/foundation/print.cs
  11. 11
      com.unity.uiwidgets/Runtime/gestures/binding.cs
  12. 11
      com.unity.uiwidgets/Runtime/gestures/pointer_signal_resolver.cs
  13. 26
      com.unity.uiwidgets/Runtime/gestures/recognizer.cs
  14. 41
      com.unity.uiwidgets/Runtime/painting/image_provider.cs
  15. 14
      com.unity.uiwidgets/Runtime/painting/image_stream.cs
  16. 33
      com.unity.uiwidgets/Runtime/rendering/box.cs
  17. 46
      com.unity.uiwidgets/Runtime/rendering/debug_overflow_indicator.cs
  18. 23
      com.unity.uiwidgets/Runtime/rendering/flex.cs
  19. 20
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  20. 97
      com.unity.uiwidgets/Runtime/rendering/object.cs
  21. 100
      com.unity.uiwidgets/Runtime/rendering/sliver.cs
  22. 57
      com.unity.uiwidgets/Runtime/scheduler2/binding.cs
  23. 14
      com.unity.uiwidgets/Runtime/scheduler2/ticker.cs
  24. 4
      com.unity.uiwidgets/Runtime/services/binding.cs
  25. 164
      com.unity.uiwidgets/Runtime/widgets/app.cs
  26. 4
      com.unity.uiwidgets/Runtime/widgets/basic.cs
  27. 2
      com.unity.uiwidgets/Runtime/widgets/binding.cs
  28. 2
      com.unity.uiwidgets/Runtime/widgets/debug.cs
  29. 16
      com.unity.uiwidgets/Runtime/widgets/framework.cs
  30. 2
      com.unity.uiwidgets/Runtime/widgets/image.cs

128
com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.gen.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.animation {
public abstract class AnimationLazyListenerMixinAnimation<T> : Animation<T> {
int _listenerCounter = 0;

}
public abstract class AnimationEagerListenerMixinAnimation<T> : Animation<T> {
protected void didRegisterListener() {
}

}
public abstract class AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T> {
public abstract class
AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T> {
readonly ObserverList<VoidCallback> _listeners = new ObserverList<VoidCallback>();
public override void addListener(VoidCallback listener) {

if (_listeners.Contains(listener)) {
listener();
}
} catch (Exception exception) {
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying listeners for " + GetType(),
informationCollector: information => {
information.AppendLine("The " + GetType() + " notifying listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying listeners for " + GetType()),
informationCollector: infoCollector
));
}
}

public abstract class AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> : AnimationEagerListenerMixinAnimation<T> {
public abstract class
AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> : AnimationEagerListenerMixinAnimation<T> {
readonly ObserverList<VoidCallback> _listeners = new ObserverList<VoidCallback>();
public override void addListener(VoidCallback listener) {

if (_listeners.Contains(listener)) {
listener();
}
} catch (Exception exception) {
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying listeners for " + GetType(),
informationCollector: information => {
information.AppendLine("The " + GetType() + " notifying listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying listeners for " + GetType()),
informationCollector: infoCollector
));
}
}

public abstract class AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> {
public abstract class
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> :
AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> {
readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {

if (_statusListeners.Contains(listener)) {
listener(status);
}
} catch (Exception exception) {
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation
<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying status listeners for " + GetType(),
informationCollector: information => {
information.AppendLine("The " + GetType() + " notifying status listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying status listeners for " + GetType()),
informationCollector: infoCollector
));
}
}

public abstract class AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T> {
public abstract class
AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T
> {
readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {

if (_statusListeners.Contains(listener)) {
listener(status);
}
} catch (Exception exception) {
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying status listeners for " + GetType(),
informationCollector: information => {
information.AppendLine("The " + GetType() + " notifying status listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying status listeners for " + GetType()),
informationCollector: infoCollector
));
}
}

public abstract class AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> : AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> {
public abstract class
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> :
AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> {
readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {

if (_statusListeners.Contains(listener)) {
listener(status);
}
} catch (Exception exception) {
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation
<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying status listeners for " + GetType(),
informationCollector: information => {
information.AppendLine("The " + GetType() + " notifying status listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying status listeners for " + GetType()),
informationCollector: infoCollector
}

30
com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.njk


listener();
}
} catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalListenersMixin{{with | safe}}>(
"The " + this.GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying listeners for " + this.GetType(),
informationCollector: information => {
information.AppendLine("The " + this.GetType() + " notifying listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying listeners for " + this.GetType()),
informationCollector: infoCollector
));
}
}

listener(status);
}
} catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalStatusListenersMixin{{with | safe}}>(
"The " + this.GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying status listeners for " + this.GetType(),
informationCollector: information => {
information.AppendLine("The " + this.GetType() + " notifying status listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying status listeners for " + this.GetType()),
informationCollector: infoCollector
));
}
}

23
com.unity.uiwidgets/Runtime/cupertino/app.cs


bool checkerboardRasterCacheImages = false,
bool checkerboardOffscreenLayers = false,
bool showSemanticsDebugger = false,
bool debugShowCheckedModeBanner = true
bool debugShowCheckedModeBanner = true,
//Dictionary<LogicalKeySet, Intent> shortcuts = null,
//Dictionary<LocalKey, ActionFactory> actions = null
Dictionary<LogicalKeySet, Intent> shortcuts = null,
Dictionary<LocalKey, ActionFactory> actions = null
//D.assert(routes != null);
//D.assert(navigatorObservers != null);
D.assert(routes != null);
D.assert(navigatorObservers != null);
D.assert(title != null);
D.assert(showPerformanceOverlay != null);
D.assert(checkerboardRasterCacheImages != null);

this.localeResolutionCallback = localeResolutionCallback;
this.supportedLocales = supportedLocales;
this.showPerformanceOverlay = showPerformanceOverlay;
this.shortcuts = shortcuts;
this.actions = actions;
}
public readonly GlobalKey<NavigatorState> navigatorKey;

public readonly bool debugShowWidgetInspector;
public readonly bool debugShowCheckedModeBanner;
//TBC ????
//public readonly Dictionary<LogicalKeySet, Intent> shortcuts;
//public readonly Dictionary<LocalKey, ActionFactory> actions;
public readonly Dictionary<LogicalKeySet, Intent> shortcuts;
public readonly Dictionary<LocalKey, ActionFactory> actions;
public override State createState() {
return new _CupertinoAppState();

padding: EdgeInsets.zero,
onPressed: onPressed
);
}//,
//shortcuts: widget.shortcuts,
//actions: widget.actions,
},
shortcuts: widget.shortcuts,
actions: widget.actions
);
}
)

381
com.unity.uiwidgets/Runtime/foundation/assertions.cs


namespace Unity.UIWidgets.foundation {
public delegate void UIWidgetsExceptionHandler(UIWidgetsErrorDetails details);
public delegate void InformationCollector(StringBuilder information);
public delegate IEnumerable<DiagnosticsNode> DiagnosticPropertiesTransformer(IEnumerable<DiagnosticsNode> properties);
public delegate IEnumerable<DiagnosticsNode> InformationCollector();
internal abstract class _ErrorDiagnostic : DiagnosticsProperty<List<object>> {
internal _ErrorDiagnostic(
String message,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.flat,
DiagnosticLevel level = DiagnosticLevel.info
) : base(
name: null,
value: new List<object>() {message},
showName: false,
showSeparator: false,
defaultValue: null,
style: style,
level: level) {
D.assert(message != null);
}
internal _ErrorDiagnostic(
List<object> messageParts,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.flat,
DiagnosticLevel level = DiagnosticLevel.info
) : base(
name: null,
value: messageParts,
showName: false,
showSeparator: false,
defaultValue: null,
style: style,
level: level) {
D.assert(messageParts != null);
}
protected override string valueToString(TextTreeConfiguration parentConfiguration = null) {
return string.Join("", value);
}
}
internal class ErrorDescription : _ErrorDiagnostic {
public ErrorDescription(string message) : base(message, level: DiagnosticLevel.info) {
}
public ErrorDescription(List<object> messageParts) : base(messageParts, level: DiagnosticLevel.info) {
}
}
internal class ErrorSummary : _ErrorDiagnostic {
public ErrorSummary(string message) : base(message, level: DiagnosticLevel.summary) {
}
public ErrorSummary(List<object> messageParts) : base(messageParts, level: DiagnosticLevel.summary) {
}
}
internal class ErrorHint : _ErrorDiagnostic {
public ErrorHint(string message) : base(message, level: DiagnosticLevel.hint) {
}
public ErrorHint(List<object> messageParts) : base(messageParts, level: DiagnosticLevel.hint) {
}
}
public class ErrorSpacer : DiagnosticsProperty<object> {
public ErrorSpacer() : base(

}
}
public class UIWidgetsErrorDetails {
public class UIWidgetsErrorDetails : Diagnosticable {
string context = null,
DiagnosticsNode context = null,
IterableFilter<string> stackFilter = null,
InformationCollector informationCollector = null,
bool silent = false

this.silent = silent;
}
public static readonly List<DiagnosticPropertiesTransformer> propertiesTransformers =
new List<DiagnosticPropertiesTransformer>();
public readonly string context;
public readonly DiagnosticsNode context;
public readonly bool silent;
public string exceptionAsString() {

return longMessage;
}
public override string ToString() {
var buffer = new StringBuilder();
if (library.isNotEmpty() || context.isNotEmpty()) {
if (library.isNotEmpty()) {
buffer.AppendFormat("Error caught by {0}", library);
if (context.isNotEmpty()) {
buffer.Append(", ");
}
Diagnosticable _exceptionToDiagnosticable() {
return null;
}
public DiagnosticsNode summary {
get {
string formatException() {
return exceptionAsString().Split('\n')[0].TrimStart();
else {
buffer.Append("Exception ");
if (foundation_.kReleaseMode) {
return DiagnosticsNode.message(formatException());
if (context.isNotEmpty()) {
buffer.AppendFormat("thrown {0}", context);
Diagnosticable diagnosticable = _exceptionToDiagnosticable();
DiagnosticsNode summary = null;
if (diagnosticable != null) {
DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder();
debugFillProperties(builder);
summary = builder.properties.First((DiagnosticsNode node) => node.level == DiagnosticLevel.summary);
buffer.Append(". ");
return summary ?? new ErrorSummary(formatException());
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
DiagnosticsNode verb = context != null
? new ErrorDescription($"thrown {new ErrorDescription($" {context}")}")
: new ErrorDescription("");
Diagnosticable diagnosticable = _exceptionToDiagnosticable();
if (exception is NullReferenceException) {
properties.add(new ErrorDescription($"The null value was {verb}."));
buffer.Append("An error was caught. ");
DiagnosticsNode errorName;
errorName = new ErrorDescription($"{exception.GetType()}");
properties.add(new ErrorDescription($"The following {errorName} was {verb}:"));
if (diagnosticable != null) {
diagnosticable.debugFillProperties(properties);
}
else {
string prefix = $"{exception.GetType()}";
string message = exceptionAsString();
if (message.StartsWith(prefix)) {
message = message.Substring(prefix.Length);
}
properties.add(new ErrorSummary(message));
}
buffer.AppendLine(exceptionAsString());
informationCollector(buffer);
properties.add(new ErrorSpacer());
foreach (var diagnosticsNode in informationCollector()) {
properties.add(diagnosticsNode);
}
}
if (exception.StackTrace != null) {
IEnumerable<string> stackLines = exception.StackTrace.TrimEnd().Split('\n');
if (stackFilter != null) {
stackLines = stackFilter(stackLines);
public override string toStringShort() {
return library != null ? $"Exception caught by {library}" : "Exception caught";
}
public override string toString(DiagnosticLevel minLevel = DiagnosticLevel.info) {
return toDiagnosticsNode(style: DiagnosticsTreeStyle.error).toStringDeep(minLevel: minLevel);
}
public override DiagnosticsNode toDiagnosticsNode(string name = null,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse) {
return new _UIWIdgetsErrorDetailsNode(
name: name,
value: this,
style: style
);
}
}
internal class _UIWIdgetsErrorDetailsNode : DiagnosticableNode<UIWidgetsErrorDetails> {
public _UIWIdgetsErrorDetailsNode(
string name,
UIWidgetsErrorDetails value,
DiagnosticsTreeStyle style
) : base(
name: name,
value: value,
style: style
) {
D.assert(value != null);
}
new DiagnosticPropertiesBuilder builder {
get {
DiagnosticPropertiesBuilder builder = base.builder;
if (builder == null) {
return null;
else {
stackLines = UIWidgetsError.defaultStackFilter(stackLines);
IEnumerable<DiagnosticsNode> properties = builder.properties;
foreach (DiagnosticPropertiesTransformer transformer in UIWidgetsErrorDetails.propertiesTransformers) {
properties = transformer(properties);
buffer.Append(string.Join("\n", stackLines.ToArray()));
return new DiagnosticPropertiesBuilder(properties.ToList());
return buffer.ToString().TrimEnd();
}
}
class DiagnosticsStackTrace : DiagnosticsBlock {

}
}
public UIWidgetsError(string message) : base(message) {
public UIWidgetsError(string message) {
string[] lines = message.Split('\n');
diagnostics = new List<DiagnosticsNode>() {
new ErrorSummary(lines[0])
};
for (var i = 1; i < lines.Length; i++) {
diagnostics.Add(new ErrorDescription(lines[i]));
}
}
public UIWidgetsError(List<DiagnosticsNode> diagnostics) {
this.diagnostics = diagnostics;
D.assert(diagnostics != null && diagnostics.isNotEmpty(), () => new UIWidgetsError(new List<DiagnosticsNode>() {new ErrorSummary("Empty FlutterError")}).ToString());
D.assert(diagnostics.first().level == DiagnosticLevel.summary,
() => new UIWidgetsError(new List<DiagnosticsNode>() {
new ErrorSummary("UIWidgetsError is missing a summary."),
new ErrorDescription("All UIWidgetsError objects should start with a short (one line) " +
"summary description of the problem that was detected."),
new DiagnosticsProperty<UIWidgetsError>("Malformed", this, expandableValue: true, showSeparator: false, style : DiagnosticsTreeStyle.whitespace),
new ErrorDescription(
"\nThis error should still help you solve your problem, " +
"however please also report this malformed error in the " +
"framework by filing a bug on GitHub:\n" +
" https://https://github.com/Unity-Technologies/com.unity.uiwidgets"
)
}).ToString());
D.assert(() => {
IEnumerable<DiagnosticsNode> summaries =
diagnostics.Where((DiagnosticsNode node) => node.level == DiagnosticLevel.summary);
if (summaries.Count() > 1) {
return false;
}
return true;
}, () => {
IEnumerable<DiagnosticsNode> summaries =
diagnostics.Where((DiagnosticsNode node) => node.level == DiagnosticLevel.summary);
List<DiagnosticsNode> message = new List<DiagnosticsNode>() {
new ErrorSummary("UIWidgetsError contained multiple error summaries."),
new ErrorDescription(
"All UIWidgetsError objects should have only a single short " +
"(one line) summary description of the problem that was " +
"detected."
),
new DiagnosticsProperty<UIWidgetsError>("Malformed", this, expandableValue: true, showSeparator: false, style : DiagnosticsTreeStyle.whitespace)
};
int i = 0;
foreach (DiagnosticsNode summary in summaries) {
message.Add(new DiagnosticsProperty<DiagnosticsNode>($"Summary {i}", summary, expandableValue : true));
i += 1;
}
message.Add(new ErrorDescription(
"\nThis error should still help you solve your problem, " +
"however please also report this malformed error in the " +
"framework by filing a bug on GitHub:\n" +
" https://https://github.com/Unity-Technologies/com.unity.uiwidgets"
));
return new UIWidgetsError(message).ToString();
});
public readonly List<DiagnosticsNode> diagnostics;
public override string Message => ToString();
static int _errorCount = 0;
public static void resetErrorCount() {
_errorCount = 0;
}
const int wrapWidth = 100;
public static void dumpErrorToConsole(UIWidgetsErrorDetails details) {
dumpErrorToConsole(details, forceReport: false);
}

return;
}
D.logError(details.ToString(), details.exception);
if (_errorCount == 0 || forceReport) {
D.logError(new TextTreeRenderer(
wrapWidth: wrapWidth,
wrapWidthProperties: wrapWidth,
maxDescendentsTruncatableNode: 5).render(
details.toDiagnosticsNode(style: DiagnosticsTreeStyle.error)).TrimEnd(), details.exception);
}
D.logError($"Another exception was thrown: ${details.summary}");
_errorCount += 1;
}
public static IEnumerable<string> defaultStackFilter(IEnumerable<string> frames) {

public static void reportError(UIWidgetsErrorDetails details) {
D.assert(details != null);
D.assert(details.exception != null);
if (onError != null) {
onError(details);
public void debugFillProperties(DiagnosticPropertiesBuilder properties) {
foreach (var diagnosticsNode in diagnostics)
{
properties.add(diagnosticsNode);
}
internal abstract class _ErrorDiagnostic : DiagnosticsProperty<List<object>> {
/// This constructor provides a reliable hook for a kernel transformer to find
/// error messages that need to be rewritten to include object references for
/// interactive display of errors.
internal _ErrorDiagnostic(
String message,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse, // DiagnosticsTreeStyle.flat
DiagnosticLevel level = DiagnosticLevel.info
) : base(
name: null,
value: new List<object>() {message},
showName: false,
showSeparator: false,
defaultValue: null,
style: style,
level: level) {
D.assert(message != null);
}
public string toStringShort() => "UIWidgetsError";
/// In debug builds, a kernel transformer rewrites calls to the default
/// constructors for [ErrorSummary], [ErrorDetails], and [ErrorHint] to use
/// this constructor.
//
// ```dart
// _ErrorDiagnostic('Element $element must be $color')
// ```
// Desugars to:
// ```dart
// _ErrorDiagnostic.fromParts(<Object>['Element ', element, ' must be ', color])
// ```
//
// Slightly more complex case:
// ```dart
// _ErrorDiagnostic('Element ${element.runtimeType} must be $color')
// ```
// Desugars to:
//```dart
// _ErrorDiagnostic.fromParts(<Object>[
// 'Element ',
// DiagnosticsProperty(null, element, description: element.runtimeType?.toString()),
// ' must be ',
// color,
// ])
// ```
internal _ErrorDiagnostic(
List<object> messageParts,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse,
DiagnosticLevel level = DiagnosticLevel.info
) : base(
name: null,
value: messageParts,
showName: false,
showSeparator: false,
defaultValue: null,
style: style,
level: level) {
D.assert(messageParts != null);
public override string ToString() {
TextTreeRenderer renderer = new TextTreeRenderer(wrapWidth: 400000000);
return string.Join("\n", diagnostics.Select((DiagnosticsNode node) => renderer.render(node).TrimEnd()));
protected override string valueToString(TextTreeConfiguration parentConfiguration = null) {
return String.Join("", value);
}
}
internal class ErrorDescription : _ErrorDiagnostic {
/// A lint enforces that this constructor can only be called with a string
/// literal to match the limitations of the Dart Kernel transformer that
/// optionally extracts out objects referenced using string interpolation in
/// the message passed in.
///
/// The message will display with the same text regardless of whether the
/// kernel transformer is used. The kernel transformer is required so that
/// debugging tools can provide interactive displays of objects described by
/// the error.
public ErrorDescription(string message) : base(message, level: DiagnosticLevel.info) {
}
/// Calls to the default constructor may be rewritten to use this constructor
/// in debug mode using a kernel transformer.
// ignore: unused_element
public ErrorDescription(List<object> messageParts) : base(messageParts, level: DiagnosticLevel.info) {
public static void reportError(UIWidgetsErrorDetails details) {
D.assert(details != null);
D.assert(details.exception != null);
if (onError != null) {
onError(details);
}
}
}
}

9
com.unity.uiwidgets/Runtime/foundation/binding.cs


protected BindingBase() {
Timeline.startSync("Framework initialization");
D.assert(!_debugInitialized);
D.assert(_debugInitialized);
initServiceExtensions();

}
static bool _debugInitialized = false;
D.assert(!_debugInitialized);
D.assert(() => {
_debugInitialized = true;
return true;
});
}
protected virtual void initServiceExtensions() {

15
com.unity.uiwidgets/Runtime/foundation/change_notifier.cs


}
}
catch (Exception ex) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<ChangeNotifier>(
$"The {GetType()} sending notification was",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while dispatching notifications for " + GetType(),
informationCollector: information => {
information.AppendLine("The " + GetType() + " sending notification was:");
information.Append(" " + this);
}
context: new ErrorDescription($"while dispatching notifications for {GetType()}"),
informationCollector: infoCollector
));
}
}

891
com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
文件差异内容过多而无法显示
查看文件

4
com.unity.uiwidgets/Runtime/foundation/object.cs


namespace Unity.UIWidgets.foundation {
public static partial class foundation_ {
public static string objectRuntimeType(object @object, string optimizedValue) {
public static string objectRuntimeType(object obj, string optimizedValue) {
optimizedValue = @object.GetType().ToString();
optimizedValue = obj.GetType().ToString();
return true;
});
return optimizedValue;

16
com.unity.uiwidgets/Runtime/foundation/observer_list.cs


_list.Add(item);
}
public void Clear() {
public bool Remove(T item) {
_list.Clear();
_set?.Clear();
return _list.Remove(item);
}
public bool Contains(T item) {

_set.Clear();
_set.UnionWith(_list);
}
_isDirty = false;
}

public void CopyTo(T[] array, int arrayIndex) {
_list.CopyTo(array, arrayIndex);
public void Clear() {
_isDirty = true;
_list.Clear();
public bool Remove(T item) {
_isDirty = true;
return _list.Remove(item);
public void CopyTo(T[] array, int arrayIndex) {
_list.CopyTo(array, arrayIndex);
}
public int Count {

6
com.unity.uiwidgets/Runtime/foundation/print.cs


using System.Text.RegularExpressions;
namespace Unity.UIWidgets.foundation {
enum _WordWrapParseMode {
inSpace,
inWord,
atBreak
}
public static class DebugPrint {
static readonly Regex _indentPattern = new Regex("^ *(?:[-+*] |[0-9]+[.):] )?");

11
com.unity.uiwidgets/Runtime/gestures/binding.cs


pointerRouter.route(evt);
}
catch (Exception ex) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<PointerEvent>("Event", evt, style: DiagnosticsTreeStyle.errorProperty);
}
context: "while dispatching a non-hit-tested pointer event",
informationCollector: information => {
information.AppendLine("Event: ");
information.AppendFormat(" {0}", evt);
}
context: new ErrorDescription("while dispatching a non-hit-tested pointer event"),
informationCollector: infoCollector
)
);
}

11
com.unity.uiwidgets/Runtime/gestures/pointer_signal_resolver.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.gestures {

_firstRegisteredCallback(_currentEvent);
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<PointerSignalEvent>("Event", evt, style: DiagnosticsTreeStyle.errorProperty);
}
context: "while resolving a PointerSignalEvent",
informationCollector: information => {
information.AppendLine("Event: ");
information.AppendFormat(" {0}", evt);
}
context: new ErrorDescription("while resolving a PointerSignalEvent"),
informationCollector: infoCollector
)
);
}

26
com.unity.uiwidgets/Runtime/gestures/recognizer.cs


result = callback();
}
catch (Exception ex) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new StringProperty("Handler", name);
yield return new DiagnosticsProperty<GestureRecognizer>("Recognizer", this, style: DiagnosticsTreeStyle.errorProperty);
}
context: "while handling a gesture",
informationCollector: information => {
information.AppendLine("Handler: " + name);
information.AppendLine("Recognizer:");
information.AppendLine(" " + this);
}
context: new ErrorDescription("while handling a gesture"),
informationCollector: infoCollector
));
}

}
catch (Exception ex) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new StringProperty("Handler", name);
yield return new DiagnosticsProperty<GestureRecognizer>("Recognizer", this, style: DiagnosticsTreeStyle.errorProperty);
}
context: "while handling a gesture",
informationCollector: information => {
information.AppendLine("Handler: " + name);
information.AppendLine("Recognizer:");
information.AppendLine(" " + this);
}
context: new ErrorDescription("while handling a gesture"),
informationCollector: infoCollector
));
}

41
com.unity.uiwidgets/Runtime/painting/image_provider.cs


stream.setCompleter(imageCompleter);
InformationCollector collector = null;
D.assert(() => {
collector = (sb) => {
sb.Append(new DiagnosticsProperty<ImageProvider>("Image provider", this));
sb.Append(new DiagnosticsProperty<ImageConfiguration>("Image configuration",
configuration));
sb.Append(new DiagnosticsProperty<T>("Image key", key, defaultValue: null));
};
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<ImageProvider>("Image provider", this);
yield return new DiagnosticsProperty<ImageConfiguration>("Image configuration",
configuration);
yield return new DiagnosticsProperty<T>("Image key", key, defaultValue: null);
}
collector = infoCollector;
return true;
});
imageCompleter.setError(

}
protected override ImageStreamCompleter load(AssetBundleImageKey key, DecoderCallback decode) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<ImageProvider>("Image provider", this);
yield return new DiagnosticsProperty<AssetBundleImageKey>("Image key", key);
}
informationCollector: information => {
information.AppendLine($"Image provider: {this}");
information.Append($"Image key: {key}");
}
informationCollector: infoCollector
);
}

}
protected override ImageStreamCompleter load(NetworkImage key, DecoderCallback decode) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new ErrorDescription($"url: {url}");
}
informationCollector: information => {
information.AppendLine($"Image provider: {this}");
information.Append($"Image key: {key}");
}
informationCollector: infoCollector
);
}

}
protected override ImageStreamCompleter load(FileImage key, DecoderCallback decode) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new ErrorDescription($"Path: {file}");
}
informationCollector: information => { information.AppendLine($"Path: {file}"); });
informationCollector: infoCollector);
}
Future<Codec> _loadAsync(FileImage key, DecoderCallback decode) {

bool silent = false
) {
reportError(
context: context.toDescription(),
context: context,
exception: exception,
informationCollector: informationCollector,
silent: silent

14
com.unity.uiwidgets/Runtime/painting/image_stream.cs


}
catch (Exception ex) {
reportError(
context: "by a synchronously-called image listener",
context: new ErrorDescription("by a synchronously-called image listener"),
exception: ex
);
}

new UIWidgetsErrorDetails(
exception: ex,
library: "image resource service",
context: "when reporting an error to an image listener"
context: new ErrorDescription("when reporting an error to an image listener")
)
);
}

}
catch (Exception ex) {
reportError(
context: "by an image listener",
context: new ErrorDescription("by an image listener"),
exception: ex
);
}

protected void reportError(
string context = null,
DiagnosticsNode context = null,
Exception exception = null,
InformationCollector informationCollector = null,
bool silent = false) {

catch (Exception ex) {
UIWidgetsError.reportError(
new UIWidgetsErrorDetails(
context: "when reporting an error to an image listener",
context: new ErrorDescription("when reporting an error to an image listener"),
library: "image resource service",
exception: ex
)

image.then_(result => { setImage(result); }).catchError(err => {
reportError(
context: "resolving a single-frame image stream",
context: new ErrorDescription("resolving a single-frame image stream"),
exception: err,
informationCollector: informationCollector,
silent: true

codec.then_((Action<Codec>) _handleCodecReady, ex => {
reportError(
context: "resolving an image codec",
context: new ErrorDescription("resolving an image codec"),
exception: ex,
informationCollector: informationCollector,
silent: true

33
com.unity.uiwidgets/Runtime/rendering/box.cs


InformationCollector informationCollector = null
) {
D.assert(() => {
var throwError = new Action<string>(message => {
var information = new StringBuilder();
var throwError = new Action<DiagnosticsNode>(message => {
var diagnositicsInfo = new List<DiagnosticsNode>();
diagnositicsInfo.Add(message);
informationCollector(information);
diagnositicsInfo.AddRange(informationCollector.Invoke());
throw new UIWidgetsError($"{message}\n{information}The offending constraints were:\n {this}");
diagnositicsInfo.Add(new DiagnosticsProperty<BoxConstraints>("The offending constraints were", this, style: DiagnosticsTreeStyle.errorProperty));
throw new UIWidgetsError(
diagnositicsInfo
);
});
if (minWidth.isNaN() ||

whichFields = affectedFieldsList.Single();
}
throwError("BoxConstraints has NaN values in " + whichFields + ".");
throwError(new ErrorSummary("BoxConstraints has NaN values in " + whichFields + "."));
throwError("BoxConstraints has both a negative minimum width and a negative minimum height.");
throwError(new ErrorSummary("BoxConstraints has both a negative minimum width and a negative minimum height."));
throwError("BoxConstraints has a negative minimum width.");
throwError(new ErrorSummary("BoxConstraints has a negative minimum width."));
throwError("BoxConstraints has a negative minimum height.");
throwError(new ErrorSummary("BoxConstraints has a negative minimum height."));
throwError("BoxConstraints has both width and height constraints non-normalized.");
throwError(new ErrorSummary("BoxConstraints has both width and height constraints non-normalized."));
throwError("BoxConstraints has non-normalized width constraints.");
throwError(new ErrorSummary("BoxConstraints has non-normalized width constraints."));
throwError("BoxConstraints has non-normalized height constraints.");
throwError(new ErrorSummary("BoxConstraints has non-normalized height constraints."));
throwError("BoxConstraints forces an infinite width and infinite height.");
throwError(new ErrorSummary("BoxConstraints forces an infinite width and infinite height."));
throwError("BoxConstraints forces an infinite width.");
throwError(new ErrorSummary("BoxConstraints forces an infinite width."));
throwError("BoxConstraints forces an infinite height.");
throwError(new ErrorSummary("BoxConstraints forces an infinite height."));
}
}

46
com.unity.uiwidgets/Runtime/rendering/debug_overflow_indicator.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEditor.PackageManager;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Gradient = Unity.UIWidgets.ui.Gradient;

return regions;
}
static void _reportOverflow(RenderObject renderObject, RelativeRect overflow, string overflowHints) {
overflowHints = overflowHints ?? $"The edge of the {renderObject.GetType()} that is " +
"overflowing has been marked in the rendering with a yellow and black " +
"striped pattern. This is usually caused by the contents being too big " +
$"for the {renderObject.GetType()}.\n" +
"This is considered an error condition because it indicates that there " +
"is content that cannot be seen. If the content is legitimately bigger " +
"than the available space, consider clipping it with a ClipRect widget " +
$"before putting it in the {renderObject.GetType()}, or using a scrollable " +
"container, like a ListView.";
static void _reportOverflow(RenderObject renderObject, RelativeRect overflow, List<DiagnosticsNode> overflowHints) {
overflowHints = overflowHints ?? new List<DiagnosticsNode>();
if (overflowHints.isEmpty()) {
overflowHints.Add(new ErrorDescription($"The edge of the {renderObject.GetType()} that is " +
"overflowing has been marked in the rendering with a yellow and black " +
"striped pattern. This is usually caused by the contents being too big " +
$"for the {renderObject.GetType()}."));
overflowHints.Add(new ErrorHint("This is considered an error condition because it indicates that there " +
"is content that cannot be seen. If the content is legitimately bigger " +
"than the available space, consider clipping it with a ClipRect widget " +
$"before putting it in the {renderObject.GetType()}, or using a scrollable " +
"container, like a ListView."));
}
List<string> overflows = new List<string> { };
if (overflow.left > 0.0f) {

break;
}
IEnumerable<DiagnosticsNode> infoCollector() {
foreach (var hint in overflowHints) {
yield return hint;
}
yield return DiagnosticsNode.message($"The specific {renderObject.GetType()} in question is: {renderObject.toStringShallow(joiner: "\n ")}");
yield return DiagnosticsNode.message(string.Concat(Enumerable.Repeat("◢◤", 32)));
}
context: "during layout",
informationCollector: (information) => {
information.AppendLine(overflowHints);
information.AppendLine($"The specific {renderObject.GetType()} in question is:");
information.AppendLine($" {renderObject.toStringShallow(joiner: "\n ")}");
information.AppendLine(string.Concat(Enumerable.Repeat("◢◤", 32)));
}
context: new ErrorDescription("during layout"),
informationCollector: infoCollector
)
);
}

Offset offset,
Rect containerRect,
Rect childRect,
string overflowHints = null
List<DiagnosticsNode> overflowHints = null
) {
RelativeRect overflow = RelativeRect.fromRect(containerRect, childRect);

23
com.unity.uiwidgets/Runtime/rendering/flex.cs


context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint);
D.assert(() => {
string debugOverflowHints =
$"The overflowing {GetType()} has an orientation of {_direction}.\n" +
List<DiagnosticsNode> debugOverflowHints = new List<DiagnosticsNode>{
new ErrorDescription(
$"The overflowing {GetType()} has an orientation of {_direction}."
),
new ErrorDescription(
"in the rendering with a yellow and black striped pattern. This is " +
$"usually caused by the contents being too big for the {GetType()}. " +
"in the rendering with a yellow and black striped pattern. This is " +
"usually caused by the contents being too big for the $runtimeType."
),
new ErrorHint(
"space instead of being sized to their natural size.\n" +
"space instead of being sized to their natural size."
),
new ErrorHint(
"than a Flex, like a ListView.";
"than a Flex, like a ListView."
)
};
Rect overflowChildRect;
switch (_direction) {
case Axis.horizontal:

20
com.unity.uiwidgets/Runtime/rendering/layer.cs


}
List<PictureLayer> _processConflictingPhysicalLayers(PhysicalModelLayer predecessor, PhysicalModelLayer child) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return child.toDiagnosticsNode(name: "Attempted to composite layer",
style: DiagnosticsTreeStyle.errorProperty);
yield return predecessor.toDiagnosticsNode(name: "after layer",
style: DiagnosticsTreeStyle.errorProperty);
yield return new ErrorDescription("which occupies the same area at a higher elevation.");
}
context: "during compositing",
informationCollector: (StringBuilder builder) => {
builder.AppendLine("Attempted to composite layer");
builder.AppendLine(child.ToString());
builder.AppendLine("after layer");
builder.AppendLine(predecessor.ToString());
builder.AppendLine("which occupies the same area at a higher elevation.");
}
library: "rendering library",
context: new ErrorDescription("during compositing"),
informationCollector: infoCollector
return new List<PictureLayer> {
_highlightConflictingLayer(predecessor),
_highlightConflictingLayer(child)

97
com.unity.uiwidgets/Runtime/rendering/object.cs


public object debugCreator;
void _debugReportException(string method, Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsDebugCreator(debugCreator);
yield return describeForError("The following RenderObject was being processed when the exception was fired");
yield return describeForError("RenderObject", style: DiagnosticsTreeStyle.truncateChildren);
}
context: "during " + method,
context: new ErrorDescription("during " + method),
informationCollector: information => {
information.AppendLine(
"The following RenderObject was being processed when the exception was fired:");
information.AppendLine(" " + toStringShallow(joiner: "\n "));
var descendants = new List<string>();
const int maxDepth = 5;
int depth = 0;
const int maxLines = 25;
int lines = 0;
RenderObjectVisitor visitor = null;
visitor = new RenderObjectVisitor((RenderObject child) => {
if (lines < maxLines) {
depth += 1;
descendants.Add(new string(' ', 2 * depth) + child);
if (depth < maxDepth) {
child.visitChildren(visitor);
}
depth -= 1;
}
else if (lines == maxLines) {
descendants.Add(" ...(descendants list truncated after " + lines + " lines)");
}
lines += 1;
});
visitChildren(visitor);
if (lines > 1) {
information.AppendLine(
"This RenderObject had the following descendants (showing up to depth " +
maxDepth + "):");
}
else if (descendants.Count == 1) {
information.AppendLine("This RenderObject had the following child:");
}
else {
information.AppendLine("This RenderObject has no descendants.");
}
information.Append(string.Join("\n", descendants.ToArray()));
}
informationCollector: infoCollector
));
}

public void layout(Constraints constraints, bool parentUsesSize = false) {
D.assert(constraints != null);
D.assert(constraints.debugAssertIsValid(
isAppliedConstraint: true,
informationCollector: information => {
// final List<String> stack = StackTrace.current.toString().split('\n');
// int targetFrame;
// final Pattern layoutFramePattern = RegExp(r'^#[0-9]+ +RenderObject.layout \(');
// for (int i = 0; i < stack.length; i += 1) {
// if (layoutFramePattern.matchAsPrefix(stack[i]) != null) {
// targetFrame = i + 1;
// break;
// }
// }
// if (targetFrame != null && targetFrame < stack.length) {
// information.writeln(
// 'These invalid constraints were provided to $runtimeType\'s layout() '
// 'function by the following function, which probably computed the '
// 'invalid constraints in question:'
// );
// final Pattern targetFramePattern = RegExp(r'^#[0-9]+ +(.+)$');
// final Match targetFrameMatch = targetFramePattern.matchAsPrefix(stack[targetFrame]);
// if (targetFrameMatch != null && targetFrameMatch.groupCount > 0) {
// information.writeln(' ${targetFrameMatch.group(1)}');
// } else {
// information.writeln(stack[targetFrame]);
// }
// }
}));
D.assert(
() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new ErrorDescription(
$"These invalid constraints were provided to {GetType()}'s layout() " +
"function by the following function, which probably computed the " +
"invalid constraints in question:\n" +
" unknown");
}
return constraints.debugAssertIsValid(
isAppliedConstraint: true,
informationCollector: infoCollector);
}
);
D.assert(!_debugDoingThisResize);
D.assert(!_debugDoingThisLayout);

);
}
}
protected DiagnosticsNode describeForError(String name, DiagnosticsTreeStyle style = DiagnosticsTreeStyle.shallow) {
return toDiagnosticsNode(name: name, style: style);
}
}
public interface RenderObjectWithChildMixin {

public UIWidgetsErrorDetailsForRendering(
Exception exception = null,
string library = null,
string context = null,
DiagnosticsNode context = null,
RenderObject renderObject = null,
InformationCollector informationCollector = null,
bool silent = false

100
com.unity.uiwidgets/Runtime/rendering/sliver.cs


using System;
using System.Collections.Generic;
using System.Text;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;

InformationCollector informationCollector = null
) {
D.assert(() => {
bool hasErrors = false;
StringBuilder errorMessage = new StringBuilder("\n");
var information = new StringBuilder();
if (informationCollector != null) {
informationCollector(information);
}
throw new UIWidgetsError(
$"{GetType()} is not valid: {message}\n{information}The offending constraints were: \n {this}");
hasErrors = true;
errorMessage.AppendLine($" {message}");
});
verify(scrollOffset >= 0.0f, "The \"scrollOffset\" is negative.");

verify(remainingCacheExtent >= 0.0f, "The \"remainingCacheExtent\" is negative.");
verify(cacheOrigin <= 0.0f, "The \"cacheOrigin\" is positive.");
verify(isNormalized, "The constraints are not normalized.");
if (hasErrors) {
List<DiagnosticsNode> diagnosticInfo = new List<DiagnosticsNode>();
diagnosticInfo.Add(new ErrorSummary($"{GetType()} is not valid: {errorMessage}"));
if (informationCollector != null) {
diagnosticInfo.AddRange(informationCollector.Invoke());
}
diagnosticInfo.Add(new DiagnosticsProperty<SliverConstraints>("The offending constraints were", this, style: DiagnosticsTreeStyle.errorProperty));
throw new UIWidgetsError(
diagnosticInfo);
}
return true;
});

public readonly float cacheExtent;
public const float precisionErrorTolerance = 1e-10f;
internal static string _debugCompareFloats(string labelA, float valueA, string labelB, float valueB) {
internal static List<DiagnosticsNode> _debugCompareFloats(string labelA, float valueA, string labelB, float valueB) {
List<DiagnosticsNode> diagnosticInfo = new List<DiagnosticsNode>();
return $"The {labelA} is {valueA:F1}, but the {labelB} is {valueB:F1}. ";
diagnosticInfo.Add(new ErrorDescription($"The {labelA} is {valueA:F1}, but the {labelB} is {valueB:F1}. "));
}
else {
diagnosticInfo.Add(new ErrorDescription($"The {labelA} is {valueA}, but the {labelB} is {valueB}."));
diagnosticInfo.Add(new ErrorHint("Maybe you have fallen prey to floating point rounding errors, and should explicitly " +
$"apply the min() or max() functions, or the clamp() method, to the {labelB}? "));
return string.Format(
"The {0} is {1}, but the {2} is {3}. " +
"Maybe you have fallen prey to floating point rounding errors, and should explicitly " +
"apply the min() or max() functions, or the clamp() method, to the {2}? ",
labelA, valueA, labelB, valueB);
return diagnosticInfo;
var verify = new Action<bool, string>((bool check, string message) => {
void verify(bool check, string summary, List<DiagnosticsNode> details = null) {
List<DiagnosticsNode> diagnosticInfo = new List<DiagnosticsNode>();
diagnosticInfo.Add(new ErrorSummary($"{GetType()} is not valid: {summary}"));
if (details != null) {
diagnosticInfo.AddRange(details);
}
var information = new StringBuilder();
informationCollector(information);
diagnosticInfo.AddRange(informationCollector.Invoke());
throw new UIWidgetsError($"{GetType()} is not valid: {message}\n{information}");
});
throw new UIWidgetsError(diagnosticInfo);
};
verify(scrollExtent >= 0.0f, "The \"scrollExtent\" is negative.");
verify(paintExtent >= 0.0f, "The \"paintExtent\" is negative.");

verify(false,
"The \"layoutExtent\" exceeds the \"paintExtent\".\n" +
_debugCompareFloats("paintExtent", paintExtent, "layoutExtent",
"The \"layoutExtent\" exceeds the \"paintExtent\".",
details: _debugCompareFloats("paintExtent", paintExtent, "layoutExtent",
var details = _debugCompareFloats("maxPaintExtent", maxPaintExtent, "paintExtent",
paintExtent);
details.Add(new ErrorDescription("By definition, a sliver can\"t paint more than the maximum that it can paint!"));
"The \"maxPaintExtent\" is less than the \"paintExtent\".\n" +
_debugCompareFloats("maxPaintExtent", maxPaintExtent, "paintExtent",
paintExtent) +
"By definition, a sliver can\"t paint more than the maximum that it can paint!"
"The \"maxPaintExtent\" is less than the \"paintExtent\".",
details: details
);
}

}
protected override void debugAssertDoesMeetConstraints() {
D.assert(geometry.debugAssertIsValid(
informationCollector: (information) => {
information.AppendLine("The RenderSliver that returned the offending geometry was:");
information.AppendLine(" " + toStringShallow(joiner: "\n "));
}));
D.assert(
() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return describeForError("The RenderSliver that returned the offending geometry was");
}
return geometry.debugAssertIsValid(
informationCollector: infoCollector);
});
List<DiagnosticsNode> diagnosticInfo = new List<DiagnosticsNode>();
diagnosticInfo.Add(new ErrorSummary("SliverGeometry has a paintOffset that exceeds the remainingPaintExtent from the constraints."));
diagnosticInfo.Add(describeForError("The render object whose geometry violates the constraints is the following:"));
diagnosticInfo.AddRange(SliverGeometry._debugCompareFloats("remainingPaintExtent", constraints.remainingPaintExtent,
"paintExtent", geometry.paintExtent));
diagnosticInfo.Add(new ErrorDescription("The paintExtent must cause the child sliver to paint within the viewport, and so " +
"cannot exceed the remainingPaintExtent."));
"SliverGeometry has a paintOffset that exceeds the remainingPaintExtent from the constraints.\n" +
"The render object whose geometry violates the constraints is the following:\n" +
" " + toStringShallow(joiner: "\n ") + "\n" +
SliverGeometry._debugCompareFloats(
"remainingPaintExtent", constraints.remainingPaintExtent,
"paintExtent", geometry.paintExtent) +
"The paintExtent must cause the child sliver to paint within the viewport, and so " +
"cannot exceed the remainingPaintExtent."
diagnosticInfo
);
}

57
com.unity.uiwidgets/Runtime/scheduler2/binding.cs


using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEditor.PackageManager;
using UnityEngine;
using FrameTiming = Unity.UIWidgets.ui.FrameTiming;
using Timer = Unity.UIWidgets.async2.Timer;

D.assert(() => {
if (debugCurrentCallbackStack == null) {
throw new UIWidgetsError(
"scheduleFrameCallback called with rescheduling true, but no callback is in scope.\n" +
"The \"rescheduling\" argument should only be set to true if the " +
"callback is being reregistered from within the callback itself, " +
"and only then if the callback itself is entirely synchronous. \n" +
"If this is the initial registration of the callback, or if the " +
"callback is asynchronous, then do not use the \"rescheduling\" " +
"argument.");
new List<DiagnosticsNode>() {
new ErrorSummary(
"scheduleFrameCallback called with rescheduling true, but no callback is in scope."),
new ErrorDescription(
"The \"rescheduling\" argument should only be set to true if the " +
"callback is being reregistered from within the callback itself, " +
"and only then if the callback itself is entirely synchronous."),
new ErrorHint("If this is the initial registration of the callback, or if the " +
"callback is asynchronous, then do not use the \"rescheduling\" " +
"argument.")
});
}
return true;

catch (Exception ex) {
InformationCollector collector = null;
D.assert(() => {
collector = (StringBuilder sb) => {
sb.AppendLine("The TimingsCallback that gets executed was " + callback);
};
IEnumerable<DiagnosticsNode> infoCollect() {
yield return new DiagnosticsProperty<TimingsCallback>(
"The TimingsCallback that gets executed was",
callback,
style: DiagnosticsTreeStyle.errorProperty);
}
collector = infoCollect;
context: "while executing callbacks for FrameTiming",
context: new ErrorDescription("while executing callbacks for FrameTiming"),
informationCollector: collector
));
}

callbackStack = entry.debugStack;
return true;
});
IEnumerable<DiagnosticsNode> infoCollector() {
yield return DiagnosticsNode.message("\nThis exception was thrown in the context of a scheduler callback. " +
"When the scheduler callback was _registered_ (as opposed to when the " +
"exception was thrown), this was the stack: " + callbackStack);
}
context: "during a task callback",
context: new ErrorDescription("during a task callback"),
informationCollector: callbackStack == null
? (InformationCollector) null
: (StringBuilder sb) => {

}
public void scheduleFrame() {
if (_hasScheduledFrame || !_framesEnabled)
if (_hasScheduledFrame || !framesEnabled)
return;
D.assert(() => {

callback(timeStamp);
}
catch (Exception ex) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return DiagnosticsNode.message("\nThis exception was thrown in the context of a scheduler callback. " +
"When the scheduler callback was _registered_ (as opposed to when the " +
"exception was thrown), this was the stack:");
StringBuilder builder = new StringBuilder();
foreach (var line in UIWidgetsError.defaultStackFilter(
callbackStack.TrimEnd().Split('\n'))) {
builder.AppendLine(line);
}
yield return DiagnosticsNode.message(builder.ToString());
}
context: "during a scheduler callback",
context: new ErrorDescription("during a scheduler callback"),
informationCollector: callbackStack == null
? (InformationCollector) null
: (StringBuilder information) => {

14
com.unity.uiwidgets/Runtime/scheduler2/ticker.cs


using System;
using System.Collections.Generic;
using System.Text;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;

D.assert(() => {
if (isActive) {
throw new UIWidgetsError(
"A ticker was started twice.\nA ticker that is already active cannot be started again without first stopping it.\n" +
"The affected ticker was: " + toString(debugIncludeStack: true));
new List<DiagnosticsNode>() {
new ErrorSummary("A ticker was started twice."),
new ErrorDescription(
"A ticker that is already active cannot be started again without first stopping it."),
describeForError("The affected ticker was: ")
});
return true;
});

}
return _future;
}
DiagnosticsNode describeForError(string name) {
return new DiagnosticsProperty<Ticker>(name, this, description: toString(debugIncludeStack: true));
}
public void stop(bool canceled = false) {

4
com.unity.uiwidgets/Runtime/services/binding.cs


UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "services library",
context: "during a platform message response callback"
context: new ErrorDescription("during a platform message response callback")
));
}
});

UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "services library",
context: "during a platform message callback")
context: new ErrorDescription("during a platform message callback"))
);
callback(null);
return FutureOr.nil;

164
com.unity.uiwidgets/Runtime/widgets/app.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Unity.UIWidgets.services;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using TextStyle = Unity.UIWidgets.painting.TextStyle;

public delegate string GenerateAppTitle(BuildContext context);
public delegate PageRoute PageRouteFactory(RouteSettings settings, WidgetBuilder builder);
public delegate List<Route> InitialRouteListFactory(string initialRoute);
public class WidgetsApp : StatefulWidget {

public readonly bool checkerboardOffscreenLayers;
public readonly bool showSemanticsDebugger;
public readonly bool debugShowWidgetInspector;
public readonly Dictionary<LogicalKeySet, Intent> shortcuts;
public readonly Dictionary<LocalKey, ActionFactory> actions;
public WidgetsApp(
Key key = null,
GlobalKey<NavigatorState> navigatorKey = null,

bool showSemanticsDebugger = false,
bool debugShowWidgetInspector = false,
bool debugShowCheckedModeBanner = true,
InspectorSelectButtonBuilder inspectorSelectButtonBuilder = null
//shortcuts
//actions
InspectorSelectButtonBuilder inspectorSelectButtonBuilder = null,
Dictionary<LogicalKeySet, Intent> shortcuts = null,
Dictionary<LocalKey, ActionFactory> actions = null
) : base(key) {
routes = routes ?? new Dictionary<string, WidgetBuilder>();

//D.assert(routes != null);
D.assert(routes != null);
this.home = home;
this.navigatorKey = navigatorKey;
this.onGenerateRoute = onGenerateRoute;

this.title = title;
this.color = color;
this.inspectorSelectButtonBuilder = inspectorSelectButtonBuilder;
this.shortcuts = shortcuts;
this.actions = actions;
D.assert(
home == null ||

);
}
/*public static readonly Dictionary<LogicalKeySet, Intent> _defaultShortcuts = new Dictionary<LogicalKeySet, Intent>(){
// Activation
{new LogicalKeySet(LogicalKeyboardKey.enter), new Intent(ActivateAction.key)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.space), new Intent(ActivateAction.key)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.gameButtonA), new Intent(ActivateAction.key)},
// Keyboard traversal.
{new widgets.LogicalKeySet(LogicalKeyboardKey.tab), new Intent(NextFocusAction.key)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.shift, LogicalKeyboardKey.tab), new Intent(PreviousFocusAction.key)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowLeft), new DirectionalFocusIntent(TraversalDirection.left)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowRight), new DirectionalFocusIntent(TraversalDirection.right)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowDown), new DirectionalFocusIntent(TraversalDirection.down)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowUp), new DirectionalFocusIntent(TraversalDirection.up)},
// Scrolling
{new widgets.LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.arrowUp), new ScrollIntent(direction: AxisDirection.up)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.arrowDown), new ScrollIntent(direction: AxisDirection.down)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.arrowLeft), new ScrollIntent(direction: AxisDirection.left)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.arrowRight), new ScrollIntent(direction: AxisDirection.right)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.pageUp), new ScrollIntent(direction: AxisDirection.up, type: ScrollIncrementType.page)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.pageDown), new ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page)},
};
// Default shortcuts for the web platform.
public static readonly Dictionary<LogicalKeySet, Intent> _defaultWebShortcuts = new Dictionary<LogicalKeySet, Intent>(){
// Activation
{new widgets.LogicalKeySet(LogicalKeyboardKey.space), new Intent(ActivateAction.key)},
// Keyboard traversal.
{new widgets.LogicalKeySet(LogicalKeyboardKey.tab), new Intent(NextFocusAction.key)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.shift, LogicalKeyboardKey.tab),new Intent(PreviousFocusAction.key)},
// Scrolling
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowUp), new ScrollIntent(direction: AxisDirection.up)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowDown), new ScrollIntent(direction: AxisDirection.down)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowLeft), new ScrollIntent(direction: AxisDirection.left)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowRight), new ScrollIntent(direction: AxisDirection.right)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.pageUp), new ScrollIntent(direction: AxisDirection.up, type: ScrollIncrementType.page)},
{new widgets.LogicalKeySet(LogicalKeyboardKey.pageDown), new ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page)},
};
// Default shortcuts for the macOS platform.
public static readonly Dictionary<LogicalKeySet, Intent> _defaultMacOsShortcuts = new Dictionary<LogicalKeySet, Intent>(){
// Activation
new LogicalKeySet(LogicalKeyboardKey.enter), new Intent(ActivateAction.key),
new LogicalKeySet(LogicalKeyboardKey.space), new Intent(ActivateAction.key),
// Keyboard traversal
{new LogicalKeySet(LogicalKeyboardKey.tab), new Intent(NextFocusAction.key)},
{new LogicalKeySet(LogicalKeyboardKey.shift, LogicalKeyboardKey.tab), new Intent(PreviousFocusAction.key)},
{new LogicalKeySet(LogicalKeyboardKey.arrowLeft), new DirectionalFocusIntent(TraversalDirection.left)},
{new LogicalKeySet(LogicalKeyboardKey.arrowRight), new DirectionalFocusIntent(TraversalDirection.right)},
{new LogicalKeySet(LogicalKeyboardKey.arrowDown), new DirectionalFocusIntent(TraversalDirection.down)},
{new LogicalKeySet(LogicalKeyboardKey.arrowUp), new DirectionalFocusIntent(TraversalDirection.up)},
// Scrolling
{new LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.arrowUp), new ScrollIntent(direction: AxisDirection.up)},
{new LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.arrowDown), new ScrollIntent(direction: AxisDirection.down)},
{new LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.arrowLeft), new ScrollIntent(direction: AxisDirection.left)},
{new LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.arrowRight), new ScrollIntent(direction: AxisDirection.right)},
{new LogicalKeySet(LogicalKeyboardKey.pageUp), new ScrollIntent(direction: AxisDirection.up, type: ScrollIncrementType.page)},
{new LogicalKeySet(LogicalKeyboardKey.pageDown), new ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page)},
};
/// Generates the default shortcut key bindings based on the
/// [defaultTargetPlatform].
///
/// Used by [WidgetsApp] to assign a default value to [WidgetsApp.shortcuts].
public static Dictionary<LogicalKeySet, Intent> defaultShortcuts {
get {
if (kIsWeb) {
return _defaultWebShortcuts;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return _defaultShortcuts;
case TargetPlatform.macOS:
return _defaultMacOsShortcuts;
case TargetPlatform.iOS:
// No keyboard support on iOS yet.
break;
}
return new Dictionary<LogicalKeySet, Intent>();
}
}
/// The default value of [WidgetsApp.actions].
public static readonly Dictionary<LocalKey, ActionFactory> defaultActions = new Dictionary<LocalKey, ActionFactory>(){
{DoNothingAction.key, () => new DoNothingAction()},
{RequestFocusAction.key, () => new RequestFocusAction()},
{NextFocusAction.key, () => new NextFocusAction()},
{PreviousFocusAction.key, () => new PreviousFocusAction()},
{DirectionalFocusAction.key, () => new DirectionalFocusAction()},
{ScrollAction.key, () => new ScrollAction()},
};*/
public override State createState() {
return new _WidgetsAppState();
}

/*bool _debugCheckLocalizations(Locale appLocale) {
D.assert(() =>{
HashSet<Type> unsupportedTypes =
_localizationsDelegates.map<Type>((LocalizationsDelegate delegate) => delegate.type).toSet();
foreach ( LocalizationsDelegate<dynamic> delegate in _localizationsDelegates) {
if (!unsupportedTypes.contains(delegate.type))
D.assert(() => {
HashSet<Type> unsupportedTypes = new HashSet<Type>();
foreach (var _delegate in _localizationsDelegates) {
unsupportedTypes.Add(_delegate.type);
}
foreach ( LocalizationsDelegate<dynamic> _delegate in _localizationsDelegates) {
if (!unsupportedTypes.Contains(_delegate.type))
if (delegate.isSupported(appLocale))
unsupportedTypes.remove(delegate.type);
if (_delegate.isSupported(appLocale))
unsupportedTypes.Remove(_delegate.type);
if (listEquals(unsupportedTypes.map((Type type) => type.toString()).toList(), <String>['CupertinoLocalizations']))
return true;
List<string> list = new List<string> {"CupertinoLocalizations"};
List<string> unsupportedTypesList = new List<string>();
foreach (var type in unsupportedTypes) {
unsupportedTypesList.Add(type.ToString());
}
if (unsupportedTypesList.SequenceEqual(list))
return true;
"Warning: This application's locale, $appLocale, is not supported by all of its\n"
'localization delegates.'
"Warning: This application's locale, $appLocale, is not supported by all of its\n" +
"localization delegates."
if (unsupportedType.toString() == 'CupertinoLocalizations')
if (unsupportedType.ToString() == "CupertinoLocalizations")
'> A $unsupportedType delegate that supports the $appLocale locale was not found.'
"> A "+ unsupportedType + " delegate that supports the " + appLocale + "locale was not found."
'See https://flutter.dev/tutorials/internationalization/ for more\n'
"information about configuring an app's locale, supportedLocales,\n"
'and localizationsDelegates parameters.'
"See https://flutter.dev/tutorials/internationalization/ for more\n" +
"information about configuring an app's locale, supportedLocales,\n" +
"and localizationsDelegates parameters."
debugPrint(message.toString());
//Debug.Log(message.toString());
return true;
});
return true;

}
}
/*public class _MediaQueryFromWindow : StatefulWidget {
public class _MediaQueryFromWindow : StatefulWidget {
public _MediaQueryFromWindow(Key key = null, Widget child = null) : base(key: key) {
}
public readonly Widget child;

base.dispose();
}
}
*/
class _InspectorSelectButton : StatelessWidget {
public readonly GestureTapCallback onPressed;

4
com.unity.uiwidgets/Runtime/widgets/basic.cs


listeners.Add("exit");
if (onHover != null)
listeners.Add("hover");
//properties.add(IterableProperty<string>("listeners", listeners, ifEmpty: "<none>"));
properties.add(new EnumerableProperty<string>("listeners", listeners, ifEmpty: "<none>"));
}
}
}
public class _MouseRegionState : State<MouseRegion> {
void handleExit(PointerExitEvent _event) {

2
com.unity.uiwidgets/Runtime/widgets/binding.cs


var details = new UIWidgetsErrorDetails(
exception: ex,
library: "widgets library",
context: "attaching to the render tree"
context: new ErrorDescription("attaching to the render tree")
);
UIWidgetsError.reportError(details);

2
com.unity.uiwidgets/Runtime/widgets/debug.cs


var details = new UIWidgetsErrorDetails(
exception: exception,
library: "widgets library",
context: context,
context: new ErrorDescription(context),
informationCollector: informationCollector
);
UIWidgetsError.reportError(details);

16
com.unity.uiwidgets/Runtime/widgets/framework.cs


_dirtyElements[index].rebuild();
}
catch (Exception ex) {
IEnumerable<DiagnosticsNode> infoCollector() {
//yield return new DiagnosticsDebugCreator(new DebugCreator(_dirtyElements[index]));
yield return _dirtyElements[index].describeElement($"The element being rebuilt at the time was index {index} of {dirtyCount}");
}
informationCollector: (information) => {
information.AppendLine(
"The element being rebuilt at the time was index "
+ index + " of " + dirtyCount + ":");
information.Append(" " + _dirtyElements[index]);
}
informationCollector: infoCollector
);
}

public delegate Widget ErrorWidgetBuilder(UIWidgetsErrorDetails details);
internal class _ElementDiagnosticableTreeNode : _DiagnosticableTreeNode {
internal class _ElementDiagnosticableTreeNode : DiagnosticableTreeNode {
internal _ElementDiagnosticableTreeNode(
Element value,
DiagnosticsTreeStyle style,

}
catch (UIWidgetsError e) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
context: "while apply parent data",
context: new ErrorDescription("while apply parent data"),
exception: e
));
}

2
com.unity.uiwidgets/Runtime/widgets/image.cs


}
else {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
context: "image failed to precache",
context: new ErrorDescription("image failed to precache"),
library: "image resource service",
exception: exception,
silent: true

正在加载...
取消
保存