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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
Index: client/dom/templates/html/dartium/impl_Document.darttemplate
diff --git a/client/dom/templates/html/dartium/impl_Document.darttemplate b/client/dom/templates/html/dartium/impl_Document.darttemplate
new file mode 100644
index 0000000000000000000000000000000000000000..08df5eea66cd89df139cfc06d4c0ba61694161f6
--- /dev/null
+++ b/client/dom/templates/html/dartium/impl_Document.darttemplate
@@ -0,0 +1,53 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class $CLASSNAME extends _ElementImpl
+ implements Document {
+$!MEMBERS
+
+ final dom.Document _documentPtr;
+ final _NodeImpl _wrappedDocumentPtr;
+
+_DocumentImpl._wrap(ptr) :
+ super._wrap(ptr),
+ _documentPtr = ptr.parentNode,
+ _wrappedDocumentPtr = ptr.parentNode != null ?
+ new _SecretHtmlDocumentImpl._wrap(ptr.parentNode) : null;
+
+ // TODO(jacobr): remove these methods and let them be generated automatically
+ // once dart supports defining fields with the same name in an interface and
+ // its parent interface.
+ String get title() => _documentPtr.title;
+ void set title(String value) => _documentPtr.title = title;
+
+ // For efficiency and simplicity, we always use the HtmlElement as the
+ // Document but sometimes internally we need the real JS document object.
+ _NodeImpl get _rawDocument() => _wrappedDocumentPtr;
+
+ // The document doesn't have a parent element.
+ _ElementImpl get parent() => null;
+}
+
+// This class should not be externally visible. If a user ever gets access to
+// a _SecretHtmlDocumentImpl object that is a bug. This object is hidden by
+// adding checks to all methods that could an HTMLDocument. We believe that
+// list is limited to Event.target, and HTMLHtmlElement.parent.
+// In a wrapper based world there isn't a need for this complexity but we
+// use this design for consistency with the wrapperless implementation so
+// that bugs show up in both cases.
+class _SecretHtmlDocumentImpl extends _NodeImpl implements Node {
+
+ _SecretHtmlDocumentImpl._wrap(ptr) : super._wrap(ptr);
+
+ _DocumentImpl get _documentElement() => _wrap(_ptr.documentElement);
+}
+
+EventTarget _FixHtmlDocumentReference(EventTarget eventTarget) {
+ if (eventTarget is _SecretHtmlDocumentImpl) {
+ _SecretHtmlDocumentImpl secretDocument = eventTarget;
+ return secretDocument._documentElement;
+ } else {
+ return eventTarget;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698