Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 11308075: Add custom annotations to some APIs for native tree shaking. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/html/scripts/generator.py » ('j') | sdk/lib/html/scripts/generator.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 283b1c82b2e471ea99417c66c24ff7a260ca1120..24b5d24d88e77afc5482a1dde54e672acb87a2a6 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -4927,7 +4927,9 @@ class CanvasRenderingContext2D extends CanvasRenderingContext native "*CanvasRen
}
throw const Exception("Incorrect number or type of arguments");
}
+ @Creates('ImageData|=Object')
_createImageData_1(imagedata) native "createImageData";
+ @Creates('ImageData|=Object')
_createImageData_2(num sw, sh) native "createImageData";
/** @domName CanvasRenderingContext2D.createLinearGradient */
@@ -4958,6 +4960,7 @@ class CanvasRenderingContext2D extends CanvasRenderingContext native "*CanvasRen
ImageData getImageData(num sx, num sy, num sw, num sh) {
return _convertNativeToDart_ImageData(_getImageData_1(sx, sy, sw, sh));
}
+ @Creates('ImageData|=Object')
_getImageData_1(sx, sy, sw, sh) native "getImageData";
/** @domName CanvasRenderingContext2D.getLineDash */
@@ -5057,6 +5060,7 @@ class CanvasRenderingContext2D extends CanvasRenderingContext native "*CanvasRen
ImageData webkitGetImageDataHD(num sx, num sy, num sw, num sh) {
return _convertNativeToDart_ImageData(_webkitGetImageDataHD_1(sx, sy, sw, sh));
}
+ @Creates('ImageData|=Object')
_webkitGetImageDataHD_1(sx, sy, sw, sh) native "webkitGetImageDataHD";
/** @domName CanvasRenderingContext2D.webkitPutImageDataHD */
@@ -6785,6 +6789,9 @@ class DocumentFragment extends Node native "*DocumentFragment" {
factory DocumentFragment.svg(String svgContent) =>
new _DocumentFragmentFactoryProvider.createDocumentFragment_svg(svgContent);
+ // This is a field of a native object, but used only from Dart code, so does
+ // not instantiate any native classes.
+ @Creates('Null')
List<Element> _elements;
List<Element> get elements {
@@ -8763,6 +8770,7 @@ class FileReader extends EventTarget native "*FileReader" {
final int readyState;
/** @domName FileReader.result */
+ @Creates('String|ArrayBuffer|Null')
final Object result;
/** @domName FileReader.abort */
@@ -9827,6 +9835,7 @@ class HttpRequest extends EventTarget native "*XMLHttpRequest" {
final int readyState;
/** @domName XMLHttpRequest.response */
+ @Creates('ArrayBuffer|Blob|Document|=Object|=List|String|num')
final Object response;
/** @domName XMLHttpRequest.responseText */
@@ -10004,6 +10013,7 @@ class IDBCursor native "*IDBCursor" {
final String direction;
/** @domName IDBCursor.key */
+ @annotation_Creates_IDBKey @annotation_Returns_IDBKey
final Object key;
/** @domName IDBCursor.primaryKey */
@@ -10047,6 +10057,7 @@ class IDBCursor native "*IDBCursor" {
class IDBCursorWithValue extends IDBCursor native "*IDBCursorWithValue" {
/** @domName IDBCursorWithValue.value */
+ @annotation_Creates_SerializedScriptValue @annotation_Returns_SerializedScriptValue
final Object value;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
@@ -10222,6 +10233,7 @@ class IDBFactory native "*IDBFactory" {
IDBVersionChangeRequest deleteDatabase(String name) native;
/** @domName IDBFactory.open */
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBDatabase')
IDBOpenDBRequest open(String name, [int version]) native;
/** @domName IDBFactory.webkitGetDatabaseNames */
@@ -10279,7 +10291,9 @@ class IDBIndex native "*IDBIndex" {
}
throw const Exception("Incorrect number or type of arguments");
}
+ @Returns('IDBRequest') @Creates('IDBRequest') @annotation_Creates_SerializedScriptValue
IDBRequest _get_1(IDBKeyRange key) native "get";
+ @Returns('IDBRequest') @Creates('IDBRequest') @annotation_Creates_SerializedScriptValue
IDBRequest _get_2(key) native "get";
/** @domName IDBIndex.getKey */
@@ -10293,7 +10307,9 @@ class IDBIndex native "*IDBIndex" {
}
throw const Exception("Incorrect number or type of arguments");
}
+ @Returns('IDBRequest') @Creates('IDBRequest') @annotation_Creates_SerializedScriptValue @Creates('IDBObjectStore')
IDBRequest _getKey_1(IDBKeyRange key) native "getKey";
+ @Returns('IDBRequest') @Creates('IDBRequest') @annotation_Creates_SerializedScriptValue @Creates('IDBObjectStore')
IDBRequest _getKey_2(key) native "getKey";
/** @domName IDBIndex.openCursor */
@@ -10320,10 +10336,15 @@ class IDBIndex native "*IDBIndex" {
}
throw const Exception("Incorrect number or type of arguments");
}
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openCursor_1() native "openCursor";
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openCursor_2(IDBKeyRange range) native "openCursor";
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openCursor_3(IDBKeyRange range, direction) native "openCursor";
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openCursor_4(key) native "openCursor";
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openCursor_5(key, direction) native "openCursor";
/** @domName IDBIndex.openKeyCursor */
@@ -10350,10 +10371,15 @@ class IDBIndex native "*IDBIndex" {
}
throw const Exception("Incorrect number or type of arguments");
}
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openKeyCursor_1() native "openKeyCursor";
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openKeyCursor_2(IDBKeyRange range) native "openKeyCursor";
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openKeyCursor_3(IDBKeyRange range, direction) native "openKeyCursor";
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openKeyCursor_4(key) native "openKeyCursor";
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openKeyCursor_5(key, direction) native "openKeyCursor";
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
@@ -10496,7 +10522,9 @@ class IDBObjectStore native "*IDBObjectStore" {
var value_3 = _convertDartToNative_SerializedScriptValue(value);
return _add_2(value_3);
}
+ @Returns('IDBRequest') @Creates('IDBRequest') @annotation_Creates_IDBKey
IDBRequest _add_1(value, key) native "add";
+ @Returns('IDBRequest') @Creates('IDBRequest') @annotation_Creates_IDBKey
IDBRequest _add_2(value) native "add";
/** @domName IDBObjectStore.clear */
@@ -10575,7 +10603,9 @@ class IDBObjectStore native "*IDBObjectStore" {
}
throw const Exception("Incorrect number or type of arguments");
}
+ @Returns('IDBRequest') @Creates('IDBRequest') @annotation_Creates_SerializedScriptValue
IDBRequest _getObject_1(IDBKeyRange key) native "get";
+ @Returns('IDBRequest') @Creates('IDBRequest') @annotation_Creates_SerializedScriptValue
IDBRequest _getObject_2(key) native "get";
/** @domName IDBObjectStore.index */
@@ -10605,10 +10635,15 @@ class IDBObjectStore native "*IDBObjectStore" {
}
throw const Exception("Incorrect number or type of arguments");
}
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openCursor_1() native "openCursor";
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openCursor_2(IDBKeyRange range) native "openCursor";
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openCursor_3(IDBKeyRange range, direction) native "openCursor";
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openCursor_4(key) native "openCursor";
+ @Returns('IDBRequest') @Creates('IDBRequest') @Creates('IDBCursor')
IDBRequest _openCursor_5(key, direction) native "openCursor";
/** @domName IDBObjectStore.put */
@@ -10621,7 +10656,9 @@ class IDBObjectStore native "*IDBObjectStore" {
var value_3 = _convertDartToNative_SerializedScriptValue(value);
return _put_2(value_3);
}
+ @Returns('IDBRequest') @Creates('IDBRequest') @annotation_Creates_IDBKey
IDBRequest _put_1(value, key) native "put";
+ @Returns('IDBRequest') @Creates('IDBRequest') @annotation_Creates_IDBKey
IDBRequest _put_2(value) native "put";
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
@@ -10674,6 +10711,7 @@ class IDBRequest extends EventTarget native "*IDBRequest" {
dynamic get _result => JS("dynamic", "#.result", this);
/** @domName IDBRequest.source */
+ @Creates('Null')
final dynamic source;
/** @domName IDBRequest.transaction */
@@ -15950,6 +15988,7 @@ class SQLResultSetRowList implements JavaScriptIndexingBehavior, List<Map> nativ
Map item(int index) {
return _convertNativeToDart_Dictionary(_item_1(index));
}
+ @Creates('=Object')
_item_1(index) native "item";
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
@@ -24458,7 +24497,7 @@ _convertDartToNative_ImageData(ImageData imageData) {
Map _convertNativeToDart_Dictionary(object) {
if (object == null) return null;
var dict = {};
- for (final key in JS('List', 'Object.getOwnPropertyNames(#)', object)) {
+ for (final key in JS('=List', 'Object.getOwnPropertyNames(#)', object)) {
dict[key] = JS('var', '#[#]', object, key);
}
return dict;
@@ -24635,7 +24674,7 @@ _convertDartToNative_PrepareForStructuredClone(value) {
var copy = readSlot(slot);
if (copy != null) {
if (true == copy) { // Cycle, so commit to making a copy.
- copy = JS('List', 'new Array(#)', length);
+ copy = JS('=List', 'new Array(#)', length);
writeSlot(slot, copy);
}
return copy;
@@ -24655,7 +24694,7 @@ _convertDartToNative_PrepareForStructuredClone(value) {
if (!identical(elementCopy, element)) {
copy = readSlot(slot); // Cyclic reference may have created it.
if (true == copy) {
- copy = JS('List', 'new Array(#)', length);
+ copy = JS('=List', 'new Array(#)', length);
writeSlot(slot, copy);
}
for (int j = 0; j < i; j++) {
@@ -24672,7 +24711,7 @@ _convertDartToNative_PrepareForStructuredClone(value) {
}
} else {
// Not a JavaScript Array. We are forced to make a copy.
- copy = JS('List', 'new Array(#)', length);
+ copy = JS('=List', 'new Array(#)', length);
writeSlot(slot, copy);
}
@@ -24752,7 +24791,7 @@ _convertNativeToDart_AcceptStructuredClone(object, {mustCopy = false}) {
copy = {};
writeSlot(slot, copy);
- for (final key in JS('List', 'Object.keys(#)', e)) {
+ for (final key in JS('=List', 'Object.keys(#)', e)) {
copy[key] = walk(JS('var', '#[#]', e, key));
}
return copy;
@@ -24766,7 +24805,7 @@ _convertNativeToDart_AcceptStructuredClone(object, {mustCopy = false}) {
int length = e.length;
// Since a JavaScript Array is an instance of Dart List, we can modify it
// in-place unless we must copy.
- copy = mustCopy ? JS('List', 'new Array(#)', length) : e;
+ copy = mustCopy ? JS('=List', 'new Array(#)', length) : e;
writeSlot(slot, copy);
for (int i = 0; i < length; i++) {
@@ -24792,6 +24831,24 @@ bool _isJavaScriptSimpleObject(value) =>
JS('bool', 'Object.getPrototypeOf(#) === Object.prototype', value);
bool _isImmutableJavaScriptArray(value) =>
JS('bool', r'!!(#.immutable$list)', value);
+
+
+
+const String _serializedScriptValue =
+ 'num|String|bool|'
+ '=List|=Object|'
+ 'Blob|File|ArrayBuffer|ArrayBufferView'
+ // TODO(sra): Add Date, RegExp.
+ ;
+
+const annotation_Creates_SerializedScriptValue =
+ const Creates(_serializedScriptValue);
+const annotation_Returns_SerializedScriptValue =
+ const Returns(_serializedScriptValue);
+
+const String _idbKey = '=List|=Object|num|String'; // TODO(sra): Add Date.
+const annotation_Creates_IDBKey = const Creates(_idbKey);
+const annotation_Returns_IDBKey = const Returns(_idbKey);
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// 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.
« no previous file with comments | « no previous file | sdk/lib/html/scripts/generator.py » ('j') | sdk/lib/html/scripts/generator.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698