aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-05-01 22:13:20 -0700
committerbors-servo <lbergstrom+bors@mozilla.com>2016-05-01 22:13:20 -0700
commit14926529c9f38a014140d75ca06cc46d1a2b72ba (patch)
tree61dde0a7176515da914060c0b0b3e58d5429e436
parentca05f03ea3a3a48382c021d300e710e6e4a96423 (diff)
parente0f3cdafe121055c2494197e2724ddd90a6e9479 (diff)
downloadservo-14926529c9f38a014140d75ca06cc46d1a2b72ba.tar.gz
servo-14926529c9f38a014140d75ca06cc46d1a2b72ba.zip
Auto merge of #10873 - izgzhen:blob, r=Manishearth
Fixes related to File API Fixing problems I met when trying to resolve https://github.com/servo/servo/issues/10851, but most of changes here are simple fixes. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10873) <!-- Reviewable:end -->
-rw-r--r--components/script/dom/blob.rs4
-rw-r--r--components/script/dom/file.rs11
-rw-r--r--components/script/dom/filelist.rs6
3 files changed, 15 insertions, 6 deletions
diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs
index 49fc47e8a68..74ddce1609a 100644
--- a/components/script/dom/blob.rs
+++ b/components/script/dom/blob.rs
@@ -66,6 +66,10 @@ impl DataSlice {
&self.bytes[self.bytes_start..self.bytes_end]
}
+ pub fn get_all_bytes(&self) -> Arc<Vec<u8>> {
+ self.bytes.clone()
+ }
+
pub fn size(&self) -> u64 {
(self.bytes_end as u64) - (self.bytes_start as u64)
}
diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs
index 8628c0ee6f6..598537cbe00 100644
--- a/components/script/dom/file.rs
+++ b/components/script/dom/file.rs
@@ -18,14 +18,15 @@ pub struct File {
}
impl File {
- fn new_inherited(_file_bits: &Blob, name: DOMString) -> File {
+ fn new_inherited(file_bits: &Blob, name: DOMString) -> File {
+ // TODO: FilePropertyBag
+ let mut bytes = Vec::new();
+ bytes.extend_from_slice(file_bits.get_data().get_all_bytes().as_slice());
+
File {
- //TODO: get type from the underlying filesystem instead of "".to_string()
- blob: Blob::new_inherited(Arc::new(Vec::new()), None, None, ""),
+ blob: Blob::new_inherited(Arc::new(bytes), None, None, ""),
name: name,
}
- // XXXManishearth Once Blob is able to store data
- // the relevant subfields of file_bits should be copied over
}
pub fn new(global: GlobalRef, file_bits: &Blob, name: DOMString) -> Root<File> {
diff --git a/components/script/dom/filelist.rs b/components/script/dom/filelist.rs
index e60258fa330..ef49e88da6d 100644
--- a/components/script/dom/filelist.rs
+++ b/components/script/dom/filelist.rs
@@ -40,7 +40,11 @@ impl FileListMethods for FileList {
// https://w3c.github.io/FileAPI/#dfn-item
fn Item(&self, index: u32) -> Option<Root<File>> {
- Some(Root::from_ref(&*(self.list[index as usize])))
+ if (index as usize) < self.list.len() {
+ Some(Root::from_ref(&*(self.list[index as usize])))
+ } else {
+ None
+ }
}
// check-tidy: no specs after this line