From 68b04d5c78612ea03d1df0014c107340f817b6d7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 25 Mar 2020 18:53:20 +0100 Subject: [PATCH] LibWeb: Implement getting and setting element.innerHTML Getting the innerHTML property will recurse through the subtree inside the element and serialize it into a string as it goes. Setting it will parse the set value as an HTML fragment. It will then remove all current children of the element and replace them with all the children inside the parsed fragment. Setting element.innerHTML will currently force a complete rebuild of the document's layout tree. This is pretty neat! :^) --- Base/home/anon/www/innerHTML.html | 17 +++++ Base/home/anon/www/welcome.html | 1 + Libraries/LibWeb/Bindings/ElementWrapper.cpp | 65 +++++++++++++++++++ Libraries/LibWeb/Bindings/ElementWrapper.h | 47 ++++++++++++++ .../Bindings/HTMLCanvasElementWrapper.cpp | 2 +- .../Bindings/HTMLCanvasElementWrapper.h | 4 +- Libraries/LibWeb/Bindings/NodeWrapper.cpp | 2 + Libraries/LibWeb/DOM/Element.cpp | 52 ++++++++++++++- Libraries/LibWeb/DOM/Element.h | 5 ++ Libraries/LibWeb/Forward.h | 1 + Libraries/LibWeb/Makefile | 1 + 11 files changed, 192 insertions(+), 5 deletions(-) create mode 100644 Base/home/anon/www/innerHTML.html create mode 100644 Libraries/LibWeb/Bindings/ElementWrapper.cpp create mode 100644 Libraries/LibWeb/Bindings/ElementWrapper.h diff --git a/Base/home/anon/www/innerHTML.html b/Base/home/anon/www/innerHTML.html new file mode 100644 index 0000000000..9bd382d497 --- /dev/null +++ b/Base/home/anon/www/innerHTML.html @@ -0,0 +1,17 @@ + + + + + +
Click me
+
This has some HTML inside it!
+ + + diff --git a/Base/home/anon/www/welcome.html b/Base/home/anon/www/welcome.html index 719d910ff4..af8dd8381d 100644 --- a/Base/home/anon/www/welcome.html +++ b/Base/home/anon/www/welcome.html @@ -23,6 +23,7 @@ h1 {

This is a very simple browser built on the LibWeb engine.

Some small test pages: