mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[web] Librarify semantics files (flutter/engine#27151)
This commit is contained in:
parent
32cded5dcd
commit
abb5180fe5
@ -564,6 +564,7 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/pointer_binding.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/pointer_converter.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/profiler.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/rrect_renderer.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/semantics.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/semantics/accessibility.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/semantics/checkable.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/semantics/image.dart
|
||||
|
||||
@ -32,7 +32,6 @@ import 'package:meta/meta.dart';
|
||||
|
||||
import '../ui.dart' as ui;
|
||||
|
||||
import 'engine/alarm_clock.dart';
|
||||
export 'engine/alarm_clock.dart';
|
||||
|
||||
export 'engine/assets.dart';
|
||||
@ -131,8 +130,30 @@ export 'engine/pointer_converter.dart';
|
||||
import 'engine/profiler.dart';
|
||||
export 'engine/profiler.dart';
|
||||
|
||||
// This import is intentionally commented out because the analyzer says it's unused.
|
||||
// import 'engine/services/buffers.dart';
|
||||
import 'engine/semantics/accessibility.dart';
|
||||
export 'engine/semantics/accessibility.dart';
|
||||
|
||||
export 'engine/semantics/checkable.dart';
|
||||
|
||||
export 'engine/semantics/image.dart';
|
||||
|
||||
export 'engine/semantics/incrementable.dart';
|
||||
|
||||
export 'engine/semantics/label_and_value.dart';
|
||||
|
||||
export 'engine/semantics/live_region.dart';
|
||||
|
||||
export 'engine/semantics/scrollable.dart';
|
||||
|
||||
import 'engine/semantics/semantics.dart';
|
||||
export 'engine/semantics/semantics.dart';
|
||||
|
||||
export 'engine/semantics/semantics_helper.dart';
|
||||
|
||||
export 'engine/semantics/tappable.dart';
|
||||
|
||||
export 'engine/semantics/text_field.dart';
|
||||
|
||||
export 'engine/services/buffers.dart';
|
||||
|
||||
import 'engine/services/message_codec.dart';
|
||||
@ -302,17 +323,6 @@ part 'engine/platform_views/content_manager.dart';
|
||||
part 'engine/platform_views/message_handler.dart';
|
||||
part 'engine/platform_views/slots.dart';
|
||||
part 'engine/rrect_renderer.dart';
|
||||
part 'engine/semantics/accessibility.dart';
|
||||
part 'engine/semantics/checkable.dart';
|
||||
part 'engine/semantics/image.dart';
|
||||
part 'engine/semantics/incrementable.dart';
|
||||
part 'engine/semantics/label_and_value.dart';
|
||||
part 'engine/semantics/live_region.dart';
|
||||
part 'engine/semantics/scrollable.dart';
|
||||
part 'engine/semantics/semantics.dart';
|
||||
part 'engine/semantics/semantics_helper.dart';
|
||||
part 'engine/semantics/tappable.dart';
|
||||
part 'engine/semantics/text_field.dart';
|
||||
part 'engine/window.dart';
|
||||
|
||||
// The mode the app is running in.
|
||||
|
||||
@ -207,6 +207,14 @@ bool get isDesktop => _desktopOperatingSystems.contains(operatingSystem);
|
||||
/// See [isDesktop].
|
||||
bool get isMobile => !isDesktop;
|
||||
|
||||
/// Whether the browser is running on macOS or iOS.
|
||||
///
|
||||
/// - See [operatingSystem].
|
||||
/// - See [OperatingSystem].
|
||||
bool get isMacOrIOS =>
|
||||
operatingSystem == OperatingSystem.iOs ||
|
||||
operatingSystem == OperatingSystem.macOs;
|
||||
|
||||
int? _cachedWebGLVersion;
|
||||
|
||||
/// The highest WebGL version supported by the current browser, or -1 if WebGL
|
||||
|
||||
@ -387,7 +387,7 @@ class DomRenderer {
|
||||
|
||||
// When debugging semantics, make the scene semi-transparent so that the
|
||||
// semantics tree is visible.
|
||||
if (_debugShowSemanticsNodes) {
|
||||
if (debugShowSemanticsNodes) {
|
||||
_sceneHostElement!.style.opacity = '0.3';
|
||||
}
|
||||
|
||||
|
||||
@ -4,11 +4,12 @@
|
||||
|
||||
import 'dart:html' as html;
|
||||
|
||||
import 'package:ui/src/engine.dart' show EnginePlatformDispatcher, EngineSemanticsOwner, registerHotRestartListener;
|
||||
import 'package:ui/src/engine.dart' show EnginePlatformDispatcher, registerHotRestartListener;
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import 'browser_detection.dart';
|
||||
import 'key_map.dart';
|
||||
import 'semantics.dart';
|
||||
|
||||
typedef _VoidCallback = void Function();
|
||||
typedef ValueGetter<T> = T Function();
|
||||
|
||||
@ -760,6 +760,15 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
|
||||
invoke(_onTextScaleFactorChanged, _onTextScaleFactorChangedZone);
|
||||
}
|
||||
|
||||
void updateSemanticsEnabled(bool semanticsEnabled) {
|
||||
if (semanticsEnabled != this.semanticsEnabled) {
|
||||
_configuration = _configuration.copyWith(semanticsEnabled: semanticsEnabled);
|
||||
if (_onSemanticsEnabledChanged != null) {
|
||||
invokeOnSemanticsEnabledChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The setting indicating the current brightness mode of the host platform.
|
||||
/// If the platform has no preference, [platformBrightness] defaults to [Brightness.light].
|
||||
ui.Brightness get platformBrightness => configuration.platformBrightness;
|
||||
|
||||
15
engine/src/flutter/lib/web_ui/lib/src/engine/semantics.dart
Normal file
15
engine/src/flutter/lib/web_ui/lib/src/engine/semantics.dart
Normal file
@ -0,0 +1,15 @@
|
||||
// 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.
|
||||
|
||||
export 'semantics/accessibility.dart';
|
||||
export 'semantics/checkable.dart';
|
||||
export 'semantics/image.dart';
|
||||
export 'semantics/incrementable.dart';
|
||||
export 'semantics/label_and_value.dart';
|
||||
export 'semantics/live_region.dart';
|
||||
export 'semantics/scrollable.dart';
|
||||
export 'semantics/semantics_helper.dart';
|
||||
export 'semantics/semantics.dart';
|
||||
export 'semantics/tappable.dart';
|
||||
export 'semantics/text_field.dart';
|
||||
@ -2,7 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
part of engine;
|
||||
import 'dart:async';
|
||||
import 'dart:html' as html;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:ui/src/engine.dart' show registerHotRestartListener;
|
||||
|
||||
import '../services.dart';
|
||||
|
||||
/// Singleton for accessing accessibility announcements from the platform.
|
||||
final AccessibilityAnnouncements accessibilityAnnouncements =
|
||||
|
||||
@ -11,7 +11,11 @@
|
||||
// framework. Currently the framework does not report the
|
||||
// grouping of radio buttons.
|
||||
|
||||
part of engine;
|
||||
import 'dart:html' as html;
|
||||
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import 'semantics.dart';
|
||||
|
||||
/// The specific type of checkable control.
|
||||
enum _CheckableKind {
|
||||
|
||||
@ -2,7 +2,9 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
part of engine;
|
||||
import 'dart:html' as html;
|
||||
|
||||
import 'semantics.dart';
|
||||
|
||||
/// Represents semantic objects that deliver information in a visual manner.
|
||||
///
|
||||
|
||||
@ -2,7 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
part of engine;
|
||||
import 'dart:html' as html;
|
||||
|
||||
import 'package:ui/src/engine.dart' show EnginePlatformDispatcher;
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import 'semantics.dart';
|
||||
|
||||
/// Adds increment/decrement event handling to a semantics object.
|
||||
///
|
||||
|
||||
@ -2,7 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
part of engine;
|
||||
import 'dart:html' as html;
|
||||
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import 'semantics.dart';
|
||||
|
||||
/// Renders [_label] and [_value] to the semantics DOM.
|
||||
///
|
||||
@ -96,7 +100,7 @@ class LabelAndValue extends RoleManager {
|
||||
// Normally use a small font size so that text doesn't leave the scope
|
||||
// of the semantics node. When debugging semantics, use a font size
|
||||
// that's reasonably visible.
|
||||
_auxiliaryValueElement!.style.fontSize = _debugShowSemanticsNodes ? '12px' : '6px';
|
||||
_auxiliaryValueElement!.style.fontSize = debugShowSemanticsNodes ? '12px' : '6px';
|
||||
semanticsObject.element.append(_auxiliaryValueElement!);
|
||||
}
|
||||
_auxiliaryValueElement!.text = combinedValue.toString();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
part of engine;
|
||||
import 'semantics.dart';
|
||||
|
||||
/// Manages semantics configurations that represent live regions.
|
||||
///
|
||||
|
||||
@ -2,7 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
part of engine;
|
||||
import 'dart:html' as html;
|
||||
|
||||
import 'package:ui/src/engine.dart' show EnginePlatformDispatcher;
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import 'semantics.dart';
|
||||
|
||||
/// Implements vertical and horizontal scrolling functionality for semantics
|
||||
/// objects.
|
||||
|
||||
@ -2,7 +2,26 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
part of engine;
|
||||
import 'dart:html' as html;
|
||||
import 'dart:math' as math;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:ui/src/engine.dart' show domRenderer, EnginePlatformDispatcher, registerHotRestartListener;
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import '../alarm_clock.dart';
|
||||
import '../browser_detection.dart';
|
||||
import '../util.dart';
|
||||
import '../vector_math.dart';
|
||||
import 'checkable.dart';
|
||||
import 'image.dart';
|
||||
import 'incrementable.dart';
|
||||
import 'label_and_value.dart';
|
||||
import 'live_region.dart';
|
||||
import 'scrollable.dart';
|
||||
import 'semantics_helper.dart';
|
||||
import 'tappable.dart';
|
||||
import 'text_field.dart';
|
||||
|
||||
/// Set this flag to `true` to cause the engine to visualize the semantics tree
|
||||
/// on the screen for debugging.
|
||||
@ -15,7 +34,7 @@ part of engine;
|
||||
/// ```
|
||||
/// flutter run -d chrome --profile --dart-define=FLUTTER_WEB_DEBUG_SHOW_SEMANTICS=true
|
||||
/// ```
|
||||
const bool _debugShowSemanticsNodes = bool.fromEnvironment(
|
||||
const bool debugShowSemanticsNodes = bool.fromEnvironment(
|
||||
'FLUTTER_WEB_DEBUG_SHOW_SEMANTICS',
|
||||
defaultValue: false,
|
||||
);
|
||||
@ -266,7 +285,7 @@ class SemanticsObject {
|
||||
element.style.position = 'absolute';
|
||||
|
||||
// The root node has some properties that other nodes do not.
|
||||
if (id == 0 && !_debugShowSemanticsNodes) {
|
||||
if (id == 0 && !debugShowSemanticsNodes) {
|
||||
// Make all semantics transparent. We use `filter` instead of `opacity`
|
||||
// attribute because `filter` is stronger. `opacity` does not apply to
|
||||
// some elements, particularly on iOS, such as the slider thumb and track.
|
||||
@ -283,7 +302,7 @@ class SemanticsObject {
|
||||
// Make semantic elements visible for debugging by outlining them using a
|
||||
// green border. We do not use `border` attribute because it affects layout
|
||||
// (`outline` does not).
|
||||
if (_debugShowSemanticsNodes) {
|
||||
if (debugShowSemanticsNodes) {
|
||||
element.style.outline = '1px solid green';
|
||||
}
|
||||
}
|
||||
@ -1353,13 +1372,7 @@ class EngineSemanticsOwner {
|
||||
_rootSemanticsElement = null;
|
||||
_gestureModeClock?.datetime = null;
|
||||
}
|
||||
if (_semanticsEnabled != EnginePlatformDispatcher.instance.semanticsEnabled) {
|
||||
EnginePlatformDispatcher.instance._configuration =
|
||||
EnginePlatformDispatcher.instance._configuration.copyWith(semanticsEnabled: _semanticsEnabled);
|
||||
if (EnginePlatformDispatcher.instance._onSemanticsEnabledChanged != null) {
|
||||
EnginePlatformDispatcher.instance.invokeOnSemanticsEnabledChanged();
|
||||
}
|
||||
}
|
||||
EnginePlatformDispatcher.instance.updateSemanticsEnabled(_semanticsEnabled);
|
||||
}
|
||||
|
||||
/// Controls how pointer events and browser-detected gestures are treated by
|
||||
|
||||
@ -2,7 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
part of engine;
|
||||
import 'dart:async';
|
||||
import 'dart:html' as html;
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../browser_detection.dart';
|
||||
import 'semantics.dart';
|
||||
|
||||
/// The maximum [semanticsActivationAttempts] before we give up waiting for
|
||||
/// the user to enable semantics.
|
||||
|
||||
@ -2,7 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
part of engine;
|
||||
import 'dart:html' as html;
|
||||
|
||||
import 'package:ui/src/engine.dart' show EnginePlatformDispatcher;
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import 'semantics.dart';
|
||||
|
||||
/// Listens to HTML "click" gestures detected by the browser.
|
||||
///
|
||||
|
||||
@ -2,7 +2,14 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
part of engine;
|
||||
import 'dart:html' as html;
|
||||
|
||||
import 'package:ui/src/engine.dart' show EnginePlatformDispatcher;
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import '../text_editing/text_editing.dart';
|
||||
import '../browser_detection.dart';
|
||||
import 'semantics.dart';
|
||||
|
||||
/// Text editing used by accesibility mode.
|
||||
///
|
||||
|
||||
@ -8,11 +8,12 @@ import 'dart:math' as math;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:ui/src/engine.dart' show domRenderer, EnginePlatformDispatcher, EngineSemanticsOwner, SemanticsTextEditingStrategy;
|
||||
import 'package:ui/src/engine.dart' show domRenderer, EnginePlatformDispatcher;
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import '../browser_detection.dart';
|
||||
import '../host_node.dart';
|
||||
import '../semantics.dart';
|
||||
import '../services.dart';
|
||||
import '../text/paragraph.dart';
|
||||
import '../util.dart';
|
||||
|
||||
@ -425,10 +425,6 @@ const Set<String> _genericFontFamilies = <String>{
|
||||
final String _fallbackFontFamily =
|
||||
isMacOrIOS ? '-apple-system, BlinkMacSystemFont' : 'Arial';
|
||||
|
||||
bool get isMacOrIOS =>
|
||||
operatingSystem == OperatingSystem.iOs ||
|
||||
operatingSystem == OperatingSystem.macOs;
|
||||
|
||||
/// Create a font-family string appropriate for CSS.
|
||||
///
|
||||
/// If the given [fontFamily] is a generic font-family, then just return it.
|
||||
|
||||
@ -7,7 +7,8 @@ import 'dart:html';
|
||||
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine.dart';
|
||||
import 'package:ui/src/engine/semantics.dart';
|
||||
import 'package:ui/src/engine/services.dart';
|
||||
|
||||
const StandardMessageCodec codec = StandardMessageCodec();
|
||||
const String testMessage = 'This is an tooltip.';
|
||||
|
||||
@ -6,7 +6,9 @@ import 'dart:html' as html;
|
||||
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine.dart';
|
||||
import 'package:ui/src/engine/browser_detection.dart';
|
||||
import 'package:ui/src/engine/pointer_binding.dart';
|
||||
import 'package:ui/src/engine/semantics.dart';
|
||||
|
||||
const PointerSupportDetector _defaultSupportDetector = PointerSupportDetector();
|
||||
|
||||
|
||||
@ -12,7 +12,10 @@ import 'package:quiver/testing/async.dart';
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:ui/src/engine.dart';
|
||||
import 'package:ui/src/engine.dart' show domRenderer;
|
||||
import 'package:ui/src/engine/browser_detection.dart';
|
||||
import 'package:ui/src/engine/semantics.dart';
|
||||
import 'package:ui/src/engine/vector_math.dart';
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import 'semantics_tester.dart';
|
||||
|
||||
@ -7,7 +7,12 @@ import 'dart:html' as html;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine.dart';
|
||||
import 'package:ui/src/engine.dart' show domRenderer, toMatrix32;
|
||||
import 'package:ui/src/engine/browser_detection.dart';
|
||||
import 'package:ui/src/engine/host_node.dart';
|
||||
import 'package:ui/src/engine/semantics.dart';
|
||||
import 'package:ui/src/engine/util.dart';
|
||||
import 'package:ui/src/engine/vector_math.dart';
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import '../../matchers.dart';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user