From fb186ce67914151ca342461f969b5a7d633d8830 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Fri, 20 Feb 2015 16:15:42 -0800 Subject: [PATCH] Implement Custom Elements This CL implements custom elements. The design is as follows: 1) Authors subclass Element and call registerElement. 2) When we create C++ elements for custom elements, we call the author's constructor synchronously. 3) The attach/detach/attributeChanged callbacks are called either: a) when exiting the current custom element callback scoped (e.g., before returning from appendChild), or b) when draining the microtask queue. The implementation in this CL is a bit fragile because we don't detect name registration conflicts and we let you create custom elements with the same name as built-in elements. Also, not every part of the engine is prepared to execute script synchronously below createElement. We'll need to iron out these issues over time, but this CL is a start. R=ojan@chromium.org Review URL: https://codereview.chromium.org/943013002 --- .../custom-elements/callbacks-expected.txt | 6 ++ .../tests/custom-elements/callbacks.sky | 55 +++++++++++++++++++ .../custom-elements/registration-expected.txt | 2 + .../tests/custom-elements/registration.sky | 27 +++++++++ 4 files changed, 90 insertions(+) create mode 100644 engine/src/flutter/tests/custom-elements/callbacks-expected.txt create mode 100644 engine/src/flutter/tests/custom-elements/callbacks.sky create mode 100644 engine/src/flutter/tests/custom-elements/registration-expected.txt create mode 100644 engine/src/flutter/tests/custom-elements/registration.sky diff --git a/engine/src/flutter/tests/custom-elements/callbacks-expected.txt b/engine/src/flutter/tests/custom-elements/callbacks-expected.txt new file mode 100644 index 0000000000..e1f4237326 --- /dev/null +++ b/engine/src/flutter/tests/custom-elements/callbacks-expected.txt @@ -0,0 +1,6 @@ +CONSOLE: unittest-suite-wait-for-done +CONSOLE: PASS: callbacks should be called +CONSOLE: +CONSOLE: All 1 tests passed. +CONSOLE: unittest-suite-success +DONE diff --git a/engine/src/flutter/tests/custom-elements/callbacks.sky b/engine/src/flutter/tests/custom-elements/callbacks.sky new file mode 100644 index 0000000000..b9d640943a --- /dev/null +++ b/engine/src/flutter/tests/custom-elements/callbacks.sky @@ -0,0 +1,55 @@ + + + diff --git a/engine/src/flutter/tests/custom-elements/registration-expected.txt b/engine/src/flutter/tests/custom-elements/registration-expected.txt new file mode 100644 index 0000000000..2a8c860db5 --- /dev/null +++ b/engine/src/flutter/tests/custom-elements/registration-expected.txt @@ -0,0 +1,2 @@ +CONSOLE: PASS: FooElement attached. + diff --git a/engine/src/flutter/tests/custom-elements/registration.sky b/engine/src/flutter/tests/custom-elements/registration.sky new file mode 100644 index 0000000000..1a2627380d --- /dev/null +++ b/engine/src/flutter/tests/custom-elements/registration.sky @@ -0,0 +1,27 @@ + + + +