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
Next Next commit
linkUri -> linkUrl plus responding to other review comments
  • Loading branch information
harryterkelsen committed Jul 3, 2024
commit 6262539031ae886d7296dc1db849e58f24cef212
2 changes: 1 addition & 1 deletion lib/ui/fixtures/ui_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void sendSemanticsUpdate() {
childrenInHitTestOrder: childrenInHitTestOrder,
additionalActions: additionalActions,
headingLevel: 0,
linkUri: '',
linkUrl: '',
);
_semanticsUpdate(builder.build());
}
Expand Down
14 changes: 7 additions & 7 deletions lib/ui/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -849,13 +849,13 @@ abstract class SemanticsUpdateBuilder {
/// inclusive. This attribute is only used for Web platform, and it will have
/// no effect on other platforms.
///
/// The `linkUrl` describes the URI that this node links to. If the node is
/// not a link, this should be an empty string.
///
/// See also:
///
/// * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/heading_role
/// * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-level
///
/// The `linkUri` describes the URI that this node links to. If the node is
/// not a link, this should be an empty string.
void updateNode({
required int id,
required int flags,
Expand Down Expand Up @@ -891,7 +891,7 @@ abstract class SemanticsUpdateBuilder {
required Int32List childrenInHitTestOrder,
required Int32List additionalActions,
int headingLevel = 0,
String linkUri = '',
String linkUrl = '',
});

/// Update the custom semantics action associated with the given `id`.
Expand Down Expand Up @@ -963,7 +963,7 @@ base class _NativeSemanticsUpdateBuilder extends NativeFieldWrapperClass1 implem
required Int32List childrenInHitTestOrder,
required Int32List additionalActions,
int headingLevel = 0,
String linkUri = '',
String linkUrl = '',
}) {
assert(_matrix4IsValid(transform));
assert (
Expand Down Expand Up @@ -1008,7 +1008,7 @@ base class _NativeSemanticsUpdateBuilder extends NativeFieldWrapperClass1 implem
childrenInHitTestOrder,
additionalActions,
headingLevel,
linkUri,
linkUrl,
);
}
@Native<
Expand Down Expand Up @@ -1090,7 +1090,7 @@ base class _NativeSemanticsUpdateBuilder extends NativeFieldWrapperClass1 implem
Int32List childrenInHitTestOrder,
Int32List additionalActions,
int headingLevel,
String linkUri);
String linkUrl);

@override
void updateCustomAction({required int id, String? label, String? hint, int overrideId = -1}) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/semantics/semantics_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct SemanticsNode {
std::vector<int32_t> customAccessibilityActions;
int32_t headingLevel = 0;

std::string linkUri;
std::string linkUrl;
};

// Contains semantic nodes that need to be updated.
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/semantics/semantics_update_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void SemanticsUpdateBuilder::updateNode(
const tonic::Int32List& childrenInHitTestOrder,
const tonic::Int32List& localContextActions,
int headingLevel,
std::string linkUri) {
std::string linkUrl) {
FML_CHECK(scrollChildren == 0 ||
(scrollChildren > 0 && childrenInHitTestOrder.data()))
<< "Semantics update contained scrollChildren but did not have "
Expand Down Expand Up @@ -122,7 +122,7 @@ void SemanticsUpdateBuilder::updateNode(
nodes_[id] = node;

node.headingLevel = headingLevel;
node.linkUri = std::move(linkUri);
node.linkUrl = std::move(linkUrl);
}

void SemanticsUpdateBuilder::updateCustomAction(int id,
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/semantics/semantics_update_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SemanticsUpdateBuilder
const tonic::Int32List& childrenInHitTestOrder,
const tonic::Int32List& customAccessibilityActions,
int headingLevel,
std::string linkUri);
std::string linkUrl);

void updateCustomAction(int id,
std::string label,
Expand Down
4 changes: 2 additions & 2 deletions lib/web_ui/lib/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class SemanticsUpdateBuilder {
required Int32List childrenInHitTestOrder,
required Int32List additionalActions,
int headingLevel = 0,
String? linkUri,
String? linkUrl,
}) {
if (transform.length != 16) {
throw ArgumentError('transform argument must have 16 entries.');
Expand Down Expand Up @@ -327,7 +327,7 @@ class SemanticsUpdateBuilder {
additionalActions: additionalActions,
platformViewId: platformViewId,
headingLevel: headingLevel,
linkUri: linkUri,
linkUrl: linkUrl,
));
}

Expand Down
10 changes: 6 additions & 4 deletions lib/web_ui/lib/src/engine/semantics/link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ class Link extends PrimaryRoleManager {
void update() {
super.update();

if (semanticsObject.hasLinkUri) {
element.setAttribute('href', semanticsObject.linkUri!);
} else {
element.removeAttribute('href');
if (semanticsObject.isLinkUrlDirty) {
if (semanticsObject.hasLinkUrl) {
element.setAttribute('href', semanticsObject.linkUrl!);
} else {
element.removeAttribute('href');
}
}
}

Expand Down
28 changes: 14 additions & 14 deletions lib/web_ui/lib/src/engine/semantics/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class SemanticsNodeUpdate {
required this.childrenInHitTestOrder,
required this.additionalActions,
required this.headingLevel,
this.linkUri,
this.linkUrl,
});

/// See [ui.SemanticsUpdateBuilder.updateNode].
Expand Down Expand Up @@ -340,7 +340,7 @@ class SemanticsNodeUpdate {
final int headingLevel;

/// See [ui.SemanticsUpdateBuilder.updateNode].
final String? linkUri;
final String? linkUrl;
}

/// Identifies [PrimaryRoleManager] implementations.
Expand Down Expand Up @@ -1151,19 +1151,19 @@ class SemanticsObject {
}

/// See [ui.SemanticsUpdateBuilder.updateNode].
String? get linkUri => _linkUri;
String? _linkUri;
String? get linkUrl => _linkUrl;
String? _linkUrl;

/// Whether this object contains a non-empty link URI.
bool get hasLinkUri => _linkUri != null && _linkUri!.isNotEmpty;
/// Whether this object contains a non-empty link URL.
bool get hasLinkUrl => _linkUrl != null && _linkUrl!.isNotEmpty;

static const int _linkUriIndex = 1 << 26;
static const int _linkUrlIndex = 1 << 26;

/// Whether the [linkUri] field has been updated but has not been
/// Whether the [linkUrl] field has been updated but has not been
/// applied to the DOM yet.
bool get isLinkUriDirty => _isDirty(_linkUriIndex);
void _markLinkUriDirty() {
_dirtyFields |= _linkUriIndex;
bool get isLinkUrlDirty => _isDirty(_linkUrlIndex);
void _markLinkUrlDirty() {
_dirtyFields |= _linkUrlIndex;
}

/// A unique permanent identifier of the semantics node in the tree.
Expand Down Expand Up @@ -1465,9 +1465,9 @@ class SemanticsObject {
_markPlatformViewIdDirty();
}

if (_linkUri != update.linkUri) {
_linkUri = update.linkUri;
_markLinkUriDirty();
if (_linkUrl != update.linkUrl) {
_linkUrl = update.linkUrl;
_markLinkUrlDirty();
}

// Apply updates to the DOM.
Expand Down
8 changes: 4 additions & 4 deletions lib/web_ui/test/engine/semantics/semantics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3604,7 +3604,7 @@ void _testLink() {
expect(object.element.hasAttribute('href'), isFalse);
});

test('link nodes with linkUri set the href attribute', () {
test('link nodes with linkUrl set the href attribute', () {
semantics()
..debugOverrideTimestampFunction(() => _testTime)
..semanticsEnabled = true;
Expand All @@ -3614,7 +3614,7 @@ void _testLink() {
tester.updateNode(
id: 0,
isLink: true,
linkUri: 'https://flutter.dev',
linkUrl: 'https://flutter.dev',
rect: const ui.Rect.fromLTRB(0, 0, 100, 50),
);
tester.apply();
Expand Down Expand Up @@ -3667,7 +3667,7 @@ void updateNode(
Int32List? childrenInHitTestOrder,
Int32List? additionalActions,
int headingLevel = 0,
String? linkUri,
String? linkUrl,
}) {
transform ??= Float64List.fromList(Matrix4.identity().storage);
childrenInTraversalOrder ??= Int32List(0);
Expand Down Expand Up @@ -3708,7 +3708,7 @@ void updateNode(
childrenInHitTestOrder: childrenInHitTestOrder,
additionalActions: additionalActions,
headingLevel: headingLevel,
linkUri: linkUri,
linkUrl: linkUrl,
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/web_ui/test/engine/semantics/semantics_tester.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class SemanticsTester {
Int32List? additionalActions,
List<SemanticsNodeUpdate>? children,
int? headingLevel,
String? linkUri,
String? linkUrl,
}) {
// Flags
if (hasCheckedState ?? false) {
Expand Down Expand Up @@ -314,7 +314,7 @@ class SemanticsTester {
childrenInHitTestOrder: childIds,
additionalActions: additionalActions ?? Int32List(0),
headingLevel: headingLevel ?? 0,
linkUri: linkUri,
linkUrl: linkUrl,
);
_nodeUpdates.add(update);
return update;
Expand Down
10 changes: 5 additions & 5 deletions shell/platform/embedder/fixtures/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Future<void> a11y_main() async {
textDirection: TextDirection.ltr,
additionalActions: Int32List(0),
headingLevel: 0,
linkUri: '',
linkUrl: '',
)
..updateNode(
id: 84,
Expand Down Expand Up @@ -216,7 +216,7 @@ Future<void> a11y_main() async {
childrenInHitTestOrder: Int32List(0),
childrenInTraversalOrder: Int32List(0),
headingLevel: 0,
linkUri: '',
linkUrl: '',
)
..updateNode(
id: 96,
Expand Down Expand Up @@ -253,7 +253,7 @@ Future<void> a11y_main() async {
textDirection: TextDirection.ltr,
additionalActions: Int32List(0),
headingLevel: 0,
linkUri: '',
linkUrl: '',
)
..updateNode(
id: 128,
Expand Down Expand Up @@ -290,7 +290,7 @@ Future<void> a11y_main() async {
childrenInHitTestOrder: Int32List(0),
childrenInTraversalOrder: Int32List(0),
headingLevel: 0,
linkUri: '',
linkUrl: '',
)
..updateCustomAction(
id: 21,
Expand Down Expand Up @@ -388,7 +388,7 @@ Future<void> a11y_string_attributes() async {
textDirection: TextDirection.ltr,
additionalActions: Int32List(0),
headingLevel: 0,
linkUri: '',
linkUrl: '',
);

PlatformDispatcher.instance.views.first.updateSemantics(builder.build());
Expand Down