[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 <sra@google.com> Commit-Queue: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
5af38092e3
commit
a39a3cd141
@@ -744,6 +744,7 @@ class AnimationEffectTiming extends AnimationEffectTimingReadOnly {
|
||||
|
||||
// Shadowing definition.
|
||||
|
||||
@Returns('num|String|Null')
|
||||
Object get duration native;
|
||||
|
||||
set duration(Object value) native;
|
||||
|
||||
@@ -3244,7 +3244,7 @@ class SvgElement extends Element implements GlobalEventHandlers, NoncedElement {
|
||||
SvgElement.created() : super.created();
|
||||
|
||||
// Shadowing definition.
|
||||
|
||||
@JSName('className')
|
||||
AnimatedString get _svgClassName native;
|
||||
|
||||
@JSName('ownerSVGElement')
|
||||
|
||||
@@ -745,6 +745,7 @@ class AnimationEffectTiming extends AnimationEffectTimingReadOnly {
|
||||
|
||||
// Shadowing definition.
|
||||
|
||||
@Returns('num|String|Null')
|
||||
Object? get duration native;
|
||||
|
||||
set duration(Object? value) native;
|
||||
|
||||
@@ -3282,7 +3282,7 @@ class SvgElement extends Element implements GlobalEventHandlers, NoncedElement {
|
||||
SvgElement.created() : super.created();
|
||||
|
||||
// Shadowing definition.
|
||||
|
||||
@JSName('className')
|
||||
AnimatedString get _svgClassName native;
|
||||
|
||||
@JSName('ownerSVGElement')
|
||||
|
||||
@@ -30,8 +30,7 @@ _dart2js_annotations = monitored.Dict(
|
||||
'dartmetadata._dart2js_annotations',
|
||||
{
|
||||
'AnimationEffectTiming.duration': [
|
||||
"@Creates('Null')",
|
||||
"@Returns('num|String')",
|
||||
"@Returns('num|String|Null')",
|
||||
],
|
||||
'ArrayBufferView': [
|
||||
"@Creates('TypedData')",
|
||||
|
||||
@@ -1394,6 +1394,14 @@ class Dart2JSBackend(HtmlDartGenerator):
|
||||
self._AddAttributeUsingProperties(attribute, html_name, read_only)
|
||||
return
|
||||
|
||||
output_type = self.SecureOutputType(attribute.type.id,
|
||||
can_narrow_type=read_only,
|
||||
nullable=attribute.type.nullable)
|
||||
|
||||
rename = self._RenamingAnnotation(attribute.id, html_name)
|
||||
metadata = self._Metadata(attribute.type.id, attribute.id, output_type,
|
||||
attribute.type.nullable)
|
||||
|
||||
# If the attribute is shadowing, we can't generate a shadowing
|
||||
# getter or setter (Issue 1633).
|
||||
# TODO(sra): _FindShadowedAttribute does not take into account the html
|
||||
@@ -1426,7 +1434,8 @@ class Dart2JSBackend(HtmlDartGenerator):
|
||||
'TreatNullAs' in attribute.ext_attrs))
|
||||
return
|
||||
self._members_emitter.Emit('\n // Shadowing definition.')
|
||||
self._AddAttributeUsingProperties(attribute, html_name, read_only)
|
||||
self._AddAttributeUsingProperties(attribute, html_name, read_only,
|
||||
rename, metadata)
|
||||
return
|
||||
|
||||
# If the attribute is shadowed incompatibly in a subclass then we also
|
||||
@@ -1438,23 +1447,18 @@ class Dart2JSBackend(HtmlDartGenerator):
|
||||
if (self._interface.id == 'DOMMatrixReadOnly' or
|
||||
self._interface.id == 'DOMPointReadOnly' or
|
||||
self._interface.id == 'DOMRectReadOnly'):
|
||||
self._AddAttributeUsingProperties(attribute, html_name, read_only)
|
||||
self._AddAttributeUsingProperties(attribute, html_name, read_only,
|
||||
rename, metadata)
|
||||
return
|
||||
|
||||
# If the type has a conversion we need a getter or setter to contain the
|
||||
# conversion code.
|
||||
if (self._OutputConversion(attribute.type.id, attribute.id) or
|
||||
self._InputConversion(attribute.type.id, attribute.id)):
|
||||
self._AddAttributeUsingProperties(attribute, html_name, read_only)
|
||||
self._AddAttributeUsingProperties(attribute, html_name, read_only,
|
||||
rename, metadata)
|
||||
return
|
||||
|
||||
rename = self._RenamingAnnotation(attribute.id, html_name)
|
||||
output_type = self.SecureOutputType(attribute.type.id,
|
||||
can_narrow_type=read_only,
|
||||
nullable=attribute.type.nullable)
|
||||
metadata = self._Metadata(attribute.type.id, attribute.id, output_type,
|
||||
attribute.type.nullable)
|
||||
|
||||
input_type = self._NarrowInputType(attribute.type.id)
|
||||
if self._nnbd and attribute.type.nullable:
|
||||
input_type += '?'
|
||||
@@ -1536,7 +1540,6 @@ class Dart2JSBackend(HtmlDartGenerator):
|
||||
return self._AddConvertingGetter(attr, html_name, conversion)
|
||||
return_type = self.SecureOutputType(attr.type.id,
|
||||
nullable=attr.type.nullable)
|
||||
native_type = self._NarrowToImplementationType(attr.type.id)
|
||||
self._members_emitter.Emit(
|
||||
'\n $RENAME'
|
||||
'\n $METADATA'
|
||||
|
||||
Reference in New Issue
Block a user