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

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

Issue 11697007: Generate static factories with optional arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/html/scripts/htmldartgenerator.py » ('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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 /// @domName HTMLAudioElement; @docsEditable true 411 /// @domName HTMLAudioElement; @docsEditable true
412 class AudioElement extends MediaElement native "*HTMLAudioElement" { 412 class AudioElement extends MediaElement native "*HTMLAudioElement" {
413 413
414 ///@docsEditable true 414 ///@docsEditable true
415 factory AudioElement([String src]) { 415 factory AudioElement([String src]) {
416 if (!?src) { 416 if (!?src) {
417 return AudioElement._create(); 417 return AudioElement._create();
418 } 418 }
419 return AudioElement._create(src); 419 return AudioElement._create(src);
420 } 420 }
421 static AudioElement _create([String src = null]) { 421 static AudioElement _create([String src]) {
422 if (src == null) return JS('AudioElement', 'new Audio()'); 422 if (!?src) {
423 return JS('AudioElement', 'new Audio()');
424 }
423 return JS('AudioElement', 'new Audio(#)', src); 425 return JS('AudioElement', 'new Audio(#)', src);
424 } 426 }
425 } 427 }
426 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 428 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
427 // for details. All rights reserved. Use of this source code is governed by a 429 // for details. All rights reserved. Use of this source code is governed by a
428 // BSD-style license that can be found in the LICENSE file. 430 // BSD-style license that can be found in the LICENSE file.
429 431
430 432
431 /// @domName HTMLBRElement; @docsEditable true 433 /// @domName HTMLBRElement; @docsEditable true
432 class BRElement extends Element native "*HTMLBRElement" { 434 class BRElement extends Element native "*HTMLBRElement" {
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 /// @domName WebKitCSSMatrix; @docsEditable true 1589 /// @domName WebKitCSSMatrix; @docsEditable true
1588 class CssMatrix native "*WebKitCSSMatrix" { 1590 class CssMatrix native "*WebKitCSSMatrix" {
1589 1591
1590 ///@docsEditable true 1592 ///@docsEditable true
1591 factory CssMatrix([String cssValue]) { 1593 factory CssMatrix([String cssValue]) {
1592 if (!?cssValue) { 1594 if (!?cssValue) {
1593 return CssMatrix._create(); 1595 return CssMatrix._create();
1594 } 1596 }
1595 return CssMatrix._create(cssValue); 1597 return CssMatrix._create(cssValue);
1596 } 1598 }
1597 static CssMatrix _create([String cssValue = '']) => 1599 static CssMatrix _create([String cssValue]) {
1598 JS('CssMatrix', 'new WebKitCSSMatrix(#)', cssValue); 1600 if (!?cssValue) {
1601 return JS('CssMatrix', 'new WebKitCSSMatrix()');
1602 }
1603 return JS('CssMatrix', 'new WebKitCSSMatrix(#)', cssValue);
1604 }
1599 1605
1600 /// @domName WebKitCSSMatrix.a; @docsEditable true 1606 /// @domName WebKitCSSMatrix.a; @docsEditable true
1601 num a; 1607 num a;
1602 1608
1603 /// @domName WebKitCSSMatrix.b; @docsEditable true 1609 /// @domName WebKitCSSMatrix.b; @docsEditable true
1604 num b; 1610 num b;
1605 1611
1606 /// @domName WebKitCSSMatrix.c; @docsEditable true 1612 /// @domName WebKitCSSMatrix.c; @docsEditable true
1607 num c; 1613 num c;
1608 1614
(...skipping 3705 matching lines...) Expand 10 before | Expand all | Expand 10 after
5314 ///@docsEditable true 5320 ///@docsEditable true
5315 factory DataView(ArrayBuffer buffer, [int byteOffset, int byteLength]) { 5321 factory DataView(ArrayBuffer buffer, [int byteOffset, int byteLength]) {
5316 if (!?byteOffset) { 5322 if (!?byteOffset) {
5317 return DataView._create(buffer); 5323 return DataView._create(buffer);
5318 } 5324 }
5319 if (!?byteLength) { 5325 if (!?byteLength) {
5320 return DataView._create(buffer, byteOffset); 5326 return DataView._create(buffer, byteOffset);
5321 } 5327 }
5322 return DataView._create(buffer, byteOffset, byteLength); 5328 return DataView._create(buffer, byteOffset, byteLength);
5323 } 5329 }
5324 static DataView _create(ArrayBuffer buffer, [int byteOffset = null, int byteLe ngth = null]) { 5330 static DataView _create(ArrayBuffer buffer, [int byteOffset, int byteLength]) {
5325 if (byteOffset == null) { 5331 if (!?byteOffset) {
5326 return JS('DataView', 'new DataView(#)', buffer); 5332 return JS('DataView', 'new DataView(#)', buffer);
5327 } 5333 }
5328 if (byteLength == null) { 5334 if (!?byteLength) {
5329 return JS('DataView', 'new DataView(#,#)', buffer, byteOffset); 5335 return JS('DataView', 'new DataView(#,#)', buffer, byteOffset);
5330 } 5336 }
5331 return JS('DataView', 'new DataView(#,#,#)', buffer, byteOffset, byteLength) ; 5337 return JS('DataView', 'new DataView(#,#,#)', buffer, byteOffset, byteLength) ;
5332 } 5338 }
5333 5339
5334 /// @domName DataView.getFloat32; @docsEditable true 5340 /// @domName DataView.getFloat32; @docsEditable true
5335 num getFloat32(int byteOffset, {bool littleEndian}) native; 5341 num getFloat32(int byteOffset, {bool littleEndian}) native;
5336 5342
5337 /// @domName DataView.getFloat64; @docsEditable true 5343 /// @domName DataView.getFloat64; @docsEditable true
5338 num getFloat64(int byteOffset, {bool littleEndian}) native; 5344 num getFloat64(int byteOffset, {bool littleEndian}) native;
(...skipping 4076 matching lines...) Expand 10 before | Expand all | Expand 10 after
9415 /// @domName FormData; @docsEditable true 9421 /// @domName FormData; @docsEditable true
9416 class FormData native "*FormData" { 9422 class FormData native "*FormData" {
9417 9423
9418 ///@docsEditable true 9424 ///@docsEditable true
9419 factory FormData([FormElement form]) { 9425 factory FormData([FormElement form]) {
9420 if (!?form) { 9426 if (!?form) {
9421 return FormData._create(); 9427 return FormData._create();
9422 } 9428 }
9423 return FormData._create(form); 9429 return FormData._create(form);
9424 } 9430 }
9425 static FormData _create([FormElement form = null]) { 9431 static FormData _create([FormElement form]) {
9426 if (form == null) return JS('FormData', 'new FormData()'); 9432 if (!?form) {
9433 return JS('FormData', 'new FormData()');
9434 }
9427 return JS('FormData', 'new FormData(#)', form); 9435 return JS('FormData', 'new FormData(#)', form);
9428 } 9436 }
9429 9437
9430 /// @domName DOMFormData.append; @docsEditable true 9438 /// @domName DOMFormData.append; @docsEditable true
9431 void append(String name, value, [String filename]) native; 9439 void append(String name, value, [String filename]) native;
9432 } 9440 }
9433 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 9441 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
9434 // for details. All rights reserved. Use of this source code is governed by a 9442 // for details. All rights reserved. Use of this source code is governed by a
9435 // BSD-style license that can be found in the LICENSE file. 9443 // BSD-style license that can be found in the LICENSE file.
9436 9444
(...skipping 4687 matching lines...) Expand 10 before | Expand all | Expand 10 after
14124 /// @domName Notification; @docsEditable true 14132 /// @domName Notification; @docsEditable true
14125 class Notification extends EventTarget native "*Notification" { 14133 class Notification extends EventTarget native "*Notification" {
14126 14134
14127 ///@docsEditable true 14135 ///@docsEditable true
14128 factory Notification(String title, [Map options]) { 14136 factory Notification(String title, [Map options]) {
14129 if (!?options) { 14137 if (!?options) {
14130 return Notification._create(title); 14138 return Notification._create(title);
14131 } 14139 }
14132 return Notification._create(title, options); 14140 return Notification._create(title, options);
14133 } 14141 }
14134 static Notification _create(String title, [Map options]) => JS('Notification', 'new Notification(#,#)', title, options); 14142 static Notification _create(String title, [Map options]) {
14143 if (!?options) {
14144 return JS('Notification', 'new Notification(#)', title);
14145 }
14146 return JS('Notification', 'new Notification(#,#)', title, options);
14147 }
14135 14148
14136 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true 14149 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true
14137 NotificationEvents get on => 14150 NotificationEvents get on =>
14138 new NotificationEvents(this); 14151 new NotificationEvents(this);
14139 14152
14140 /// @domName Notification.dir; @docsEditable true 14153 /// @domName Notification.dir; @docsEditable true
14141 String dir; 14154 String dir;
14142 14155
14143 /// @domName Notification.permission; @docsEditable true 14156 /// @domName Notification.permission; @docsEditable true
14144 final String permission; 14157 final String permission;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
14409 return OptionElement._create(data); 14422 return OptionElement._create(data);
14410 } 14423 }
14411 if (!?defaultSelected) { 14424 if (!?defaultSelected) {
14412 return OptionElement._create(data, value); 14425 return OptionElement._create(data, value);
14413 } 14426 }
14414 if (!?selected) { 14427 if (!?selected) {
14415 return OptionElement._create(data, value, defaultSelected); 14428 return OptionElement._create(data, value, defaultSelected);
14416 } 14429 }
14417 return OptionElement._create(data, value, defaultSelected, selected); 14430 return OptionElement._create(data, value, defaultSelected, selected);
14418 } 14431 }
14419 static OptionElement _create( 14432 static OptionElement _create([String data, String value, bool defaultSelected, bool selected]) {
14420 [String data, String value, bool defaultSelected, bool selected]) { 14433 if (!?data) {
14421 if (data == null) {
14422 return JS('OptionElement', 'new Option()'); 14434 return JS('OptionElement', 'new Option()');
14423 } 14435 }
14424 if (value == null) { 14436 if (!?value) {
14425 return JS('OptionElement', 'new Option(#)', data); 14437 return JS('OptionElement', 'new Option(#)', data);
14426 } 14438 }
14427 if (defaultSelected == null) { 14439 if (!?defaultSelected) {
14428 return JS('OptionElement', 'new Option(#,#)', data, value); 14440 return JS('OptionElement', 'new Option(#,#)', data, value);
14429 } 14441 }
14430 if (selected == null) { 14442 if (!?selected) {
14431 return JS('OptionElement', 'new Option(#,#,#)', 14443 return JS('OptionElement', 'new Option(#,#,#)', data, value, defaultSelect ed);
14432 data, value, defaultSelected);
14433 } 14444 }
14434 return JS('OptionElement', 'new Option(#,#,#,#)', 14445 return JS('OptionElement', 'new Option(#,#,#,#)', data, value, defaultSelect ed, selected);
14435 data, value, defaultSelected, selected);
14436 } 14446 }
14437 14447
14438 /// @domName HTMLOptionElement.defaultSelected; @docsEditable true 14448 /// @domName HTMLOptionElement.defaultSelected; @docsEditable true
14439 bool defaultSelected; 14449 bool defaultSelected;
14440 14450
14441 /// @domName HTMLOptionElement.disabled; @docsEditable true 14451 /// @domName HTMLOptionElement.disabled; @docsEditable true
14442 bool disabled; 14452 bool disabled;
14443 14453
14444 /// @domName HTMLOptionElement.form; @docsEditable true 14454 /// @domName HTMLOptionElement.form; @docsEditable true
14445 final FormElement form; 14455 final FormElement form;
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
15203 /// @domName RTCPeerConnection; @docsEditable true 15213 /// @domName RTCPeerConnection; @docsEditable true
15204 class RtcPeerConnection extends EventTarget native "*RTCPeerConnection" { 15214 class RtcPeerConnection extends EventTarget native "*RTCPeerConnection" {
15205 15215
15206 ///@docsEditable true 15216 ///@docsEditable true
15207 factory RtcPeerConnection(Map rtcIceServers, [Map mediaConstraints]) { 15217 factory RtcPeerConnection(Map rtcIceServers, [Map mediaConstraints]) {
15208 if (!?mediaConstraints) { 15218 if (!?mediaConstraints) {
15209 return RtcPeerConnection._create(rtcIceServers); 15219 return RtcPeerConnection._create(rtcIceServers);
15210 } 15220 }
15211 return RtcPeerConnection._create(rtcIceServers, mediaConstraints); 15221 return RtcPeerConnection._create(rtcIceServers, mediaConstraints);
15212 } 15222 }
15213 static RtcPeerConnection _create(Map rtcIceServers, [Map mediaConstraints]) => JS('RtcPeerConnection', 'new RTCPeerConnection(#,#)', rtcIceServers, mediaConst raints); 15223 static RtcPeerConnection _create(Map rtcIceServers, [Map mediaConstraints]) {
15224 if (!?mediaConstraints) {
15225 return JS('RtcPeerConnection', 'new RTCPeerConnection(#)', rtcIceServers);
15226 }
15227 return JS('RtcPeerConnection', 'new RTCPeerConnection(#,#)', rtcIceServers, mediaConstraints);
15228 }
15214 15229
15215 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true 15230 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true
15216 RtcPeerConnectionEvents get on => 15231 RtcPeerConnectionEvents get on =>
15217 new RtcPeerConnectionEvents(this); 15232 new RtcPeerConnectionEvents(this);
15218 15233
15219 /// @domName RTCPeerConnection.iceGatheringState; @docsEditable true 15234 /// @domName RTCPeerConnection.iceGatheringState; @docsEditable true
15220 final String iceGatheringState; 15235 final String iceGatheringState;
15221 15236
15222 /// @domName RTCPeerConnection.iceState; @docsEditable true 15237 /// @domName RTCPeerConnection.iceState; @docsEditable true
15223 final String iceState; 15238 final String iceState;
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
15752 class SharedWorker extends AbstractWorker native "*SharedWorker" { 15767 class SharedWorker extends AbstractWorker native "*SharedWorker" {
15753 15768
15754 ///@docsEditable true 15769 ///@docsEditable true
15755 factory SharedWorker(String scriptURL, [String name]) { 15770 factory SharedWorker(String scriptURL, [String name]) {
15756 if (!?name) { 15771 if (!?name) {
15757 return SharedWorker._create(scriptURL); 15772 return SharedWorker._create(scriptURL);
15758 } 15773 }
15759 return SharedWorker._create(scriptURL, name); 15774 return SharedWorker._create(scriptURL, name);
15760 } 15775 }
15761 static SharedWorker _create(String scriptURL, [String name]) { 15776 static SharedWorker _create(String scriptURL, [String name]) {
15762 if (name == null) return JS('SharedWorker', 'new SharedWorker(#)', scriptURL ); 15777 if (!?name) {
15778 return JS('SharedWorker', 'new SharedWorker(#)', scriptURL);
15779 }
15763 return JS('SharedWorker', 'new SharedWorker(#,#)', scriptURL, name); 15780 return JS('SharedWorker', 'new SharedWorker(#,#)', scriptURL, name);
15764 } 15781 }
15765 15782
15766 /// @domName SharedWorker.port; @docsEditable true 15783 /// @domName SharedWorker.port; @docsEditable true
15767 final MessagePort port; 15784 final MessagePort port;
15768 } 15785 }
15769 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 15786 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
15770 // for details. All rights reserved. Use of this source code is governed by a 15787 // for details. All rights reserved. Use of this source code is governed by a
15771 // BSD-style license that can be found in the LICENSE file. 15788 // BSD-style license that can be found in the LICENSE file.
15772 15789
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after
17197 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 17214 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
17198 // for details. All rights reserved. Use of this source code is governed by a 17215 // for details. All rights reserved. Use of this source code is governed by a
17199 // BSD-style license that can be found in the LICENSE file. 17216 // BSD-style license that can be found in the LICENSE file.
17200 17217
17201 17218
17202 /// @domName TextTrackCue; @docsEditable true 17219 /// @domName TextTrackCue; @docsEditable true
17203 class TextTrackCue extends EventTarget native "*TextTrackCue" { 17220 class TextTrackCue extends EventTarget native "*TextTrackCue" {
17204 17221
17205 ///@docsEditable true 17222 ///@docsEditable true
17206 factory TextTrackCue(num startTime, num endTime, String text) => TextTrackCue. _create(startTime, endTime, text); 17223 factory TextTrackCue(num startTime, num endTime, String text) => TextTrackCue. _create(startTime, endTime, text);
17207 static TextTrackCue _create( 17224 static TextTrackCue _create(num startTime, num endTime, String text) => JS('Te xtTrackCue', 'new TextTrackCue(#,#,#)', startTime, endTime, text);
17208 num startTime, num endTime, String text,
17209 [String settings, bool pauseOnExit]) {
podivilov 2012/12/29 07:42:49 Were these optional arguments used anywhere?
Anton Muhin 2012/12/29 08:32:07 I do not have a slightest idea
17210 if (settings == null) {
17211 return JS('TextTrackCue',
17212 'new TextTrackCue(#,#,#)',
17213 startTime, endTime, text);
17214 }
17215 if (pauseOnExit == null) {
17216 return JS('TextTrackCue',
17217 'new TextTrackCue(#,#,#,#)',
17218 startTime, endTime, text, settings);
17219 }
17220 return JS('TextTrackCue',
17221 'new TextTrackCue(#,#,#,#,#)',
17222 startTime, endTime, text, settings, pauseOnExit);
17223 }
17224 17225
17225 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true 17226 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true
17226 TextTrackCueEvents get on => 17227 TextTrackCueEvents get on =>
17227 new TextTrackCueEvents(this); 17228 new TextTrackCueEvents(this);
17228 17229
17229 /// @domName TextTrackCue.align; @docsEditable true 17230 /// @domName TextTrackCue.align; @docsEditable true
17230 String align; 17231 String align;
17231 17232
17232 /// @domName TextTrackCue.endTime; @docsEditable true 17233 /// @domName TextTrackCue.endTime; @docsEditable true
17233 num endTime; 17234 num endTime;
(...skipping 8025 matching lines...) Expand 10 before | Expand all | Expand 10 after
25259 T next() { 25260 T next() {
25260 if (!hasNext) { 25261 if (!hasNext) {
25261 throw new StateError("No more elements"); 25262 throw new StateError("No more elements");
25262 } 25263 }
25263 return _array[_pos++]; 25264 return _array[_pos++];
25264 } 25265 }
25265 25266
25266 final List<T> _array; 25267 final List<T> _array;
25267 int _pos; 25268 int _pos;
25268 } 25269 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/html/scripts/htmldartgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698