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

Side by Side Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 11647044: Adding annotation for partial browser support and example implementation for MutationObservers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added experimental annotation to MutationObserver. Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library html; 1 library html;
2 2
3 import 'dart:collection'; 3 import 'dart:collection';
4 import 'dart:html_common'; 4 import 'dart:html_common';
5 import 'dart:indexed_db'; 5 import 'dart:indexed_db';
6 import 'dart:isolate'; 6 import 'dart:isolate';
7 import 'dart:json'; 7 import 'dart:json';
8 import 'dart:svg' as svg; 8 import 'dart:svg' as svg;
9 import 'dart:web_audio' as web_audio; 9 import 'dart:web_audio' as web_audio;
10 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 10 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
(...skipping 13247 matching lines...) Expand 10 before | Expand all | Expand 10 after
13258 13258
13259 /// @domName MutationEvent.initMutationEvent; @docsEditable true 13259 /// @domName MutationEvent.initMutationEvent; @docsEditable true
13260 void initMutationEvent(String type, bool canBubble, bool cancelable, Node rela tedNode, String prevValue, String newValue, String attrName, int attrChange) nat ive; 13260 void initMutationEvent(String type, bool canBubble, bool cancelable, Node rela tedNode, String prevValue, String newValue, String attrName, int attrChange) nat ive;
13261 } 13261 }
13262 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 13262 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
13263 // for details. All rights reserved. Use of this source code is governed by a 13263 // for details. All rights reserved. Use of this source code is governed by a
13264 // BSD-style license that can be found in the LICENSE file. 13264 // BSD-style license that can be found in the LICENSE file.
13265 13265
13266 13266
13267 /// @domName MutationObserver 13267 /// @domName MutationObserver
13268 @SupportedBrowser(SupportedBrowser.CHROME)
13269 @SupportedBrowser(SupportedBrowser.FIREFOX)
13270 @SupportedBrowser(SupportedBrowser.SAFARI)
13271 @Experimental()
13268 class MutationObserver native "*MutationObserver" { 13272 class MutationObserver native "*MutationObserver" {
13269 13273
13270 ///@docsEditable true 13274 ///@docsEditable true
13271 factory MutationObserver(MutationCallback callback) => _MutationObserverFactor yProvider.createMutationObserver(callback); 13275 factory MutationObserver(MutationCallback callback) => _MutationObserverFactor yProvider.createMutationObserver(callback);
13272 13276
13273 /// @domName MutationObserver.disconnect; @docsEditable true 13277 /// @domName MutationObserver.disconnect; @docsEditable true
13274 void disconnect() native; 13278 void disconnect() native;
13275 13279
13276 /// @domName MutationObserver._observe; @docsEditable true 13280 /// @domName MutationObserver._observe; @docsEditable true
13277 void _observe(Node target, Map options) { 13281 void _observe(Node target, Map options) {
13278 var options_1 = convertDartToNative_Dictionary(options); 13282 var options_1 = convertDartToNative_Dictionary(options);
13279 __observe_1(target, options_1); 13283 __observe_1(target, options_1);
13280 return; 13284 return;
13281 } 13285 }
13282 @JSName('observe') 13286 @JSName('observe')
13283 void __observe_1(Node target, options) native; 13287 void __observe_1(Node target, options) native;
13284 13288
13285 /// @domName MutationObserver.takeRecords; @docsEditable true 13289 /// @domName MutationObserver.takeRecords; @docsEditable true
13286 List<MutationRecord> takeRecords() native; 13290 List<MutationRecord> takeRecords() native;
13287 13291
13292 /**
13293 * Checks to see if the mutation observer API is supported on the current
13294 * platform.
13295 */
13296 static bool get supported {
13297 return JS('bool',
13298 '!!(window.MutationObserver || window.WebKitMutationObserver)');
13299 }
13300
13288 void observe(Node target, 13301 void observe(Node target,
13289 {Map options, 13302 {Map options,
13290 bool childList, 13303 bool childList,
13291 bool attributes, 13304 bool attributes,
13292 bool characterData, 13305 bool characterData,
13293 bool subtree, 13306 bool subtree,
13294 bool attributeOldValue, 13307 bool attributeOldValue,
13295 bool characterDataOldValue, 13308 bool characterDataOldValue,
13296 List<String> attributeFilter}) { 13309 List<String> attributeFilter}) {
13297 13310
(...skipping 11375 matching lines...) Expand 10 before | Expand all | Expand 10 after
24673 class _MeasurementRequest<T> { 24686 class _MeasurementRequest<T> {
24674 final ComputeValue computeValue; 24687 final ComputeValue computeValue;
24675 final Completer<T> completer; 24688 final Completer<T> completer;
24676 Object value; 24689 Object value;
24677 bool exception = false; 24690 bool exception = false;
24678 _MeasurementRequest(this.computeValue, this.completer); 24691 _MeasurementRequest(this.computeValue, this.completer);
24679 } 24692 }
24680 24693
24681 typedef void _MeasurementCallback(); 24694 typedef void _MeasurementCallback();
24682 24695
24683
24684 /** 24696 /**
24685 * This class attempts to invoke a callback as soon as the current event stack 24697 * This class attempts to invoke a callback as soon as the current event stack
24686 * unwinds, but before the browser repaints. 24698 * unwinds, but before the browser repaints.
24687 */ 24699 */
24688 abstract class _MeasurementScheduler { 24700 abstract class _MeasurementScheduler {
24689 bool _nextMeasurementFrameScheduled = false; 24701 bool _nextMeasurementFrameScheduled = false;
24690 _MeasurementCallback _callback; 24702 _MeasurementCallback _callback;
24691 24703
24692 _MeasurementScheduler(this._callback); 24704 _MeasurementScheduler(this._callback);
24693 24705
24694 /** 24706 /**
24695 * Creates the best possible measurement scheduler for the current platform. 24707 * Creates the best possible measurement scheduler for the current platform.
24696 */ 24708 */
24697 factory _MeasurementScheduler.best(_MeasurementCallback callback) { 24709 factory _MeasurementScheduler.best(_MeasurementCallback callback) {
24698 if (_isMutationObserverSupported()) { 24710 if (MutationObserver.supported) {
24699 return new _MutationObserverScheduler(callback); 24711 return new _MutationObserverScheduler(callback);
24700 } 24712 }
24701 return new _PostMessageScheduler(callback); 24713 return new _PostMessageScheduler(callback);
24702 } 24714 }
24703 24715
24704 /** 24716 /**
24705 * Schedules a measurement callback if one has not been scheduled already. 24717 * Schedules a measurement callback if one has not been scheduled already.
24706 */ 24718 */
24707 void maybeSchedule() { 24719 void maybeSchedule() {
24708 if (this._nextMeasurementFrameScheduled) { 24720 if (this._nextMeasurementFrameScheduled) {
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
25517 25529
25518 25530
25519 static _get(p, m) => JS('var', '#[#]', p, m); 25531 static _get(p, m) => JS('var', '#[#]', p, m);
25520 static _set(p, m, v) => JS('void', '#[#] = #', p, m, v); 25532 static _set(p, m, v) => JS('void', '#[#] = #', p, m, v);
25521 } 25533 }
25522 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 25534 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
25523 // for details. All rights reserved. Use of this source code is governed by a 25535 // for details. All rights reserved. Use of this source code is governed by a
25524 // BSD-style license that can be found in the LICENSE file. 25536 // BSD-style license that can be found in the LICENSE file.
25525 25537
25526 25538
25527 /**
25528 * Checks to see if the mutation observer API is supported on the current
25529 * platform.
25530 */
25531 bool _isMutationObserverSupported() =>
25532 JS('bool', '!!(window.MutationObserver || window.WebKitMutationObserver)');
25533 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
25534 // for details. All rights reserved. Use of this source code is governed by a
25535 // BSD-style license that can be found in the LICENSE file.
25536
25537
25538 class _TypedArrayFactoryProvider { 25539 class _TypedArrayFactoryProvider {
25539 25540
25540 static Float32Array createFloat32Array(int length) => _F32(length); 25541 static Float32Array createFloat32Array(int length) => _F32(length);
25541 static Float32Array createFloat32Array_fromList(List<num> list) => 25542 static Float32Array createFloat32Array_fromList(List<num> list) =>
25542 _F32(ensureNative(list)); 25543 _F32(ensureNative(list));
25543 static Float32Array createFloat32Array_fromBuffer(ArrayBuffer buffer, 25544 static Float32Array createFloat32Array_fromBuffer(ArrayBuffer buffer,
25544 [int byteOffset = 0, int length]) { 25545 [int byteOffset = 0, int length]) {
25545 if (length == null) return _F32_2(buffer, byteOffset); 25546 if (length == null) return _F32_2(buffer, byteOffset);
25546 return _F32_3(buffer, byteOffset, length); 25547 return _F32_3(buffer, byteOffset, length);
25547 } 25548 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
25727 T next() { 25728 T next() {
25728 if (!hasNext) { 25729 if (!hasNext) {
25729 throw new StateError("No more elements"); 25730 throw new StateError("No more elements");
25730 } 25731 }
25731 return _array[_pos++]; 25732 return _array[_pos++];
25732 } 25733 }
25733 25734
25734 final List<T> _array; 25735 final List<T> _array;
25735 int _pos; 25736 int _pos;
25736 } 25737 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698