From 2bb03e4344646ccf80ec2773ec7432db43a2e7d0 Mon Sep 17 00:00:00 2001 From: Kallen Tu Date: Mon, 29 Aug 2022 20:06:45 +0000 Subject: [PATCH] Eliminate .style and ._initKeyboardEvent from html_dart2js. Change-Id: I16ea832e8eff2b2aea02fb73e1cf7ee9702923af Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256581 Reviewed-by: Leaf Petersen Commit-Queue: Kallen Tu Reviewed-by: Lasse Nielsen --- pkg/compiler/test/analyses/api_allowed.json | 2 -- sdk/lib/html/dart2js/html_dart2js.dart | 20 ++++++++++--------- tools/dom/scripts/css_code_generator.py | 13 ++++++------ tools/dom/src/dart2js_KeyEvent.dart | 4 ++-- .../impl_CSSStyleDeclaration.darttemplate | 13 ++++++------ 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/pkg/compiler/test/analyses/api_allowed.json b/pkg/compiler/test/analyses/api_allowed.json index 500928cb372..4f4eb91bc19 100644 --- a/pkg/compiler/test/analyses/api_allowed.json +++ b/pkg/compiler/test/analyses/api_allowed.json @@ -27,9 +27,7 @@ "Dynamic invocation of 'toJson'.": 1 }, "org-dartlang-sdk:///lib/html/dart2js/html_dart2js.dart": { - "Dynamic access of 'style'.": 1, "Dynamic invocation of 'call'.": 2, - "Dynamic invocation of 'dart.dom.html::_initKeyboardEvent'.": 1, "Dynamic access of 'attributes'.": 1, "Dynamic invocation of '[]'.": 1, "Dynamic invocation of 'toLowerCase'.": 1, diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart index 512f1520380..f33cff732e1 100644 --- a/sdk/lib/html/dart2js/html_dart2js.dart +++ b/sdk/lib/html/dart2js/html_dart2js.dart @@ -5434,19 +5434,18 @@ class CssStyleDeclaration extends JavaScriptObject class _CssStyleDeclarationSet extends Object with CssStyleDeclarationBase { final Iterable _elementIterable; - Iterable? _elementCssStyleDeclarationSetIterable; + Iterable _elementCssStyleDeclarationSetIterable; - _CssStyleDeclarationSet(this._elementIterable) { - _elementCssStyleDeclarationSetIterable = - new List.from(_elementIterable).map((e) => e.style); - } + _CssStyleDeclarationSet(this._elementIterable) + : _elementCssStyleDeclarationSetIterable = + new List.of(_elementIterable).map((e) => e.style); String getPropertyValue(String propertyName) => - _elementCssStyleDeclarationSetIterable!.first + _elementCssStyleDeclarationSetIterable.first .getPropertyValue(propertyName); void setProperty(String propertyName, String? value, [String? priority]) { - _elementCssStyleDeclarationSetIterable! + _elementCssStyleDeclarationSetIterable .forEach((e) => e.setProperty(propertyName, value, priority)); } @@ -34638,6 +34637,7 @@ abstract class _DocumentType extends Node implements ChildNode { } // From ChildNode + } // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file @@ -35752,6 +35752,7 @@ abstract class _WorkerLocation extends JavaScriptObject } // From URLUtilsReadOnly + } // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file @@ -35769,6 +35770,7 @@ abstract class _WorkerNavigator extends NavigatorConcurrentHardware // From NavigatorID // From NavigatorOnLine + } // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file @@ -40596,7 +40598,7 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent { view = window; } - dynamic eventObj; + KeyboardEvent eventObj; // Currently this works on everything but Safari. Safari throws an // "Attempting to change access mechanism for an unconfigurable property" @@ -40607,7 +40609,7 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent { // initialize initKeyEvent. eventObj = new Event.eventType('KeyboardEvent', type, - canBubble: canBubble, cancelable: cancelable); + canBubble: canBubble, cancelable: cancelable) as KeyboardEvent; // Chromium Hack JS( diff --git a/tools/dom/scripts/css_code_generator.py b/tools/dom/scripts/css_code_generator.py index 3510eddaaaf..16cf73b4856 100644 --- a/tools/dom/scripts/css_code_generator.py +++ b/tools/dom/scripts/css_code_generator.py @@ -232,20 +232,19 @@ $!MEMBERS class _CssStyleDeclarationSet extends Object with CssStyleDeclarationBase { final Iterable _elementIterable; - Iterable$NULLABLE _elementCssStyleDeclarationSetIterable; + Iterable _elementCssStyleDeclarationSetIterable; - _CssStyleDeclarationSet(this._elementIterable) { - _elementCssStyleDeclarationSetIterable = new List.from( - _elementIterable).map((e) => e.style); - } + _CssStyleDeclarationSet(this._elementIterable) + : _elementCssStyleDeclarationSetIterable = + new List.of(_elementIterable).map((e) => e.style); String getPropertyValue(String propertyName) => - _elementCssStyleDeclarationSetIterable$NULLASSERT.first.getPropertyValue( + _elementCssStyleDeclarationSetIterable.first.getPropertyValue( propertyName); void setProperty(String propertyName, String$NULLABLE value, [String$NULLABLE priority]) { - _elementCssStyleDeclarationSetIterable$NULLASSERT.forEach((e) => + _elementCssStyleDeclarationSetIterable.forEach((e) => e.setProperty(propertyName, value, priority)); } diff --git a/tools/dom/src/dart2js_KeyEvent.dart b/tools/dom/src/dart2js_KeyEvent.dart index d5734376d90..e6e964f6164 100644 --- a/tools/dom/src/dart2js_KeyEvent.dart +++ b/tools/dom/src/dart2js_KeyEvent.dart @@ -108,7 +108,7 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent { view = window; } - dynamic eventObj; + KeyboardEvent eventObj; // Currently this works on everything but Safari. Safari throws an // "Attempting to change access mechanism for an unconfigurable property" @@ -119,7 +119,7 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent { // initialize initKeyEvent. eventObj = new Event.eventType('KeyboardEvent', type, - canBubble: canBubble, cancelable: cancelable); + canBubble: canBubble, cancelable: cancelable) as KeyboardEvent; // Chromium Hack JS( diff --git a/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate b/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate index 7aade9840a6..10ea0fc54f7 100644 --- a/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate +++ b/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate @@ -1373,20 +1373,19 @@ $!MEMBERS class _CssStyleDeclarationSet extends Object with CssStyleDeclarationBase { final Iterable _elementIterable; - Iterable$NULLABLE _elementCssStyleDeclarationSetIterable; + Iterable _elementCssStyleDeclarationSetIterable; - _CssStyleDeclarationSet(this._elementIterable) { - _elementCssStyleDeclarationSetIterable = new List.from( - _elementIterable).map((e) => e.style); - } + _CssStyleDeclarationSet(this._elementIterable) + : _elementCssStyleDeclarationSetIterable = + new List.of(_elementIterable).map((e) => e.style); String getPropertyValue(String propertyName) => - _elementCssStyleDeclarationSetIterable$NULLASSERT.first.getPropertyValue( + _elementCssStyleDeclarationSetIterable.first.getPropertyValue( propertyName); void setProperty(String propertyName, String$NULLABLE value, [String$NULLABLE priority]) { - _elementCssStyleDeclarationSetIterable$NULLASSERT.forEach((e) => + _elementCssStyleDeclarationSetIterable.forEach((e) => e.setProperty(propertyName, value, priority)); }