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

Side by Side Diff: client/dom/templates/html/dartium/impl_Document.darttemplate

Issue 9537001: Generate dart:html bindings for Dartium as well as Frog. All unittests now pass (or are disabled fo… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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
OLDNEW
(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.Document _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 // 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
25 // Document but sometimes internally we need the real JS document object.
26 _NodeImpl get _rawDocument() => _wrappedDocumentPtr;
27
28 // The document doesn't have a parent element.
29 _ElementImpl get parent() => null;
30 }
31
32 // 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
34 // adding checks to all methods that could an HTMLDocument. We believe that
35 // list is limited to Event.target, and HTMLHtmlElement.parent.
36 // In a wrapper based world there isn't a need for this complexity but we
37 // use this design for consistency with the wrapperless implementation so
38 // that bugs show up in both cases.
39 class _SecretHtmlDocumentImpl extends _NodeImpl implements Node {
40
41 _SecretHtmlDocumentImpl._wrap(ptr) : super._wrap(ptr);
42
43 _DocumentImpl get _documentElement() => _wrap(_ptr.documentElement);
44 }
45
46 EventTarget _FixHtmlDocumentReference(EventTarget eventTarget) {
47 if (eventTarget is _SecretHtmlDocumentImpl) {
48 _SecretHtmlDocumentImpl secretDocument = eventTarget;
49 return secretDocument._documentElement;
50 } else {
51 return eventTarget;
52 }
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698