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

Unified Diff: tools/dom/templates/html/dart2js/impl_ArrayBuffer.darttemplate

Issue 11757002: Fixing ArrayBuffer et al on IE. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 12 months 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
Index: tools/dom/templates/html/dart2js/impl_ArrayBuffer.darttemplate
diff --git a/tools/dom/templates/html/dart2js/impl_ArrayBuffer.darttemplate b/tools/dom/templates/html/dart2js/impl_ArrayBuffer.darttemplate
new file mode 100644
index 0000000000000000000000000000000000000000..ab440b0cac2e351761e0eb4ae4d2585aa0398018
--- /dev/null
+++ b/tools/dom/templates/html/dart2js/impl_ArrayBuffer.darttemplate
@@ -0,0 +1,38 @@
+// Copyright (c) 2013, 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.
+
+part of $LIBRARYNAME;
+
+/// @domName $DOMNAME$ANNOTATIONS
+class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
+$!MEMBERS
+ /// @domName ArrayBuffer.slice;
+ ArrayBuffer slice(int begin, [int end]) {
+ // IE10 supports ArrayBuffers but does not have the slice method.
+ if (JS('bool', '!!#.slice', this)) {
+ if (?end) {
+ return JS('ArrayBuffer', '#.slice(#, #)', this, begin, end);
+ }
+ return JS('ArrayBuffer', '#.slice(#)', this, begin);
+ } else {
+ var start = begin;
+ // Negative values go from end.
+ if (start < 0) {
+ start = this.byteLength + start;
+ }
+ var finish = ?end ? min(end, byteLength) : byteLength;
+ if (finish < 0) {
+ finish = this.byteLength + finish;
+ }
+ var length = max(finish - start, 0);
+
+ var clone = new Int8Array(length);
+ var source = new Int8Array.fromBuffer(this, start);
+ for (var i = 0; i < length; ++i) {
+ clone[i] = source[i];
+ }
+ return clone.buffer;
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698