OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 class $CLASSNAME extends _ElementImpl | 5 class $CLASSNAME extends _ElementImpl |
6 implements Document { | 6 implements Document { |
7 $!MEMBERS | 7 $!MEMBERS |
8 | 8 |
9 final dom.Document _documentPtr; | 9 final dom.HTMLDocument _documentPtr; |
10 final _NodeImpl _wrappedDocumentPtr; | 10 final _NodeImpl _wrappedDocumentPtr; |
11 | 11 |
12 _DocumentImpl._wrap(ptr) : | 12 _DocumentImpl._wrap(ptr) : |
13 super._wrap(ptr), | 13 super._wrap(ptr), |
14 _documentPtr = ptr.parentNode, | 14 _documentPtr = ptr.parentNode, |
15 _wrappedDocumentPtr = ptr.parentNode != null ? | 15 _wrappedDocumentPtr = ptr.parentNode != null ? |
16 new _SecretHtmlDocumentImpl._wrap(ptr.parentNode) : null; | 16 new _SecretHtmlDocumentImpl._wrap(ptr.parentNode) : null; |
17 | 17 |
18 // TODO(jacobr): remove these methods and let them be generated automatically | |
19 // once dart supports defining fields with the same name in an interface and | |
20 // its parent interface. | |
21 String get title() => _documentPtr.title; | |
22 void set title(String value) => _documentPtr.title = title; | |
23 | |
24 // For efficiency and simplicity, we always use the HtmlElement as the | 18 // For efficiency and simplicity, we always use the HtmlElement as the |
25 // Document but sometimes internally we need the real JS document object. | 19 // Document but sometimes internally we need the real JS document object. |
26 _NodeImpl get _rawDocument() => _wrappedDocumentPtr; | 20 _NodeImpl get _rawDocument() => _wrappedDocumentPtr; |
27 | 21 |
28 // The document doesn't have a parent element. | 22 // The document doesn't have a parent element. |
29 _ElementImpl get parent() => null; | 23 _ElementImpl get parent() => null; |
30 } | 24 } |
31 | 25 |
32 // This class should not be externally visible. If a user ever gets access to | 26 // This class should not be externally visible. If a user ever gets access to |
33 // a _SecretHtmlDocumentImpl object that is a bug. This object is hidden by | 27 // a _SecretHtmlDocumentImpl object that is a bug. This object is hidden by |
(...skipping 10 matching lines...) Expand all Loading... |
44 } | 38 } |
45 | 39 |
46 EventTarget _FixHtmlDocumentReference(EventTarget eventTarget) { | 40 EventTarget _FixHtmlDocumentReference(EventTarget eventTarget) { |
47 if (eventTarget is _SecretHtmlDocumentImpl) { | 41 if (eventTarget is _SecretHtmlDocumentImpl) { |
48 _SecretHtmlDocumentImpl secretDocument = eventTarget; | 42 _SecretHtmlDocumentImpl secretDocument = eventTarget; |
49 return secretDocument._documentElement; | 43 return secretDocument._documentElement; |
50 } else { | 44 } else { |
51 return eventTarget; | 45 return eventTarget; |
52 } | 46 } |
53 } | 47 } |
OLD | NEW |