OLD | NEW |
---|---|
1 library html; | 1 library html; |
2 | 2 |
3 import 'dart:isolate'; | 3 import 'dart:isolate'; |
4 import 'dart:json'; | 4 import 'dart:json'; |
5 import 'dart:svg' as svg; | 5 import 'dart:svg' as svg; |
6 import 'dart:web_audio' as web_audio; | 6 import 'dart:web_audio' as web_audio; |
7 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 7 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
8 // for details. All rights reserved. Use of this source code is governed by a | 8 // for details. All rights reserved. Use of this source code is governed by a |
9 // BSD-style license that can be found in the LICENSE file. | 9 // BSD-style license that can be found in the LICENSE file. |
10 | 10 |
(...skipping 5995 matching lines...) Loading... | |
6006 class DivElement extends Element implements Element native "*HTMLDivElement" { | 6006 class DivElement extends Element implements Element native "*HTMLDivElement" { |
6007 | 6007 |
6008 factory DivElement() => document.$dom_createElement("div"); | 6008 factory DivElement() => document.$dom_createElement("div"); |
6009 } | 6009 } |
6010 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 6010 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
6011 // for details. All rights reserved. Use of this source code is governed by a | 6011 // for details. All rights reserved. Use of this source code is governed by a |
6012 // BSD-style license that can be found in the LICENSE file. | 6012 // BSD-style license that can be found in the LICENSE file. |
6013 | 6013 |
6014 | 6014 |
6015 /// @domName Document | 6015 /// @domName Document |
6016 /** | |
6017 * The base class for all documents. | |
6018 * | |
6019 * Each web page loaded in the browser has its own [Document] object, which is | |
6020 * typically an [HtmlDocument]. | |
6021 * | |
6022 * If you aren't comfortable with DOM concepts, see the Dart tutorial | |
6023 * [Target 2: Connect Dart & HTML](http://www.dartlang.org/docs/tutorials/connec t-dart-html/). | |
6024 */ | |
6016 class Document extends Node native "*Document" | 6025 class Document extends Node native "*Document" |
6017 { | 6026 { |
6018 | 6027 |
6019 | 6028 |
6020 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true | 6029 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true |
6021 DocumentEvents get on => | 6030 DocumentEvents get on => |
6022 new DocumentEvents(this); | 6031 new DocumentEvents(this); |
6023 | 6032 |
6024 /// @domName Document.body; @docsEditable true | 6033 /// @domName Document.body; @docsEditable true |
6025 Element get $dom_body => JS("Element", "#.body", this); | 6034 Element get $dom_body => JS("Element", "#.body", this); |
6026 | 6035 |
6036 /// Moved to [HtmlDocument]. | |
6027 /// @domName Document.body; @docsEditable true | 6037 /// @domName Document.body; @docsEditable true |
6028 void set $dom_body(Element value) { | 6038 void set $dom_body(Element value) { |
6029 JS("void", "#.body = #", this, value); | 6039 JS("void", "#.body = #", this, value); |
6030 } | 6040 } |
6031 | 6041 |
6032 /// @domName Document.charset; @docsEditable true | 6042 /// @domName Document.charset; @docsEditable true |
6033 String charset; | 6043 String charset; |
6034 | 6044 |
6035 /// @domName Document.cookie; @docsEditable true | 6045 /// @domName Document.cookie; @docsEditable true |
6036 String cookie; | 6046 String cookie; |
6037 | 6047 |
6048 /// Returns the [Window] associated with the document. | |
6038 /// @domName Document.defaultView; @docsEditable true | 6049 /// @domName Document.defaultView; @docsEditable true |
6039 Window get window => _convertNativeToDart_Window(this._window); | 6050 Window get window => _convertNativeToDart_Window(this._window); |
6040 dynamic get _window => JS("dynamic", "#.defaultView", this); | 6051 dynamic get _window => JS("dynamic", "#.defaultView", this); |
6041 | 6052 |
6042 /// @domName Document.documentElement; @docsEditable true | 6053 /// @domName Document.documentElement; @docsEditable true |
6043 final Element documentElement; | 6054 final Element documentElement; |
6044 | 6055 |
6045 /// @domName Document.domain; @docsEditable true | 6056 /// @domName Document.domain; @docsEditable true |
6046 final String domain; | 6057 final String domain; |
6047 | 6058 |
6059 /// Moved to [HtmlDocument]. | |
6048 /// @domName Document.head; @docsEditable true | 6060 /// @domName Document.head; @docsEditable true |
6049 HeadElement get $dom_head => JS("HeadElement", "#.head", this); | 6061 HeadElement get $dom_head => JS("HeadElement", "#.head", this); |
6050 | 6062 |
6051 /// @domName Document.implementation; @docsEditable true | 6063 /// @domName Document.implementation; @docsEditable true |
6052 final DOMImplementation implementation; | 6064 final DOMImplementation implementation; |
6053 | 6065 |
6066 /// Moved to [HtmlDocument]. | |
6054 /// @domName Document.lastModified; @docsEditable true | 6067 /// @domName Document.lastModified; @docsEditable true |
6055 String get $dom_lastModified => JS("String", "#.lastModified", this); | 6068 String get $dom_lastModified => JS("String", "#.lastModified", this); |
6056 | 6069 |
6057 /// @domName Document.preferredStylesheetSet; @docsEditable true | 6070 /// @domName Document.preferredStylesheetSet; @docsEditable true |
6058 final String preferredStylesheetSet; | 6071 final String preferredStylesheetSet; |
6059 | 6072 |
6060 /// @domName Document.readyState; @docsEditable true | 6073 /// @domName Document.readyState; @docsEditable true |
6061 final String readyState; | 6074 final String readyState; |
6062 | 6075 |
6076 /// Moved to [HtmlDocument]. | |
6063 /// @domName Document.referrer; @docsEditable true | 6077 /// @domName Document.referrer; @docsEditable true |
6064 String get $dom_referrer => JS("String", "#.referrer", this); | 6078 String get $dom_referrer => JS("String", "#.referrer", this); |
6065 | 6079 |
6066 /// @domName Document.selectedStylesheetSet; @docsEditable true | 6080 /// @domName Document.selectedStylesheetSet; @docsEditable true |
6067 String selectedStylesheetSet; | 6081 String selectedStylesheetSet; |
6068 | 6082 |
6083 /// Moved to [HtmlDocument]. | |
6069 /// @domName Document.styleSheets; @docsEditable true | 6084 /// @domName Document.styleSheets; @docsEditable true |
6070 List<StyleSheet> get $dom_styleSheets => JS("_StyleSheetList", "#.styleSheets" , this); | 6085 List<StyleSheet> get $dom_styleSheets => JS("_StyleSheetList", "#.styleSheets" , this); |
6071 | 6086 |
6087 /// Moved to [HtmlDocument]. | |
6072 /// @domName Document.title; @docsEditable true | 6088 /// @domName Document.title; @docsEditable true |
6073 String get $dom_title => JS("String", "#.title", this); | 6089 String get $dom_title => JS("String", "#.title", this); |
6074 | 6090 |
6091 /// Moved to [HtmlDocument]. | |
6075 /// @domName Document.title; @docsEditable true | 6092 /// @domName Document.title; @docsEditable true |
6076 void set $dom_title(String value) { | 6093 void set $dom_title(String value) { |
6077 JS("void", "#.title = #", this, value); | 6094 JS("void", "#.title = #", this, value); |
6078 } | 6095 } |
6079 | 6096 |
6097 /// Moved to [HtmlDocument]. | |
6080 /// @domName Document.webkitFullscreenElement; @docsEditable true | 6098 /// @domName Document.webkitFullscreenElement; @docsEditable true |
6081 Element get $dom_webkitFullscreenElement => JS("Element", "#.webkitFullscreenE lement", this); | 6099 Element get $dom_webkitFullscreenElement => JS("Element", "#.webkitFullscreenE lement", this); |
6082 | 6100 |
6101 /// Moved to [HtmlDocument]. | |
6083 /// @domName Document.webkitFullscreenEnabled; @docsEditable true | 6102 /// @domName Document.webkitFullscreenEnabled; @docsEditable true |
6084 bool get $dom_webkitFullscreenEnabled => JS("bool", "#.webkitFullscreenEnabled ", this); | 6103 bool get $dom_webkitFullscreenEnabled => JS("bool", "#.webkitFullscreenEnabled ", this); |
6085 | 6104 |
6105 /// Moved to [HtmlDocument]. | |
6086 /// @domName Document.webkitHidden; @docsEditable true | 6106 /// @domName Document.webkitHidden; @docsEditable true |
6087 bool get $dom_webkitHidden => JS("bool", "#.webkitHidden", this); | 6107 bool get $dom_webkitHidden => JS("bool", "#.webkitHidden", this); |
6088 | 6108 |
6109 /// Moved to [HtmlDocument]. | |
6089 /// @domName Document.webkitIsFullScreen; @docsEditable true | 6110 /// @domName Document.webkitIsFullScreen; @docsEditable true |
6090 bool get $dom_webkitIsFullScreen => JS("bool", "#.webkitIsFullScreen", this); | 6111 bool get $dom_webkitIsFullScreen => JS("bool", "#.webkitIsFullScreen", this); |
6091 | 6112 |
6113 /// Moved to [HtmlDocument]. | |
6092 /// @domName Document.webkitPointerLockElement; @docsEditable true | 6114 /// @domName Document.webkitPointerLockElement; @docsEditable true |
6093 Element get $dom_webkitPointerLockElement => JS("Element", "#.webkitPointerLoc kElement", this); | 6115 Element get $dom_webkitPointerLockElement => JS("Element", "#.webkitPointerLoc kElement", this); |
6094 | 6116 |
6117 /// Moved to [HtmlDocument]. | |
6095 /// @domName Document.webkitVisibilityState; @docsEditable true | 6118 /// @domName Document.webkitVisibilityState; @docsEditable true |
6096 String get $dom_webkitVisibilityState => JS("String", "#.webkitVisibilityState ", this); | 6119 String get $dom_webkitVisibilityState => JS("String", "#.webkitVisibilityState ", this); |
6097 | 6120 |
6121 /// Use the [Range] constructor instead. | |
6098 /// @domName Document.caretRangeFromPoint; @docsEditable true | 6122 /// @domName Document.caretRangeFromPoint; @docsEditable true |
6099 Range $dom_caretRangeFromPoint(int x, int y) native "caretRangeFromPoint"; | 6123 Range $dom_caretRangeFromPoint(int x, int y) native "caretRangeFromPoint"; |
6100 | 6124 |
6101 /// @domName Document.createCDATASection; @docsEditable true | 6125 /// @domName Document.createCDATASection; @docsEditable true |
6102 CDATASection createCDataSection(String data) native "createCDATASection"; | 6126 CDATASection createCDataSection(String data) native "createCDATASection"; |
6103 | 6127 |
6104 /// @domName Document.createDocumentFragment; @docsEditable true | 6128 /// @domName Document.createDocumentFragment; @docsEditable true |
6105 DocumentFragment createDocumentFragment() native; | 6129 DocumentFragment createDocumentFragment() native; |
6106 | 6130 |
6131 /// Deprecated: use new Element.tag(tagName) instead. | |
6107 /// @domName Document.createElement; @docsEditable true | 6132 /// @domName Document.createElement; @docsEditable true |
6108 Element $dom_createElement(String tagName) native "createElement"; | 6133 Element $dom_createElement(String tagName) native "createElement"; |
6109 | 6134 |
6110 /// @domName Document.createElementNS; @docsEditable true | 6135 /// @domName Document.createElementNS; @docsEditable true |
6111 Element $dom_createElementNS(String namespaceURI, String qualifiedName) native "createElementNS"; | 6136 Element $dom_createElementNS(String namespaceURI, String qualifiedName) native "createElementNS"; |
6112 | 6137 |
6113 /// @domName Document.createEvent; @docsEditable true | 6138 /// @domName Document.createEvent; @docsEditable true |
6114 Event $dom_createEvent(String eventType) native "createEvent"; | 6139 Event $dom_createEvent(String eventType) native "createEvent"; |
6115 | 6140 |
6116 /// @domName Document.createRange; @docsEditable true | 6141 /// @domName Document.createRange; @docsEditable true |
6117 Range createRange() native; | 6142 Range createRange() native; |
6118 | 6143 |
6119 /// @domName Document.createTextNode; @docsEditable true | 6144 /// @domName Document.createTextNode; @docsEditable true |
6120 Text $dom_createTextNode(String data) native "createTextNode"; | 6145 Text $dom_createTextNode(String data) native "createTextNode"; |
6121 | 6146 |
6122 /// @domName Document.createTouch; @docsEditable true | 6147 /// @domName Document.createTouch; @docsEditable true |
6123 Touch createTouch(LocalWindow window, EventTarget target, int identifier, int pageX, int pageY, int screenX, int screenY, int webkitRadiusX, int webkitRadiusY , num webkitRotationAngle, num webkitForce) { | 6148 Touch createTouch(LocalWindow window, EventTarget target, int identifier, int pageX, int pageY, int screenX, int screenY, int webkitRadiusX, int webkitRadiusY , num webkitRotationAngle, num webkitForce) { |
6124 var target_1 = _convertDartToNative_EventTarget(target); | 6149 var target_1 = _convertDartToNative_EventTarget(target); |
6125 return _createTouch_1(window, target_1, identifier, pageX, pageY, screenX, s creenY, webkitRadiusX, webkitRadiusY, webkitRotationAngle, webkitForce); | 6150 return _createTouch_1(window, target_1, identifier, pageX, pageY, screenX, s creenY, webkitRadiusX, webkitRadiusY, webkitRotationAngle, webkitForce); |
6126 } | 6151 } |
6127 Touch _createTouch_1(LocalWindow window, target, identifier, pageX, pageY, scr eenX, screenY, webkitRadiusX, webkitRadiusY, webkitRotationAngle, webkitForce) n ative "createTouch"; | 6152 Touch _createTouch_1(LocalWindow window, target, identifier, pageX, pageY, scr eenX, screenY, webkitRadiusX, webkitRadiusY, webkitRotationAngle, webkitForce) n ative "createTouch"; |
6128 | 6153 |
6154 /// Use the [TouchList] constructor isntead. | |
6129 /// @domName Document.createTouchList; @docsEditable true | 6155 /// @domName Document.createTouchList; @docsEditable true |
6130 TouchList $dom_createTouchList() native "createTouchList"; | 6156 TouchList $dom_createTouchList() native "createTouchList"; |
6131 | 6157 |
6158 /// Moved to [HtmlDocument]. | |
6132 /// @domName Document.elementFromPoint; @docsEditable true | 6159 /// @domName Document.elementFromPoint; @docsEditable true |
6133 Element $dom_elementFromPoint(int x, int y) native "elementFromPoint"; | 6160 Element $dom_elementFromPoint(int x, int y) native "elementFromPoint"; |
6134 | 6161 |
6135 /// @domName Document.execCommand; @docsEditable true | 6162 /// @domName Document.execCommand; @docsEditable true |
6136 bool execCommand(String command, bool userInterface, String value) native; | 6163 bool execCommand(String command, bool userInterface, String value) native; |
6137 | 6164 |
6138 /// @domName Document.getCSSCanvasContext; @docsEditable true | 6165 /// @domName Document.getCSSCanvasContext; @docsEditable true |
6139 CanvasRenderingContext getCssCanvasContext(String contextId, String name, int width, int height) native "getCSSCanvasContext"; | 6166 CanvasRenderingContext getCssCanvasContext(String contextId, String name, int width, int height) native "getCSSCanvasContext"; |
6140 | 6167 |
6168 /// Deprecated: use query("#$elementId") instead. | |
6141 /// @domName Document.getElementById; @docsEditable true | 6169 /// @domName Document.getElementById; @docsEditable true |
6142 Element $dom_getElementById(String elementId) native "getElementById"; | 6170 Element $dom_getElementById(String elementId) native "getElementById"; |
6143 | 6171 |
6172 /// Deprecated: use query("#$elementId") instead. | |
6144 /// @domName Document.getElementsByClassName; @docsEditable true | 6173 /// @domName Document.getElementsByClassName; @docsEditable true |
6145 @Returns('_NodeList') @Creates('_NodeList') | 6174 @Returns('_NodeList') @Creates('_NodeList') |
6146 List<Node> $dom_getElementsByClassName(String tagname) native "getElementsByCl assName"; | 6175 List<Node> $dom_getElementsByClassName(String tagname) native "getElementsByCl assName"; |
6147 | 6176 |
6148 /// @domName Document.getElementsByName; @docsEditable true | 6177 /// @domName Document.getElementsByName; @docsEditable true |
6149 @Returns('_NodeList') @Creates('_NodeList') | 6178 @Returns('_NodeList') @Creates('_NodeList') |
6150 List<Node> $dom_getElementsByName(String elementName) native "getElementsByNam e"; | 6179 List<Node> $dom_getElementsByName(String elementName) native "getElementsByNam e"; |
6151 | 6180 |
6152 /// @domName Document.getElementsByTagName; @docsEditable true | 6181 /// @domName Document.getElementsByTagName; @docsEditable true |
6153 @Returns('_NodeList') @Creates('_NodeList') | 6182 @Returns('_NodeList') @Creates('_NodeList') |
6154 List<Node> $dom_getElementsByTagName(String tagname) native "getElementsByTagN ame"; | 6183 List<Node> $dom_getElementsByTagName(String tagname) native "getElementsByTagN ame"; |
6155 | 6184 |
6156 /// @domName Document.queryCommandEnabled; @docsEditable true | 6185 /// @domName Document.queryCommandEnabled; @docsEditable true |
6157 bool queryCommandEnabled(String command) native; | 6186 bool queryCommandEnabled(String command) native; |
6158 | 6187 |
6159 /// @domName Document.queryCommandIndeterm; @docsEditable true | 6188 /// @domName Document.queryCommandIndeterm; @docsEditable true |
6160 bool queryCommandIndeterm(String command) native; | 6189 bool queryCommandIndeterm(String command) native; |
6161 | 6190 |
6162 /// @domName Document.queryCommandState; @docsEditable true | 6191 /// @domName Document.queryCommandState; @docsEditable true |
6163 bool queryCommandState(String command) native; | 6192 bool queryCommandState(String command) native; |
6164 | 6193 |
6165 /// @domName Document.queryCommandSupported; @docsEditable true | 6194 /// @domName Document.queryCommandSupported; @docsEditable true |
6166 bool queryCommandSupported(String command) native; | 6195 bool queryCommandSupported(String command) native; |
6167 | 6196 |
6168 /// @domName Document.queryCommandValue; @docsEditable true | 6197 /// @domName Document.queryCommandValue; @docsEditable true |
6169 String queryCommandValue(String command) native; | 6198 String queryCommandValue(String command) native; |
6170 | 6199 |
6200 /// Deprecated: renamed to the shorter name [query]. | |
6171 /// @domName Document.querySelector; @docsEditable true | 6201 /// @domName Document.querySelector; @docsEditable true |
6172 Element $dom_querySelector(String selectors) native "querySelector"; | 6202 Element $dom_querySelector(String selectors) native "querySelector"; |
6173 | 6203 |
6174 /// @domName Document.querySelectorAll; @docsEditable true | 6204 /// @domName Document.querySelectorAll; @docsEditable true |
6175 @Returns('_NodeList') @Creates('_NodeList') | 6205 @Returns('_NodeList') @Creates('_NodeList') |
6176 List<Node> $dom_querySelectorAll(String selectors) native "querySelectorAll"; | 6206 List<Node> $dom_querySelectorAll(String selectors) native "querySelectorAll"; |
6177 | 6207 |
6208 /// Moved to [HtmlDocument]. | |
6178 /// @domName Document.webkitCancelFullScreen; @docsEditable true | 6209 /// @domName Document.webkitCancelFullScreen; @docsEditable true |
6179 void $dom_webkitCancelFullScreen() native "webkitCancelFullScreen"; | 6210 void $dom_webkitCancelFullScreen() native "webkitCancelFullScreen"; |
6180 | 6211 |
6212 /// Moved to [HtmlDocument]. | |
6181 /// @domName Document.webkitExitFullscreen; @docsEditable true | 6213 /// @domName Document.webkitExitFullscreen; @docsEditable true |
6182 void $dom_webkitExitFullscreen() native "webkitExitFullscreen"; | 6214 void $dom_webkitExitFullscreen() native "webkitExitFullscreen"; |
6183 | 6215 |
6216 /// Moved to [HtmlDocument]. | |
6184 /// @domName Document.webkitExitPointerLock; @docsEditable true | 6217 /// @domName Document.webkitExitPointerLock; @docsEditable true |
6185 void $dom_webkitExitPointerLock() native "webkitExitPointerLock"; | 6218 void $dom_webkitExitPointerLock() native "webkitExitPointerLock"; |
6186 | 6219 |
6187 // TODO(jacobr): implement all Element methods not on Document. | |
6188 | 6220 |
6221 /** | |
6222 * Finds the first descendant element of this document that matches the | |
6223 * specified group of selectors. | |
6224 * | |
6225 * Unless your webpage contains multiple documents, the top level query | |
Kathy Walrath
2012/11/30 18:50:14
top level query -> top-level [query]
(top-level h
Jacob
2012/11/30 20:59:51
Sadly you can't link to a top level method in dart
| |
6226 * method behaves the same as this method so you should use it instead to | |
Kathy Walrath
2012/11/30 18:50:14
method so you should use it -> method, so you can
Jacob
2012/11/30 20:59:51
Done.
| |
6227 * save typing a few characters. | |
6228 * | |
6229 * [selectors] should be a string using CSS selector syntax. | |
6230 * var element1 = document.query('.className'); | |
6231 * var element2 = document.query('#id'); | |
6232 * | |
6233 * For details about CSS selector syntax, see the | |
6234 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
6235 */ | |
6189 Element query(String selectors) { | 6236 Element query(String selectors) { |
6190 // It is fine for our RegExp to detect element id query selectors to have | 6237 // It is fine for our RegExp to detect element id query selectors to have |
6191 // false negatives but not false positives. | 6238 // false negatives but not false positives. |
6192 if (new RegExp("^#[_a-zA-Z]\\w*\$").hasMatch(selectors)) { | 6239 if (new RegExp("^#[_a-zA-Z]\\w*\$").hasMatch(selectors)) { |
6193 return $dom_getElementById(selectors.substring(1)); | 6240 return $dom_getElementById(selectors.substring(1)); |
6194 } | 6241 } |
6195 return $dom_querySelector(selectors); | 6242 return $dom_querySelector(selectors); |
6196 } | 6243 } |
6197 | 6244 |
6245 /** | |
6246 * Finds all descendant elements of this document that match the specified | |
6247 * group of selectors. | |
6248 * | |
6249 * Unless your webpage contains multiple documents, the top level queryAll | |
Kathy Walrath
2012/11/30 18:50:14
same comments as for query description above
Jacob
2012/11/30 20:59:51
Done.
| |
6250 * method behaves the same as this method so you should use it instead to | |
6251 * save typing a few characters. | |
6252 * | |
6253 * [selectors] should be a string using CSS selector syntax. | |
6254 * var items = document.queryAll('.itemClassName'); | |
6255 * | |
6256 * For details about CSS selector syntax, see the | |
6257 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
6258 */ | |
6198 List<Element> queryAll(String selectors) { | 6259 List<Element> queryAll(String selectors) { |
6199 if (new RegExp("""^\\[name=["'][^'"]+['"]\\]\$""").hasMatch(selectors)) { | 6260 if (new RegExp("""^\\[name=["'][^'"]+['"]\\]\$""").hasMatch(selectors)) { |
6200 final mutableMatches = $dom_getElementsByName( | 6261 final mutableMatches = $dom_getElementsByName( |
6201 selectors.substring(7,selectors.length - 2)); | 6262 selectors.substring(7,selectors.length - 2)); |
6202 int len = mutableMatches.length; | 6263 int len = mutableMatches.length; |
6203 final copyOfMatches = new List<Element>(len); | 6264 final copyOfMatches = new List<Element>(len); |
6204 for (int i = 0; i < len; ++i) { | 6265 for (int i = 0; i < len; ++i) { |
6205 copyOfMatches[i] = mutableMatches[i]; | 6266 copyOfMatches[i] = mutableMatches[i]; |
6206 } | 6267 } |
6207 return new _FrozenElementList._wrap(copyOfMatches); | 6268 return new _FrozenElementList._wrap(copyOfMatches); |
(...skipping 158 matching lines...) Loading... | |
6366 String get title => ""; | 6427 String get title => ""; |
6367 String get tagName => ""; | 6428 String get tagName => ""; |
6368 String get webkitdropzone => ""; | 6429 String get webkitdropzone => ""; |
6369 String get webkitRegionOverflow => ""; | 6430 String get webkitRegionOverflow => ""; |
6370 Element get $m_firstElementChild { | 6431 Element get $m_firstElementChild { |
6371 if (elements.length > 0) { | 6432 if (elements.length > 0) { |
6372 return elements[0]; | 6433 return elements[0]; |
6373 } | 6434 } |
6374 return null; | 6435 return null; |
6375 } | 6436 } |
6376 Element get $m_lastElementChild() => elements.last; | 6437 Element get $m_lastElementChild => elements.last; |
6377 Element get nextElementSibling => null; | 6438 Element get nextElementSibling => null; |
6378 Element get previousElementSibling => null; | 6439 Element get previousElementSibling => null; |
6379 Element get offsetParent => null; | 6440 Element get offsetParent => null; |
6380 Element get parent => null; | 6441 Element get parent => null; |
6381 Map<String, String> get attributes => const {}; | 6442 Map<String, String> get attributes => const {}; |
6382 CssClassSet get classes => new _FrozenCssClassSet(); | 6443 CssClassSet get classes => new _FrozenCssClassSet(); |
6383 Map<String, String> get dataAttributes => const {}; | 6444 Map<String, String> get dataAttributes => const {}; |
6384 CSSStyleDeclaration get style => new Element.tag('div').style; | 6445 CSSStyleDeclaration get style => new Element.tag('div').style; |
6385 Future<CSSStyleDeclaration> get computedStyle => | 6446 Future<CSSStyleDeclaration> get computedStyle => |
6386 _emptyStyleFuture(); | 6447 _emptyStyleFuture(); |
(...skipping 1439 matching lines...) Loading... | |
7826 | 7887 |
7827 EventListenerList get message => this['message']; | 7888 EventListenerList get message => this['message']; |
7828 | 7889 |
7829 EventListenerList get open => this['open']; | 7890 EventListenerList get open => this['open']; |
7830 } | 7891 } |
7831 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 7892 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
7832 // for details. All rights reserved. Use of this source code is governed by a | 7893 // for details. All rights reserved. Use of this source code is governed by a |
7833 // BSD-style license that can be found in the LICENSE file. | 7894 // BSD-style license that can be found in the LICENSE file. |
7834 | 7895 |
7835 | 7896 |
7897 /** | |
7898 * Base class that supports listening for and dispatching browser events. | |
7899 * | |
7900 * Events can either be accessed by string name (using the indexed getter) or by | |
7901 * getters exposed by subclasses. Use the getters exposed by subclasses when | |
7902 * possible for better compile-time type checks. | |
7903 * | |
7904 * Using an indexed getter: | |
7905 * events['mouseover'].add((e) => print("Mouse over!")) | |
Kathy Walrath
2012/11/30 18:50:14
Nice examples!
Add a ; to the end of each example
Jacob
2012/11/30 20:59:51
Done.
| |
7906 * | |
7907 * Using a getter provided by a subclass: | |
7908 * elementEvents.mouseOver.add((e) => print("Mouse over!")) | |
7909 */ | |
7836 class Events { | 7910 class Events { |
7837 /* Raw event target. */ | 7911 /* Raw event target. */ |
7838 final EventTarget _ptr; | 7912 final EventTarget _ptr; |
7839 | 7913 |
7840 Events(this._ptr); | 7914 Events(this._ptr); |
7841 | 7915 |
7842 EventListenerList operator [](String type) { | 7916 EventListenerList operator [](String type) { |
7843 return new EventListenerList(_ptr, type); | 7917 return new EventListenerList(_ptr, type); |
7844 } | 7918 } |
7845 } | 7919 } |
7846 | 7920 |
7921 /** | |
7922 * Supports adding, removing, and dispatching events for a specific event type. | |
7923 */ | |
7847 class EventListenerList { | 7924 class EventListenerList { |
7848 | 7925 |
7849 final EventTarget _ptr; | 7926 final EventTarget _ptr; |
7850 final String _type; | 7927 final String _type; |
7851 | 7928 |
7852 EventListenerList(this._ptr, this._type); | 7929 EventListenerList(this._ptr, this._type); |
7853 | 7930 |
7854 // TODO(jacobr): implement equals. | 7931 // TODO(jacobr): implement equals. |
7855 | 7932 |
7856 EventListenerList add(EventListener listener, | 7933 EventListenerList add(EventListener listener, |
(...skipping 15 matching lines...) Loading... | |
7872 void _add(EventListener listener, bool useCapture) { | 7949 void _add(EventListener listener, bool useCapture) { |
7873 _ptr.$dom_addEventListener(_type, listener, useCapture); | 7950 _ptr.$dom_addEventListener(_type, listener, useCapture); |
7874 } | 7951 } |
7875 | 7952 |
7876 void _remove(EventListener listener, bool useCapture) { | 7953 void _remove(EventListener listener, bool useCapture) { |
7877 _ptr.$dom_removeEventListener(_type, listener, useCapture); | 7954 _ptr.$dom_removeEventListener(_type, listener, useCapture); |
7878 } | 7955 } |
7879 } | 7956 } |
7880 | 7957 |
7881 /// @domName EventTarget | 7958 /// @domName EventTarget |
7959 /** | |
7960 * Base class for all browser objects that support events. | |
7961 * | |
7962 * Use the [on] property to add, remove, and dispatch events (rather than | |
7963 * [$dom_addEventListener], [$dom_dispatchEvent], and | |
7964 * [$dom_removeEventListener]) for compile-time type checks and a more concise | |
7965 * API. | |
7966 */ | |
7882 class EventTarget native "*EventTarget" { | 7967 class EventTarget native "*EventTarget" { |
7883 | 7968 |
7884 /** @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent */ | 7969 /** @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent */ |
7885 Events get on => new Events(this); | 7970 Events get on => new Events(this); |
7886 | 7971 |
7887 /// @domName EventTarget.addEventListener; @docsEditable true | 7972 /// @domName EventTarget.addEventListener; @docsEditable true |
7888 void $dom_addEventListener(String type, EventListener listener, [bool useCaptu re]) native "addEventListener"; | 7973 void $dom_addEventListener(String type, EventListener listener, [bool useCaptu re]) native "addEventListener"; |
7889 | 7974 |
7890 /// @domName EventTarget.dispatchEvent; @docsEditable true | 7975 /// @domName EventTarget.dispatchEvent; @docsEditable true |
7891 bool $dom_dispatchEvent(Event event) native "dispatchEvent"; | 7976 bool $dom_dispatchEvent(Event event) native "dispatchEvent"; |
(...skipping 3282 matching lines...) Loading... | |
11174 if (options == null) { | 11259 if (options == null) { |
11175 return _DOMWindowCrossFrame._createSafe(_open2(url, name)); | 11260 return _DOMWindowCrossFrame._createSafe(_open2(url, name)); |
11176 } else { | 11261 } else { |
11177 return _DOMWindowCrossFrame._createSafe(_open3(url, name, options)); | 11262 return _DOMWindowCrossFrame._createSafe(_open3(url, name, options)); |
11178 } | 11263 } |
11179 } | 11264 } |
11180 | 11265 |
11181 // API level getter and setter for Location. | 11266 // API level getter and setter for Location. |
11182 // TODO: The cross domain safe wrapper can be inserted here or folded into | 11267 // TODO: The cross domain safe wrapper can be inserted here or folded into |
11183 // _LocationWrapper. | 11268 // _LocationWrapper. |
11184 LocalLocation get location() { | 11269 LocalLocation get location { |
11185 // Firefox work-around for Location. The Firefox location object cannot be | 11270 // Firefox work-around for Location. The Firefox location object cannot be |
11186 // made to behave like a Dart object so must be wrapped. | 11271 // made to behave like a Dart object so must be wrapped. |
11187 var result = _location; | 11272 var result = _location; |
11188 if (_isDartLocation(result)) return result; // e.g. on Chrome. | 11273 if (_isDartLocation(result)) return result; // e.g. on Chrome. |
11189 if (null == _location_wrapper) { | 11274 if (null == _location_wrapper) { |
11190 _location_wrapper = new _LocationWrapper(result); | 11275 _location_wrapper = new _LocationWrapper(result); |
11191 } | 11276 } |
11192 return _location_wrapper; | 11277 return _location_wrapper; |
11193 } | 11278 } |
11194 | 11279 |
(...skipping 76 matching lines...) Loading... | |
11271 $this.requestAnimationFrame = function(callback) { | 11356 $this.requestAnimationFrame = function(callback) { |
11272 return window.setTimeout(function() { | 11357 return window.setTimeout(function() { |
11273 callback(Date.now()); | 11358 callback(Date.now()); |
11274 }, 16 /* 16ms ~= 60fps */); | 11359 }, 16 /* 16ms ~= 60fps */); |
11275 }; | 11360 }; |
11276 $this.cancelAnimationFrame = function(id) { clearTimeout(id); } | 11361 $this.cancelAnimationFrame = function(id) { clearTimeout(id); } |
11277 })(#)""", | 11362 })(#)""", |
11278 this); | 11363 this); |
11279 } | 11364 } |
11280 | 11365 |
11281 IDBFactory get indexedDB() => | 11366 IDBFactory get indexedDB => |
11282 JS('IDBFactory', | 11367 JS('IDBFactory', |
11283 '#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB', | 11368 '#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB', |
11284 this, this, this); | 11369 this, this, this); |
11285 | 11370 |
11286 /** | 11371 /** |
11287 * Lookup a port by its [name]. Return null if no port is | 11372 * Lookup a port by its [name]. Return null if no port is |
11288 * registered under [name]. | 11373 * registered under [name]. |
11289 */ | 11374 */ |
11290 SendPortSync lookupPort(String name) { | 11375 SendPortSync lookupPort(String name) { |
11291 var port = JSON.parse(document.documentElement.attributes['dart-port:$name'] ); | 11376 var port = JSON.parse(document.documentElement.attributes['dart-port:$name'] ); |
(...skipping 13167 matching lines...) Loading... | |
24459 if (length < 0) throw new ArgumentError('length'); | 24544 if (length < 0) throw new ArgumentError('length'); |
24460 if (start < 0) throw new RangeError.value(start); | 24545 if (start < 0) throw new RangeError.value(start); |
24461 int end = start + length; | 24546 int end = start + length; |
24462 if (end > a.length) throw new RangeError.value(end); | 24547 if (end > a.length) throw new RangeError.value(end); |
24463 for (int i = start; i < end; i++) { | 24548 for (int i = start; i < end; i++) { |
24464 accumulator.add(a[i]); | 24549 accumulator.add(a[i]); |
24465 } | 24550 } |
24466 return accumulator; | 24551 return accumulator; |
24467 } | 24552 } |
24468 } | 24553 } |
OLD | NEW |