[dart:html] Delete unused private methods

The outdated custom element support has already been removed so these
methods are no longer needed.

Removes an access of `.__proto__`.

Issue: https://github.com/dart-lang/sdk/issues/52372
CoreLibraryReviewExempt: Change in web only library
Change-Id: Ia55c3be7f6c19433234c02b90981424e973866aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304781
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
Nicholas Shahan 2023-05-23 21:40:32 +00:00 committed by Commit Queue
parent c7dcbff358
commit 15903b76fe
2 changed files with 0 additions and 276 deletions

View file

@ -40035,53 +40035,6 @@ _convertNativeToDart_XHR_Response(o) {
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
_callConstructor(constructor, interceptor) {
return (receiver) {
setNativeSubclassDispatchRecord(receiver, interceptor);
// Mirrors uses the constructor property to cache lookups, so we need it to
// be set correctly, including on IE where it is not automatically picked
// up from the __proto__.
JS('', '#.constructor = #.__proto__.constructor', receiver, receiver);
return JS('', '#(#)', constructor, receiver);
};
}
_callAttached(Element receiver) {
return receiver.attached();
}
_callDetached(Element receiver) {
return receiver.detached();
}
_callAttributeChanged(
Element receiver, String name, String oldValue, String newValue) {
return receiver.attributeChanged(name, oldValue, newValue);
}
_makeCallbackMethod(callback) {
return JS(
'',
'''((function(invokeCallback) {
return function() {
return invokeCallback(this);
};
})(#))''',
convertDartClosureToJS(callback, 1));
}
_makeCallbackMethod3(callback) {
return JS(
'',
'''((function(invokeCallback) {
return function(arg1, arg2, arg3) {
return invokeCallback(this, arg1, arg2, arg3);
};
})(#))''',
convertDartClosureToJS(callback, 4));
}
/// Checks whether the given [element] correctly extends from the native class
/// with the given [baseClassName]. This method will throw if the base class
/// doesn't match, except when the element extends from `template` and it's base
@ -40098,97 +40051,6 @@ void _checkExtendsNativeClassOrTemplate(
}
}
Function _registerCustomElement(context, Document document, String tag,
[Map? options]) {
// Function follows the same pattern as the following JavaScript code for
// registering a custom element.
//
// var proto = Object.create(HTMLElement.prototype, {
// createdCallback: {
// value: function() {
// window.console.log('here');
// }
// }
// });
// document.registerElement('x-foo', { prototype: proto });
// ...
// var e = document.createElement('x-foo');
String? extendsTagName = '';
Type? type;
if (options != null) {
extendsTagName = options['extends'];
type = options['prototype'];
}
var interceptorClass = findInterceptorConstructorForType(type);
if (interceptorClass == null) {
throw new ArgumentError(type);
}
var interceptor = JS('=Object', '#.prototype', interceptorClass);
var constructor = findConstructorForNativeSubclassType(type, 'created');
if (constructor == null) {
throw new ArgumentError("$type has no constructor called 'created'");
}
// Workaround for 13190- use an article element to ensure that HTMLElement's
// interceptor is resolved correctly.
getNativeInterceptor(new Element.tag('article'));
String baseClassName = findDispatchTagForInterceptorClass(interceptorClass);
if (baseClassName == null) {
throw new ArgumentError(type);
}
if (extendsTagName == null) {
if (baseClassName != 'HTMLElement') {
throw new UnsupportedError('Class must provide extendsTag if base '
'native class is not HtmlElement');
}
} else {
var element = document.createElement(extendsTagName);
_checkExtendsNativeClassOrTemplate(element, extendsTagName, baseClassName);
}
var baseConstructor = JS('=Object', '#[#]', context, baseClassName);
var properties = JS('=Object', '{}');
JS(
'void',
'#.createdCallback = #',
properties,
JS('=Object', '{value: #}',
_makeCallbackMethod(_callConstructor(constructor, interceptor))));
JS('void', '#.attachedCallback = #', properties,
JS('=Object', '{value: #}', _makeCallbackMethod(_callAttached)));
JS('void', '#.detachedCallback = #', properties,
JS('=Object', '{value: #}', _makeCallbackMethod(_callDetached)));
JS('void', '#.attributeChangedCallback = #', properties,
JS('=Object', '{value: #}', _makeCallbackMethod3(_callAttributeChanged)));
var baseProto = JS('=Object', '#.prototype', baseConstructor);
var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties);
setNativeSubclassDispatchRecord(proto, interceptor);
var opts = JS('=Object', '{prototype: #}', proto);
if (extendsTagName != null) {
JS('=Object', '#.extends = #', opts, extendsTagName);
}
return JS(
'JavaScriptFunction', '#.registerElement(#, #)', document, tag, opts);
}
//// Called by Element.created to do validation & initialization.
void _initializeCustomElement(Element e) {
// TODO(blois): Add validation that this is only in response to an upgrade.
}
/// Dart2JS implementation of ElementUpgrader
class _JSElementUpgrader implements ElementUpgrader {
var _interceptor;

View file

@ -4,53 +4,6 @@
part of dart.dom.html;
_callConstructor(constructor, interceptor) {
return (receiver) {
setNativeSubclassDispatchRecord(receiver, interceptor);
// Mirrors uses the constructor property to cache lookups, so we need it to
// be set correctly, including on IE where it is not automatically picked
// up from the __proto__.
JS('', '#.constructor = #.__proto__.constructor', receiver, receiver);
return JS('', '#(#)', constructor, receiver);
};
}
_callAttached(Element receiver) {
return receiver.attached();
}
_callDetached(Element receiver) {
return receiver.detached();
}
_callAttributeChanged(
Element receiver, String name, String oldValue, String newValue) {
return receiver.attributeChanged(name, oldValue, newValue);
}
_makeCallbackMethod(callback) {
return JS(
'',
'''((function(invokeCallback) {
return function() {
return invokeCallback(this);
};
})(#))''',
convertDartClosureToJS(callback, 1));
}
_makeCallbackMethod3(callback) {
return JS(
'',
'''((function(invokeCallback) {
return function(arg1, arg2, arg3) {
return invokeCallback(this, arg1, arg2, arg3);
};
})(#))''',
convertDartClosureToJS(callback, 4));
}
/// Checks whether the given [element] correctly extends from the native class
/// with the given [baseClassName]. This method will throw if the base class
/// doesn't match, except when the element extends from `template` and it's base
@ -67,97 +20,6 @@ void _checkExtendsNativeClassOrTemplate(
}
}
Function _registerCustomElement(context, Document document, String tag,
[Map? options]) {
// Function follows the same pattern as the following JavaScript code for
// registering a custom element.
//
// var proto = Object.create(HTMLElement.prototype, {
// createdCallback: {
// value: function() {
// window.console.log('here');
// }
// }
// });
// document.registerElement('x-foo', { prototype: proto });
// ...
// var e = document.createElement('x-foo');
String? extendsTagName = '';
Type? type;
if (options != null) {
extendsTagName = options['extends'];
type = options['prototype'];
}
var interceptorClass = findInterceptorConstructorForType(type);
if (interceptorClass == null) {
throw new ArgumentError(type);
}
var interceptor = JS('=Object', '#.prototype', interceptorClass);
var constructor = findConstructorForNativeSubclassType(type, 'created');
if (constructor == null) {
throw new ArgumentError("$type has no constructor called 'created'");
}
// Workaround for 13190- use an article element to ensure that HTMLElement's
// interceptor is resolved correctly.
getNativeInterceptor(new Element.tag('article'));
String baseClassName = findDispatchTagForInterceptorClass(interceptorClass);
if (baseClassName == null) {
throw new ArgumentError(type);
}
if (extendsTagName == null) {
if (baseClassName != 'HTMLElement') {
throw new UnsupportedError('Class must provide extendsTag if base '
'native class is not HtmlElement');
}
} else {
var element = document.createElement(extendsTagName);
_checkExtendsNativeClassOrTemplate(element, extendsTagName, baseClassName);
}
var baseConstructor = JS('=Object', '#[#]', context, baseClassName);
var properties = JS('=Object', '{}');
JS(
'void',
'#.createdCallback = #',
properties,
JS('=Object', '{value: #}',
_makeCallbackMethod(_callConstructor(constructor, interceptor))));
JS('void', '#.attachedCallback = #', properties,
JS('=Object', '{value: #}', _makeCallbackMethod(_callAttached)));
JS('void', '#.detachedCallback = #', properties,
JS('=Object', '{value: #}', _makeCallbackMethod(_callDetached)));
JS('void', '#.attributeChangedCallback = #', properties,
JS('=Object', '{value: #}', _makeCallbackMethod3(_callAttributeChanged)));
var baseProto = JS('=Object', '#.prototype', baseConstructor);
var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties);
setNativeSubclassDispatchRecord(proto, interceptor);
var opts = JS('=Object', '{prototype: #}', proto);
if (extendsTagName != null) {
JS('=Object', '#.extends = #', opts, extendsTagName);
}
return JS(
'JavaScriptFunction', '#.registerElement(#, #)', document, tag, opts);
}
//// Called by Element.created to do validation & initialization.
void _initializeCustomElement(Element e) {
// TODO(blois): Add validation that this is only in response to an upgrade.
}
/// Dart2JS implementation of ElementUpgrader
class _JSElementUpgrader implements ElementUpgrader {
var _interceptor;