Skip to content

Commit 5b23373

Browse files
srujzscommit-bot@chromium.org
authored andcommitted
Modify fields in some abstract and native classes
Since we transitioned to natives for dart:html, manually written native fields should be rewritten. Similarly, if there are fields in abstract classes that represent interfaces, they should be converted. Fields in abstract classes that are used in that class are left alone. Change-Id: I924363639a4430b88b810b7348815bbc3f040e7c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137642 Commit-Queue: Srujan Gaddam <[email protected]> Reviewed-by: Stephen Adams <[email protected]>
1 parent 9f79dfc commit 5b23373

File tree

7 files changed

+76
-116
lines changed

7 files changed

+76
-116
lines changed

sdk/lib/html/dart2js/html_dart2js.dart

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ class HtmlElement extends Element implements NoncedElement {
117117
HtmlElement.created() : super.created();
118118

119119
// From NoncedElement
120-
String nonce;
120+
String get nonce native;
121+
set nonce(String value) native;
121122
}
122123

123124
/**
@@ -13746,7 +13747,8 @@ class Element extends Node
1374613747
String get innerHtml => _innerHtml;
1374713748

1374813749
@JSName('innerText')
13749-
String innerText;
13750+
String get innerText native;
13751+
set innerText(String value) native;
1375013752

1375113753
/**
1375213754
* This is an ease-of-use accessor for event streams which should only be
@@ -13817,7 +13819,7 @@ class Element extends Node
1381713819
return result;
1381813820
}
1381913821

13820-
final Element offsetParent;
13822+
Element get offsetParent native;
1382113823

1382213824
int get offsetHeight => JS<num>('num', '#.offsetHeight', this).round();
1382313825

@@ -15399,7 +15401,8 @@ class Event extends Interceptor {
1539915401
}
1540015402

1540115403
/** The CSS selector involved with event delegation. */
15402-
String _selector;
15404+
String get _selector native;
15405+
set _selector(String value) native;
1540315406

1540415407
/**
1540515408
* A pointer to the element whose CSS selector matched within which an event
@@ -19214,17 +19217,23 @@ class InputElement extends HtmlElement
1921419217
* Exposes the functionality common between all InputElement types.
1921519218
*/
1921619219
abstract class InputElementBase implements Element {
19217-
bool autofocus;
19220+
bool get autofocus;
19221+
set autofocus(bool value);
1921819222

19219-
bool disabled;
19223+
bool get disabled;
19224+
set disabled(bool value);
1922019225

19221-
bool incremental;
19226+
bool get incremental;
19227+
set incremental(bool value);
1922219228

19223-
bool indeterminate;
19229+
bool get indeterminate;
19230+
set indeterminate(bool value);
1922419231

19225-
String name;
19232+
String get name;
19233+
set name(String value);
1922619234

19227-
String value;
19235+
String get value;
19236+
set value(String value);
1922819237

1922919238
List<Node> get labels;
1923019239

@@ -19250,27 +19259,37 @@ abstract class HiddenInputElement implements InputElementBase {
1925019259
* Base interface for all inputs which involve text editing.
1925119260
*/
1925219261
abstract class TextInputElementBase implements InputElementBase {
19253-
String autocomplete;
19262+
String get autocomplete;
19263+
set autocomplete(String value);
1925419264

19255-
int maxLength;
19265+
int get maxLength;
19266+
set maxLength(int value);
1925619267

19257-
String pattern;
19268+
String get pattern;
19269+
set pattern(String value);
1925819270

19259-
String placeholder;
19271+
String get placeholder;
19272+
set placeholder(String value);
1926019273

19261-
bool readOnly;
19274+
bool get readOnly;
19275+
set readOnly(bool value);
1926219276

19263-
bool required;
19277+
bool get required;
19278+
set required(bool value);
1926419279

19265-
int size;
19280+
int get size;
19281+
set size(int value);
1926619282

1926719283
void select();
1926819284

19269-
String selectionDirection;
19285+
String get selectionDirection;
19286+
set selectionDirection(String value);
1927019287

19271-
int selectionEnd;
19288+
int get selectionEnd;
19289+
set selectionEnd(int value);
1927219290

19273-
int selectionStart;
19291+
int get selectionStart;
19292+
set selectionStart(int value);
1927419293

1927519294
void setSelectionRange(int start, int end, [String direction]);
1927619295
}
@@ -19414,13 +19433,17 @@ abstract class PasswordInputElement implements TextInputElementBase {
1941419433
abstract class RangeInputElementBase implements InputElementBase {
1941519434
Element get list;
1941619435

19417-
String max;
19436+
String get max;
19437+
set max(String value);
1941819438

19419-
String min;
19439+
String get min;
19440+
set min(String value);
1942019441

19421-
String step;
19442+
String get step;
19443+
set step(String value);
1942219444

19423-
num valueAsNumber;
19445+
num get valueAsNumber;
19446+
set valueAsNumber(num value);
1942419447

1942519448
void stepDown([int n]);
1942619449

@@ -23103,7 +23126,7 @@ class Node extends EventTarget {
2310323126
*/
2310423127
@Returns('NodeList')
2310523128
@Creates('NodeList')
23106-
final List<Node> childNodes;
23129+
List<Node> get childNodes native;
2310723130

2310823131
// To suppress missing implicit constructor warnings.
2310923132
factory Node._() {

sdk_nnbd/lib/html/dart2js/html_dart2js.dart

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,8 @@ class HtmlElement extends Element implements NoncedElement {
115115
HtmlElement.created() : super.created();
116116

117117
// From NoncedElement
118-
String get nonce => JS("String", "#.nonce", this);
119-
120-
set nonce(String value) {
121-
JS("void", "#.nonce = #", this, value);
122-
}
118+
String get nonce native;
119+
set nonce(String value) native;
123120
}
124121

125122
/**
@@ -13768,10 +13765,8 @@ class Element extends Node
1376813765
String get innerHtml => _innerHtml;
1376913766

1377013767
@JSName('innerText')
13771-
String get innerText => JS<String>("String", "#.innerText", this);
13772-
set innerText(String value) {
13773-
JS("void", "#.innerText = #", this, value);
13774-
}
13768+
String get innerText native;
13769+
set innerText(String value) native;
1377513770

1377613771
/**
1377713772
* This is an ease-of-use accessor for event streams which should only be
@@ -13842,7 +13837,7 @@ class Element extends Node
1384213837
return result;
1384313838
}
1384413839

13845-
Element get offsetParent => JS("Element", "#.offsetParent", this);
13840+
Element get offsetParent native;
1384613841

1384713842
int get offsetHeight => JS<num>('num', '#.offsetHeight', this).round();
1384813843

@@ -15424,7 +15419,8 @@ class Event extends Interceptor {
1542415419
}
1542515420

1542615421
/** The CSS selector involved with event delegation. */
15427-
String? _selector;
15422+
String? get _selector native;
15423+
set _selector(String? value) native;
1542815424

1542915425
/**
1543015426
* A pointer to the element whose CSS selector matched within which an event
@@ -19245,8 +19241,6 @@ class InputElement extends HtmlElement
1924519241
* Exposes the functionality common between all InputElement types.
1924619242
*/
1924719243
abstract class InputElementBase implements Element {
19248-
// These fields here and below are overridden by generated code and therefore
19249-
// can't be nullable. Opted to translate these fields to getters/setters.
1925019244
bool get autofocus;
1925119245
set autofocus(bool value);
1925219246

@@ -19312,11 +19306,14 @@ abstract class TextInputElementBase implements InputElementBase {
1931219306

1931319307
void select();
1931419308

19315-
String? selectionDirection;
19309+
String? get selectionDirection;
19310+
set selectionDirection(String? value);
1931619311

19317-
int? selectionEnd;
19312+
int? get selectionEnd;
19313+
set selectionEnd(int? value);
1931819314

19319-
int? selectionStart;
19315+
int? get selectionStart;
19316+
set selectionStart(int? value);
1932019317

1932119318
void setSelectionRange(int start, int end, [String? direction]);
1932219319
}
@@ -23159,7 +23156,7 @@ class Node extends EventTarget {
2315923156
*/
2316023157
@Returns('NodeList')
2316123158
@Creates('NodeList')
23162-
List<Node> get childNodes => JS("NodeList", "#.childNodes", this);
23159+
List<Node> get childNodes native;
2316323160

2316423161
// To suppress missing implicit constructor warnings.
2316523162
factory Node._() {

tools/dom/templates/html/dart2js/html_dart2js.darttemplate

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,8 @@ class HtmlElement extends Element implements NoncedElement {
132132
HtmlElement.created() : super.created();
133133

134134
// From NoncedElement
135-
$if NNBD
136-
String get nonce => JS("String", "#.nonce", this);
137-
138-
set nonce(String value) {
139-
JS("void", "#.nonce = #", this, value);
140-
}
141-
$else
142-
String nonce;
143-
$endif
144-
135+
String get nonce native;
136+
set nonce(String value) native;
145137
}
146138

147139
/**

tools/dom/templates/html/impl/impl_Element.darttemplate

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,14 +1428,8 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
14281428
String get innerHtml => _innerHtml;
14291429

14301430
@JSName('innerText')
1431-
$if NNBD
1432-
String get innerText => JS<String>("String", "#.innerText", this);
1433-
set innerText(String value) {
1434-
JS("void", "#.innerText = #", this, value);
1435-
}
1436-
$else
1437-
String innerText;
1438-
$endif
1431+
String get innerText native;
1432+
set innerText(String value) native;
14391433

14401434
/**
14411435
* This is an ease-of-use accessor for event streams which should only be
@@ -1503,11 +1497,7 @@ $endif
15031497
return result;
15041498
}
15051499

1506-
$if NNBD
1507-
Element get offsetParent => JS("Element", "#.offsetParent", this);
1508-
$else
1509-
final Element offsetParent;
1510-
$endif
1500+
Element get offsetParent native;
15111501

15121502
int get offsetHeight => JS<num>('num', '#.offsetHeight', this).round();
15131503

tools/dom/templates/html/impl/impl_Event.darttemplate

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
3535
}
3636

3737
/** The CSS selector involved with event delegation. */
38-
String$NULLABLE _selector;
38+
String$NULLABLE get _selector native;
39+
set _selector(String$NULLABLE value) native;
3940

4041
/**
4142
* A pointer to the element whose CSS selector matched within which an event

tools/dom/templates/html/impl/impl_HTMLInputElement.darttemplate

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ $!MEMBERS
5050
* Exposes the functionality common between all InputElement types.
5151
*/
5252
abstract class InputElementBase implements Element {
53-
$if NNBD
54-
// These fields here and below are overridden by generated code and therefore
55-
// can't be nullable. Opted to translate these fields to getters/setters.
5653
bool get autofocus;
5754
set autofocus(bool value);
5855

@@ -70,19 +67,6 @@ $if NNBD
7067

7168
String get value;
7269
set value(String value);
73-
$else
74-
bool autofocus;
75-
76-
bool disabled;
77-
78-
bool incremental;
79-
80-
bool indeterminate;
81-
82-
String name;
83-
84-
String value;
85-
$endif
8670

8771
List<Node> get labels;
8872

@@ -109,7 +93,6 @@ abstract class HiddenInputElement implements InputElementBase {
10993
* Base interface for all inputs which involve text editing.
11094
*/
11195
abstract class TextInputElementBase implements InputElementBase {
112-
$if NNBD
11396
String get autocomplete;
11497
set autocomplete(String value);
11598

@@ -130,29 +113,17 @@ $if NNBD
130113

131114
int get size;
132115
set size(int value);
133-
$else
134-
String autocomplete;
135-
136-
int maxLength;
137-
138-
String pattern;
139-
140-
String placeholder;
141-
142-
bool readOnly;
143-
144-
bool required;
145-
146-
int size;
147-
$endif
148116

149117
void select();
150118

151-
String$NULLABLE selectionDirection;
119+
String$NULLABLE get selectionDirection;
120+
set selectionDirection(String$NULLABLE value);
152121

153-
int$NULLABLE selectionEnd;
122+
int$NULLABLE get selectionEnd;
123+
set selectionEnd(int$NULLABLE value);
154124

155-
int$NULLABLE selectionStart;
125+
int$NULLABLE get selectionStart;
126+
set selectionStart(int$NULLABLE value);
156127

157128
void setSelectionRange(int start, int end, [String$NULLABLE direction]);
158129
}
@@ -297,7 +268,6 @@ abstract class RangeInputElementBase implements InputElementBase {
297268

298269
Element$NULLABLE get list;
299270

300-
$if NNBD
301271
String get max;
302272
set max(String value);
303273

@@ -309,15 +279,6 @@ $if NNBD
309279

310280
num get valueAsNumber;
311281
set valueAsNumber(num value);
312-
$else
313-
String max;
314-
315-
String min;
316-
317-
String step;
318-
319-
num valueAsNumber;
320-
$endif
321282

322283
void stepDown([int$NULLABLE n]);
323284

tools/dom/templates/html/impl/impl_Node.darttemplate

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,7 @@ $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
268268
*/
269269
@Returns('NodeList')
270270
@Creates('NodeList')
271-
$if NNBD
272-
List<Node> get childNodes => JS("NodeList", "#.childNodes", this);
273-
$else
274-
final List<Node> childNodes;
275-
$endif
271+
List<Node> get childNodes native;
276272

277273
$!MEMBERS
278274
}

0 commit comments

Comments
 (0)