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

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

Issue 11453027: Fixed a lot of dartanalyzer static analysis issues with the html lib. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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') | sdk/lib/html/src/Isolates.dart » ('J')
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 5514 matching lines...) Expand 10 before | Expand all | Expand 10 after
5525 5525
5526 /// @domName DirectoryReaderSync.readEntries; @docsEditable true 5526 /// @domName DirectoryReaderSync.readEntries; @docsEditable true
5527 @Returns('_EntryArraySync') @Creates('_EntryArraySync') 5527 @Returns('_EntryArraySync') @Creates('_EntryArraySync')
5528 List<EntrySync> readEntries() native; 5528 List<EntrySync> readEntries() native;
5529 } 5529 }
5530 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 5530 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
5531 // for details. All rights reserved. Use of this source code is governed by a 5531 // for details. All rights reserved. Use of this source code is governed by a
5532 // BSD-style license that can be found in the LICENSE file. 5532 // BSD-style license that can be found in the LICENSE file.
5533 5533
5534 5534
5535 /**
5536 * Represents an HTML <div> element.
5537 *
5538 * The [DivElement] is a generic container for content and does not have any
5539 * special significance. It is functionally similar to [SpanElement].
5540 *
5541 * The [DivElement] is a block-level element, as opposed to [SpanElement],
5542 * which is an inline-level element.
5543 *
5544 * Example usage:
5545 *
5546 * DivElement div = new DivElement();
5547 * div.text = 'Here's my new DivElem
5548 * document.body.elements.add(elem);
5549 *
5550 * See also:
5551 *
5552 * * [HTML <div> element](http://www.w3.org/TR/html-markup/div.html) from W3C.
5553 * * [Block-level element](http://www.w3.org/TR/CSS2/visuren.html#block-boxes) f rom W3C.
5554 * * [Inline-level element](http://www.w3.org/TR/CSS2/visuren.html#inline-boxes) from W3C.
5555 */
5556 /// @domName HTMLDivElement; @docsEditable true 5535 /// @domName HTMLDivElement; @docsEditable true
5557 class DivElement extends Element implements Element native "*HTMLDivElement" { 5536 class DivElement extends Element implements Element native "*HTMLDivElement" {
5558 5537
5559 factory DivElement() => document.$dom_createElement("div"); 5538 factory DivElement() => document.$dom_createElement("div");
5560 } 5539 }
5561 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 5540 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
5562 // for details. All rights reserved. Use of this source code is governed by a 5541 // for details. All rights reserved. Use of this source code is governed by a
5563 // BSD-style license that can be found in the LICENSE file. 5542 // BSD-style license that can be found in the LICENSE file.
5564 5543
5565 5544
(...skipping 18 matching lines...) Expand all
5584 /// @domName Document.body; @docsEditable true 5563 /// @domName Document.body; @docsEditable true
5585 @JSName('body') 5564 @JSName('body')
5586 Element $dom_body; 5565 Element $dom_body;
5587 5566
5588 /// @domName Document.charset; @docsEditable true 5567 /// @domName Document.charset; @docsEditable true
5589 String charset; 5568 String charset;
5590 5569
5591 /// @domName Document.cookie; @docsEditable true 5570 /// @domName Document.cookie; @docsEditable true
5592 String cookie; 5571 String cookie;
5593 5572
5594 /// Returns the [Window] associated with the document.
5595 /// @domName Document.defaultView; @docsEditable true 5573 /// @domName Document.defaultView; @docsEditable true
5596 Window get window => _convertNativeToDart_Window(this._window); 5574 Window get window => _convertNativeToDart_Window(this._window);
5597 @JSName('defaultView') 5575 @JSName('defaultView')
5598 @Creates('LocalWindow|=Object') @Returns('LocalWindow|=Object') 5576 @Creates('LocalWindow|=Object') @Returns('LocalWindow|=Object')
5599 final dynamic _window; 5577 final dynamic _window;
5600 5578
5601 /// @domName Document.documentElement; @docsEditable true 5579 /// @domName Document.documentElement; @docsEditable true
5602 final Element documentElement; 5580 final Element documentElement;
5603 5581
5604 /// @domName Document.domain; @docsEditable true 5582 /// @domName Document.domain; @docsEditable true
(...skipping 6591 matching lines...) Expand 10 before | Expand all | Expand 10 after
12196 final int totalJSHeapSize; 12174 final int totalJSHeapSize;
12197 12175
12198 /// @domName MemoryInfo.usedJSHeapSize; @docsEditable true 12176 /// @domName MemoryInfo.usedJSHeapSize; @docsEditable true
12199 final int usedJSHeapSize; 12177 final int usedJSHeapSize;
12200 } 12178 }
12201 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 12179 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
12202 // for details. All rights reserved. Use of this source code is governed by a 12180 // for details. All rights reserved. Use of this source code is governed by a
12203 // BSD-style license that can be found in the LICENSE file. 12181 // BSD-style license that can be found in the LICENSE file.
12204 12182
12205 12183
12206 /**
12207 * An HTML <menu> element.
12208 *
12209 * A <menu> element represents an unordered list of menu commands.
12210 *
12211 * See also:
12212 *
12213 * * [Menu Element](https://developer.mozilla.org/en-US/docs/HTML/Element/menu) from MDN.
12214 * * [Menu Element](http://www.w3.org/TR/html5/the-menu-element.html#the-menu-e lement) from the W3C.
12215 */
12216 /// @domName HTMLMenuElement; @docsEditable true 12184 /// @domName HTMLMenuElement; @docsEditable true
12217 class MenuElement extends Element implements Element native "*HTMLMenuElement" { 12185 class MenuElement extends Element implements Element native "*HTMLMenuElement" {
12218 12186
12219 factory MenuElement() => document.$dom_createElement("menu"); 12187 factory MenuElement() => document.$dom_createElement("menu");
12220 } 12188 }
12221 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 12189 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
12222 // for details. All rights reserved. Use of this source code is governed by a 12190 // for details. All rights reserved. Use of this source code is governed by a
12223 // BSD-style license that can be found in the LICENSE file. 12191 // BSD-style license that can be found in the LICENSE file.
12224 12192
12225 12193
(...skipping 9491 matching lines...) Expand 10 before | Expand all | Expand 10 after
21717 * window.location('http://www.mysite.com', 'foo'); 21685 * window.location('http://www.mysite.com', 'foo');
21718 * // Does not close this window, as the history has changed. 21686 * // Does not close this window, as the history has changed.
21719 * window.close(); 21687 * window.close();
21720 * print(window.closed()); // 'false' 21688 * print(window.closed()); // 'false'
21721 * 21689 *
21722 * See also: 21690 * See also:
21723 * 21691 *
21724 * * [Window close discussion](http://www.w3.org/TR/html5/browsers.html#dom-wi ndow-close) from the W3C 21692 * * [Window close discussion](http://www.w3.org/TR/html5/browsers.html#dom-wi ndow-close) from the W3C
21725 */ 21693 */
21726 void close(); 21694 void close();
21727 void postMessage(var message, String targetOrigin, [List messagePorts = null]) ; 21695 void postMessage(var message, String targetOrigin, [List messagePorts]);
21728 } 21696 }
21729 21697
21730 abstract class Location { 21698 abstract class Location {
21731 void set href(String val); 21699 void set href(String val);
21732 } 21700 }
21733 21701
21734 abstract class History { 21702 abstract class History {
21735 void back(); 21703 void back();
21736 void forward(); 21704 void forward();
21737 void go(int distance); 21705 void go(int distance);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
22048 */ 22016 */
22049 List<KeyboardEvent> _keyDownList; 22017 List<KeyboardEvent> _keyDownList;
22050 22018
22051 /** The set of functions that wish to be notified when a KeyEvent happens. */ 22019 /** The set of functions that wish to be notified when a KeyEvent happens. */
22052 List<Function> _callbacks; 22020 List<Function> _callbacks;
22053 22021
22054 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */ 22022 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */
22055 String _type; 22023 String _type;
22056 22024
22057 /** The element we are watching for events to happen on. */ 22025 /** The element we are watching for events to happen on. */
22058 EventTarget _target; 22026 Element _target;
22059 22027
22060 // The distance to shift from upper case alphabet Roman letters to lower case. 22028 // The distance to shift from upper case alphabet Roman letters to lower case.
22061 final int _ROMAN_ALPHABET_OFFSET = "a".charCodes[0] - "A".charCodes[0]; 22029 final int _ROMAN_ALPHABET_OFFSET = "a".charCodes[0] - "A".charCodes[0];
22062 22030
22063 // Instance members referring to the internal event handlers because closures 22031 // Instance members referring to the internal event handlers because closures
22064 // are not hashable. 22032 // are not hashable.
22065 var _keyUp, _keyDown, _keyPress; 22033 var _keyUp, _keyDown, _keyPress;
22066 22034
22067 /** 22035 /**
22068 * An enumeration of key identifiers currently part of the W3C draft for DOM3 22036 * An enumeration of key identifiers currently part of the W3C draft for DOM3
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
22107 22075
22108 /** Named constructor to add an onKeyDown event listener to our handler. */ 22076 /** Named constructor to add an onKeyDown event listener to our handler. */
22109 KeyboardEventController.keydown(EventTarget target) { 22077 KeyboardEventController.keydown(EventTarget target) {
22110 _KeyboardEventController(target, 'keydown'); 22078 _KeyboardEventController(target, 'keydown');
22111 } 22079 }
22112 22080
22113 /** 22081 /**
22114 * General constructor, performs basic initialization for our improved 22082 * General constructor, performs basic initialization for our improved
22115 * KeyboardEvent controller. 22083 * KeyboardEvent controller.
22116 */ 22084 */
22117 _KeyboardEventController(EventTarget target, String type) { 22085 _KeyboardEventController(Element target, String type) {
22118 _callbacks = []; 22086 _callbacks = [];
22119 _type = type; 22087 _type = type;
22120 _target = target; 22088 _target = target;
22121 _keyDown = processKeyDown; 22089 _keyDown = processKeyDown;
22122 _keyUp = processKeyUp; 22090 _keyUp = processKeyUp;
22123 _keyPress = processKeyPress; 22091 _keyPress = processKeyPress;
22124 } 22092 }
22125 22093
22126 /** 22094 /**
22127 * Hook up all event listeners under the covers so we can estimate keycodes 22095 * Hook up all event listeners under the covers so we can estimate keycodes
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
23296 23264
23297 visitJsSendPortSync(_JsSendPortSync x) { 23265 visitJsSendPortSync(_JsSendPortSync x) {
23298 return [ 'sendport', 'nativejs', x._id ]; 23266 return [ 'sendport', 'nativejs', x._id ];
23299 } 23267 }
23300 23268
23301 visitLocalSendPortSync(_LocalSendPortSync x) { 23269 visitLocalSendPortSync(_LocalSendPortSync x) {
23302 return [ 'sendport', 'dart', 23270 return [ 'sendport', 'dart',
23303 ReceivePortSync._isolateId, x._receivePort._portId ]; 23271 ReceivePortSync._isolateId, x._receivePort._portId ];
23304 } 23272 }
23305 23273
23274 visitSendPort(SendPort x) {
23275 throw new UnimplementedError('Asynchronous send port not yet implemented.');
23276 }
23277
23306 visitRemoteSendPortSync(_RemoteSendPortSync x) { 23278 visitRemoteSendPortSync(_RemoteSendPortSync x) {
23307 return [ 'sendport', 'dart', 23279 return [ 'sendport', 'dart',
23308 x._receivePort._isolateId, x._receivePort._portId ]; 23280 x._isolateId, x._portId ];
23309 } 23281 }
23310 } 23282 }
23311 23283
23312 _deserialize(var message) { 23284 _deserialize(var message) {
23313 return new _JsDeserializer().deserialize(message); 23285 return new _JsDeserializer().deserialize(message);
23314 } 23286 }
23315 23287
23316 23288
23317 class _JsDeserializer extends _Deserializer { 23289 class _JsDeserializer extends _Deserializer {
23318 23290
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
23356 int _portId; 23328 int _portId;
23357 _RemoteSendPortSync(this._isolateId, this._portId); 23329 _RemoteSendPortSync(this._isolateId, this._portId);
23358 23330
23359 callSync(var message) { 23331 callSync(var message) {
23360 var serialized = _serialize(message); 23332 var serialized = _serialize(message);
23361 var result = _call(_isolateId, _portId, serialized); 23333 var result = _call(_isolateId, _portId, serialized);
23362 return _deserialize(result); 23334 return _deserialize(result);
23363 } 23335 }
23364 23336
23365 static _call(int isolateId, int portId, var message) { 23337 static _call(int isolateId, int portId, var message) {
23366 var target = 'dart-port-$isolateId-$portId'; 23338 var target = 'dart-port-$isolateId-$portId';
23367 // TODO(vsm): Make this re-entrant. 23339 // TODO(vsm): Make this re-entrant.
23368 // TODO(vsm): Set this up set once, on the first call. 23340 // TODO(vsm): Set this up set once, on the first call.
23369 var source = '$target-result'; 23341 var source = '$target-result';
23370 var result = null; 23342 var result = null;
23371 var listener = (Event e) { 23343 var listener = (Event e) {
23372 result = JSON.parse(_getPortSyncEventData(e)); 23344 result = JSON.parse(_getPortSyncEventData(e));
23373 }; 23345 };
23374 window.on[source].add(listener); 23346 window.on[source].add(listener);
23375 _dispatchEvent(target, [source, message]); 23347 _dispatchEvent(target, [source, message]);
23376 window.on[source].remove(listener); 23348 window.on[source].remove(listener);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
23421 _portIdCount = 0; 23393 _portIdCount = 0;
23422 _portMap = new Map<int, ReceivePortSync>(); 23394 _portMap = new Map<int, ReceivePortSync>();
23423 } 23395 }
23424 _portId = _portIdCount++; 23396 _portId = _portIdCount++;
23425 _portMap[_portId] = this; 23397 _portMap[_portId] = this;
23426 } 23398 }
23427 23399
23428 static int get _isolateId { 23400 static int get _isolateId {
23429 // TODO(vsm): Make this coherent with existing isolate code. 23401 // TODO(vsm): Make this coherent with existing isolate code.
23430 if (_cachedIsolateId == null) { 23402 if (_cachedIsolateId == null) {
23431 _cachedIsolateId = _getNewIsolateId(); 23403 _cachedIsolateId = _getNewIsolateId();
23432 } 23404 }
23433 return _cachedIsolateId; 23405 return _cachedIsolateId;
23434 } 23406 }
23435 23407
23436 static String _getListenerName(isolateId, portId) => 23408 static String _getListenerName(isolateId, portId) =>
23437 'dart-port-$isolateId-$portId'; 23409 'dart-port-$isolateId-$portId';
23438 String get _listenerName => _getListenerName(_isolateId, _portId); 23410 String get _listenerName => _getListenerName(_isolateId, _portId);
23439 23411
23440 void receive(callback(var message)) { 23412 void receive(callback(var message)) {
23441 _callback = callback; 23413 _callback = callback;
23442 if (_listener == null) { 23414 if (_listener == null) {
23443 _listener = (Event e) { 23415 _listener = (Event e) {
23444 var data = JSON.parse(_getPortSyncEventData(e)); 23416 var data = JSON.parse(_getPortSyncEventData(e));
23445 var replyTo = data[0]; 23417 var replyTo = data[0];
23446 var message = _deserialize(data[1]); 23418 var message = _deserialize(data[1]);
23447 var result = _callback(message); 23419 var result = _callback(message);
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
24214 void stopPropagation() => _parent.stopPropagation(); 24186 void stopPropagation() => _parent.stopPropagation();
24215 void $dom_initUIEvent(String type, bool canBubble, bool cancelable, 24187 void $dom_initUIEvent(String type, bool canBubble, bool cancelable,
24216 LocalWindow view, int detail) { 24188 LocalWindow view, int detail) {
24217 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent."); 24189 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent.");
24218 } 24190 }
24219 void $dom_initEvent(String eventTypeArg, bool canBubbleArg, 24191 void $dom_initEvent(String eventTypeArg, bool canBubbleArg,
24220 bool cancelableArg) { 24192 bool cancelableArg) {
24221 throw new UnsupportedError("Cannot initialize an Event from a KeyEvent."); 24193 throw new UnsupportedError("Cannot initialize an Event from a KeyEvent.");
24222 } 24194 }
24223 String get _shadowKeyIdentifier => JS('String', '#.keyIdentifier', _parent); 24195 String get _shadowKeyIdentifier => JS('String', '#.keyIdentifier', _parent);
24196
24197 int get $dom_charCode => charCode;
24198 int get $dom_keyCode => keyCode;
24199 EventTarget get target => _parent.target;
24200 String get $dom_keyIdentifier {
24201 throw new UnsupportedError("keyIdentifier is deprecated");
24202 }
24203 void $dom_initKeyboardEvent(String type, bool canBubble, bool cancelable,
24204 LocalWindow view, String keyIdentifier, int keyLocation, bool ctrlKey,
24205 bool altKey, bool shiftKey, bool metaKey,
24206 bool altGraphKey) {
24207 throw new UnsupportedError("Cannot initialize a KeyboardEvent from a KeyEven t.");
24208 }
24224 } 24209 }
24225 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 24210 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
24226 // for details. All rights reserved. Use of this source code is governed by a 24211 // for details. All rights reserved. Use of this source code is governed by a
24227 // BSD-style license that can be found in the LICENSE file. 24212 // BSD-style license that can be found in the LICENSE file.
24228 24213
24229 24214
24230 class _PointFactoryProvider { 24215 class _PointFactoryProvider {
24231 static Point createPoint(num x, num y) => 24216 static Point createPoint(num x, num y) =>
24232 JS('Point', 'new WebKitPoint(#, #)', x, y); 24217 JS('Point', 'new WebKitPoint(#, #)', x, y);
24233 } 24218 }
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
24532 T next() { 24517 T next() {
24533 if (!hasNext) { 24518 if (!hasNext) {
24534 throw new StateError("No more elements"); 24519 throw new StateError("No more elements");
24535 } 24520 }
24536 return _array[_pos++]; 24521 return _array[_pos++];
24537 } 24522 }
24538 24523
24539 final List<T> _array; 24524 final List<T> _array;
24540 int _pos; 24525 int _pos;
24541 } 24526 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | sdk/lib/html/src/Isolates.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698