| 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 $CLASSNAME extends _ElementImpl | |
| 6 implements Document { | |
| 7 $!MEMBERS | |
| 8 | |
| 9 final dom.HTMLDocument _documentPtr; | |
| 10 final _NodeImpl _wrappedDocumentPtr; | |
| 11 | |
| 12 _DocumentImpl._wrap(ptr) : | |
| 13 super._wrap(ptr), | |
| 14 _documentPtr = ptr.parentNode, | |
| 15 _wrappedDocumentPtr = ptr.parentNode != null ? | |
| 16 new _SecretHtmlDocumentImpl._wrap(ptr.parentNode) : null; | |
| 17 | |
| 18 // For efficiency and simplicity, we always use the HtmlElement as the | |
| 19 // Document but sometimes internally we need the real JS document object. | |
| 20 _NodeImpl get _rawDocument() => _wrappedDocumentPtr; | |
| 21 | |
| 22 // The document doesn't have a parent element. | |
| 23 _ElementImpl get parent() => null; | |
| 24 } | |
| 25 | |
| 26 // This class should not be externally visible. If a user ever gets access to | |
| 27 // a _SecretHtmlDocumentImpl object that is a bug. This object is hidden by | |
| 28 // adding checks to all methods that could an HTMLDocument. We believe that | |
| 29 // list is limited to Event.target, and HTMLHtmlElement.parent. | |
| 30 // In a wrapper based world there isn't a need for this complexity but we | |
| 31 // use this design for consistency with the wrapperless implementation so | |
| 32 // that bugs show up in both cases. | |
| 33 class _SecretHtmlDocumentImpl extends _NodeImpl implements Node { | |
| 34 | |
| 35 _SecretHtmlDocumentImpl._wrap(ptr) : super._wrap(ptr); | |
| 36 | |
| 37 _DocumentImpl get _documentElement() => _wrap(_ptr.documentElement); | |
| 38 } | |
| 39 | |
| 40 EventTarget _FixHtmlDocumentReference(EventTarget eventTarget) { | |
| 41 if (eventTarget is _SecretHtmlDocumentImpl) { | |
| 42 _SecretHtmlDocumentImpl secretDocument = eventTarget; | |
| 43 return secretDocument._documentElement; | |
| 44 } else { | |
| 45 return eventTarget; | |
| 46 } | |
| 47 } | |
| OLD | NEW |