Remove some SVG types from bindings map

Our maps are string-based and assume there's only one one @Native
class with a given name. This isn't true for these four classes,
where there are two types with the same name for each one.
This then results in us dropping the definition of one of the
two types.

Since one of the two types is essentially unused, we should choose
to drop that one instead for now. Long-term, we should deprecate
the unused types or change our conformance handling to handle
multiple types with the same name. We could also choose to unify
both definitions, but this may lead to either false positives or
renames of members being dropped.

This allows us to catch uses of the types that are actually used.

Change-Id: I9386cad5b014bee60cd72d21cdf0546640138704
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341331
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
Srujan Gaddam
2023-12-13 01:59:37 +00:00
committed by Commit Queue
parent 8715f8007f
commit b42103c9d1
3 changed files with 48 additions and 32 deletions
+1 -1
View File
@@ -45,5 +45,5 @@ cd ./tools/dom/scripts
# Calculate, emit, and format the bindings.
BINDINGS="../web_library_bindings.dart"
dart ./web_library_bindings_emitter.dart $BINDINGS
dart --enable-asserts ./web_library_bindings_emitter.dart $BINDINGS
dart format $BINDINGS
@@ -39,6 +39,13 @@ void main(List<String> args) {
'dart:web_gl'
};
const Set<String> duplicateClassNames = {
'ImageElement',
'ScriptElement',
'StyleElement',
'TitleElement'
};
for (var library in component.libraries) {
if (webLibraries.contains(library.importUri.toString())) {
for (var cls in library.classes) {
@@ -46,9 +53,20 @@ void main(List<String> args) {
// All strings in the maps are annotated with quotes, so that we print
// proper Dart code when we print the maps.
var clsName = "'${cls.name}'";
var nativeTypes = getNativeNames(cls);
nativeTypes = nativeTypes.map((name) => "'$name'").toList();
var nativeTypes = getNativeNames(cls).map((name) => "'$name'").toList();
if (nativeTypes.isEmpty) nativeTypes = [clsName];
// There are a couple of cases where there are two classes with the same
// name. They are all element classes bound to an `HTML` and an `SVG`
// version. For now, ignore the `SVG` version, as they're unused in
// google3 and most of them are marked unstable, and their `HTML`
// variants are much more common.
// TODO(srujzs): Remove this if we decide to deprecate these classes.
if (duplicateClassNames.contains(cls.name)) {
if (nativeTypes.length == 1 && nativeTypes[0] == "'SVG${cls.name}'") {
continue;
}
}
assert(!dartTypeToNativeTypes.containsKey(clsName));
dartTypeToNativeTypes[clsName] = SplayTreeSet.from(nativeTypes);
var nativePropToDartProp = SplayTreeMap<String, SplayTreeSet<String>>();
+27 -29
View File
@@ -3486,15 +3486,6 @@ final Map<String, Map<String, Set<String>>> nativeTypeToDartMembers = {
'systemLanguage': {'systemLanguage'},
'transform': {'transform'}
},
'SVGImageElement': {
'async': {'async'},
'height': {'height'},
'href': {'href'},
'preserveAspectRatio': {'preserveAspectRatio'},
'width': {'width'},
'x': {'x'},
'y': {'y'}
},
'SVGLength': {
'convertToSpecifiedUnits': {'convertToSpecifiedUnits'},
'newValueSpecifiedUnits': {'newValueSpecifiedUnits'},
@@ -3678,10 +3669,6 @@ final Map<String, Map<String, Set<String>>> nativeTypeToDartMembers = {
'y': {'y'},
'zoomAndPan': {'zoomAndPan'}
},
'SVGScriptElement': {
'href': {'href'},
'type': {'type'}
},
'SVGStopElement': {
'offset': {'gradientOffset'}
},
@@ -3695,12 +3682,6 @@ final Map<String, Map<String, Set<String>>> nativeTypeToDartMembers = {
'removeItem': {'removeItem'},
'replaceItem': {'replaceItem'}
},
'SVGStyleElement': {
'disabled': {'disabled'},
'media': {'media'},
'sheet': {'sheet'},
'type': {'type'}
},
'SVGSymbolElement': {
'preserveAspectRatio': {'preserveAspectRatio'},
'viewBox': {'viewBox'}
@@ -6537,13 +6518,21 @@ final Map<String, Map<String, String>> dartTypeToNativeMembers = {
'ImageCapture': {'track': 'track'},
'ImageData': {'data': 'data', 'height': 'height', 'width': 'width'},
'ImageElement': {
'alt': 'alt',
'async': 'async',
'complete': 'complete',
'crossOrigin': 'crossOrigin',
'currentSrc': 'currentSrc',
'height': 'height',
'href': 'href',
'preserveAspectRatio': 'preserveAspectRatio',
'width': 'width',
'x': 'x',
'y': 'y'
'isMap': 'isMap',
'naturalHeight': 'naturalHeight',
'naturalWidth': 'naturalWidth',
'referrerPolicy': 'referrerPolicy',
'sizes': 'sizes',
'src': 'src',
'srcset': 'srcset',
'useMap': 'useMap',
'width': 'width'
},
'Index': {
'getAll': 'getAll',
@@ -8143,7 +8132,16 @@ final Map<String, Map<String, String>> dartTypeToNativeMembers = {
'width': 'width'
},
'ScreenOrientation': {'angle': 'angle', 'type': 'type', 'unlock': 'unlock'},
'ScriptElement': {'href': 'href', 'type': 'type'},
'ScriptElement': {
'async': 'async',
'charset': 'charset',
'crossOrigin': 'crossOrigin',
'defer': 'defer',
'integrity': 'integrity',
'noModule': 'noModule',
'src': 'src',
'type': 'type'
},
'ScriptProcessorNode': {
'bufferSize': 'bufferSize',
'setEventListener': 'setEventListener'
@@ -9465,7 +9463,7 @@ final Map<String, Set<String>> dartTypeToNativeTypes = {
'ImageButtonInputElement': {'ImageButtonInputElement'},
'ImageCapture': {'ImageCapture'},
'ImageData': {'ImageData'},
'ImageElement': {'SVGImageElement'},
'ImageElement': {'HTMLImageElement'},
'ImmutableListMixin': {'ImmutableListMixin'},
'Index': {'IDBIndex'},
'InputDeviceCapabilities': {'InputDeviceCapabilities'},
@@ -9737,7 +9735,7 @@ final Map<String, Set<String>> dartTypeToNativeTypes = {
'Sampler': {'WebGLSampler'},
'Screen': {'Screen'},
'ScreenOrientation': {'ScreenOrientation'},
'ScriptElement': {'SVGScriptElement'},
'ScriptElement': {'HTMLScriptElement'},
'ScriptProcessorNode': {'JavaScriptAudioNode', 'ScriptProcessorNode'},
'ScrollAlignment': {'ScrollAlignment'},
'ScrollState': {'ScrollState'},
@@ -9783,7 +9781,7 @@ final Map<String, Set<String>> dartTypeToNativeTypes = {
'StorageEvent': {'StorageEvent'},
'StorageManager': {'StorageManager'},
'StringList': {'SVGStringList'},
'StyleElement': {'SVGStyleElement'},
'StyleElement': {'HTMLStyleElement'},
'StyleMedia': {'StyleMedia'},
'StylePropertyMap': {'StylePropertyMap'},
'StylePropertyMapReadonly': {'StylePropertyMapReadonly'},
@@ -9831,7 +9829,7 @@ final Map<String, Set<String>> dartTypeToNativeTypes = {
'TimeInputElement': {'TimeInputElement'},
'TimeRanges': {'TimeRanges'},
'TimerQueryExt': {'WebGLTimerQueryEXT'},
'TitleElement': {'SVGTitleElement'},
'TitleElement': {'HTMLTitleElement'},
'Touch': {'Touch'},
'TouchEvent': {'TouchEvent'},
'TouchList': {'TouchList'},