aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-12-27 06:56:15 -0800
committerGitHub <noreply@github.com>2016-12-27 06:56:15 -0800
commiteb64edec848f570bc89ac87cb185ecd87c16e005 (patch)
tree6d545cc4422f101a233c76bbe871bc39104b786e /components/script
parent93e3c3f4241d09521005725699cf1ed1e2ba8f46 (diff)
parent40fa021fc115fdfa61a34f3bfc5f94cff4899d21 (diff)
downloadservo-eb64edec848f570bc89ac87cb185ecd87c16e005.tar.gz
servo-eb64edec848f570bc89ac87cb185ecd87c16e005.zip
Auto merge of #14727 - zaynetro:textdecoder-use-typedarray, r=jdm
Use typed array in TextDecoder::Decode <!-- Please describe your changes on the following line: --> Use typed array API in TextDecoder::Decode --- <!-- 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 #14674 <!-- Either: --> - [x] These changes do not require tests because no new methods were introduced <!-- 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14727) <!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/textdecoder.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/components/script/dom/textdecoder.rs b/components/script/dom/textdecoder.rs
index abb2f0c4195..1c3ba6cf082 100644
--- a/components/script/dom/textdecoder.rs
+++ b/components/script/dom/textdecoder.rs
@@ -4,7 +4,6 @@
use dom::bindings::codegen::Bindings::TextDecoderBinding;
use dom::bindings::codegen::Bindings::TextDecoderBinding::TextDecoderMethods;
-use dom::bindings::conversions::array_buffer_view_data;
use dom::bindings::error::{Error, Fallible};
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
@@ -85,9 +84,10 @@ impl TextDecoderMethods for TextDecoder {
None => return Ok(USVString("".to_owned())),
};
- let data = match array_buffer_view_data::<u8>(input) {
- Some(data) => data,
- None => {
+ typedarray!(in(_cx) let data_res: ArrayBufferView = input);
+ let mut data = match data_res {
+ Ok(data) => data,
+ Err(_) => {
return Err(Error::Type("Argument to TextDecoder.decode is not an ArrayBufferView".to_owned()));
}
};
@@ -98,7 +98,7 @@ impl TextDecoderMethods for TextDecoder {
DecoderTrap::Replace
};
- match self.encoding.decode(data, trap) {
+ match self.encoding.decode(data.as_slice(), trap) {
Ok(s) => Ok(USVString(s)),
Err(_) => Err(Error::Type("Decoding failed".to_owned())),
}