mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:17:42 +00:00
LibWeb: Add <canvas> element and start fleshing out CRC2D
This patch adds HTMLCanvasElement along with a LayoutCanvas object. The DOM and layout parts are very similar to <img> elements. The <canvas> element holds a Gfx::Bitmap which is sized according to the "width" and "height" attributes on the element. Calling .getContext("2d") on a <canvas> element gives you a context object that draws into the underlying Gfx::Bitmap of the <canvas>. The context weakly points to the <canvas> which allows it to outlive the canvas element if needed. This is really quite cool. :^)
This commit is contained in:
parent
73d28a0551
commit
a37c29e353
19 changed files with 649 additions and 1 deletions
|
@ -26,12 +26,25 @@
|
|||
|
||||
#include <LibJS/Runtime/PrimitiveString.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
#include <LibWeb/Bindings/DocumentWrapper.h>
|
||||
#include <LibWeb/Bindings/HTMLCanvasElementWrapper.h>
|
||||
#include <LibWeb/Bindings/NodeWrapper.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/HTMLCanvasElement.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
|
||||
namespace Web {
|
||||
namespace Bindings {
|
||||
|
||||
NodeWrapper* wrap(JS::Heap& heap, Node& node)
|
||||
{
|
||||
if (is<Document>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(heap, to<Document>(node)));
|
||||
if (is<HTMLCanvasElement>(node))
|
||||
return static_cast<NodeWrapper*>(wrap_impl(heap, to<HTMLCanvasElement>(node)));
|
||||
return static_cast<NodeWrapper*>(wrap_impl(heap, node));
|
||||
}
|
||||
|
||||
NodeWrapper::NodeWrapper(Node& node)
|
||||
: EventTargetWrapper(node)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue