Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
make constants into statics on PlatformViewRegistry
  • Loading branch information
mdebbar committed Jul 26, 2023
commit ad3774e56fde0499141b13cb5a6e4e61bb9e466a
4 changes: 2 additions & 2 deletions lib/web_ui/lib/src/engine/platform_views/content_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class PlatformViewManager {
PlatformViewManager() {
// Register some default factories.
registerFactory(
ui_web.kDefaultVisibleViewType,
ui_web.PlatformViewRegistry.defaultVisibleViewType,
_defaultFactory,
);
registerFactory(
ui_web.kDefaultInvisibleViewType,
ui_web.PlatformViewRegistry.defaultInvisibleViewType,
_defaultFactory,
isVisible: false,
);
Expand Down
26 changes: 14 additions & 12 deletions lib/web_ui/lib/ui_web/src/ui_web/platform_view_registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@

import 'package:ui/src/engine.dart';

/// The view type of the factory that creates visible platform view DOM elements.
///
/// There's no need to register this view type with [PlatformViewRegistry]
/// because it is registered by default.
const String kDefaultVisibleViewType = '_default_document_create_element_visible';

/// The view type of the factory that creates invisible platform view DOM elements.
///
/// There's no need to register this view type with [PlatformViewRegistry]
/// because it is registered by default.
const String kDefaultInvisibleViewType = '_default_document_create_element_invisible';

/// A function which takes a unique `id` and some `params` and creates an HTML
/// element.
typedef ParameterizedPlatformViewFactory = Object Function(
Expand All @@ -31,6 +19,20 @@ final PlatformViewRegistry platformViewRegistry = PlatformViewRegistry();

/// A registry for factories that create platform views.
class PlatformViewRegistry {
/// The view type of the built-in factory that creates visible platform view
/// DOM elements.
///
/// There's no need to register this view type with [PlatformViewRegistry]
/// because it is registered by default.
static const String defaultVisibleViewType = '_default_document_create_element_visible';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ and without the "k" prefix.

tumblr_70976177f0cdc973a43fba42c9c04621_20bc424a_400


/// The view type of the built-in factory that creates invisible platform view
/// DOM elements.
///
/// There's no need to register this view type with [PlatformViewRegistry]
/// because it is registered by default.
static const String defaultInvisibleViewType = '_default_document_create_element_invisible';

/// Register [viewType] as being created by the given [viewFactory].
///
/// [viewFactory] can be any function that takes an integer and optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void testMain() {

test('default factories', () {
final DomElement content0 = contentManager.renderContent(
ui_web.kDefaultVisibleViewType,
ui_web.PlatformViewRegistry.defaultVisibleViewType,
viewId,
<dynamic, dynamic>{'tagName': 'table'},
);
Expand All @@ -218,7 +218,7 @@ void testMain() {
expect(contentManager.isInvisible(viewId), isFalse);

final DomElement content1 = contentManager.renderContent(
ui_web.kDefaultInvisibleViewType,
ui_web.PlatformViewRegistry.defaultInvisibleViewType,
viewId + 1,
<dynamic, dynamic>{'tagName': 'script'},
);
Expand All @@ -230,7 +230,7 @@ void testMain() {
expect(contentManager.isInvisible(viewId + 1), isTrue);

final DomElement content2 = contentManager.renderContent(
ui_web.kDefaultVisibleViewType,
ui_web.PlatformViewRegistry.defaultVisibleViewType,
viewId + 2,
<dynamic, dynamic>{'tagName': 'p'},
);
Expand Down