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

Unified Diff: sky/engine/bindings/custom/dart_element_custom.cc

Issue 943153002: Make it possible for sky-element to register any tag name (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « sky/engine/bindings/BUILD.gn ('k') | sky/engine/bindings/scripts/templates/interface_dart.template » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/bindings/custom/dart_element_custom.cc
diff --git a/sky/engine/bindings/custom/dart_element_custom.cc b/sky/engine/bindings/custom/dart_element_custom.cc
new file mode 100644
index 0000000000000000000000000000000000000000..39ea4a02eaa53efbc152d80ffad685c55f83ad70
--- /dev/null
+++ b/sky/engine/bindings/custom/dart_element_custom.cc
@@ -0,0 +1,37 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sky/engine/config.h"
+#include "sky/engine/core/dom/Element.h"
+
+#include "dart/runtime/include/dart_api.h"
+#include "sky/engine/core/script/dom_dart_state.h"
+#include "sky/engine/tonic/dart_converter.h"
+
+namespace blink {
+namespace DartElementInternal {
+
+void constructorCallback(Dart_NativeArguments args) {
+ Dart_Handle receiver = Dart_GetNativeArgument(args, 0);
+ DCHECK(!LogIfError(receiver));
+
+ Dart_Handle tag_name = Dart_GetField(receiver,
+ Dart_NewStringFromCString("tagName"));
+ if (!Dart_IsString(tag_name)) {
+ Dart_ThrowException(Dart_NewStringFromCString("tagName is not a string"));
+ return;
+ }
+
+ RefPtr<Element> element = Element::create(
+ QualifiedName(StringFromDart(tag_name)), DOMDartState::CurrentDocument());
+
+ // TODO(abarth): We should remove these states because elements are never
+ // waiting for upgrades.
+ element->setCustomElementState(Element::WaitingForUpgrade);
+ element->setCustomElementState(Element::Upgraded);
+ element->AssociateWithDartWrapper(args);
+}
+
+} // namespace DartElementInternal
+} // namespace blink
« no previous file with comments | « sky/engine/bindings/BUILD.gn ('k') | sky/engine/bindings/scripts/templates/interface_dart.template » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698