diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-07-05 06:24:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-05 06:24:46 -0700 |
commit | 87c77725279ba3f1b612e27fccf353c81eae17b8 (patch) | |
tree | 6c808ba9d7dd60914cf5b156906e59e0c49e6535 /components/script/dom/filereader.rs | |
parent | 9860584edf8e1ae4783d6ac4d75bda6b06da2057 (diff) | |
parent | ab14777312b6bc0e21736f907bc22364dea143d3 (diff) | |
download | servo-87c77725279ba3f1b612e27fccf353c81eae17b8.tar.gz servo-87c77725279ba3f1b612e27fccf353c81eae17b8.zip |
Auto merge of #12258 - izgzhen:remove-data-slice, r=Manishearth
Remove DataSlice, fix #12249
r? @Manishearth
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #12249
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- 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/12258)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/filereader.rs')
-rw-r--r-- | components/script/dom/filereader.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs index 9e3f4674fa1..634f2facafe 100644 --- a/components/script/dom/filereader.rs +++ b/components/script/dom/filereader.rs @@ -13,7 +13,7 @@ use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{Reflectable, reflect_dom_object}; use dom::bindings::str::DOMString; -use dom::blob::{Blob, DataSlice}; +use dom::blob::Blob; use dom::domexception::{DOMErrorName, DOMException}; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::eventtarget::EventTarget; @@ -27,6 +27,7 @@ use script_runtime::ScriptThreadEventCategory::FileRead; use script_runtime::{ScriptChan, CommonScriptMsg}; use script_thread::Runnable; use std::cell::Cell; +use std::sync::Arc; use string_cache::Atom; use util::thread::spawn_named; @@ -160,7 +161,7 @@ impl FileReader { // https://w3c.github.io/FileAPI/#dfn-readAsText pub fn process_read_eof(filereader: TrustedFileReader, gen_id: GenerationId, - data: ReadMetaData, blob_contents: DataSlice) { + data: ReadMetaData, blob_contents: Arc<Vec<u8>>) { let fr = filereader.root(); macro_rules! return_on_abort( @@ -176,12 +177,11 @@ impl FileReader { fr.change_ready_state(FileReaderReadyState::Done); // Step 8.2 - let bytes = blob_contents.get_bytes(); let output = match data.function { FileReaderFunction::ReadAsDataUrl => - FileReader::perform_readasdataurl(data, bytes), + FileReader::perform_readasdataurl(data, &blob_contents), FileReaderFunction::ReadAsText => - FileReader::perform_readastext(data, bytes), + FileReader::perform_readastext(data, &blob_contents), }; *fr.result.borrow_mut() = Some(output); @@ -349,7 +349,7 @@ impl FileReader { self.change_ready_state(FileReaderReadyState::Loading); // Step 4 - let blob_contents = blob.get_slice_or_empty(); + let blob_contents = Arc::new(blob.get_bytes().unwrap_or(vec![])); let type_ = blob.Type(); @@ -376,7 +376,7 @@ pub enum FileReaderEvent { ProcessRead(TrustedFileReader, GenerationId), ProcessReadData(TrustedFileReader, GenerationId), ProcessReadError(TrustedFileReader, GenerationId, DOMErrorName), - ProcessReadEOF(TrustedFileReader, GenerationId, ReadMetaData, DataSlice) + ProcessReadEOF(TrustedFileReader, GenerationId, ReadMetaData, Arc<Vec<u8>>) } impl Runnable for FileReaderEvent { @@ -400,7 +400,7 @@ impl Runnable for FileReaderEvent { } // https://w3c.github.io/FileAPI/#thread-read-operation -fn perform_annotated_read_operation(gen_id: GenerationId, data: ReadMetaData, blob_contents: DataSlice, +fn perform_annotated_read_operation(gen_id: GenerationId, data: ReadMetaData, blob_contents: Arc<Vec<u8>>, filereader: TrustedFileReader, script_chan: Box<ScriptChan + Send>) { let chan = &script_chan; // Step 4 |