Skip to content

Commit a39a3cd

Browse files
srujzscommit-bot@chromium.org
authored andcommitted
[dart:html] Add rename/metadata for some attributes
Some fields that were changed to native getters/setters should include renaming/metadata whenever possible to account for name differences. While this is already the case with most fields, this CL adds it to some places that missed it. Annotations for AnimationEffectTiming.duration are changed to be accurate as well. Change-Id: Idb8b94a9b916086d127753f868e97f1a1b9db53f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148464 Reviewed-by: Stephen Adams <[email protected]> Commit-Queue: Srujan Gaddam <[email protected]>
1 parent 5af3809 commit a39a3cd

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

sdk/lib/html/dart2js/html_dart2js.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ class AnimationEffectTiming extends AnimationEffectTimingReadOnly {
744744

745745
// Shadowing definition.
746746

747+
@Returns('num|String|Null')
747748
Object get duration native;
748749

749750
set duration(Object value) native;

sdk/lib/svg/dart2js/svg_dart2js.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3244,7 +3244,7 @@ class SvgElement extends Element implements GlobalEventHandlers, NoncedElement {
32443244
SvgElement.created() : super.created();
32453245

32463246
// Shadowing definition.
3247-
3247+
@JSName('className')
32483248
AnimatedString get _svgClassName native;
32493249

32503250
@JSName('ownerSVGElement')

sdk_nnbd/lib/html/dart2js/html_dart2js.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ class AnimationEffectTiming extends AnimationEffectTimingReadOnly {
745745

746746
// Shadowing definition.
747747

748+
@Returns('num|String|Null')
748749
Object? get duration native;
749750

750751
set duration(Object? value) native;

sdk_nnbd/lib/svg/dart2js/svg_dart2js.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3282,7 +3282,7 @@ class SvgElement extends Element implements GlobalEventHandlers, NoncedElement {
32823282
SvgElement.created() : super.created();
32833283

32843284
// Shadowing definition.
3285-
3285+
@JSName('className')
32863286
AnimatedString get _svgClassName native;
32873287

32883288
@JSName('ownerSVGElement')

tools/dom/scripts/dartmetadata.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
'dartmetadata._dart2js_annotations',
3131
{
3232
'AnimationEffectTiming.duration': [
33-
"@Creates('Null')",
34-
"@Returns('num|String')",
33+
"@Returns('num|String|Null')",
3534
],
3635
'ArrayBufferView': [
3736
"@Creates('TypedData')",

tools/dom/scripts/systemhtml.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,14 @@ def EmitAttribute(self, attribute, html_name, read_only):
13941394
self._AddAttributeUsingProperties(attribute, html_name, read_only)
13951395
return
13961396

1397+
output_type = self.SecureOutputType(attribute.type.id,
1398+
can_narrow_type=read_only,
1399+
nullable=attribute.type.nullable)
1400+
1401+
rename = self._RenamingAnnotation(attribute.id, html_name)
1402+
metadata = self._Metadata(attribute.type.id, attribute.id, output_type,
1403+
attribute.type.nullable)
1404+
13971405
# If the attribute is shadowing, we can't generate a shadowing
13981406
# getter or setter (Issue 1633).
13991407
# TODO(sra): _FindShadowedAttribute does not take into account the html
@@ -1426,7 +1434,8 @@ def EmitAttribute(self, attribute, html_name, read_only):
14261434
'TreatNullAs' in attribute.ext_attrs))
14271435
return
14281436
self._members_emitter.Emit('\n // Shadowing definition.')
1429-
self._AddAttributeUsingProperties(attribute, html_name, read_only)
1437+
self._AddAttributeUsingProperties(attribute, html_name, read_only,
1438+
rename, metadata)
14301439
return
14311440

14321441
# If the attribute is shadowed incompatibly in a subclass then we also
@@ -1438,23 +1447,18 @@ def EmitAttribute(self, attribute, html_name, read_only):
14381447
if (self._interface.id == 'DOMMatrixReadOnly' or
14391448
self._interface.id == 'DOMPointReadOnly' or
14401449
self._interface.id == 'DOMRectReadOnly'):
1441-
self._AddAttributeUsingProperties(attribute, html_name, read_only)
1450+
self._AddAttributeUsingProperties(attribute, html_name, read_only,
1451+
rename, metadata)
14421452
return
14431453

14441454
# If the type has a conversion we need a getter or setter to contain the
14451455
# conversion code.
14461456
if (self._OutputConversion(attribute.type.id, attribute.id) or
14471457
self._InputConversion(attribute.type.id, attribute.id)):
1448-
self._AddAttributeUsingProperties(attribute, html_name, read_only)
1458+
self._AddAttributeUsingProperties(attribute, html_name, read_only,
1459+
rename, metadata)
14491460
return
14501461

1451-
rename = self._RenamingAnnotation(attribute.id, html_name)
1452-
output_type = self.SecureOutputType(attribute.type.id,
1453-
can_narrow_type=read_only,
1454-
nullable=attribute.type.nullable)
1455-
metadata = self._Metadata(attribute.type.id, attribute.id, output_type,
1456-
attribute.type.nullable)
1457-
14581462
input_type = self._NarrowInputType(attribute.type.id)
14591463
if self._nnbd and attribute.type.nullable:
14601464
input_type += '?'
@@ -1536,7 +1540,6 @@ def _AddRenamingGetter(self, attr, html_name, rename, metadata):
15361540
return self._AddConvertingGetter(attr, html_name, conversion)
15371541
return_type = self.SecureOutputType(attr.type.id,
15381542
nullable=attr.type.nullable)
1539-
native_type = self._NarrowToImplementationType(attr.type.id)
15401543
self._members_emitter.Emit(
15411544
'\n $RENAME'
15421545
'\n $METADATA'

0 commit comments

Comments
 (0)