-
Notifications
You must be signed in to change notification settings - Fork 6k
Add Semantics Property linkUrl
#53507
Changes from 1 commit
73dded3
bbbb01f
9b4ef86
6262539
d2be434
c2f954c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,10 @@ class Link extends PrimaryRoleManager { | |
| @override | ||
| DomElement createElement() { | ||
| final DomElement element = domDocument.createElement('a'); | ||
| // TODO(mdebbar): Fill in the real link once the framework sends entire uri. | ||
| // https://github.com/flutter/flutter/issues/150263. | ||
| element.style.display = 'block'; | ||
| if (semanticsObject.hasLinkUri) { | ||
|
||
| element.setAttribute('href', semanticsObject.linkUri!); | ||
| } | ||
| return element; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,6 +234,7 @@ class SemanticsNodeUpdate { | |
| required this.childrenInHitTestOrder, | ||
| required this.additionalActions, | ||
| required this.headingLevel, | ||
| this.linkUri, | ||
| }); | ||
|
|
||
| /// See [ui.SemanticsUpdateBuilder.updateNode]. | ||
|
|
@@ -337,6 +338,9 @@ class SemanticsNodeUpdate { | |
|
|
||
| /// See [ui.SemanticsUpdateBuilder.updateNode]. | ||
| final int headingLevel; | ||
|
|
||
| /// See [ui.SemanticsUpdateBuilder.updateNode]. | ||
| final String? linkUri; | ||
|
||
| } | ||
|
|
||
| /// Identifies [PrimaryRoleManager] implementations. | ||
|
|
@@ -1146,6 +1150,22 @@ class SemanticsObject { | |
| _dirtyFields |= _identifierIndex; | ||
| } | ||
|
|
||
| /// See [ui.SemanticsUpdateBuilder.updateNode]. | ||
| String? get linkUri => _linkUri; | ||
| String? _linkUri; | ||
|
|
||
| /// Whether this object contains a non-empty link URI. | ||
| bool get hasLinkUri => _linkUri != null && _linkUri!.isNotEmpty; | ||
|
|
||
| static const int _linkUriIndex = 1 << 26; | ||
|
|
||
| /// Whether the [linkUri] field has been updated but has not been | ||
| /// applied to the DOM yet. | ||
| bool get isLinkUriDirty => _isDirty(_linkUriIndex); | ||
| void _markLinkUriDirty() { | ||
| _dirtyFields |= _linkUriIndex; | ||
| } | ||
|
|
||
| /// A unique permanent identifier of the semantics node in the tree. | ||
| final int id; | ||
|
|
||
|
|
@@ -1445,6 +1465,11 @@ class SemanticsObject { | |
| _markPlatformViewIdDirty(); | ||
| } | ||
|
|
||
| if (_linkUri != update.linkUri) { | ||
| _linkUri = update.linkUri; | ||
| _markLinkUriDirty(); | ||
| } | ||
|
|
||
| // Apply updates to the DOM. | ||
| _updateRoles(); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "URL" is more accurate here than "URI". The
<a>tag and theLinkwidget only work with URIs that are also fetchable over the network via the same URI. Using arbitrary URIs as abstract identifiers without being able to fetch them is not something that's supported by this property, AFAICT. Unless there's something on the mobile side that extends beyond that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done