mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
Fix strong mode errors in SVG
BUG= R=alanknight@google.com Review URL: https://codereview.chromium.org/1903893003 .
This commit is contained in:
parent
1e574a1ffc
commit
819ed4bb60
|
@ -14836,9 +14836,8 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
|
|||
@DocsEditable()
|
||||
bool hidden;
|
||||
|
||||
@DomName('Element.isContentEditable')
|
||||
@DocsEditable()
|
||||
final bool isContentEditable;
|
||||
// Using property as subclass shadows.
|
||||
bool get isContentEditable => JS("bool", "#.isContentEditable", this);
|
||||
|
||||
@DomName('Element.lang')
|
||||
@DocsEditable()
|
||||
|
@ -14963,10 +14962,8 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
|
|||
// Use implementation from Node.
|
||||
// final String _namespaceUri;
|
||||
|
||||
@JSName('outerHTML')
|
||||
@DomName('Element.outerHTML')
|
||||
@DocsEditable()
|
||||
final String outerHtml;
|
||||
// Using property as subclass shadows.
|
||||
String get outerHtml => JS("String", "#.outerHTML", this);
|
||||
|
||||
@JSName('scrollHeight')
|
||||
@DomName('Element.scrollHeight')
|
||||
|
|
|
@ -4646,12 +4646,8 @@ class StyleElement extends SvgElement {
|
|||
@Experimental() // untriaged
|
||||
final StyleSheet sheet;
|
||||
|
||||
// Shadowing definition.
|
||||
String get title => JS("String", "#.title", this);
|
||||
|
||||
set title(String value) {
|
||||
JS("void", "#.title = #", this, value);
|
||||
}
|
||||
// Use implementation from Element.
|
||||
// final String title;
|
||||
|
||||
@DomName('SVGStyleElement.type')
|
||||
@DocsEditable()
|
||||
|
@ -5085,12 +5081,8 @@ class SvgElement extends Element implements GlobalEventHandlers {
|
|||
// Use implementation from Element.
|
||||
// final CssStyleDeclaration style;
|
||||
|
||||
// Shadowing definition.
|
||||
int get tabIndex => JS("int", "#.tabIndex", this);
|
||||
|
||||
set tabIndex(int value) {
|
||||
JS("void", "#.tabIndex = #", this, value);
|
||||
}
|
||||
// Use implementation from Element.
|
||||
// final int tabIndex;
|
||||
|
||||
@DomName('SVGElement.viewportElement')
|
||||
@DocsEditable()
|
||||
|
|
|
@ -19,6 +19,21 @@ _logger = logging.getLogger('systemhtml')
|
|||
HTML_LIBRARY_NAMES = ['html', 'indexed_db', 'svg',
|
||||
'web_audio', 'web_gl', 'web_sql']
|
||||
|
||||
# The following two sets let us avoid shadowing fields with properties.
|
||||
# This information could be derived from the IDL files but would require
|
||||
# a significant refactor to compute accurately. Instead we manually compute
|
||||
# these sets based on manual triage of strong mode errors.
|
||||
_force_property_members = monitored.Set('systemhtml._force_property_members', [
|
||||
'Element.outerHtml',
|
||||
'Element.isContentEditable',
|
||||
'AudioContext.createGain',
|
||||
'AudioContext.createScriptProcessor',
|
||||
])
|
||||
_safe_to_ignore_shadowing_members = monitored.Set('systemhtml._safe_to_ignore_shadowing_members', [
|
||||
'SVGElement.tabIndex',
|
||||
'SVGStyleElement.title',
|
||||
])
|
||||
|
||||
_js_custom_members = monitored.Set('systemhtml._js_custom_members', [
|
||||
'AudioBufferSourceNode.start',
|
||||
'AudioBufferSourceNode.stop',
|
||||
|
@ -895,8 +910,13 @@ class Dart2JSBackend(HtmlDartGenerator):
|
|||
# is renamed.
|
||||
(super_attribute, super_attribute_interface) = self._FindShadowedAttribute(
|
||||
attribute)
|
||||
if self._ForcePropertyMember(html_name):
|
||||
self._members_emitter.Emit('\n // Using property as subclass shadows.');
|
||||
self._AddAttributeUsingProperties(attribute, html_name, read_only)
|
||||
return
|
||||
|
||||
if super_attribute:
|
||||
if read_only:
|
||||
if read_only or self._SafeToIgnoreShadowingMember(html_name):
|
||||
if attribute.type.id == super_attribute.type.id:
|
||||
# Compatible attribute, use the superclass property. This works
|
||||
# because JavaScript will do its own dynamic dispatch.
|
||||
|
@ -1161,6 +1181,14 @@ class Dart2JSBackend(HtmlDartGenerator):
|
|||
member_name = '%s.%s' % (self._interface.doc_js_name, member_name)
|
||||
return member_name in _js_custom_members
|
||||
|
||||
def _ForcePropertyMember(self, member_name):
|
||||
member_name = '%s.%s' % (self._interface.doc_js_name, member_name)
|
||||
return member_name in _force_property_members
|
||||
|
||||
def _SafeToIgnoreShadowingMember(self, member_name):
|
||||
member_name = '%s.%s' % (self._interface.doc_js_name, member_name)
|
||||
return member_name in _safe_to_ignore_shadowing_members
|
||||
|
||||
def _RenamingAnnotation(self, idl_name, member_name):
|
||||
if member_name != idl_name:
|
||||
return "@JSName('%s')\n " % idl_name
|
||||
|
|
Loading…
Reference in a new issue