Commit graph

40 commits

Author SHA1 Message Date
Srujan Gaddam 5b23373f7e 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 <srujzs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2020-02-29 01:29:35 +00:00
Srujan Gaddam 9f79dfc37d Address analyzer errors in golden files in dart:html
New analyzer errors are reported for dart:html around nullability.
Non-nullable fields are translated to native getters and setters if part
of a concrete class and normal getters and setters if abstract.

Change-Id: I2fd87803a08872b2a7eae4de0af704f184997c7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137481
Reviewed-by: Stephen Adams <sra@google.com>
2020-02-29 01:29:35 +00:00
Srujan Gaddam 80f84e1942 Change all fields to native getters/setters
Bug: https://github.com/dart-lang/sdk/issues/40772

Attributes are translated to native getters and setters regardless of
NNBD. Some logic was removed for fields that no longer apply due to this
change.

Change-Id: Ia1a05778ff8c6f082506a1c95a3057a7c5f7f896
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136880
Reviewed-by: Stephen Adams <sra@google.com>
2020-02-29 01:29:35 +00:00
Srujan Gaddam 3ec6ec2a2d Change getters/setters to native for nnbd
NNBD fields that were non-nullable or final were transformed to getters
so that they were compilable. They need to be transformed to natives now
for performance.

Change-Id: Ice0082f9468c542098a6d12083a826438d15eba4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135860
Reviewed-by: Stephen Adams <sra@google.com>
2020-02-29 01:29:35 +00:00
Srujan Gaddam 55f4b1294e Change setProperty to take in nullable |value|
IDL allows |value| to be nullable.

Change-Id: I1db4a7929f0a83c4772e1a11384afb70ead53501
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136722
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2020-02-22 02:22:21 +00:00
Srujan Gaddam 6d051311b6 Add back in null assertions for legacy weak mode
These assertions need to be added back into the nnbd sdk in order to be
compatible with weak mode.

Change-Id: Ie774fffda1fb0e79dbc7fe13cb75b9d28e4268fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136720
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2020-02-21 19:13:31 +00:00
Srujan Gaddam a42c072017 Remove unnecessary null check in getPropertyValue
CSSStyleDeclaration.getPropertyValue returns a non-nullable string.
It will also return an empty string if the property is not found. Since
getPropertyValue returns the value of the native getPropertyValue, the
null check should be removed.

Change-Id: I9846553d3f9fcd68cbd15b9c39d2104cab594b7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136413
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2020-02-20 20:49:26 +00:00
Robert Nystrom 156c503620 Change indexOf() and lastIndexOf() back to Object.
In the legacy SDK these two methods in ListMixin take Object, not E.
When I migrated them to NNBD, I changed them to E to match the
declaration of the methods in List. This was an unintended breaking
change.

Fix that by changing them to "Object?", which is the NNBD equivalent of
the declarations in the legacy SDK.

Change-Id: I2a75e9f26a8198e4f51cb32a55055d5e64a69ed1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136412
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2020-02-20 09:00:17 +00:00
Srujan Gaddam 59370f29c5 Fix html methods without returns
Several method bodies did not return a value conditionally or at all.

Change-Id: I01ca87e2e0501597bacb49bcddd10668b59026b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135626
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-02-19 20:43:34 +00:00
Srujan Gaddam e2ff83724b Fix nullability for some templates
Addresses discrepancies between IDL and template files for some
operations. There's probably more I'm missing since this was
from a cursory check through all the templates.

Change-Id: Id79710b343f4a5fe0b5529f64c341d4f63d69b9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135222
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2020-02-11 20:28:54 +00:00
Nicholas Shahan 905a154f59 Remove import of dart:mirrors from dart:html
This probably should have been part of
https://dart-review.googlesource.com/c/sdk/+/134405 and I suspect it
caused no failures because the import was unused.

Change-Id: I418448ddef5d50267a89ae183f215fded56a425e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134863
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-02-11 01:04:55 +00:00
Srujan Gaddam e7ee11a95b Fix input and output for conversions
Fixes tests lib_2/html/event_customerevent_test
            co19_2/LibtTest/html/Document/window_A01_t01

JS inline incorrectly uses the converted html name for attributes for
getters. Similarly, dynamics do not need to be marked as nullable as
they are already nullable. This also fixes some of the nullability logic
for conversion input and output.

Change-Id: I77efde95a4e5d52461b3412f8650578e967ca5cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135201
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2020-02-11 00:27:05 +00:00
Srujan Gaddam 5e74472449 Handle optionals in DOM scripts for NNBD
Optionals were being ignored for some methods and for optionals that
have a default of Undefined or None, they should be marked nullable in
Dart syntax regardless of whether they are in the IDL.

Change-Id: Icc71300dc7d8e06fef640a5ca8d502b093c0580c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134765
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-02-10 22:26:35 +00:00
Srujan Gaddam cd53f4ffe1 Add null-safety to html_common
Bug: https://github.com/dart-lang/sdk/issues/37931

Change-Id: I454ffd0cbd090d5f4ff0aa4f2a778710eea7c5b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133860
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-02-10 19:14:34 +00:00
Srujan Gaddam 9af1ffc558 Don't generate getters/setters for read only promises
Bug: https://github.com/dart-lang/sdk/issues/40530

For attributes that return promises and are read only, we
use promiseToFuture casts that should be maintained.

Change-Id: I02e23fc9c47321ced64a152c245cbdccd7337033
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134902
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2020-02-10 18:55:35 +00:00
Srujan Gaddam 8c0d72db1d Fix how composedPath is called
Bug: b/149075352

Event.path should call composedPath if the result of the inline is
True. As it is, it only calls it if the result is null, which is
erroneous.

Change-Id: Idacc9ccddafc4374aca10de84265bf82cfbd0ab9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134887
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-02-07 23:25:22 +00:00
Srujan Gaddam dae60008ab DOM script changes to handle nnbd
-Adds field for type nullability for IDL operations
-Adds field for conversions to reflect input and output type nullability
--based on implementation
-Corrects generic object types to include nullability
-Changes 'any' types to dynamics
-Adds nullability to types in various operations
-Converts finals and non-initialized non-nullable fields to getters and
setters
--TODO: convert these to native instead of JS inline
-Modifies nullability for annotations and removes annotations from
setters

Change-Id: Iab19830fd1d7f37b170a4da8672f922c3f9b0863
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132967
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-02-07 01:05:14 +00:00
Srujan Gaddam 3776313e65 Change dart:html templates to generate null-safe code
Introduces NULLASSERT token and NNBD condition to allow code to
conditionally compile with NNBD.

Change-Id: Ib71e439f32c793e69b66c328cd7c9900358d886e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134045
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-02-06 23:18:24 +00:00
Srujan Gaddam 851912cc1d Change nnbd_src files to be null-safe
Translates the forked nnbd_src files to address analyzer issues.

Change-Id: Ida21988bff63a6c5a037b548d0c8b11208317b3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130131
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-02-04 01:57:39 +00:00
Sigmund Cherem 07675de0c0 Fix type error within _EventStream.onData
The constructor was wrapping the onData handler to hide the type-mismatch. This
copies the same logic to the onData handler.

In non-nnbd code this code was not exercised. The migration of dart:async
made this code reachable on our tests. That's because Stream.first used to
do:

  var subscription;
  this.listen(() => ... cancel subscription here, ...)

it now avoids making subscription nullable by registering the onData handler
later:

  var subscrition = stream.listen(null, ...);
  subscription.onData(() => ... cancel subscription here);

This change fixes the following 6 html tests under nnbd:
html/history_test/history/history
html/transferables_test
html/transition_event_test
html/websocket_test
html/worker_test/functional/functional
html/xhr_test


Change-Id: I095ea8d545e65b047504af0367586884bba84d72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134120
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2020-02-02 05:58:24 +00:00
Srujan Gaddam 28917d8b1d Handle invalid overrides in template and src dart files
Several functions did not override their parents' function signatures
correctly for nnbd.

Change-Id: Ibd935ffa39b3175db65bb43d15396134700d2f78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129143
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-01-29 22:22:50 +00:00
Srujan Gaddam 151dc015c0 Add $#NAME syntax to emitter to allow subtemplates
NNBD will require explicit casts in various locations in the dart:html
libraries. To avoid taking on this overhead in the pre-nnbd dart:html
library, syntax is introduced in the emitter to allow tokens with
arguments.

Test: emitter_test.py

Change-Id: Ie6de714f491e0cda654f33ee389a91b765cacc9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133333
Reviewed-by: Stephen Adams <sra@google.com>
2020-01-29 22:22:50 +00:00
Srujan Gaddam 7db61c6b01 Changing the dart:html generator scripts to generate null-safe/nnbd code
Change-Id: I4a8b097b126864366076b1e73cf3e0296600380e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128376
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2020-01-29 00:20:42 +00:00
asiva 7bc25eca34 [VM/developer] Opt libraries dart:developer and dart:nativewrappers into NNBD
Change-Id: Ifb7696d53e03bf77c69b4df7d96691a31e2d01ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131900
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-01-16 17:56:57 +00:00
Srujan Gaddam a865b9c379 Change Future lists to use dynamic
Bug: https://github.com/dart-lang/sdk/issues/39627

Lists in a future should be typed with dynamic since they come from JS
interop.

Change-Id: I93d4da16eb27c3af23820a170cfad7cc5c3b4472
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128368
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2019-12-14 00:23:54 +00:00
Srujan Gaddam b84d6ba0f8 Change type MediaDeviceInfo to dynamic in Future
Bug: https://github.com/dart-lang/sdk/issues/39627

Lists in a future should be typed with dynamic since they come from JS
interop.

Results from running tools/dom/scripts/go.sh

Change-Id: I4ed37d6f5fa570beef71652dcad17c3bcf7560ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128300
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2019-12-13 22:17:11 +00:00
Sigmund Cherem 16bc1806ea (html) remove type parameter from callback argument
This was a case missed when fixing #33891, and fixes #36798

Change-Id: I96e177a7d8020635e191d829afdec45f888658a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127500
Reviewed-by: Alan Knight <alanknight@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2019-12-06 19:02:02 +00:00
Alan Knight 752bbce46f Copy dart:html files to sdk_nnbd automatically and opt out
Change-Id: I78ab534da123afb12a31681b47ba1f2fb9567992
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124202
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Alan Knight <alanknight@google.com>
2019-11-06 23:59:33 +00:00
Derek Xu 6d28f59c54 Added promiseToFuture function to js_util.dart
Change-Id: I1bfd3fadb0a212ec0ff150cad02bdf285e2e7edb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122240
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2019-11-04 22:56:45 +00:00
Nicholas Shahan 2495c5ca9f [html] Avoid dynamic in Rectangle operator ==
* Rely on type promotion instead.
* The is! type promotion isn't working in the CFE yet.

Change-Id: Ia4c8b4bcbac50cd0ab07c60f7440ef3837675b7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122179
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-10-21 19:40:18 +00:00
Sam Rawlins f9648cb477 Fix doc comment for Element.animate
Change-Id: Iace87105cf2a1fa4aacc579b07c9760329c7d160
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119420
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Terry Lucas <terry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2019-10-15 17:36:52 +00:00
Nate Bosch 17702e4af0 Export promiseToFuture function from dart:html
Fixes #38805

Change-Id: I1ff58eacdc4bb2fbb610335ae1eaaa7bd911a1ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120935
Reviewed-by: Vijay Menon <vsm@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: David Morgan <davidmorgan@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
2019-10-11 09:23:56 +00:00
Nate Bosch 0f1d5fa7e6 Centralize functions to convert Promise
Merge the two copies of a function that convert a JS promise to a Dart
Future. Reuse this function for the specialized case of converting to a
`Future<Map>`.

- Rename `convertNativePromiseToDartFuture` to the shorter and more
  widely used `promiseToFuture`. Update one existing use of the old
  name.
- Make the method generic to match the previous implementation of
  `promiseToFuture`.
- Update the code generator template to not emit the second copy of the
  method.
- Use the existing `promiseToFuture` with a `.then` call to implement
  `promiseToFutureAsMap`. Update the doc comment to follow best
  practices.
- Duplicate all above changes to nnbd SDK copy.

Change-Id: Ib3bbf17477efec3666b24fd4019ca8ce68f0b5b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119174
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-10-08 21:33:42 +00:00
Devon Carew de2e16d39d Add gni files to the html, js, and js_util packages in support of adding them to the flutter sdk.
Bug: https://github.com/flutter/flutter/issues/35588
Change-Id: I1f6c0c5edee99114ed72893a83a1954ff61c2c57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118472
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2019-09-24 15:28:29 +00:00
Mark Zhou d012dfc7a6 Removing 'webkit' prefix, as most modern web browsers will accept 'RTCPeerConnection'
Fixes #38325

Change-Id: I08589781c8e8647c1e6d403baf4d6106d5308181
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116941
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Auto-Submit: Mark Zhou <markzipan@google.com>
2019-09-24 00:04:00 +00:00
Mark Zhou 4c74b486af Re-adding dart sdk version comment
Change-Id: Ifc1ddc6ebc8b14107424e36dc5e8388bcf69d262
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118370
Auto-Submit: Mark Zhou <markzipan@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2019-09-20 23:26:39 +00:00
Mayank Patke 7e68a0c95e Copy changes from f057e25 to sdk_nnbd.
Change-Id: Id31fa5d37970b74f38a06e7b2490937de93b1441
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118400
Commit-Queue: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Auto-Submit: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2019-09-20 22:05:57 +00:00
Mark Zhou 56913c2555 Changing val to accommodate double values
Change-Id: If19b6aece45b46a0ceb85d98b0ac73eb3735e0dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118240
Reviewed-by: Vijay Menon <vsm@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2019-09-20 16:23:35 +00:00
Lasse R.H. Nielsen e88057fe04 Add non-NNBD language version marker on all sdk_nnbd files.
Change-Id: I2ab3d4b1efe0f3c79f4b770e79476153380220f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118040
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2019-09-19 19:44:37 +00:00
Paul Berry 004d49bd6b Make a fork of sdk/lib for use by NNBD.
Change-Id: I7f5892d66f9e7bd08ca064fb2df329794a56faf5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116527
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-09-10 19:20:12 +00:00