未验证 提交 daf44674 编写于 作者: M Mouad Debbar 提交者: GitHub

[web] Librarify all remaining files (#27296)

上级 f0336978
...@@ -19,16 +19,20 @@ import 'dart:async'; ...@@ -19,16 +19,20 @@ import 'dart:async';
// ignore: unused_import // ignore: unused_import
import 'dart:collection' import 'dart:collection'
show ListBase, IterableBase, DoubleLinkedQueue, DoubleLinkedQueueEntry; show ListBase, IterableBase, DoubleLinkedQueue, DoubleLinkedQueueEntry;
// ignore: unused_import
import 'dart:convert' hide Codec; import 'dart:convert' hide Codec;
import 'dart:developer' as developer; import 'dart:developer' as developer;
import 'dart:html' as html; import 'dart:html' as html;
// ignore: unused_import
import 'dart:js' as js; import 'dart:js' as js;
// ignore: unused_import
import 'dart:js_util' as js_util; import 'dart:js_util' as js_util;
// ignore: unused_import // ignore: unused_import
import 'dart:math' as math; import 'dart:math' as math;
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:js/js.dart'; import 'package:js/js.dart';
// ignore: unused_import
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import '../ui.dart' as ui; import '../ui.dart' as ui;
...@@ -37,16 +41,23 @@ export 'engine/alarm_clock.dart'; ...@@ -37,16 +41,23 @@ export 'engine/alarm_clock.dart';
export 'engine/assets.dart'; export 'engine/assets.dart';
import 'engine/browser_detection.dart';
export 'engine/browser_detection.dart'; export 'engine/browser_detection.dart';
export 'engine/canvas_pool.dart'; export 'engine/canvas_pool.dart';
export 'engine/clipboard.dart';
export 'engine/color_filter.dart';
import 'engine/dom_renderer.dart';
export 'engine/dom_renderer.dart';
export 'engine/engine_canvas.dart'; export 'engine/engine_canvas.dart';
export 'engine/font_change_util.dart';
export 'engine/frame_reference.dart'; export 'engine/frame_reference.dart';
import 'engine/host_node.dart';
export 'engine/host_node.dart'; export 'engine/host_node.dart';
export 'engine/html_image_codec.dart'; export 'engine/html_image_codec.dart';
...@@ -105,7 +116,6 @@ export 'engine/html/recording_canvas.dart'; ...@@ -105,7 +116,6 @@ export 'engine/html/recording_canvas.dart';
export 'engine/html/render_vertices.dart'; export 'engine/html/render_vertices.dart';
import 'engine/html/scene.dart';
export 'engine/html/scene.dart'; export 'engine/html/scene.dart';
export 'engine/html/scene_builder.dart'; export 'engine/html/scene_builder.dart';
...@@ -130,7 +140,6 @@ export 'engine/html/surface_stats.dart'; ...@@ -130,7 +140,6 @@ export 'engine/html/surface_stats.dart';
export 'engine/html/transform.dart'; export 'engine/html/transform.dart';
import 'engine/keyboard_binding.dart';
export 'engine/keyboard_binding.dart'; export 'engine/keyboard_binding.dart';
import 'engine/keyboard.dart'; import 'engine/keyboard.dart';
...@@ -141,7 +150,6 @@ export 'engine/key_map.dart'; ...@@ -141,7 +150,6 @@ export 'engine/key_map.dart';
import 'engine/mouse_cursor.dart'; import 'engine/mouse_cursor.dart';
export 'engine/mouse_cursor.dart'; export 'engine/mouse_cursor.dart';
import 'engine/navigation/history.dart';
export 'engine/navigation/history.dart'; export 'engine/navigation/history.dart';
import 'engine/navigation/js_url_strategy.dart'; import 'engine/navigation/js_url_strategy.dart';
...@@ -154,10 +162,20 @@ export 'engine/onscreen_logging.dart'; ...@@ -154,10 +162,20 @@ export 'engine/onscreen_logging.dart';
export 'engine/picture.dart'; export 'engine/picture.dart';
import 'engine/plugins.dart'; import 'engine/platform_dispatcher.dart';
export 'engine/platform_dispatcher.dart';
export 'engine/platform_views.dart';
import 'engine/platform_views/content_manager.dart';
export 'engine/platform_views/content_manager.dart';
export 'engine/platform_views/message_handler.dart';
export 'engine/platform_views/slots.dart';
export 'engine/plugins.dart'; export 'engine/plugins.dart';
import 'engine/pointer_binding.dart';
export 'engine/pointer_binding.dart'; export 'engine/pointer_binding.dart';
export 'engine/pointer_converter.dart'; export 'engine/pointer_converter.dart';
...@@ -167,7 +185,6 @@ export 'engine/profiler.dart'; ...@@ -167,7 +185,6 @@ export 'engine/profiler.dart';
export 'engine/rrect_renderer.dart'; export 'engine/rrect_renderer.dart';
import 'engine/semantics/accessibility.dart';
export 'engine/semantics/accessibility.dart'; export 'engine/semantics/accessibility.dart';
export 'engine/semantics/checkable.dart'; export 'engine/semantics/checkable.dart';
...@@ -182,7 +199,6 @@ export 'engine/semantics/live_region.dart'; ...@@ -182,7 +199,6 @@ export 'engine/semantics/live_region.dart';
export 'engine/semantics/scrollable.dart'; export 'engine/semantics/scrollable.dart';
import 'engine/semantics/semantics.dart';
export 'engine/semantics/semantics.dart'; export 'engine/semantics/semantics.dart';
export 'engine/semantics/semantics_helper.dart'; export 'engine/semantics/semantics_helper.dart';
...@@ -193,17 +209,14 @@ export 'engine/semantics/text_field.dart'; ...@@ -193,17 +209,14 @@ export 'engine/semantics/text_field.dart';
export 'engine/services/buffers.dart'; export 'engine/services/buffers.dart';
import 'engine/services/message_codec.dart';
export 'engine/services/message_codec.dart'; export 'engine/services/message_codec.dart';
import 'engine/services/message_codecs.dart';
export 'engine/services/message_codecs.dart'; export 'engine/services/message_codecs.dart';
export 'engine/services/serialization.dart'; export 'engine/services/serialization.dart';
export 'engine/shadow.dart'; export 'engine/shadow.dart';
import 'engine/test_embedding.dart';
export 'engine/test_embedding.dart'; export 'engine/test_embedding.dart';
export 'engine/text/font_collection.dart'; export 'engine/text/font_collection.dart';
...@@ -214,7 +227,6 @@ export 'engine/text/line_break_properties.dart'; ...@@ -214,7 +227,6 @@ export 'engine/text/line_break_properties.dart';
export 'engine/text/line_breaker.dart'; export 'engine/text/line_breaker.dart';
import 'engine/text/measurement.dart';
export 'engine/text/measurement.dart'; export 'engine/text/measurement.dart';
export 'engine/text/paint_service.dart'; export 'engine/text/paint_service.dart';
...@@ -239,10 +251,8 @@ export 'engine/text_editing/input_type.dart'; ...@@ -239,10 +251,8 @@ export 'engine/text_editing/input_type.dart';
export 'engine/text_editing/text_capitalization.dart'; export 'engine/text_editing/text_capitalization.dart';
import 'engine/text_editing/text_editing.dart';
export 'engine/text_editing/text_editing.dart'; export 'engine/text_editing/text_editing.dart';
import 'engine/util.dart';
export 'engine/util.dart'; export 'engine/util.dart';
export 'engine/validators.dart'; export 'engine/validators.dart';
...@@ -252,17 +262,17 @@ export 'engine/vector_math.dart'; ...@@ -252,17 +262,17 @@ export 'engine/vector_math.dart';
import 'engine/web_experiments.dart'; import 'engine/web_experiments.dart';
export 'engine/web_experiments.dart'; export 'engine/web_experiments.dart';
import 'engine/window.dart';
export 'engine/window.dart';
export 'engine/canvaskit/canvas.dart'; export 'engine/canvaskit/canvas.dart';
import 'engine/canvaskit/canvaskit_api.dart';
export 'engine/canvaskit/canvaskit_api.dart'; export 'engine/canvaskit/canvaskit_api.dart';
export 'engine/canvaskit/canvaskit_canvas.dart'; export 'engine/canvaskit/canvaskit_canvas.dart';
import 'engine/canvaskit/color_filter.dart';
export 'engine/canvaskit/color_filter.dart'; export 'engine/canvaskit/color_filter.dart';
import 'engine/canvaskit/embedded_views.dart';
export 'engine/canvaskit/embedded_views.dart'; export 'engine/canvaskit/embedded_views.dart';
export 'engine/canvaskit/fonts.dart'; export 'engine/canvaskit/fonts.dart';
...@@ -273,14 +283,12 @@ export 'engine/canvaskit/image.dart'; ...@@ -273,14 +283,12 @@ export 'engine/canvaskit/image.dart';
export 'engine/canvaskit/image_filter.dart'; export 'engine/canvaskit/image_filter.dart';
import 'engine/canvaskit/initialization.dart';
export 'engine/canvaskit/initialization.dart'; export 'engine/canvaskit/initialization.dart';
export 'engine/canvaskit/interval_tree.dart'; export 'engine/canvaskit/interval_tree.dart';
export 'engine/canvaskit/layer.dart'; export 'engine/canvaskit/layer.dart';
import 'engine/canvaskit/layer_scene_builder.dart';
export 'engine/canvaskit/layer_scene_builder.dart'; export 'engine/canvaskit/layer_scene_builder.dart';
export 'engine/canvaskit/layer_tree.dart'; export 'engine/canvaskit/layer_tree.dart';
...@@ -299,7 +307,6 @@ export 'engine/canvaskit/picture.dart'; ...@@ -299,7 +307,6 @@ export 'engine/canvaskit/picture.dart';
export 'engine/canvaskit/picture_recorder.dart'; export 'engine/canvaskit/picture_recorder.dart';
import 'engine/canvaskit/rasterizer.dart';
export 'engine/canvaskit/rasterizer.dart'; export 'engine/canvaskit/rasterizer.dart';
export 'engine/canvaskit/raster_cache.dart'; export 'engine/canvaskit/raster_cache.dart';
...@@ -318,16 +325,6 @@ export 'engine/canvaskit/util.dart'; ...@@ -318,16 +325,6 @@ export 'engine/canvaskit/util.dart';
export 'engine/canvaskit/vertices.dart'; export 'engine/canvaskit/vertices.dart';
part 'engine/clipboard.dart';
part 'engine/color_filter.dart';
part 'engine/dom_renderer.dart';
part 'engine/font_change_util.dart';
part 'engine/platform_dispatcher.dart';
part 'engine/platform_views.dart';
part 'engine/platform_views/content_manager.dart';
part 'engine/platform_views/message_handler.dart';
part 'engine/platform_views/slots.dart';
part 'engine/window.dart';
// The mode the app is running in. // The mode the app is running in.
// Keep these in sync with the same constants on the framework-side under foundation/constants.dart. // Keep these in sync with the same constants on the framework-side under foundation/constants.dart.
...@@ -428,12 +425,12 @@ void initializeEngine() { ...@@ -428,12 +425,12 @@ void initializeEngine() {
// part of the rasterization process, particularly in the HTML // part of the rasterization process, particularly in the HTML
// renderer, takes place in the `SceneBuilder.build()`. // renderer, takes place in the `SceneBuilder.build()`.
frameTimingsOnBuildStart(); frameTimingsOnBuildStart();
if (EnginePlatformDispatcher.instance._onBeginFrame != null) { if (EnginePlatformDispatcher.instance.onBeginFrame != null) {
EnginePlatformDispatcher.instance.invokeOnBeginFrame( EnginePlatformDispatcher.instance.invokeOnBeginFrame(
Duration(microseconds: highResTimeMicroseconds)); Duration(microseconds: highResTimeMicroseconds));
} }
if (EnginePlatformDispatcher.instance._onDrawFrame != null) { if (EnginePlatformDispatcher.instance.onDrawFrame != null) {
// TODO(yjbanov): technically Flutter flushes microtasks between // TODO(yjbanov): technically Flutter flushes microtasks between
// onBeginFrame and onDrawFrame. We don't, which hasn't // onBeginFrame and onDrawFrame. We don't, which hasn't
// been an issue yet, but eventually we'll have to // been an issue yet, but eventually we'll have to
...@@ -449,12 +446,12 @@ void initializeEngine() { ...@@ -449,12 +446,12 @@ void initializeEngine() {
} }
void _addUrlStrategyListener() { void _addUrlStrategyListener() {
_jsSetUrlStrategy = allowInterop((JsUrlStrategy? jsStrategy) { jsSetUrlStrategy = allowInterop((JsUrlStrategy? jsStrategy) {
customUrlStrategy = customUrlStrategy =
jsStrategy == null ? null : CustomUrlStrategy.fromJs(jsStrategy); jsStrategy == null ? null : CustomUrlStrategy.fromJs(jsStrategy);
}); });
registerHotRestartListener(() { registerHotRestartListener(() {
_jsSetUrlStrategy = null; jsSetUrlStrategy = null;
}); });
} }
......
...@@ -2,7 +2,13 @@ ...@@ -2,7 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
part of engine; import 'dart:html' as html;
import 'package:ui/ui.dart' as ui;
import 'browser_detection.dart';
import 'services.dart';
import 'util.dart';
/// Handles clipboard related platform messages. /// Handles clipboard related platform messages.
class ClipboardMessageHandler { class ClipboardMessageHandler {
...@@ -78,17 +84,13 @@ class ClipboardMessageHandler { ...@@ -78,17 +84,13 @@ class ClipboardMessageHandler {
} }
} }
bool _unsafeIsNull(dynamic object) {
return object == null;
}
/// Provides functionality for writing text to clipboard. /// Provides functionality for writing text to clipboard.
/// ///
/// A concrete implementation is picked at runtime based on the available /// A concrete implementation is picked at runtime based on the available
/// APIs and the browser. /// APIs and the browser.
abstract class CopyToClipboardStrategy { abstract class CopyToClipboardStrategy {
factory CopyToClipboardStrategy() { factory CopyToClipboardStrategy() {
return !_unsafeIsNull(html.window.navigator.clipboard) return !unsafeIsNull(html.window.navigator.clipboard)
? ClipboardAPICopyStrategy() ? ClipboardAPICopyStrategy()
: ExecCommandCopyStrategy(); : ExecCommandCopyStrategy();
} }
...@@ -108,7 +110,7 @@ abstract class CopyToClipboardStrategy { ...@@ -108,7 +110,7 @@ abstract class CopyToClipboardStrategy {
abstract class PasteFromClipboardStrategy { abstract class PasteFromClipboardStrategy {
factory PasteFromClipboardStrategy() { factory PasteFromClipboardStrategy() {
return (browserEngine == BrowserEngine.firefox || return (browserEngine == BrowserEngine.firefox ||
_unsafeIsNull(html.window.navigator.clipboard)) unsafeIsNull(html.window.navigator.clipboard))
? ExecCommandPasteStrategy() ? ExecCommandPasteStrategy()
: ClipboardAPIPasteStrategy(); : ClipboardAPIPasteStrategy();
} }
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
part of engine; import 'package:ui/ui.dart' as ui;
import 'canvaskit/color_filter.dart';
/// A description of a color filter to apply when drawing a shape or compositing /// A description of a color filter to apply when drawing a shape or compositing
/// a layer with a particular [Paint]. A color filter is a function that takes /// a layer with a particular [Paint]. A color filter is a function that takes
......
...@@ -2,7 +2,26 @@ ...@@ -2,7 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
part of engine; import 'dart:async';
import 'dart:html' as html;
import 'dart:js' as js;
import 'dart:js_util' as js_util;
import 'package:ui/src/engine.dart' show buildMode, registerHotRestartListener;
import 'package:ui/ui.dart' as ui;
import 'browser_detection.dart';
import 'canvaskit/initialization.dart';
import 'canvaskit/canvaskit_api.dart';
import 'host_node.dart';
import 'keyboard_binding.dart';
import 'platform_dispatcher.dart';
import 'pointer_binding.dart';
import 'semantics.dart';
import 'text/measurement.dart';
import 'text_editing/text_editing.dart';
import 'util.dart';
import 'window.dart';
class DomRenderer { class DomRenderer {
DomRenderer() { DomRenderer() {
...@@ -514,7 +533,7 @@ class DomRenderer { ...@@ -514,7 +533,7 @@ class DomRenderer {
} }
_localeSubscription = _localeSubscription =
languageChangeEvent.forTarget(html.window).listen(_languageDidChange); languageChangeEvent.forTarget(html.window).listen(_languageDidChange);
EnginePlatformDispatcher.instance._updateLocales(); EnginePlatformDispatcher.instance.updateLocales();
} }
// Creates a [HostNode] into a `root` [html.Element]. // Creates a [HostNode] into a `root` [html.Element].
...@@ -550,7 +569,7 @@ class DomRenderer { ...@@ -550,7 +569,7 @@ class DomRenderer {
window.computeOnScreenKeyboardInsets(true); window.computeOnScreenKeyboardInsets(true);
EnginePlatformDispatcher.instance.invokeOnMetricsChanged(); EnginePlatformDispatcher.instance.invokeOnMetricsChanged();
} else { } else {
window._computePhysicalSize(); window.computePhysicalSize();
// When physical size changes this value has to be recalculated. // When physical size changes this value has to be recalculated.
window.computeOnScreenKeyboardInsets(false); window.computeOnScreenKeyboardInsets(false);
EnginePlatformDispatcher.instance.invokeOnMetricsChanged(); EnginePlatformDispatcher.instance.invokeOnMetricsChanged();
...@@ -559,7 +578,7 @@ class DomRenderer { ...@@ -559,7 +578,7 @@ class DomRenderer {
/// Called immediately after browser window language change. /// Called immediately after browser window language change.
void _languageDidChange(html.Event event) { void _languageDidChange(html.Event event) {
EnginePlatformDispatcher.instance._updateLocales(); EnginePlatformDispatcher.instance.updateLocales();
if (ui.window.onLocaleChanged != null) { if (ui.window.onLocaleChanged != null) {
ui.window.onLocaleChanged!(); ui.window.onLocaleChanged!();
} }
...@@ -626,9 +645,9 @@ class DomRenderer { ...@@ -626,9 +645,9 @@ class DomRenderer {
/// See w3c screen api: https://www.w3.org/TR/screen-orientation/ /// See w3c screen api: https://www.w3.org/TR/screen-orientation/
Future<bool> setPreferredOrientation(List<dynamic> orientations) { Future<bool> setPreferredOrientation(List<dynamic> orientations) {
final html.Screen screen = html.window.screen!; final html.Screen screen = html.window.screen!;
if (!_unsafeIsNull(screen)) { if (!unsafeIsNull(screen)) {
final html.ScreenOrientation? screenOrientation = screen.orientation; final html.ScreenOrientation? screenOrientation = screen.orientation;
if (!_unsafeIsNull(screenOrientation)) { if (!unsafeIsNull(screenOrientation)) {
if (orientations.isEmpty) { if (orientations.isEmpty) {
screenOrientation!.unlock(); screenOrientation!.unlock();
return Future.value(true); return Future.value(true);
......
...@@ -2,7 +2,12 @@ ...@@ -2,7 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
part of engine; import 'dart:async';
import 'dart:html' as html;
import 'dart:typed_data';
import 'platform_dispatcher.dart';
import 'services.dart';
final ByteData? _fontChangeMessage = final ByteData? _fontChangeMessage =
JSONMessageCodec().encodeMessage(<String, dynamic>{'type': 'fontsChange'}); JSONMessageCodec().encodeMessage(<String, dynamic>{'type': 'fontsChange'});
......
...@@ -2,7 +2,30 @@ ...@@ -2,7 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
part of engine; import 'dart:async';
import 'dart:html' as html;
import 'dart:typed_data';
import 'dart:convert';
import 'package:meta/meta.dart';
import 'package:ui/src/engine.dart' show platformViewManager, registerHotRestartListener;
import 'package:ui/ui.dart' as ui;
import 'canvaskit/initialization.dart';
import 'canvaskit/layer_scene_builder.dart';
import 'canvaskit/rasterizer.dart';
import 'clipboard.dart';
import 'dom_renderer.dart';
import 'html/scene.dart';
import 'profiler.dart';
import 'mouse_cursor.dart';
import 'platform_views/message_handler.dart';
import 'plugins.dart';
import 'semantics.dart';
import 'services.dart';
import 'text_editing/text_editing.dart';
import 'util.dart';
import 'window.dart';
/// Requests that the browser schedule a frame. /// Requests that the browser schedule a frame.
/// ///
...@@ -54,12 +77,14 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher { ...@@ -54,12 +77,14 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
/// The current list of windows, /// The current list of windows,
Iterable<ui.FlutterView> get views => _windows.values; Iterable<ui.FlutterView> get views => _windows.values;
Map<Object, ui.FlutterWindow> get windows => _windows;
Map<Object, ui.FlutterWindow> _windows = <Object, ui.FlutterWindow>{}; Map<Object, ui.FlutterWindow> _windows = <Object, ui.FlutterWindow>{};
/// A map of opaque platform window identifiers to window configurations. /// A map of opaque platform window identifiers to window configurations.
/// ///
/// This should be considered a protected member, only to be used by /// This should be considered a protected member, only to be used by
/// [PlatformDispatcher] subclasses. /// [PlatformDispatcher] subclasses.
Map<Object, ui.ViewConfiguration> get windowConfigurations => _windowConfigurations;
Map<Object, ui.ViewConfiguration> _windowConfigurations = Map<Object, ui.ViewConfiguration> _windowConfigurations =
<Object, ui.ViewConfiguration>{}; <Object, ui.ViewConfiguration>{};
...@@ -326,7 +351,7 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher { ...@@ -326,7 +351,7 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
return; return;
} }
if (_debugPrintPlatformMessages) { if (debugPrintPlatformMessages) {
print('Sent platform message on channel: "$name"'); print('Sent platform message on channel: "$name"');
} }
...@@ -684,7 +709,7 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher { ...@@ -684,7 +709,7 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
} }
// Called by DomRenderer when browser languages change. // Called by DomRenderer when browser languages change.
void _updateLocales() { void updateLocales() {
_configuration = _configuration.copyWith(locales: parseBrowserLanguages()); _configuration = _configuration.copyWith(locales: parseBrowserLanguages());
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
part of engine;
// TODO(yjbanov): The code in this file was temporarily moved to lib/web_ui/lib/ui.dart // TODO(yjbanov): The code in this file was temporarily moved to lib/web_ui/lib/ui.dart
// during the NNBD migration so that `dart:ui` does not have to export // during the NNBD migration so that `dart:ui` does not have to export
// `dart:_engine`. NNBD does not allow exported non-migrated libraries // `dart:_engine`. NNBD does not allow exported non-migrated libraries
......
...@@ -2,7 +2,12 @@ ...@@ -2,7 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
part of engine; import 'dart:html' as html;
import '../browser_detection.dart';
import '../dom_renderer.dart';
import '../util.dart';
import 'slots.dart';
/// A function which takes a unique `id` and some `params` and creates an HTML element. /// A function which takes a unique `id` and some `params` and creates an HTML element.
/// ///
...@@ -149,7 +154,7 @@ class PlatformViewManager { ...@@ -149,7 +154,7 @@ class PlatformViewManager {
final html.Element slot = html.document.createElement('slot') final html.Element slot = html.document.createElement('slot')
..style.display = 'none' ..style.display = 'none'
..setAttribute('name', tombstoneName); ..setAttribute('name', tombstoneName);
domRenderer._glassPaneShadow!.append(slot); domRenderer.glassPaneShadow!.append(slot);
// Link the element to the new slot // Link the element to the new slot
element.setAttribute('slot', tombstoneName); element.setAttribute('slot', tombstoneName);
// Delete both the element, and the new slot // Delete both the element, and the new slot
......
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
part of engine; import 'dart:html' as html;
import 'dart:typed_data';
import '../services.dart';
import 'content_manager.dart';
/// The signature for a callback for a Platform Message. From the `ui` package. /// The signature for a callback for a Platform Message. From the `ui` package.
/// Copied here so there's no circular dependencies. /// Copied here so there's no circular dependencies.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
part of engine; import 'dart:html' as html;
/// Returns the name of a slot from its `viewId`. /// Returns the name of a slot from its `viewId`.
/// ///
......
...@@ -555,3 +555,8 @@ bool listEquals<T>(List<T>? a, List<T>? b) { ...@@ -555,3 +555,8 @@ bool listEquals<T>(List<T>? a, List<T>? b) {
String blurSigmasToCssString(double sigmaX, double sigmaY) { String blurSigmasToCssString(double sigmaX, double sigmaY) {
return 'blur(${(sigmaX + sigmaY) * 0.5}px)'; return 'blur(${(sigmaX + sigmaY) * 0.5}px)';
} }
/// Checks if the dynamic [object] is equal to null.
bool unsafeIsNull(dynamic object) {
return object == null;
}
...@@ -2,12 +2,30 @@ ...@@ -2,12 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
part of engine; @JS()
library window;
import 'dart:async';
import 'dart:html' as html;
import 'dart:typed_data';
import 'package:js/js.dart';
import 'package:meta/meta.dart';
import 'package:ui/src/engine.dart' show registerHotRestartListener;
import 'package:ui/ui.dart' as ui;
import 'browser_detection.dart';
import 'navigation/history.dart';
import 'navigation/js_url_strategy.dart';
import 'navigation/url_strategy.dart';
import 'platform_dispatcher.dart';
import 'services.dart';
import 'test_embedding.dart';
typedef _HandleMessageCallBack = Future<bool> Function(); typedef _HandleMessageCallBack = Future<bool> Function();
/// When set to true, all platform messages will be printed to the console. /// When set to true, all platform messages will be printed to the console.
const bool /*!*/ _debugPrintPlatformMessages = false; const bool debugPrintPlatformMessages = false;
/// Whether [_customUrlStrategy] has been set or not. /// Whether [_customUrlStrategy] has been set or not.
/// ///
...@@ -28,8 +46,8 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow { ...@@ -28,8 +46,8 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
EngineFlutterWindow(this._windowId, this.platformDispatcher) { EngineFlutterWindow(this._windowId, this.platformDispatcher) {
final EnginePlatformDispatcher engineDispatcher = final EnginePlatformDispatcher engineDispatcher =
platformDispatcher as EnginePlatformDispatcher; platformDispatcher as EnginePlatformDispatcher;
engineDispatcher._windows[_windowId] = this; engineDispatcher.windows[_windowId] = this;
engineDispatcher._windowConfigurations[_windowId] = ui.ViewConfiguration(); engineDispatcher.windowConfigurations[_windowId] = ui.ViewConfiguration();
if (_isUrlStrategySet) { if (_isUrlStrategySet) {
_browserHistory = _browserHistory =
MultiEntriesBrowserHistory(urlStrategy: _customUrlStrategy); MultiEntriesBrowserHistory(urlStrategy: _customUrlStrategy);
...@@ -44,7 +62,6 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow { ...@@ -44,7 +62,6 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
/// Handles the browser history integration to allow users to use the back /// Handles the browser history integration to allow users to use the back
/// button, etc. /// button, etc.
@visibleForTesting
BrowserHistory get browserHistory { BrowserHistory get browserHistory {
return _browserHistory ??= return _browserHistory ??=
MultiEntriesBrowserHistory(urlStrategy: _urlStrategyForInitialization); MultiEntriesBrowserHistory(urlStrategy: _urlStrategyForInitialization);
...@@ -164,15 +181,15 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow { ...@@ -164,15 +181,15 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
ui.ViewConfiguration get viewConfiguration { ui.ViewConfiguration get viewConfiguration {
final EnginePlatformDispatcher engineDispatcher = final EnginePlatformDispatcher engineDispatcher =
platformDispatcher as EnginePlatformDispatcher; platformDispatcher as EnginePlatformDispatcher;
assert(engineDispatcher._windowConfigurations.containsKey(_windowId)); assert(engineDispatcher.windowConfigurations.containsKey(_windowId));
return engineDispatcher._windowConfigurations[_windowId] ?? return engineDispatcher.windowConfigurations[_windowId] ??
ui.ViewConfiguration(); ui.ViewConfiguration();
} }
@override @override
ui.Size get physicalSize { ui.Size get physicalSize {
if (_physicalSize == null) { if (_physicalSize == null) {
_computePhysicalSize(); computePhysicalSize();
} }
assert(_physicalSize != null); assert(_physicalSize != null);
return _physicalSize!; return _physicalSize!;
...@@ -182,7 +199,7 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow { ...@@ -182,7 +199,7 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
/// ///
/// This function is expensive. It triggers browser layout if there are /// This function is expensive. It triggers browser layout if there are
/// pending DOM writes. /// pending DOM writes.
void _computePhysicalSize() { void computePhysicalSize() {
bool override = false; bool override = false;
assert(() { assert(() {
...@@ -231,7 +248,7 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow { ...@@ -231,7 +248,7 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
/// Forces the window to recompute its physical size. Useful for tests. /// Forces the window to recompute its physical size. Useful for tests.
void debugForceResize() { void debugForceResize() {
_computePhysicalSize(); computePhysicalSize();
} }
void computeOnScreenKeyboardInsets(bool isEditingOnMobile) { void computeOnScreenKeyboardInsets(bool isEditingOnMobile) {
...@@ -315,7 +332,7 @@ typedef _JsSetUrlStrategy = void Function(JsUrlStrategy?); ...@@ -315,7 +332,7 @@ typedef _JsSetUrlStrategy = void Function(JsUrlStrategy?);
// //
// TODO: Add integration test https://github.com/flutter/flutter/issues/66852 // TODO: Add integration test https://github.com/flutter/flutter/issues/66852
@JS('_flutter_web_set_location_strategy') @JS('_flutter_web_set_location_strategy')
external set _jsSetUrlStrategy(_JsSetUrlStrategy? newJsSetUrlStrategy); external set jsSetUrlStrategy(_JsSetUrlStrategy? newJsSetUrlStrategy);
UrlStrategy? _createDefaultUrlStrategy() { UrlStrategy? _createDefaultUrlStrategy() {
return ui.debugEmulateFlutterTesterEnvironment return ui.debugEmulateFlutterTesterEnvironment
...@@ -356,8 +373,8 @@ class EngineFlutterWindowView extends ui.FlutterWindow { ...@@ -356,8 +373,8 @@ class EngineFlutterWindowView extends ui.FlutterWindow {
ui.ViewConfiguration get viewConfiguration { ui.ViewConfiguration get viewConfiguration {
final EnginePlatformDispatcher engineDispatcher = final EnginePlatformDispatcher engineDispatcher =
platformDispatcher as EnginePlatformDispatcher; platformDispatcher as EnginePlatformDispatcher;
assert(engineDispatcher._windowConfigurations.containsKey(_viewId)); assert(engineDispatcher.windowConfigurations.containsKey(_viewId));
return engineDispatcher._windowConfigurations[_viewId] ?? return engineDispatcher.windowConfigurations[_viewId] ??
ui.ViewConfiguration(); ui.ViewConfiguration();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册