OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 class _DocumentImpl extends _ElementImpl |
| 6 implements Document { |
| 7 |
| 8 Element get activeElement() => _wrap(_documentPtr.activeElement); |
| 9 |
| 10 Element get body() => _wrap(_documentPtr.body); |
| 11 |
| 12 void set body(Element value) { _documentPtr.body = _unwrap(value); } |
| 13 |
| 14 String get charset() => _wrap(_documentPtr.charset); |
| 15 |
| 16 void set charset(String value) { _documentPtr.charset = _unwrap(value); } |
| 17 |
| 18 String get cookie() => _wrap(_documentPtr.cookie); |
| 19 |
| 20 void set cookie(String value) { _documentPtr.cookie = _unwrap(value); } |
| 21 |
| 22 Window get window() => _wrap(_documentPtr.defaultView); |
| 23 |
| 24 String get domain() => _wrap(_documentPtr.domain); |
| 25 |
| 26 HeadElement get head() => _wrap(_documentPtr.head); |
| 27 |
| 28 String get lastModified() => _wrap(_documentPtr.lastModified); |
| 29 |
| 30 String get preferredStylesheetSet() => _wrap(_documentPtr.preferredStylesheetS
et); |
| 31 |
| 32 String get readyState() => _wrap(_documentPtr.readyState); |
| 33 |
| 34 String get referrer() => _wrap(_documentPtr.referrer); |
| 35 |
| 36 String get selectedStylesheetSet() => _wrap(_documentPtr.selectedStylesheetSet
); |
| 37 |
| 38 void set selectedStylesheetSet(String value) { _documentPtr.selectedStylesheet
Set = _unwrap(value); } |
| 39 |
| 40 StyleSheetList get styleSheets() => _wrap(_documentPtr.styleSheets); |
| 41 |
| 42 Element get webkitCurrentFullScreenElement() => _wrap(_documentPtr.webkitCurre
ntFullScreenElement); |
| 43 |
| 44 bool get webkitFullScreenKeyboardInputAllowed() => _wrap(_documentPtr.webkitFu
llScreenKeyboardInputAllowed); |
| 45 |
| 46 bool get webkitHidden() => _wrap(_documentPtr.webkitHidden); |
| 47 |
| 48 bool get webkitIsFullScreen() => _wrap(_documentPtr.webkitIsFullScreen); |
| 49 |
| 50 String get webkitVisibilityState() => _wrap(_documentPtr.webkitVisibilityState
); |
| 51 |
| 52 _DocumentEventsImpl get on() { |
| 53 if (_on == null) _on = new _DocumentEventsImpl(_wrappedDocumentPtr); |
| 54 return _on; |
| 55 } |
| 56 |
| 57 Range caretRangeFromPoint(int x, int y) { |
| 58 return _wrap(_documentPtr.caretRangeFromPoint(_unwrap(x), _unwrap(y))); |
| 59 } |
| 60 |
| 61 CDATASection createCDATASection(String data) { |
| 62 return _wrap(_documentPtr.createCDATASection(_unwrap(data))); |
| 63 } |
| 64 |
| 65 DocumentFragment createDocumentFragment() { |
| 66 return _wrap(_documentPtr.createDocumentFragment()); |
| 67 } |
| 68 |
| 69 Element _createElement(String tagName) { |
| 70 return _wrap(_documentPtr.createElement(_unwrap(tagName))); |
| 71 } |
| 72 |
| 73 Event _createEvent(String eventType) { |
| 74 return _wrap(_documentPtr.createEvent(_unwrap(eventType))); |
| 75 } |
| 76 |
| 77 Range createRange() { |
| 78 return _wrap(_documentPtr.createRange()); |
| 79 } |
| 80 |
| 81 Text _createTextNode(String data) { |
| 82 return _wrap(_documentPtr.createTextNode(_unwrap(data))); |
| 83 } |
| 84 |
| 85 Touch createTouch(Window window, EventTarget target, int identifier, int pageX
, int pageY, int screenX, int screenY, int webkitRadiusX, int webkitRadiusY, num
webkitRotationAngle, num webkitForce) { |
| 86 return _wrap(_documentPtr.createTouch(_unwrap(window), _unwrap(target), _unw
rap(identifier), _unwrap(pageX), _unwrap(pageY), _unwrap(screenX), _unwrap(scree
nY), _unwrap(webkitRadiusX), _unwrap(webkitRadiusY), _unwrap(webkitRotationAngle
), _unwrap(webkitForce))); |
| 87 } |
| 88 |
| 89 TouchList _createTouchList() { |
| 90 return _wrap(_documentPtr.createTouchList()); |
| 91 } |
| 92 |
| 93 Element elementFromPoint(int x, int y) { |
| 94 return _wrap(_documentPtr.elementFromPoint(_unwrap(x), _unwrap(y))); |
| 95 } |
| 96 |
| 97 bool execCommand(String command, bool userInterface, String value) { |
| 98 return _wrap(_documentPtr.execCommand(_unwrap(command), _unwrap(userInterfac
e), _unwrap(value))); |
| 99 } |
| 100 |
| 101 Object getCSSCanvasContext(String contextId, String name, int width, int heigh
t) { |
| 102 return _wrap(_documentPtr.getCSSCanvasContext(_unwrap(contextId), _unwrap(na
me), _unwrap(width), _unwrap(height))); |
| 103 } |
| 104 |
| 105 bool queryCommandEnabled(String command) { |
| 106 return _wrap(_documentPtr.queryCommandEnabled(_unwrap(command))); |
| 107 } |
| 108 |
| 109 bool queryCommandIndeterm(String command) { |
| 110 return _wrap(_documentPtr.queryCommandIndeterm(_unwrap(command))); |
| 111 } |
| 112 |
| 113 bool queryCommandState(String command) { |
| 114 return _wrap(_documentPtr.queryCommandState(_unwrap(command))); |
| 115 } |
| 116 |
| 117 bool queryCommandSupported(String command) { |
| 118 return _wrap(_documentPtr.queryCommandSupported(_unwrap(command))); |
| 119 } |
| 120 |
| 121 String queryCommandValue(String command) { |
| 122 return _wrap(_documentPtr.queryCommandValue(_unwrap(command))); |
| 123 } |
| 124 |
| 125 void webkitCancelFullScreen() { |
| 126 _documentPtr.webkitCancelFullScreen(); |
| 127 return; |
| 128 } |
| 129 |
| 130 WebKitNamedFlow webkitGetFlowByName(String name) { |
| 131 return _wrap(_documentPtr.webkitGetFlowByName(_unwrap(name))); |
| 132 } |
| 133 |
| 134 |
| 135 final dom.Document _documentPtr; |
| 136 final _NodeImpl _wrappedDocumentPtr; |
| 137 |
| 138 _DocumentImpl._wrap(ptr) : |
| 139 super._wrap(ptr), |
| 140 _documentPtr = ptr.parentNode, |
| 141 _wrappedDocumentPtr = ptr.parentNode != null ? |
| 142 new _SecretHtmlDocumentImpl._wrap(ptr.parentNode) : null; |
| 143 |
| 144 // TODO(jacobr): remove these methods and let them be generated automatically |
| 145 // once dart supports defining fields with the same name in an interface and |
| 146 // its parent interface. |
| 147 String get title() => _documentPtr.title; |
| 148 void set title(String value) => _documentPtr.title = title; |
| 149 |
| 150 // For efficiency and simplicity, we always use the HtmlElement as the |
| 151 // Document but sometimes internally we need the real JS document object. |
| 152 _NodeImpl get _rawDocument() => _wrappedDocumentPtr; |
| 153 |
| 154 // The document doesn't have a parent element. |
| 155 _ElementImpl get parent() => null; |
| 156 } |
| 157 |
| 158 // This class should not be externally visible. If a user ever gets access to |
| 159 // a _SecretHtmlDocumentImpl object that is a bug. This object is hidden by |
| 160 // adding checks to all methods that could an HTMLDocument. We believe that |
| 161 // list is limited to Event.target, and HTMLHtmlElement.parent. |
| 162 // In a wrapper based world there isn't a need for this complexity but we |
| 163 // use this design for consistency with the wrapperless implementation so |
| 164 // that bugs show up in both cases. |
| 165 class _SecretHtmlDocumentImpl extends _NodeImpl implements Node { |
| 166 |
| 167 _SecretHtmlDocumentImpl._wrap(ptr) : super._wrap(ptr); |
| 168 |
| 169 _DocumentImpl get _documentElement() => _wrap(_ptr.documentElement); |
| 170 } |
| 171 |
| 172 EventTarget _FixHtmlDocumentReference(EventTarget eventTarget) { |
| 173 if (eventTarget is _SecretHtmlDocumentImpl) { |
| 174 _SecretHtmlDocumentImpl secretDocument = eventTarget; |
| 175 return secretDocument._documentElement; |
| 176 } else { |
| 177 return eventTarget; |
| 178 } |
| 179 } |
| 180 |
| 181 class _DocumentEventsImpl extends _ElementEventsImpl implements DocumentEvents { |
| 182 _DocumentEventsImpl(_ptr) : super(_ptr); |
| 183 |
| 184 EventListenerList get abort() => _get('abort'); |
| 185 |
| 186 EventListenerList get beforeCopy() => _get('beforecopy'); |
| 187 |
| 188 EventListenerList get beforeCut() => _get('beforecut'); |
| 189 |
| 190 EventListenerList get beforePaste() => _get('beforepaste'); |
| 191 |
| 192 EventListenerList get blur() => _get('blur'); |
| 193 |
| 194 EventListenerList get change() => _get('change'); |
| 195 |
| 196 EventListenerList get click() => _get('click'); |
| 197 |
| 198 EventListenerList get contextMenu() => _get('contextmenu'); |
| 199 |
| 200 EventListenerList get copy() => _get('copy'); |
| 201 |
| 202 EventListenerList get cut() => _get('cut'); |
| 203 |
| 204 EventListenerList get doubleClick() => _get('dblclick'); |
| 205 |
| 206 EventListenerList get drag() => _get('drag'); |
| 207 |
| 208 EventListenerList get dragEnd() => _get('dragend'); |
| 209 |
| 210 EventListenerList get dragEnter() => _get('dragenter'); |
| 211 |
| 212 EventListenerList get dragLeave() => _get('dragleave'); |
| 213 |
| 214 EventListenerList get dragOver() => _get('dragover'); |
| 215 |
| 216 EventListenerList get dragStart() => _get('dragstart'); |
| 217 |
| 218 EventListenerList get drop() => _get('drop'); |
| 219 |
| 220 EventListenerList get error() => _get('error'); |
| 221 |
| 222 EventListenerList get focus() => _get('focus'); |
| 223 |
| 224 EventListenerList get fullscreenChange() => _get('webkitfullscreenchange'); |
| 225 |
| 226 EventListenerList get fullscreenError() => _get('webkitfullscreenerror'); |
| 227 |
| 228 EventListenerList get input() => _get('input'); |
| 229 |
| 230 EventListenerList get invalid() => _get('invalid'); |
| 231 |
| 232 EventListenerList get keyDown() => _get('keydown'); |
| 233 |
| 234 EventListenerList get keyPress() => _get('keypress'); |
| 235 |
| 236 EventListenerList get keyUp() => _get('keyup'); |
| 237 |
| 238 EventListenerList get load() => _get('load'); |
| 239 |
| 240 EventListenerList get mouseDown() => _get('mousedown'); |
| 241 |
| 242 EventListenerList get mouseMove() => _get('mousemove'); |
| 243 |
| 244 EventListenerList get mouseOut() => _get('mouseout'); |
| 245 |
| 246 EventListenerList get mouseOver() => _get('mouseover'); |
| 247 |
| 248 EventListenerList get mouseUp() => _get('mouseup'); |
| 249 |
| 250 EventListenerList get mouseWheel() => _get('mousewheel'); |
| 251 |
| 252 EventListenerList get paste() => _get('paste'); |
| 253 |
| 254 EventListenerList get readyStateChange() => _get('readystatechange'); |
| 255 |
| 256 EventListenerList get reset() => _get('reset'); |
| 257 |
| 258 EventListenerList get scroll() => _get('scroll'); |
| 259 |
| 260 EventListenerList get search() => _get('search'); |
| 261 |
| 262 EventListenerList get select() => _get('select'); |
| 263 |
| 264 EventListenerList get selectStart() => _get('selectstart'); |
| 265 |
| 266 EventListenerList get selectionChange() => _get('selectionchange'); |
| 267 |
| 268 EventListenerList get submit() => _get('submit'); |
| 269 |
| 270 EventListenerList get touchCancel() => _get('touchcancel'); |
| 271 |
| 272 EventListenerList get touchEnd() => _get('touchend'); |
| 273 |
| 274 EventListenerList get touchMove() => _get('touchmove'); |
| 275 |
| 276 EventListenerList get touchStart() => _get('touchstart'); |
| 277 } |
OLD | NEW |