未验证 提交 c2938d06 编写于 作者: Y Yuqian Li 提交者: GitHub

Revert "Migration to PlatformDispatcher and multi-window #20496" (#21792)

* Revert "Fix documentation build for window changes. (#21780)"

This reverts commit 931a0468.

* Revert "Migration to PlatformDispatcher and multi-window (#20496)"

This reverts commit 85b0031f.
上级 05d97932
......@@ -371,7 +371,6 @@ FILE: ../../../flutter/lib/ui/painting/single_frame_codec.h
FILE: ../../../flutter/lib/ui/painting/vertices.cc
FILE: ../../../flutter/lib/ui/painting/vertices.h
FILE: ../../../flutter/lib/ui/painting/vertices_unittests.cc
FILE: ../../../flutter/lib/ui/platform_dispatcher.dart
FILE: ../../../flutter/lib/ui/plugins.dart
FILE: ../../../flutter/lib/ui/plugins/callback_cache.cc
FILE: ../../../flutter/lib/ui/plugins/callback_cache.h
......@@ -500,7 +499,6 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/keyboard.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/mouse_cursor.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/onscreen_logging.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/picture.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/platform_views.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/plugins.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/pointer_binding.dart
......@@ -555,7 +553,6 @@ FILE: ../../../flutter/lib/web_ui/lib/src/ui/natives.dart
FILE: ../../../flutter/lib/web_ui/lib/src/ui/painting.dart
FILE: ../../../flutter/lib/web_ui/lib/src/ui/path.dart
FILE: ../../../flutter/lib/web_ui/lib/src/ui/path_metrics.dart
FILE: ../../../flutter/lib/web_ui/lib/src/ui/platform_dispatcher.dart
FILE: ../../../flutter/lib/web_ui/lib/src/ui/pointer.dart
FILE: ../../../flutter/lib/web_ui/lib/src/ui/semantics.dart
FILE: ../../../flutter/lib/web_ui/lib/src/ui/test_embedding.dart
......
......@@ -10,8 +10,8 @@ part of dart.ui;
///
/// To create a Scene object, use a [SceneBuilder].
///
/// Scene objects can be displayed on the screen using the [FlutterView.render]
/// method.
/// Scene objects can be displayed on the screen using the
/// [Window.render] method.
@pragma('vm:entry-point')
class Scene extends NativeFieldWrapperClass2 {
/// This class is created by the engine, and should not be instantiated
......@@ -186,7 +186,7 @@ class PhysicalShapeEngineLayer extends _EngineLayerWrapper {
/// Builds a [Scene] containing the given visuals.
///
/// A [Scene] can then be rendered using [FlutterView.render].
/// A [Scene] can then be rendered using [Window.render].
///
/// To draw graphical operations onto a [Scene], first create a
/// [Picture] using a [PictureRecorder] and a [Canvas], and then add
......@@ -655,13 +655,13 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
/// - 0x08: visualizeEngineStatistics - graph UI thread frame times
/// Set enabledOptions to 0x0F to enable all the currently defined features.
///
/// The "UI thread" is the thread that includes all the execution of the main
/// Dart isolate (the isolate that can call [FlutterView.render]). The UI
/// thread frame time is the total time spent executing the
/// [PlatformDispatcher.onBeginFrame] callback. The "raster thread" is the
/// thread (running on the CPU) that subsequently processes the [Scene]
/// provided by the Dart code to turn it into GPU commands and send it to the
/// GPU.
/// The "UI thread" is the thread that includes all the execution of
/// the main Dart isolate (the isolate that can call
/// [Window.render]). The UI thread frame time is the total time
/// spent executing the [Window.onBeginFrame] callback. The "raster
/// thread" is the thread (running on the CPU) that subsequently
/// processes the [Scene] provided by the Dart code to turn it into
/// GPU commands and send it to the GPU.
///
/// See also the [PerformanceOverlayOption] enum in the rendering library.
/// for more details.
......@@ -802,7 +802,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
///
/// Returns a [Scene] containing the objects that have been added to
/// this scene builder. The [Scene] can then be displayed on the
/// screen with [FlutterView.render].
/// screen with [Window.render].
///
/// After calling this function, the scene builder object is invalid and
/// cannot be used further.
......
......@@ -42,10 +42,9 @@ Scene::Scene(std::shared_ptr<flutter::Layer> rootLayer,
uint32_t rasterizerTracingThreshold,
bool checkerboardRasterCacheImages,
bool checkerboardOffscreenLayers) {
// Currently only supports a single window.
auto viewport_metrics = UIDartState::Current()
->platform_configuration()
->get_window(0)
->window()
->viewport_metrics();
layer_tree_ = std::make_unique<LayerTree>(
......
......@@ -13,7 +13,6 @@ dart_ui_files = [
"//flutter/lib/ui/lerp.dart",
"//flutter/lib/ui/natives.dart",
"//flutter/lib/ui/painting.dart",
"//flutter/lib/ui/platform_dispatcher.dart",
"//flutter/lib/ui/plugins.dart",
"//flutter/lib/ui/pointer.dart",
"//flutter/lib/ui/semantics.dart",
......
......@@ -11,7 +11,6 @@ part of dart.ui;
@pragma('vm:entry-point')
// ignore: unused_element
void _updateWindowMetrics(
Object id,
double devicePixelRatio,
double width,
double height,
......@@ -28,96 +27,186 @@ void _updateWindowMetrics(
double systemGestureInsetBottom,
double systemGestureInsetLeft,
) {
PlatformDispatcher.instance._updateWindowMetrics(
id,
devicePixelRatio,
width,
height,
viewPaddingTop,
viewPaddingRight,
viewPaddingBottom,
viewPaddingLeft,
viewInsetTop,
viewInsetRight,
viewInsetBottom,
viewInsetLeft,
systemGestureInsetTop,
systemGestureInsetRight,
systemGestureInsetBottom,
systemGestureInsetLeft,
);
window
.._devicePixelRatio = devicePixelRatio
.._physicalSize = Size(width, height)
.._viewPadding = WindowPadding._(
top: viewPaddingTop,
right: viewPaddingRight,
bottom: viewPaddingBottom,
left: viewPaddingLeft)
.._viewInsets = WindowPadding._(
top: viewInsetTop,
right: viewInsetRight,
bottom: viewInsetBottom,
left: viewInsetLeft)
.._padding = WindowPadding._(
top: math.max(0.0, viewPaddingTop - viewInsetTop),
right: math.max(0.0, viewPaddingRight - viewInsetRight),
bottom: math.max(0.0, viewPaddingBottom - viewInsetBottom),
left: math.max(0.0, viewPaddingLeft - viewInsetLeft))
.._systemGestureInsets = WindowPadding._(
top: math.max(0.0, systemGestureInsetTop),
right: math.max(0.0, systemGestureInsetRight),
bottom: math.max(0.0, systemGestureInsetBottom),
left: math.max(0.0, systemGestureInsetLeft));
_invoke(window.onMetricsChanged, window._onMetricsChangedZone);
}
typedef _LocaleClosure = String? Function();
String? _localeClosure() {
if (window.locale == null) {
return null;
}
return window.locale.toString();
}
@pragma('vm:entry-point')
// ignore: unused_element
_LocaleClosure? _getLocaleClosure() => PlatformDispatcher.instance._localeClosure;
_LocaleClosure? _getLocaleClosure() => _localeClosure;
@pragma('vm:entry-point')
// ignore: unused_element
void _updateLocales(List<String> locales) {
PlatformDispatcher.instance._updateLocales(locales);
const int stringsPerLocale = 4;
final int numLocales = locales.length ~/ stringsPerLocale;
final List<Locale> newLocales = <Locale>[];
for (int localeIndex = 0; localeIndex < numLocales; localeIndex++) {
final String countryCode = locales[localeIndex * stringsPerLocale + 1];
final String scriptCode = locales[localeIndex * stringsPerLocale + 2];
newLocales.add(Locale.fromSubtags(
languageCode: locales[localeIndex * stringsPerLocale],
countryCode: countryCode.isEmpty ? null : countryCode,
scriptCode: scriptCode.isEmpty ? null : scriptCode,
));
}
window._locales = newLocales;
_invoke(window.onLocaleChanged, window._onLocaleChangedZone);
}
@pragma('vm:entry-point')
// ignore: unused_element
void _updateUserSettingsData(String jsonData) {
PlatformDispatcher.instance._updateUserSettingsData(jsonData);
final Map<String, dynamic> data = json.decode(jsonData) as Map<String, dynamic>;
if (data.isEmpty) {
return;
}
_updateTextScaleFactor((data['textScaleFactor'] as num).toDouble());
_updateAlwaysUse24HourFormat(data['alwaysUse24HourFormat'] as bool);
_updatePlatformBrightness(data['platformBrightness'] as String);
}
@pragma('vm:entry-point')
// ignore: unused_element
void _updateLifecycleState(String state) {
PlatformDispatcher.instance._updateLifecycleState(state);
// We do not update the state if the state has already been used to initialize
// the lifecycleState.
if (!window._initialLifecycleStateAccessed)
window._initialLifecycleState = state;
}
void _updateTextScaleFactor(double textScaleFactor) {
window._textScaleFactor = textScaleFactor;
_invoke(window.onTextScaleFactorChanged, window._onTextScaleFactorChangedZone);
}
void _updateAlwaysUse24HourFormat(bool alwaysUse24HourFormat) {
window._alwaysUse24HourFormat = alwaysUse24HourFormat;
}
void _updatePlatformBrightness(String brightnessName) {
window._platformBrightness = brightnessName == 'dark' ? Brightness.dark : Brightness.light;
_invoke(window.onPlatformBrightnessChanged, window._onPlatformBrightnessChangedZone);
}
@pragma('vm:entry-point')
// ignore: unused_element
void _updateSemanticsEnabled(bool enabled) {
PlatformDispatcher.instance._updateSemanticsEnabled(enabled);
window._semanticsEnabled = enabled;
_invoke(window.onSemanticsEnabledChanged, window._onSemanticsEnabledChangedZone);
}
@pragma('vm:entry-point')
// ignore: unused_element
void _updateAccessibilityFeatures(int values) {
PlatformDispatcher.instance._updateAccessibilityFeatures(values);
final AccessibilityFeatures newFeatures = AccessibilityFeatures._(values);
if (newFeatures == window._accessibilityFeatures)
return;
window._accessibilityFeatures = newFeatures;
_invoke(window.onAccessibilityFeaturesChanged, window._onAccessibilityFeaturesChangedZone);
}
@pragma('vm:entry-point')
// ignore: unused_element
void _dispatchPlatformMessage(String name, ByteData? data, int responseId) {
PlatformDispatcher.instance._dispatchPlatformMessage(name, data, responseId);
if (name == ChannelBuffers.kControlChannelName) {
try {
channelBuffers.handleMessage(data!);
} catch (ex) {
_printDebug('Message to "$name" caused exception $ex');
} finally {
window._respondToPlatformMessage(responseId, null);
}
} else if (window.onPlatformMessage != null) {
_invoke3<String, ByteData?, PlatformMessageResponseCallback>(
window.onPlatformMessage,
window._onPlatformMessageZone,
name,
data,
(ByteData? responseData) {
window._respondToPlatformMessage(responseId, responseData);
},
);
} else {
channelBuffers.push(name, data, (ByteData? responseData) {
window._respondToPlatformMessage(responseId, responseData);
});
}
}
@pragma('vm:entry-point')
// ignore: unused_element
void _dispatchPointerDataPacket(ByteData packet) {
PlatformDispatcher.instance._dispatchPointerDataPacket(packet);
if (window.onPointerDataPacket != null)
_invoke1<PointerDataPacket>(window.onPointerDataPacket, window._onPointerDataPacketZone, _unpackPointerDataPacket(packet));
}
@pragma('vm:entry-point')
// ignore: unused_element
void _dispatchSemanticsAction(int id, int action, ByteData? args) {
PlatformDispatcher.instance._dispatchSemanticsAction(id, action, args);
_invoke3<int, SemanticsAction, ByteData?>(
window.onSemanticsAction,
window._onSemanticsActionZone,
id,
SemanticsAction.values[action]!,
args,
);
}
@pragma('vm:entry-point')
// ignore: unused_element
void _beginFrame(int microseconds) {
PlatformDispatcher.instance._beginFrame(microseconds);
_invoke1<Duration>(window.onBeginFrame, window._onBeginFrameZone, Duration(microseconds: microseconds));
}
@pragma('vm:entry-point')
// ignore: unused_element
void _reportTimings(List<int> timings) {
PlatformDispatcher.instance._reportTimings(timings);
assert(timings.length % FramePhase.values.length == 0);
final List<FrameTiming> frameTimings = <FrameTiming>[];
for (int i = 0; i < timings.length; i += FramePhase.values.length) {
frameTimings.add(FrameTiming._(timings.sublist(i, i + FramePhase.values.length)));
}
_invoke1(window.onReportTimings, window._onReportTimingsZone, frameTimings);
}
@pragma('vm:entry-point')
// ignore: unused_element
void _drawFrame() {
PlatformDispatcher.instance._drawFrame();
_invoke(window.onDrawFrame, window._onDrawFrameZone);
}
// ignore: always_declare_return_types, prefer_generic_function_type_aliases
......@@ -130,7 +219,7 @@ typedef _BinaryFunction(Null args, Null message);
void _runMainZoned(Function startMainIsolateFunction,
Function userMainFunction,
List<String> args) {
startMainIsolateFunction(() {
startMainIsolateFunction((){
runZonedGuarded<void>(() {
if (userMainFunction is _BinaryFunction) {
// This seems to be undocumented but supported by the command line VM.
......@@ -150,10 +239,9 @@ void _runMainZoned(Function startMainIsolateFunction,
void _reportUnhandledException(String error, String stackTrace) native 'PlatformConfiguration_reportUnhandledException';
/// Invokes [callback] inside the given [zone].
void _invoke(void Function()? callback, Zone zone) {
if (callback == null) {
void _invoke(void callback()?, Zone zone) {
if (callback == null)
return;
}
assert(zone != null); // ignore: unnecessary_null_comparison
......@@ -165,10 +253,9 @@ void _invoke(void Function()? callback, Zone zone) {
}
/// Invokes [callback] inside the given [zone] passing it [arg].
void _invoke1<A>(void Function(A a)? callback, Zone zone, A arg) {
if (callback == null) {
void _invoke1<A>(void callback(A a)?, Zone zone, A arg) {
if (callback == null)
return;
}
assert(zone != null); // ignore: unnecessary_null_comparison
......@@ -180,16 +267,9 @@ void _invoke1<A>(void Function(A a)? callback, Zone zone, A arg) {
}
/// Invokes [callback] inside the given [zone] passing it [arg1], [arg2], and [arg3].
void _invoke3<A1, A2, A3>(
void Function(A1 a1, A2 a2, A3 a3)? callback,
Zone zone,
A1 arg1,
A2 arg2,
A3 arg3,
) {
if (callback == null) {
void _invoke3<A1, A2, A3>(void callback(A1 a1, A2 a2, A3 a3)?, Zone zone, A1 arg1, A2 arg2, A3 arg3) {
if (callback == null)
return;
}
assert(zone != null); // ignore: unnecessary_null_comparison
......@@ -201,3 +281,54 @@ void _invoke3<A1, A2, A3>(
});
}
}
// If this value changes, update the encoding code in the following files:
//
// * pointer_data.cc
// * pointer.dart
// * AndroidTouchProcessor.java
const int _kPointerDataFieldCount = 29;
PointerDataPacket _unpackPointerDataPacket(ByteData packet) {
const int kStride = Int64List.bytesPerElement;
const int kBytesPerPointerData = _kPointerDataFieldCount * kStride;
final int length = packet.lengthInBytes ~/ kBytesPerPointerData;
assert(length * kBytesPerPointerData == packet.lengthInBytes);
final List<PointerData> data = <PointerData>[];
for (int i = 0; i < length; ++i) {
int offset = i * _kPointerDataFieldCount;
data.add(PointerData(
embedderId: packet.getInt64(kStride * offset++, _kFakeHostEndian),
timeStamp: Duration(microseconds: packet.getInt64(kStride * offset++, _kFakeHostEndian)),
change: PointerChange.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)],
kind: PointerDeviceKind.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)],
signalKind: PointerSignalKind.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)],
device: packet.getInt64(kStride * offset++, _kFakeHostEndian),
pointerIdentifier: packet.getInt64(kStride * offset++, _kFakeHostEndian),
physicalX: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
physicalY: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
physicalDeltaX: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
physicalDeltaY: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
buttons: packet.getInt64(kStride * offset++, _kFakeHostEndian),
obscured: packet.getInt64(kStride * offset++, _kFakeHostEndian) != 0,
synthesized: packet.getInt64(kStride * offset++, _kFakeHostEndian) != 0,
pressure: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
pressureMin: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
pressureMax: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
distance: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
distanceMax: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
size: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
radiusMajor: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
radiusMinor: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
radiusMin: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
radiusMax: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
orientation: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
tilt: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
platformData: packet.getInt64(kStride * offset++, _kFakeHostEndian),
scrollDeltaX: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
scrollDeltaY: packet.getFloat64(kStride * offset++, _kFakeHostEndian)
));
assert(offset == (i + 1) * _kPointerDataFieldCount);
}
return PointerDataPacket(data: data);
}
......@@ -34,7 +34,7 @@ Future<developer.ServiceExtensionResponse> _scheduleFrame(
Map<String, String> parameters
) async {
// Schedule the frame.
PlatformDispatcher.instance.scheduleFrame();
window.scheduleFrame();
// Always succeed.
return developer.ServiceExtensionResponse.result(json.encode(<String, String>{
'type': 'Success',
......
......@@ -468,7 +468,7 @@ void Canvas::drawShadow(const CanvasPath* path,
}
SkScalar dpr = UIDartState::Current()
->platform_configuration()
->get_window(0)
->window()
->viewport_metrics()
.device_pixel_ratio;
flutter::PhysicalShapeLayer::DrawShadow(canvas_, path->path(), color,
......
此差异已折叠。
......@@ -625,8 +625,7 @@ class SemanticsFlag {
/// An object that creates [SemanticsUpdate] objects.
///
/// Once created, the [SemanticsUpdate] objects can be passed to
/// [PlatformDispatcher.updateSemantics] to update the semantics conveyed to the
/// user.
/// [Window.updateSemantics] to update the semantics conveyed to the user.
@pragma('vm:entry-point')
class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
/// Creates an empty [SemanticsUpdateBuilder] object.
......@@ -654,10 +653,10 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
///
/// The `actions` are a bit field of [SemanticsAction]s that can be undertaken
/// by this node. If the user wishes to undertake one of these actions on this
/// node, the [PlatformDispatcher.onSemanticsAction] will be called with `id`
/// and one of the possible [SemanticsAction]s. Because the semantics tree is
/// maintained asynchronously, the [PlatformDispatcher.onSemanticsAction]
/// callback might be called with an action that is no longer possible.
/// node, the [Window.onSemanticsAction] will be called with `id` and one of
/// the possible [SemanticsAction]s. Because the semantics tree is maintained
/// asynchronously, the [Window.onSemanticsAction] callback might be called
/// with an action that is no longer possible.
///
/// The `label` is a string that describes this node. The `value` property
/// describes the current value of the node as a string. The `increasedValue`
......@@ -833,8 +832,8 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
/// Creates a [SemanticsUpdate] object that encapsulates the updates recorded
/// by this object.
///
/// The returned object can be passed to [PlatformDispatcher.updateSemantics]
/// to actually update the semantics retained by the system.
/// The returned object can be passed to [Window.updateSemantics] to actually
/// update the semantics retained by the system.
SemanticsUpdate build() {
final SemanticsUpdate semanticsUpdate = SemanticsUpdate._();
_build(semanticsUpdate);
......@@ -848,7 +847,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
/// To create a SemanticsUpdate object, use a [SemanticsUpdateBuilder].
///
/// Semantics updates can be applied to the system's retained semantics tree
/// using the [PlatformDispatcher.updateSemantics] method.
/// using the [Window.updateSemantics] method.
@pragma('vm:entry-point')
class SemanticsUpdate extends NativeFieldWrapperClass2 {
/// This class is created by the engine, and should not be instantiated
......
......@@ -2273,7 +2273,7 @@ final ByteData _fontChangeMessage = utf8.encoder.convert(
).buffer.asByteData();
FutureOr<void> _sendFontChangeMessage() async {
PlatformDispatcher.instance.onPlatformMessage?.call(
window.onPlatformMessage?.call(
'flutter/system',
_fontChangeMessage,
(_) {},
......
......@@ -33,7 +33,6 @@ part 'isolate_name_server.dart';
part 'lerp.dart';
part 'natives.dart';
part 'painting.dart';
part 'platform_dispatcher.dart';
part 'plugins.dart';
part 'pointer.dart';
part 'semantics.dart';
......
此差异已折叠。
......@@ -9,7 +9,6 @@
#include "flutter/lib/ui/compositing/scene.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "flutter/lib/ui/window/platform_message_response_dart.h"
#include "flutter/lib/ui/window/viewport_metrics.h"
#include "flutter/lib/ui/window/window.h"
#include "third_party/tonic/converter/dart_converter.h"
#include "third_party/tonic/dart_args.h"
......@@ -198,8 +197,7 @@ PlatformConfiguration::~PlatformConfiguration() {}
void PlatformConfiguration::DidCreateIsolate() {
library_.Set(tonic::DartState::Current(),
Dart_LookupLibrary(tonic::ToDart("dart:ui")));
windows_.insert(std::make_pair(0, std::unique_ptr<Window>(new Window{
0, ViewportMetrics{1.0, 0.0, 0.0}})));
window_.reset(new Window({1.0, 0.0, 0.0}));
}
void PlatformConfiguration::UpdateLocales(
......@@ -423,7 +421,7 @@ void PlatformConfiguration::RegisterNatives(
true},
{"PlatformConfiguration_respondToPlatformMessage",
_RespondToPlatformMessage, 3, true},
{"PlatformConfiguration_render", Render, 3, true},
{"PlatformConfiguration_render", Render, 2, true},
{"PlatformConfiguration_updateSemantics", UpdateSemantics, 2, true},
{"PlatformConfiguration_setIsolateDebugName", SetIsolateDebugName, 2,
true},
......
......@@ -6,12 +6,14 @@
#define FLUTTER_LIB_UI_WINDOW_PLATFORM_CONFIGURATION_H_
#include <memory>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#include "flutter/fml/time/time_point.h"
#include "flutter/lib/ui/semantics/semantics_update.h"
#include "flutter/lib/ui/window/platform_message.h"
#include "flutter/lib/ui/window/pointer_data_packet.h"
#include "flutter/lib/ui/window/viewport_metrics.h"
#include "flutter/lib/ui/window/window.h"
......@@ -376,14 +378,11 @@ class PlatformConfiguration final {
static void RegisterNatives(tonic::DartLibraryNatives* natives);
//----------------------------------------------------------------------------
/// @brief Retrieves the Window with the given ID managed by the
/// `PlatformConfiguration`.
///
/// @param[in] window_id The id of the window to find and return.
/// @brief Retrieves the Window managed by the PlatformConfiguration.
///
/// @return a pointer to the Window.
///
Window* get_window(int window_id) { return windows_[window_id].get(); }
Window* window() const { return window_.get(); }
//----------------------------------------------------------------------------
/// @brief Responds to a previous platform message to the engine from the
......@@ -409,7 +408,7 @@ class PlatformConfiguration final {
PlatformConfigurationClient* client_;
tonic::DartPersistentValue library_;
std::unordered_map<int64_t, std::unique_ptr<Window>> windows_;
std::unique_ptr<Window> window_;
// We use id 0 to mean that no response is expected.
int next_response_id_ = 1;
......
......@@ -54,14 +54,11 @@ TEST_F(ShellTest, PlatformConfigurationInitialization) {
Dart_NativeArguments args) {
PlatformConfiguration* configuration =
UIDartState::Current()->platform_configuration();
ASSERT_NE(configuration->get_window(0), nullptr);
ASSERT_EQ(
configuration->get_window(0)->viewport_metrics().device_pixel_ratio,
1.0);
ASSERT_EQ(configuration->get_window(0)->viewport_metrics().physical_width,
0.0);
ASSERT_EQ(configuration->get_window(0)->viewport_metrics().physical_height,
0.0);
ASSERT_NE(configuration->window(), nullptr);
ASSERT_EQ(configuration->window()->viewport_metrics().device_pixel_ratio,
1.0);
ASSERT_EQ(configuration->window()->viewport_metrics().physical_width, 0.0);
ASSERT_EQ(configuration->window()->viewport_metrics().physical_height, 0.0);
message_latch->Signal();
};
......@@ -100,15 +97,13 @@ TEST_F(ShellTest, PlatformConfigurationWindowMetricsUpdate) {
PlatformConfiguration* configuration =
UIDartState::Current()->platform_configuration();
ASSERT_NE(configuration->get_window(0), nullptr);
configuration->get_window(0)->UpdateWindowMetrics(
ASSERT_NE(configuration->window(), nullptr);
configuration->window()->UpdateWindowMetrics(
ViewportMetrics{2.0, 10.0, 20.0});
ASSERT_EQ(
configuration->get_window(0)->viewport_metrics().device_pixel_ratio,
2.0);
ASSERT_EQ(configuration->get_window(0)->viewport_metrics().physical_width,
10.0);
ASSERT_EQ(configuration->get_window(0)->viewport_metrics().physical_height,
ASSERT_EQ(configuration->window()->viewport_metrics().device_pixel_ratio,
2.0);
ASSERT_EQ(configuration->window()->viewport_metrics().physical_width, 10.0);
ASSERT_EQ(configuration->window()->viewport_metrics().physical_height,
20.0);
message_latch->Signal();
......
......@@ -11,8 +11,7 @@
namespace flutter {
Window::Window(int64_t window_id, ViewportMetrics metrics)
: window_id_(window_id), viewport_metrics_(metrics) {
Window::Window(ViewportMetrics metrics) : viewport_metrics_(metrics) {
library_.Set(tonic::DartState::Current(),
Dart_LookupLibrary(tonic::ToDart("dart:ui")));
}
......@@ -47,7 +46,6 @@ void Window::UpdateWindowMetrics(const ViewportMetrics& metrics) {
tonic::LogIfError(tonic::DartInvokeField(
library_.value(), "_updateWindowMetrics",
{
tonic::ToDart(window_id_),
tonic::ToDart(metrics.device_pixel_ratio),
tonic::ToDart(metrics.physical_width),
tonic::ToDart(metrics.physical_height),
......
......@@ -18,12 +18,10 @@
namespace flutter {
class Window final {
public:
Window(int64_t window_id, ViewportMetrics metrics);
explicit Window(ViewportMetrics metrics);
~Window();
int window_id() const { return window_id_; }
const ViewportMetrics& viewport_metrics() const { return viewport_metrics_; }
void DispatchPointerDataPacket(const PointerDataPacket& packet);
......@@ -31,7 +29,6 @@ class Window final {
private:
tonic::DartPersistentValue library_;
int64_t window_id_;
ViewportMetrics viewport_metrics_;
};
......
......@@ -99,7 +99,6 @@ part 'engine/keyboard.dart';
part 'engine/mouse_cursor.dart';
part 'engine/onscreen_logging.dart';
part 'engine/picture.dart';
part 'engine/platform_dispatcher.dart';
part 'engine/platform_views.dart';
part 'engine/plugins.dart';
part 'engine/pointer_binding.dart';
......@@ -225,17 +224,17 @@ void initializeEngine() {
// part of the rasterization process, particularly in the HTML
// renderer, takes place in the `SceneBuilder.build()`.
_frameTimingsOnBuildStart();
if (EnginePlatformDispatcher.instance._onBeginFrame != null) {
EnginePlatformDispatcher.instance.invokeOnBeginFrame(
if (window._onBeginFrame != null) {
window.invokeOnBeginFrame(
Duration(microseconds: highResTimeMicroseconds));
}
if (EnginePlatformDispatcher.instance._onDrawFrame != null) {
if (window._onDrawFrame != null) {
// TODO(yjbanov): technically Flutter flushes microtasks between
// onBeginFrame and onDrawFrame. We don't, which hasn't
// been an issue yet, but eventually we'll have to
// implement it properly.
EnginePlatformDispatcher.instance.invokeOnDrawFrame();
window.invokeOnDrawFrame();
}
});
}
......
......@@ -71,7 +71,7 @@ class BitmapCanvas extends EngineCanvas {
/// Keeps track of what device pixel ratio was used when this [BitmapCanvas]
/// was created.
final double _devicePixelRatio = EnginePlatformDispatcher.browserDevicePixelRatio;
final double _devicePixelRatio = EngineWindow.browserDevicePixelRatio;
// Compensation for [_initializeViewport] snapping canvas position to 1 pixel.
int? _canvasPositionX, _canvasPositionY;
......@@ -150,13 +150,13 @@ class BitmapCanvas extends EngineCanvas {
static int _widthToPhysical(double width) {
final double boundsWidth = width + 1;
return (boundsWidth * EnginePlatformDispatcher.browserDevicePixelRatio).ceil() +
return (boundsWidth * EngineWindow.browserDevicePixelRatio).ceil() +
2 * kPaddingPixels;
}
static int _heightToPhysical(double height) {
final double boundsHeight = height + 1;
return (boundsHeight * EnginePlatformDispatcher.browserDevicePixelRatio).ceil() +
return (boundsHeight * EngineWindow.browserDevicePixelRatio).ceil() +
2 * kPaddingPixels;
}
......@@ -198,7 +198,7 @@ class BitmapCanvas extends EngineCanvas {
/// * [PersistedPicture._recycleCanvas] which also uses this method
/// for the same reason.
bool isReusable() {
return _devicePixelRatio == EnginePlatformDispatcher.browserDevicePixelRatio;
return _devicePixelRatio == EngineWindow.browserDevicePixelRatio;
}
/// Returns a "data://" URI containing a representation of the image in this
......
......@@ -99,9 +99,9 @@ class _CanvasPool extends _SaveStackTracking {
// * To make sure that when we scale the canvas by devicePixelRatio (see
// _initializeViewport below) the pixels line up.
final double cssWidth =
_widthInBitmapPixels / EnginePlatformDispatcher.browserDevicePixelRatio;
_widthInBitmapPixels / EngineWindow.browserDevicePixelRatio;
final double cssHeight =
_heightInBitmapPixels / EnginePlatformDispatcher.browserDevicePixelRatio;
_heightInBitmapPixels / EngineWindow.browserDevicePixelRatio;
canvas = html.CanvasElement(
width: _widthInBitmapPixels,
height: _heightInBitmapPixels,
......@@ -194,7 +194,7 @@ class _CanvasPool extends _SaveStackTracking {
clipTimeTransform[5] != prevTransform[5] ||
clipTimeTransform[12] != prevTransform[12] ||
clipTimeTransform[13] != prevTransform[13]) {
final double ratio = EnginePlatformDispatcher.browserDevicePixelRatio;
final double ratio = EngineWindow.browserDevicePixelRatio;
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
ctx.transform(
clipTimeTransform[0],
......@@ -223,7 +223,7 @@ class _CanvasPool extends _SaveStackTracking {
transform[5] != prevTransform[5] ||
transform[12] != prevTransform[12] ||
transform[13] != prevTransform[13]) {
final double ratio = EnginePlatformDispatcher.browserDevicePixelRatio;
final double ratio = EngineWindow.browserDevicePixelRatio;
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
ctx.transform(transform[0], transform[1], transform[4], transform[5],
transform[12], transform[13]);
......@@ -307,8 +307,8 @@ class _CanvasPool extends _SaveStackTracking {
// This scale makes sure that 1 CSS pixel is translated to the correct
// number of bitmap pixels.
ctx.scale(EnginePlatformDispatcher.browserDevicePixelRatio,
EnginePlatformDispatcher.browserDevicePixelRatio);
ctx.scale(EngineWindow.browserDevicePixelRatio,
EngineWindow.browserDevicePixelRatio);
}
void resetTransform() {
......
......@@ -292,7 +292,7 @@ class HtmlViewEmbedder {
//
// HTML elements use logical (CSS) pixels, but we have been using physical
// pixels, so scale down the head element to match the logical resolution.
final double scale = EnginePlatformDispatcher.browserDevicePixelRatio;
final double scale = EngineWindow.browserDevicePixelRatio;
final double inverseScale = 1 / scale;
final Matrix4 scaleMatrix =
Matrix4.diagonal3Values(inverseScale, inverseScale, 1);
......
......@@ -348,7 +348,7 @@ class SkiaObjects {
if (_addedCleanupCallback) {
return;
}
EnginePlatformDispatcher.instance.rasterizer!.addPostFrameCallback(postFrameCleanUp);
window.rasterizer!.addPostFrameCallback(postFrameCleanUp);
_addedCleanupCallback = true;
}
......
......@@ -466,7 +466,7 @@ flt-glass-pane * {
}
_localeSubscription = languageChangeEvent.forTarget(html.window)
.listen(_languageDidChange);
EnginePlatformDispatcher.instance._updateLocales();
window._updateLocales();
}
/// Called immediately after browser window metrics change.
......@@ -481,18 +481,18 @@ flt-glass-pane * {
void _metricsDidChange(html.Event? event) {
if(isMobile && !window.isRotation() && textEditing.isEditing) {
window.computeOnScreenKeyboardInsets();
EnginePlatformDispatcher.instance.invokeOnMetricsChanged();
window.invokeOnMetricsChanged();
} else {
window._computePhysicalSize();
// When physical size changes this value has to be recalculated.
window.computeOnScreenKeyboardInsets();
EnginePlatformDispatcher.instance.invokeOnMetricsChanged();
window.invokeOnMetricsChanged();
}
}
/// Called immediately after browser window language change.
void _languageDidChange(html.Event event) {
EnginePlatformDispatcher.instance._updateLocales();
window._updateLocales();
if (ui.window.onLocaleChanged != null) {
ui.window.onLocaleChanged!();
}
......
......@@ -668,8 +668,8 @@ class _OffscreenCanvas {
height: heightInPixels,
);
_glCanvas!.className = 'gl-canvas';
final double cssWidth = widthInPixels / EnginePlatformDispatcher.browserDevicePixelRatio;
final double cssHeight = heightInPixels / EnginePlatformDispatcher.browserDevicePixelRatio;
final double cssWidth = widthInPixels / EngineWindow.browserDevicePixelRatio;
final double cssHeight = heightInPixels / EngineWindow.browserDevicePixelRatio;
_glCanvas!.style
..position = 'absolute'
..width = '${cssWidth}px'
......
......@@ -125,9 +125,9 @@ void _debugRepaintSurfaceStatsOverlay(PersistedScene scene) {
..fill();
final double physicalScreenWidth =
html.window.innerWidth! * EnginePlatformDispatcher.browserDevicePixelRatio;
html.window.innerWidth! * EngineWindow.browserDevicePixelRatio;
final double physicalScreenHeight =
html.window.innerHeight! * EnginePlatformDispatcher.browserDevicePixelRatio;
html.window.innerHeight! * EngineWindow.browserDevicePixelRatio;
final double physicsScreenPixelCount =
physicalScreenWidth * physicalScreenHeight;
......@@ -296,9 +296,9 @@ void _debugPrintSurfaceStats(PersistedScene scene, int frameNumber) {
return pixels;
}).fold(0, (int total, int pixels) => total + pixels);
final double physicalScreenWidth =
html.window.innerWidth! * EnginePlatformDispatcher.browserDevicePixelRatio;
html.window.innerWidth! * EngineWindow.browserDevicePixelRatio;
final double physicalScreenHeight =
html.window.innerHeight! * EnginePlatformDispatcher.browserDevicePixelRatio;
html.window.innerHeight! * EngineWindow.browserDevicePixelRatio;
final double physicsScreenPixelCount =
physicalScreenWidth * physicalScreenHeight;
final double screenPixelRatio = pixelCount / physicsScreenPixelCount;
......
......@@ -81,7 +81,7 @@ class Keyboard {
final html.KeyboardEvent keyboardEvent = event;
if (EnginePlatformDispatcher.instance._onPlatformMessage == null) {
if (window._onPlatformMessage == null) {
return;
}
......@@ -135,7 +135,7 @@ class Keyboard {
'metaState': _lastMetaState,
};
EnginePlatformDispatcher.instance.invokeOnPlatformMessage('flutter/keyevent',
window.invokeOnPlatformMessage('flutter/keyevent',
_messageCodec.encodeMessage(eventData), _noopCallback);
}
......@@ -157,7 +157,7 @@ class Keyboard {
'metaState': _lastMetaState,
};
EnginePlatformDispatcher.instance.invokeOnPlatformMessage('flutter/keyevent',
window.invokeOnPlatformMessage('flutter/keyevent',
_messageCodec.encodeMessage(eventData), _noopCallback);
}
}
......
......@@ -151,8 +151,8 @@ class MultiEntriesBrowserHistory extends BrowserHistory {
currentPath);
}
_lastSeenSerialCount = _currentSerialCount;
if (EnginePlatformDispatcher.instance._onPlatformMessage != null) {
EnginePlatformDispatcher.instance.invokeOnPlatformMessage(
if (window._onPlatformMessage != null) {
window.invokeOnPlatformMessage(
'flutter/navigation',
const JSONMethodCodec().encodeMethodCall(
MethodCall('pushRouteInformation', <dynamic, dynamic>{
......@@ -272,8 +272,8 @@ class SingleEntryBrowserHistory extends BrowserHistory {
_setupFlutterEntry(urlStrategy!);
// 2. Send a 'popRoute' platform message so the app can handle it accordingly.
if (EnginePlatformDispatcher.instance._onPlatformMessage != null) {
EnginePlatformDispatcher.instance.invokeOnPlatformMessage(
if (window._onPlatformMessage != null) {
window.invokeOnPlatformMessage(
'flutter/navigation',
const JSONMethodCodec().encodeMethodCall(_popRouteMethodCall),
(_) {},
......@@ -291,8 +291,8 @@ class SingleEntryBrowserHistory extends BrowserHistory {
_userProvidedRouteName = null;
// Send a 'pushRoute' platform message so the app handles it accordingly.
if (EnginePlatformDispatcher.instance._onPlatformMessage != null) {
EnginePlatformDispatcher.instance.invokeOnPlatformMessage(
if (window._onPlatformMessage != null) {
window.invokeOnPlatformMessage(
'flutter/navigation',
const JSONMethodCodec().encodeMethodCall(
MethodCall('pushRoute', newRouteName),
......
......@@ -125,7 +125,9 @@ class PointerBinding {
void _onPointerData(Iterable<ui.PointerData> data) {
final ui.PointerDataPacket packet = ui.PointerDataPacket(data: data.toList());
EnginePlatformDispatcher.instance.invokeOnPointerDataPacket(packet);
if (window._onPointerDataPacket != null) {
window.invokeOnPointerDataPacket(packet);
}
}
}
......
......@@ -110,7 +110,7 @@ class Profiler {
/// Whether we are collecting [ui.FrameTiming]s.
bool get _frameTimingsEnabled {
return EnginePlatformDispatcher.instance._onReportTimings != null;
return window._onReportTimings != null;
}
/// Collects frame timings from frames.
......@@ -202,7 +202,7 @@ void _frameTimingsOnRasterFinish() {
_rasterFinishMicros = -1;
if (now - _frameTimingsLastSubmitTime > _kFrameTimingsSubmitInterval) {
_frameTimingsLastSubmitTime = now;
EnginePlatformDispatcher.instance.invokeOnReportTimings(_frameTimings);
window.invokeOnReportTimings(_frameTimings);
_frameTimings = <ui.FrameTiming>[];
}
}
......
......@@ -53,11 +53,11 @@ class Incrementable extends RoleManager {
final int newInputValue = int.parse(_element.value!);
if (newInputValue > _currentSurrogateValue) {
_currentSurrogateValue += 1;
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
window.invokeOnSemanticsAction(
semanticsObject.id, ui.SemanticsAction.increase, null);
} else if (newInputValue < _currentSurrogateValue) {
_currentSurrogateValue -= 1;
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
window.invokeOnSemanticsAction(
semanticsObject.id, ui.SemanticsAction.decrease, null);
}
});
......
......@@ -53,20 +53,20 @@ class Scrollable extends RoleManager {
final int semanticsId = semanticsObject.id;
if (doScrollForward) {
if (semanticsObject.isVerticalScrollContainer) {
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
window.invokeOnSemanticsAction(
semanticsId, ui.SemanticsAction.scrollUp, null);
} else {
assert(semanticsObject.isHorizontalScrollContainer);
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
window.invokeOnSemanticsAction(
semanticsId, ui.SemanticsAction.scrollLeft, null);
}
} else {
if (semanticsObject.isVerticalScrollContainer) {
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
window.invokeOnSemanticsAction(
semanticsId, ui.SemanticsAction.scrollDown, null);
} else {
assert(semanticsObject.isHorizontalScrollContainer);
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
window.invokeOnSemanticsAction(
semanticsId, ui.SemanticsAction.scrollRight, null);
}
}
......
......@@ -1253,8 +1253,8 @@ class EngineSemanticsOwner {
_gestureModeClock?.datetime = null;
}
if (EnginePlatformDispatcher.instance._onSemanticsEnabledChanged != null) {
EnginePlatformDispatcher.instance.invokeOnSemanticsEnabledChanged();
if (window._onSemanticsEnabledChanged != null) {
window.invokeOnSemanticsEnabledChanged();
}
}
......
......@@ -40,7 +40,7 @@ class Tappable extends RoleManager {
GestureMode.browserGestures) {
return;
}
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
window.invokeOnSemanticsAction(
semanticsObject.id, ui.SemanticsAction.tap, null);
};
element.addEventListener('click', _clickListener);
......
......@@ -148,7 +148,7 @@ class TextField extends RoleManager {
}
textEditing.useCustomEditableElement(textEditingElement);
EnginePlatformDispatcher.instance
window
.invokeOnSemanticsAction(semanticsObject.id, ui.SemanticsAction.tap, null);
});
}
......@@ -186,7 +186,7 @@ class TextField extends RoleManager {
if (offsetX * offsetX + offsetY * offsetY < kTouchSlop) {
// Recognize it as a tap that requires a keyboard.
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
window.invokeOnSemanticsAction(
semanticsObject.id, ui.SemanticsAction.tap, null);
}
} else {
......
......@@ -276,8 +276,8 @@ class EngineAutofillForm {
/// Sends the 'TextInputClient.updateEditingStateWithTag' message to the framework.
void _sendAutofillEditingState(String? tag, EditingState editingState) {
if (EnginePlatformDispatcher.instance._onPlatformMessage != null) {
EnginePlatformDispatcher.instance.invokeOnPlatformMessage(
if (window._onPlatformMessage != null) {
window.invokeOnPlatformMessage(
'flutter/textinput',
const JSONMethodCodec().encodeMethodCall(
MethodCall(
......@@ -1363,7 +1363,7 @@ class TextEditingChannel {
throw StateError(
'Unsupported method call on the flutter/textinput channel: ${call.method}');
}
EnginePlatformDispatcher.instance._replyToPlatformMessage(callback, codec.encodeSuccessEnvelope(true));
window._replyToPlatformMessage(callback, codec.encodeSuccessEnvelope(true));
}
/// Used for submitting the forms attached on the DOM.
......@@ -1392,8 +1392,8 @@ class TextEditingChannel {
/// Sends the 'TextInputClient.updateEditingState' message to the framework.
void updateEditingState(int? clientId, EditingState? editingState) {
if (EnginePlatformDispatcher.instance._onPlatformMessage != null) {
EnginePlatformDispatcher.instance.invokeOnPlatformMessage(
if (window._onPlatformMessage != null) {
window.invokeOnPlatformMessage(
'flutter/textinput',
const JSONMethodCodec().encodeMethodCall(
MethodCall('TextInputClient.updateEditingState', <dynamic>[
......@@ -1408,8 +1408,8 @@ class TextEditingChannel {
/// Sends the 'TextInputClient.performAction' message to the framework.
void performAction(int? clientId, String? inputAction) {
if (EnginePlatformDispatcher.instance._onPlatformMessage != null) {
EnginePlatformDispatcher.instance.invokeOnPlatformMessage(
if (window._onPlatformMessage != null) {
window.invokeOnPlatformMessage(
'flutter/textinput',
const JSONMethodCodec().encodeMethodCall(
MethodCall(
......@@ -1424,8 +1424,8 @@ class TextEditingChannel {
/// Sends the 'TextInputClient.onConnectionClosed' message to the framework.
void onConnectionClosed(int? clientId) {
if (EnginePlatformDispatcher.instance._onPlatformMessage != null) {
EnginePlatformDispatcher.instance.invokeOnPlatformMessage(
if (window._onPlatformMessage != null) {
window.invokeOnPlatformMessage(
'flutter/textinput',
const JSONMethodCodec().encodeMethodCall(
MethodCall(
......
......@@ -482,13 +482,13 @@ final ByteData? _fontChangeMessage = JSONMessageCodec().encodeMessage(<String, d
bool _fontChangeScheduled = false;
FutureOr<void> sendFontChangeMessage() async {
if (EnginePlatformDispatcher.instance._onPlatformMessage != null)
if (window._onPlatformMessage != null)
if (!_fontChangeScheduled) {
_fontChangeScheduled = true;
// Batch updates into next animationframe.
html.window.requestAnimationFrame((num _) {
_fontChangeScheduled = false;
EnginePlatformDispatcher.instance.invokeOnPlatformMessage(
window.invokeOnPlatformMessage(
'flutter/system',
_fontChangeMessage,
(_) {},
......
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.10
part of ui;
typedef VoidCallback = void Function();
typedef FrameCallback = void Function(Duration duration);
typedef TimingsCallback = void Function(List<FrameTiming> timings);
typedef PointerDataPacketCallback = void Function(PointerDataPacket packet);
typedef SemanticsActionCallback = void Function(int id, SemanticsAction action, ByteData? args);
typedef PlatformMessageResponseCallback = void Function(ByteData? data);
typedef PlatformMessageCallback = void Function(
String name, ByteData? data, PlatformMessageResponseCallback? callback);
typedef PlatformConfigurationChangedCallback = void Function(PlatformConfiguration configuration);
abstract class PlatformDispatcher {
static PlatformDispatcher get instance => engine.EnginePlatformDispatcher.instance;
PlatformConfiguration get configuration;
VoidCallback? get onPlatformConfigurationChanged;
set onPlatformConfigurationChanged(VoidCallback? callback);
Iterable<FlutterView> get views;
VoidCallback? get onMetricsChanged;
set onMetricsChanged(VoidCallback? callback);
FrameCallback? get onBeginFrame;
set onBeginFrame(FrameCallback? callback);
VoidCallback? get onDrawFrame;
set onDrawFrame(VoidCallback? callback);
PointerDataPacketCallback? get onPointerDataPacket;
set onPointerDataPacket(PointerDataPacketCallback? callback);
TimingsCallback? get onReportTimings;
set onReportTimings(TimingsCallback? callback);
void sendPlatformMessage(
String name,
ByteData? data,
PlatformMessageResponseCallback? callback,
);
PlatformMessageCallback? get onPlatformMessage;
set onPlatformMessage(PlatformMessageCallback? callback);
void setIsolateDebugName(String name) {}
ByteData? getPersistentIsolateData() => null;
void scheduleFrame();
void render(Scene scene, [FlutterView view]);
AccessibilityFeatures get accessibilityFeatures;
VoidCallback? get onAccessibilityFeaturesChanged;
set onAccessibilityFeaturesChanged(VoidCallback? callback);
void updateSemantics(SemanticsUpdate update);
Locale get locale;
List<Locale> get locales => configuration.locales;
Locale? computePlatformResolvedLocale(List<Locale> supportedLocales);
VoidCallback? get onLocaleChanged;
set onLocaleChanged(VoidCallback? callback);
String get initialLifecycleState => 'AppLifecycleState.resumed';
bool get alwaysUse24HourFormat => configuration.alwaysUse24HourFormat;
double get textScaleFactor => configuration.textScaleFactor;
VoidCallback? get onTextScaleFactorChanged;
set onTextScaleFactorChanged(VoidCallback? callback);
Brightness get platformBrightness => configuration.platformBrightness;
VoidCallback? get onPlatformBrightnessChanged;
set onPlatformBrightnessChanged(VoidCallback? callback);
bool get semanticsEnabled => configuration.semanticsEnabled;
VoidCallback? get onSemanticsEnabledChanged;
set onSemanticsEnabledChanged(VoidCallback? callback);
SemanticsActionCallback? get onSemanticsAction;
set onSemanticsAction(SemanticsActionCallback? callback);
String get defaultRouteName;
}
class PlatformConfiguration {
const PlatformConfiguration({
this.accessibilityFeatures = const AccessibilityFeatures._(0),
this.alwaysUse24HourFormat = false,
this.semanticsEnabled = false,
this.platformBrightness = Brightness.light,
this.textScaleFactor = 1.0,
this.locales = const <Locale>[],
this.defaultRouteName = '/',
});
PlatformConfiguration copyWith({
AccessibilityFeatures? accessibilityFeatures,
bool? alwaysUse24HourFormat,
bool? semanticsEnabled,
Brightness? platformBrightness,
double? textScaleFactor,
List<Locale>? locales,
String? defaultRouteName,
}) {
return PlatformConfiguration(
accessibilityFeatures: accessibilityFeatures ?? this.accessibilityFeatures,
alwaysUse24HourFormat: alwaysUse24HourFormat ?? this.alwaysUse24HourFormat,
semanticsEnabled: semanticsEnabled ?? this.semanticsEnabled,
platformBrightness: platformBrightness ?? this.platformBrightness,
textScaleFactor: textScaleFactor ?? this.textScaleFactor,
locales: locales ?? this.locales,
defaultRouteName: defaultRouteName ?? this.defaultRouteName,
);
}
final AccessibilityFeatures accessibilityFeatures;
final bool alwaysUse24HourFormat;
final bool semanticsEnabled;
final Brightness platformBrightness;
final double textScaleFactor;
final List<Locale> locales;
final String defaultRouteName;
}
class ViewConfiguration {
const ViewConfiguration({
this.window,
this.devicePixelRatio = 1.0,
this.geometry = Rect.zero,
this.visible = false,
this.viewInsets = WindowPadding.zero,
this.viewPadding = WindowPadding.zero,
this.systemGestureInsets = WindowPadding.zero,
this.padding = WindowPadding.zero,
});
ViewConfiguration copyWith({
FlutterWindow? window,
double? devicePixelRatio,
Rect? geometry,
bool? visible,
WindowPadding? viewInsets,
WindowPadding? viewPadding,
WindowPadding? systemGestureInsets,
WindowPadding? padding,
}) {
return ViewConfiguration(
window: window ?? this.window,
devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio,
geometry: geometry ?? this.geometry,
visible: visible ?? this.visible,
viewInsets: viewInsets ?? this.viewInsets,
viewPadding: viewPadding ?? this.viewPadding,
systemGestureInsets: systemGestureInsets ?? this.systemGestureInsets,
padding: padding ?? this.padding,
);
}
final FlutterWindow? window;
final double devicePixelRatio;
final Rect geometry;
final bool visible;
final WindowPadding viewInsets;
final WindowPadding viewPadding;
final WindowPadding systemGestureInsets;
final WindowPadding padding;
@override
String toString() {
return '$runtimeType[window: $window, geometry: $geometry]';
}
}
enum FramePhase {
vsyncStart,
buildStart,
buildFinish,
rasterStart,
rasterFinish,
}
class FrameTiming {
factory FrameTiming({
required int vsyncStart,
required int buildStart,
required int buildFinish,
required int rasterStart,
required int rasterFinish,
}) {
return FrameTiming._(<int>[
vsyncStart,
buildStart,
buildFinish,
rasterStart,
rasterFinish
]);
}
FrameTiming._(this._timestamps)
: assert(_timestamps.length == FramePhase.values.length);
int timestampInMicroseconds(FramePhase phase) => _timestamps[phase.index];
Duration _rawDuration(FramePhase phase) => Duration(microseconds: _timestamps[phase.index]);
Duration get buildDuration =>
_rawDuration(FramePhase.buildFinish) - _rawDuration(FramePhase.buildStart);
Duration get rasterDuration =>
_rawDuration(FramePhase.rasterFinish) - _rawDuration(FramePhase.rasterStart);
Duration get vsyncOverhead => _rawDuration(FramePhase.buildStart) - _rawDuration(FramePhase.vsyncStart);
Duration get totalSpan =>
_rawDuration(FramePhase.rasterFinish) - _rawDuration(FramePhase.vsyncStart);
final List<int> _timestamps; // in microseconds
String _formatMS(Duration duration) => '${duration.inMicroseconds * 0.001}ms';
@override
String toString() {
return '$runtimeType(buildDuration: ${_formatMS(buildDuration)}, rasterDuration: ${_formatMS(rasterDuration)}, vsyncOverhead: ${_formatMS(vsyncOverhead)}, totalSpan: ${_formatMS(totalSpan)})';
}
}
enum AppLifecycleState {
resumed,
inactive,
paused,
detached,
}
abstract class WindowPadding {
const factory WindowPadding._(
{required double left,
required double top,
required double right,
required double bottom}) = engine.WindowPadding;
double get left;
double get top;
double get right;
double get bottom;
static const WindowPadding zero = WindowPadding._(left: 0.0, top: 0.0, right: 0.0, bottom: 0.0);
@override
String toString() {
return 'WindowPadding(left: $left, top: $top, right: $right, bottom: $bottom)';
}
}
class Locale {
const Locale(
this._languageCode, [
this._countryCode,
]) : assert(_languageCode != null), // ignore: unnecessary_null_comparison
assert(_languageCode != ''),
scriptCode = null;
const Locale.fromSubtags({
String languageCode = 'und',
this.scriptCode,
String? countryCode,
}) : assert(languageCode != null), // ignore: unnecessary_null_comparison
assert(languageCode != ''),
_languageCode = languageCode,
assert(scriptCode != ''),
assert(countryCode != ''),
_countryCode = countryCode;
String get languageCode => _deprecatedLanguageSubtagMap[_languageCode] ?? _languageCode;
final String _languageCode;
// This map is generated by //flutter/tools/gen_locale.dart
// Mappings generated for language subtag registry as of 2019-02-27.
static const Map<String, String> _deprecatedLanguageSubtagMap = <String, String>{
'in': 'id', // Indonesian; deprecated 1989-01-01
'iw': 'he', // Hebrew; deprecated 1989-01-01
'ji': 'yi', // Yiddish; deprecated 1989-01-01
'jw': 'jv', // Javanese; deprecated 2001-08-13
'mo': 'ro', // Moldavian, Moldovan; deprecated 2008-11-22
'aam': 'aas', // Aramanik; deprecated 2015-02-12
'adp': 'dz', // Adap; deprecated 2015-02-12
'aue': 'ktz', // ǂKxʼauǁʼein; deprecated 2015-02-12
'ayx': 'nun', // Ayi (China); deprecated 2011-08-16
'bgm': 'bcg', // Baga Mboteni; deprecated 2016-05-30
'bjd': 'drl', // Bandjigali; deprecated 2012-08-12
'ccq': 'rki', // Chaungtha; deprecated 2012-08-12
'cjr': 'mom', // Chorotega; deprecated 2010-03-11
'cka': 'cmr', // Khumi Awa Chin; deprecated 2012-08-12
'cmk': 'xch', // Chimakum; deprecated 2010-03-11
'coy': 'pij', // Coyaima; deprecated 2016-05-30
'cqu': 'quh', // Chilean Quechua; deprecated 2016-05-30
'drh': 'khk', // Darkhat; deprecated 2010-03-11
'drw': 'prs', // Darwazi; deprecated 2010-03-11
'gav': 'dev', // Gabutamon; deprecated 2010-03-11
'gfx': 'vaj', // Mangetti Dune ǃXung; deprecated 2015-02-12
'ggn': 'gvr', // Eastern Gurung; deprecated 2016-05-30
'gti': 'nyc', // Gbati-ri; deprecated 2015-02-12
'guv': 'duz', // Gey; deprecated 2016-05-30
'hrr': 'jal', // Horuru; deprecated 2012-08-12
'ibi': 'opa', // Ibilo; deprecated 2012-08-12
'ilw': 'gal', // Talur; deprecated 2013-09-10
'jeg': 'oyb', // Jeng; deprecated 2017-02-23
'kgc': 'tdf', // Kasseng; deprecated 2016-05-30
'kgh': 'kml', // Upper Tanudan Kalinga; deprecated 2012-08-12
'koj': 'kwv', // Sara Dunjo; deprecated 2015-02-12
'krm': 'bmf', // Krim; deprecated 2017-02-23
'ktr': 'dtp', // Kota Marudu Tinagas; deprecated 2016-05-30
'kvs': 'gdj', // Kunggara; deprecated 2016-05-30
'kwq': 'yam', // Kwak; deprecated 2015-02-12
'kxe': 'tvd', // Kakihum; deprecated 2015-02-12
'kzj': 'dtp', // Coastal Kadazan; deprecated 2016-05-30
'kzt': 'dtp', // Tambunan Dusun; deprecated 2016-05-30
'lii': 'raq', // Lingkhim; deprecated 2015-02-12
'lmm': 'rmx', // Lamam; deprecated 2014-02-28
'meg': 'cir', // Mea; deprecated 2013-09-10
'mst': 'mry', // Cataelano Mandaya; deprecated 2010-03-11
'mwj': 'vaj', // Maligo; deprecated 2015-02-12
'myt': 'mry', // Sangab Mandaya; deprecated 2010-03-11
'nad': 'xny', // Nijadali; deprecated 2016-05-30
'ncp': 'kdz', // Ndaktup; deprecated 2018-03-08
'nnx': 'ngv', // Ngong; deprecated 2015-02-12
'nts': 'pij', // Natagaimas; deprecated 2016-05-30
'oun': 'vaj', // ǃOǃung; deprecated 2015-02-12
'pcr': 'adx', // Panang; deprecated 2013-09-10
'pmc': 'huw', // Palumata; deprecated 2016-05-30
'pmu': 'phr', // Mirpur Panjabi; deprecated 2015-02-12
'ppa': 'bfy', // Pao; deprecated 2016-05-30
'ppr': 'lcq', // Piru; deprecated 2013-09-10
'pry': 'prt', // Pray 3; deprecated 2016-05-30
'puz': 'pub', // Purum Naga; deprecated 2014-02-28
'sca': 'hle', // Sansu; deprecated 2012-08-12
'skk': 'oyb', // Sok; deprecated 2017-02-23
'tdu': 'dtp', // Tempasuk Dusun; deprecated 2016-05-30
'thc': 'tpo', // Tai Hang Tong; deprecated 2016-05-30
'thx': 'oyb', // The; deprecated 2015-02-12
'tie': 'ras', // Tingal; deprecated 2011-08-16
'tkk': 'twm', // Takpa; deprecated 2011-08-16
'tlw': 'weo', // South Wemale; deprecated 2012-08-12
'tmp': 'tyj', // Tai Mène; deprecated 2016-05-30
'tne': 'kak', // Tinoc Kallahan; deprecated 2016-05-30
'tnf': 'prs', // Tangshewi; deprecated 2010-03-11
'tsf': 'taj', // Southwestern Tamang; deprecated 2015-02-12
'uok': 'ema', // Uokha; deprecated 2015-02-12
'xba': 'cax', // Kamba (Brazil); deprecated 2016-05-30
'xia': 'acn', // Xiandao; deprecated 2013-09-10
'xkh': 'waw', // Karahawyana; deprecated 2016-05-30
'xsj': 'suj', // Subi; deprecated 2015-02-12
'ybd': 'rki', // Yangbye; deprecated 2012-08-12
'yma': 'lrr', // Yamphe; deprecated 2012-08-12
'ymt': 'mtm', // Mator-Taygi-Karagas; deprecated 2015-02-12
'yos': 'zom', // Yos; deprecated 2013-09-10
'yuu': 'yug', // Yugh; deprecated 2014-02-28
};
final String? scriptCode;
String? get countryCode => _deprecatedRegionSubtagMap[_countryCode] ?? _countryCode;
final String? _countryCode;
// This map is generated by //flutter/tools/gen_locale.dart
// Mappings generated for language subtag registry as of 2019-02-27.
static const Map<String, String> _deprecatedRegionSubtagMap = <String, String>{
'BU': 'MM', // Burma; deprecated 1989-12-05
'DD': 'DE', // German Democratic Republic; deprecated 1990-10-30
'FX': 'FR', // Metropolitan France; deprecated 1997-07-14
'TP': 'TL', // East Timor; deprecated 2002-05-20
'YD': 'YE', // Democratic Yemen; deprecated 1990-08-14
'ZR': 'CD', // Zaire; deprecated 1997-07-14
};
@override
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}
return other is Locale
&& other.languageCode == languageCode
&& other.scriptCode == scriptCode
&& other.countryCode == countryCode;
}
@override
int get hashCode => hashValues(languageCode, scriptCode, countryCode);
@override
String toString() => _rawToString('_');
// TODO(yjbanov): implement to match flutter native.
String toLanguageTag() => _rawToString('-');
String _rawToString(String separator) {
final StringBuffer out = StringBuffer(languageCode);
if (scriptCode != null) {
out.write('$separator$scriptCode');
}
if (_countryCode != null) {
out.write('$separator$countryCode');
}
return out.toString();
}
}
\ No newline at end of file
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Synced 2019-05-30T14:20:57.833907.
// @dart = 2.10
part of ui;
......
此差异已折叠。
......@@ -29,7 +29,6 @@ part 'src/ui/natives.dart';
part 'src/ui/painting.dart';
part 'src/ui/path.dart';
part 'src/ui/path_metrics.dart';
part 'src/ui/platform_dispatcher.dart';
part 'src/ui/pointer.dart';
part 'src/ui/semantics.dart';
part 'src/ui/test_embedding.dart';
......
......@@ -50,7 +50,7 @@ void _tests() {
when(mockRasterizer.addPostFrameCallback(any)).thenAnswer((_) {
addPostFrameCallbackCount++;
});
EnginePlatformDispatcher.instance.rasterizer = mockRasterizer;
window.rasterizer = mockRasterizer;
// Trigger first create
final TestSkiaObject testObject = TestSkiaObject();
......
......@@ -292,7 +292,7 @@ void testMain() {
expect(strategy.history, hasLength(1));
expect(strategy.currentEntry.state, _tagStateWithSerialCount('initial state', 0));
expect(strategy.currentEntry.url, '/home');
await routeInformationUpdated('/page1', 'page1 state');
await routeInfomrationUpdated('/page1', 'page1 state');
// Should have two history entries now.
expect(strategy.history, hasLength(2));
expect(strategy.currentEntryIndex, 1);
......@@ -329,8 +329,8 @@ void testMain() {
);
await window.debugInitializeHistory(strategy, useSingle: false);
await routeInformationUpdated('/page1', 'page1 state');
await routeInformationUpdated('/page2', 'page2 state');
await routeInfomrationUpdated('/page1', 'page1 state');
await routeInfomrationUpdated('/page2', 'page2 state');
// Make sure we are on page2.
expect(strategy.history, hasLength(3));
......@@ -426,8 +426,8 @@ void testMain() {
);
await window.debugInitializeHistory(strategy, useSingle: false);
await routeInformationUpdated('/page1', 'page1 state');
await routeInformationUpdated('/page2', 'page2 state');
await routeInfomrationUpdated('/page1', 'page1 state');
await routeInfomrationUpdated('/page2', 'page2 state');
// Make sure we are on page2.
expect(strategy.history, hasLength(3));
......@@ -522,7 +522,7 @@ Future<void> routeUpdated(String routeName) {
return completer.future;
}
Future<void> routeInformationUpdated(String location, dynamic state) {
Future<void> routeInfomrationUpdated(String location, dynamic state) {
final Completer<void> completer = Completer<void>();
window.sendPlatformMessage(
'flutter/navigation',
......
......@@ -15,7 +15,7 @@ import 'package:test/test.dart';
import '../../matchers.dart';
const MethodCodec codec = StandardMethodCodec();
final EngineSingletonFlutterWindow window = EngineSingletonFlutterWindow(0, EnginePlatformDispatcher.instance);
final EngineWindow window = EngineWindow();
void main() {
internalBootstrapBrowserTest(() => testMain);
......
......@@ -31,7 +31,7 @@ void testMain() {
expect(window.onTextScaleFactorChanged, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnTextScaleFactorChanged();
window.invokeOnTextScaleFactorChanged();
});
test('onPlatformBrightnessChanged preserves the zone', () {
......@@ -47,7 +47,7 @@ void testMain() {
expect(window.onPlatformBrightnessChanged, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnPlatformBrightnessChanged();
window.invokeOnPlatformBrightnessChanged();
});
test('onMetricsChanged preserves the zone', () {
......@@ -63,7 +63,7 @@ void testMain() {
expect(window.onMetricsChanged, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnMetricsChanged();
window.invokeOnMetricsChanged();
});
test('onLocaleChanged preserves the zone', () {
......@@ -79,7 +79,7 @@ void testMain() {
expect(window.onLocaleChanged, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnLocaleChanged();
window.invokeOnLocaleChanged();
});
test('onBeginFrame preserves the zone', () {
......@@ -95,7 +95,7 @@ void testMain() {
expect(window.onBeginFrame, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnBeginFrame(null);
window.invokeOnBeginFrame(null);
});
test('onReportTimings preserves the zone', () {
......@@ -111,7 +111,7 @@ void testMain() {
expect(window.onReportTimings, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnReportTimings(null);
window.invokeOnReportTimings(null);
});
test('onDrawFrame preserves the zone', () {
......@@ -127,7 +127,7 @@ void testMain() {
expect(window.onDrawFrame, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnDrawFrame();
window.invokeOnDrawFrame();
});
test('onPointerDataPacket preserves the zone', () {
......@@ -143,7 +143,7 @@ void testMain() {
expect(window.onPointerDataPacket, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnPointerDataPacket(null);
window.invokeOnPointerDataPacket(null);
});
test('onSemanticsEnabledChanged preserves the zone', () {
......@@ -159,7 +159,7 @@ void testMain() {
expect(window.onSemanticsEnabledChanged, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnSemanticsEnabledChanged();
window.invokeOnSemanticsEnabledChanged();
});
test('onSemanticsAction preserves the zone', () {
......@@ -175,7 +175,7 @@ void testMain() {
expect(window.onSemanticsAction, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(null, null, null);
window.invokeOnSemanticsAction(null, null, null);
});
test('onAccessibilityFeaturesChanged preserves the zone', () {
......@@ -191,7 +191,7 @@ void testMain() {
expect(window.onAccessibilityFeaturesChanged, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnAccessibilityFeaturesChanged();
window.invokeOnAccessibilityFeaturesChanged();
});
test('onPlatformMessage preserves the zone', () {
......@@ -207,7 +207,7 @@ void testMain() {
expect(window.onPlatformMessage, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnPlatformMessage(null, null, null);
window.invokeOnPlatformMessage(null, null, null);
});
test('sendPlatformMessage preserves the zone', () async {
......@@ -290,8 +290,8 @@ void testMain() {
// Trigger a change notification (reset locales because the notification
// doesn't actually change the list of languages; the test only observes
// that the list is populated again).
EnginePlatformDispatcher.instance.debugResetLocales();
expect(window.locales, isEmpty);
window.debugResetLocales();
expect(window.locales, null);
expect(localeChangedCount, 0);
html.window.dispatchEvent(html.Event('languagechange'));
expect(window.locales, isNotEmpty);
......
......@@ -227,8 +227,8 @@ void testMain() async {
);
final SceneBuilder sb = SceneBuilder();
sb.pushTransform(Matrix4.diagonal3Values(EnginePlatformDispatcher.browserDevicePixelRatio,
EnginePlatformDispatcher.browserDevicePixelRatio, 1.0).toFloat64());
sb.pushTransform(Matrix4.diagonal3Values(EngineWindow.browserDevicePixelRatio,
EngineWindow.browserDevicePixelRatio, 1.0).toFloat64());
sb.pushTransform(Matrix4.rotationZ(math.pi / 2).toFloat64());
sb.pushOffset(0, -500);
sb.pushClipRect(canvasSize);
......
......@@ -412,8 +412,8 @@ void _testCullRectComputation() {
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
builder.pushTransform(Matrix4.diagonal3Values(
EnginePlatformDispatcher.browserDevicePixelRatio,
EnginePlatformDispatcher.browserDevicePixelRatio, 1.0).toFloat64());
EngineWindow.browserDevicePixelRatio,
EngineWindow.browserDevicePixelRatio, 1.0).toFloat64());
// TODO(yjbanov): see the TODO below.
// final double screenWidth = html.window.innerWidth.toDouble();
......
......@@ -71,7 +71,7 @@ void testMain() {
expect(window.browserHistory.currentPath, '/');
// Perform some navigation operations.
routeInformationUpdated('/foo/bar', null);
routeInfomrationUpdated('/foo/bar', null);
// Path should not be updated because URL strategy is disabled.
expect(window.browserHistory.currentPath, '/');
});
......
......@@ -188,7 +188,7 @@ bool RuntimeController::SetViewportMetrics(const ViewportMetrics& metrics) {
platform_data_.viewport_metrics = metrics;
if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
platform_configuration->get_window(0)->UpdateWindowMetrics(metrics);
platform_configuration->window()->UpdateWindowMetrics(metrics);
return true;
}
......@@ -310,7 +310,7 @@ bool RuntimeController::DispatchPointerDataPacket(
if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
TRACE_EVENT1("flutter", "RuntimeController::DispatchPointerDataPacket",
"mode", "basic");
platform_configuration->get_window(0)->DispatchPointerDataPacket(packet);
platform_configuration->window()->DispatchPointerDataPacket(packet);
return true;
}
......
......@@ -147,7 +147,7 @@ class RuntimeController : public PlatformConfigurationClient {
/// If the isolate is not running, these metrics will be saved and
/// flushed to the isolate when it starts.
///
/// @param[in] metrics The window's viewport metrics.
/// @param[in] metrics The viewport metrics.
///
/// @return If the window metrics were forwarded to the running isolate.
///
......
......@@ -202,14 +202,13 @@ class Engine final : public RuntimeDelegate,
/// @brief Notifies the shell of the name of the root isolate and its
/// port when that isolate is launched, restarted (in the
/// cold-restart scenario) or the application itself updates the
/// name of the root isolate (via
/// `PlatformDispatcher.setIsolateDebugName` in
/// `platform_dispatcher.dart`). The name of the isolate is
/// meaningless to the engine but is used in instrumentation and
/// tooling. Currently, this information is to update the
/// service protocol list of available root isolates running in
/// the VM and their names so that the appropriate isolate can
/// be selected in the tools for debugging and instrumentation.
/// name of the root isolate (via `Window.setIsolateDebugName`
/// in `window.dart`). The name of the isolate is meaningless to
/// the engine but is used in instrumentation and tooling.
/// Currently, this information is to update the service
/// protocol list of available root isolates running in the VM
/// and their names so that the appropriate isolate can be
/// selected in the tools for debugging and instrumentation.
///
/// @param[in] isolate_name The isolate name
/// @param[in] isolate_port The isolate port
......@@ -553,8 +552,8 @@ class Engine final : public RuntimeDelegate,
/// "main.dart", the entrypoint is "main" and the port name
/// "1234". Once launched, the isolate may re-christen itself
/// using a name it selects via `setIsolateDebugName` in
/// `platform_dispatcher.dart`. This name is purely advisory and
/// only used by instrumentation and reporting purposes.
/// `window.dart`. This name is purely advisory and only used by
/// instrumentation and reporting purposes.
///
/// @return The debug name of the root isolate.
///
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册