[dart:html] Add different bindings for FileSystem APIs
Closes https://github.com/dart-lang/sdk/issues/45036
The FileSystem API has different bindings for different browsers,
and the values are all taken directly from the MDN:
https://developer.mozilla.org/en-US/docs/Web/API/File_and_Directory_Entries_API
Along with this, some APIs that need to expose these bindings are modified to
expose all possible bindings.
Change-Id: I18ce6d1208349eb9d5bd9d802d17dda1ddae2dec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225323
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index c6280c1..182872b 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -9165,12 +9165,19 @@
Entry getAsEntry() {
Entry entry = _webkitGetAsEntry() as Entry;
- if (entry.isFile!)
+ if (entry.isFile!) {
applyExtension('FileEntry', entry);
- else if (entry.isDirectory!)
+ applyExtension('webkitFileSystemFileEntry', entry);
+ applyExtension('FileSystemFileEntry', entry);
+ } else if (entry.isDirectory!) {
applyExtension('DirectoryEntry', entry);
- else
+ applyExtension('webkitFileSystemDirectoryEntry', entry);
+ applyExtension('FileSystemDirectoryEntry', entry);
+ } else {
applyExtension('Entry', entry);
+ applyExtension('webkitFileSystemEntry', entry);
+ applyExtension('FileSystemEntry', entry);
+ }
return entry;
}
@@ -9597,7 +9604,8 @@
// 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.
-@Native("DirectoryEntry")
+@Native(
+ "DirectoryEntry,webkitFileSystemDirectoryEntry,FileSystemDirectoryEntry")
class DirectoryEntry extends Entry {
/**
* Create a new directory with the specified `path`. If `exclusive` is true,
@@ -9612,6 +9620,9 @@
DirectoryReader createReader() {
DirectoryReader reader = _createReader();
applyExtension('DirectoryReader', reader);
+ applyExtension('WebKitDirectoryReader', reader);
+ applyExtension('webkitFileSystemDirectoryReader', reader);
+ applyExtension('FileSystemDirectoryReader', reader);
return reader;
}
@@ -9732,6 +9743,8 @@
var completer = new Completer<Entry>();
__getFile(path, options, (value) {
applyExtension('FileEntry', value);
+ applyExtension('webkitFileSystemFileEntry', value);
+ applyExtension('FileSystemFileEntry', value);
completer.complete(value);
}, (error) {
completer.completeError(error);
@@ -9758,7 +9771,8 @@
// 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.
-@Native("DirectoryReader")
+@Native(
+ "DirectoryReader,WebKitDirectoryReader,webkitFileSystemDirectoryReader,FileSystemDirectoryReader")
class DirectoryReader extends JavaScriptObject {
// To suppress missing implicit constructor warnings.
factory DirectoryReader._() {
@@ -9774,10 +9788,18 @@
_readEntries((values) {
values.forEach((value) {
applyExtension('Entry', value);
+ applyExtension('webkitFileSystemEntry', value);
+ applyExtension('FileSystemEntry', value);
Entry entry = value as Entry;
- if (entry.isFile!)
+ if (entry.isFile!) {
applyExtension('FileEntry', entry);
- else if (entry.isDirectory!) applyExtension('DirectoryEntry', entry);
+ applyExtension('webkitFileSystemFileEntry', entry);
+ applyExtension('FileSystemFileEntry', entry);
+ } else if (entry.isDirectory!) {
+ applyExtension('DirectoryEntry', entry);
+ applyExtension('webkitFileSystemDirectoryEntry', entry);
+ applyExtension('FileSystemDirectoryEntry', entry);
+ }
});
completer.complete(new List<Entry>.from(values));
}, (error) {
@@ -15334,7 +15356,7 @@
// 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.
-@Native("Entry")
+@Native("Entry,webkitFileSystemEntry,FileSystemEntry")
class Entry extends JavaScriptObject {
// To suppress missing implicit constructor warnings.
factory Entry._() {
@@ -15393,6 +15415,8 @@
var completer = new Completer<Entry>();
_getParent((value) {
applyExtension('Entry', value);
+ applyExtension('webkitFileSystemEntry', value);
+ applyExtension('FileSystemEntry', value);
completer.complete(value);
}, (error) {
completer.completeError(error);
@@ -16093,7 +16117,7 @@
// 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.
-@Native("FileEntry")
+@Native("FileEntry,webkitFileSystemFileEntry,FileSystemFileEntry")
class FileEntry extends Entry {
// To suppress missing implicit constructor warnings.
factory FileEntry._() {
@@ -16312,7 +16336,7 @@
// BSD-style license that can be found in the LICENSE file.
@SupportedBrowser(SupportedBrowser.CHROME)
-@Native("DOMFileSystem")
+@Native("DOMFileSystem,WebKitFileSystem,webkitFileSystem,FileSystem")
class FileSystem extends JavaScriptObject {
// To suppress missing implicit constructor warnings.
factory FileSystem._() {
@@ -33355,7 +33379,12 @@
var completer = new Completer<FileSystem>();
__requestFileSystem(type, size, (value) {
applyExtension('DOMFileSystem', value);
+ applyExtension('WebKitFileSystem', value);
+ applyExtension('webkitFileSystem', value);
+ applyExtension('FileSystem', value);
applyExtension('DirectoryEntry', value.root);
+ applyExtension('webkitFileSystemDirectoryEntry', value.root);
+ applyExtension('FileSystemDirectoryEntry', value.root);
completer.complete(value);
}, (error) {
completer.completeError(error);
diff --git a/tools/dom/scripts/generator.py b/tools/dom/scripts/generator.py
index bcc36f3..6ac22ce 100644
--- a/tools/dom/scripts/generator.py
+++ b/tools/dom/scripts/generator.py
@@ -293,8 +293,23 @@
'CSSStyleDeclaration,MSStyleCSSProperties,CSS2Properties',
'ApplicationCache':
'ApplicationCache,DOMApplicationCache,OfflineResourceList',
+ 'DirectoryEntry':
+ #Chrome Edge/Opera
+ 'DirectoryEntry,webkitFileSystemDirectoryEntry,FileSystemDirectoryEntry',
+ 'DirectoryReader':
+ #Chrome Edge Opera
+ 'DirectoryReader,WebKitDirectoryReader,webkitFileSystemDirectoryReader,FileSystemDirectoryReader',
+ 'DOMFileSystem':
+ #Chrome Edge Opera
+ 'DOMFileSystem,WebKitFileSystem,webkitFileSystem,FileSystem',
+ 'Entry':
+ #Chrome Edge
+ 'Entry,webkitFileSystemEntry,FileSystemEntry',
'Event':
'Event,InputEvent,SubmitEvent', # Workaround for issue 40901.
+ 'FileEntry':
+ #Chrome Edge
+ 'FileEntry,webkitFileSystemFileEntry,FileSystemFileEntry',
'HTMLTableCellElement':
'HTMLTableCellElement,HTMLTableDataCellElement,HTMLTableHeaderCellElement',
'GainNode':
diff --git a/tools/dom/scripts/htmlrenamer.py b/tools/dom/scripts/htmlrenamer.py
index 7e84e7c..30fa1af 100644
--- a/tools/dom/scripts/htmlrenamer.py
+++ b/tools/dom/scripts/htmlrenamer.py
@@ -268,6 +268,8 @@
'getDirectory': [''],
'getFile': [
'applyExtension(\'FileEntry\', value);',
+ 'applyExtension(\'webkitFileSystemFileEntry\', value);',
+ 'applyExtension(\'FileSystemFileEntry\', value);',
]
},
'Entry': {
@@ -276,6 +278,8 @@
],
'getParent': [
'applyExtension(\'Entry\', value);',
+ 'applyExtension(\'webkitFileSystemEntry\', value);',
+ 'applyExtension(\'FileSystemEntry\', value);',
]
},
'FileEntry': {
@@ -291,7 +295,12 @@
'Window': {
'webkitRequestFileSystem': [
'applyExtension(\'DOMFileSystem\', value);',
+ 'applyExtension(\'WebKitFileSystem\', value);',
+ 'applyExtension(\'webkitFileSystem\', value);',
+ 'applyExtension(\'FileSystem\', value);',
'applyExtension(\'DirectoryEntry\', value.root);',
+ 'applyExtension(\'webkitFileSystemDirectoryEntry\', value.root);',
+ 'applyExtension(\'FileSystemDirectoryEntry\', value.root);',
]
},
})
diff --git a/tools/dom/templates/html/impl/impl_DataTransferItem.darttemplate b/tools/dom/templates/html/impl/impl_DataTransferItem.darttemplate
index ca64994..42e643d 100644
--- a/tools/dom/templates/html/impl/impl_DataTransferItem.darttemplate
+++ b/tools/dom/templates/html/impl/impl_DataTransferItem.darttemplate
@@ -9,12 +9,19 @@
Entry getAsEntry() {
Entry entry = _webkitGetAsEntry() $#NULLSAFECAST(as Entry);
- if (entry.isFile$NULLASSERT)
+ if (entry.isFile$NULLASSERT) {
applyExtension('FileEntry', entry);
- else if (entry.isDirectory$NULLASSERT)
+ applyExtension('webkitFileSystemFileEntry', entry);
+ applyExtension('FileSystemFileEntry', entry);
+ } else if (entry.isDirectory$NULLASSERT) {
applyExtension('DirectoryEntry', entry);
- else
+ applyExtension('webkitFileSystemDirectoryEntry', entry);
+ applyExtension('FileSystemDirectoryEntry', entry);
+ } else {
applyExtension('Entry', entry);
+ applyExtension('webkitFileSystemEntry', entry);
+ applyExtension('FileSystemEntry', entry);
+ }
return entry;
}
diff --git a/tools/dom/templates/html/impl/impl_DirectoryEntry.darttemplate b/tools/dom/templates/html/impl/impl_DirectoryEntry.darttemplate
index 98cced4..1e31f90 100644
--- a/tools/dom/templates/html/impl/impl_DirectoryEntry.darttemplate
+++ b/tools/dom/templates/html/impl/impl_DirectoryEntry.darttemplate
@@ -19,6 +19,9 @@
DirectoryReader createReader() {
DirectoryReader reader = _createReader();
applyExtension('DirectoryReader', reader);
+ applyExtension('WebKitDirectoryReader', reader);
+ applyExtension('webkitFileSystemDirectoryReader', reader);
+ applyExtension('FileSystemDirectoryReader', reader);
return reader;
}
diff --git a/tools/dom/templates/html/impl/impl_DirectoryReader.darttemplate b/tools/dom/templates/html/impl/impl_DirectoryReader.darttemplate
index b643159..ab4f199 100644
--- a/tools/dom/templates/html/impl/impl_DirectoryReader.darttemplate
+++ b/tools/dom/templates/html/impl/impl_DirectoryReader.darttemplate
@@ -12,11 +12,18 @@
_readEntries((values) {
values.forEach((value) {
applyExtension('Entry', value);
+ applyExtension('webkitFileSystemEntry', value);
+ applyExtension('FileSystemEntry', value);
Entry entry = value as Entry;
- if (entry.isFile$NULLASSERT)
+ if (entry.isFile$NULLASSERT) {
applyExtension('FileEntry', entry);
- else if (entry.isDirectory$NULLASSERT)
+ applyExtension('webkitFileSystemFileEntry', entry);
+ applyExtension('FileSystemFileEntry', entry);
+ } else if (entry.isDirectory$NULLASSERT) {
applyExtension('DirectoryEntry', entry);
+ applyExtension('webkitFileSystemDirectoryEntry', entry);
+ applyExtension('FileSystemDirectoryEntry', entry);
+ }
});
completer.complete(new List<Entry>.from(values));
}, (error) {