1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 11:55:08 +00:00

LibWeb: Fix Document construction mishap in <template> element

Ref-counted objects must not be stack allocated. Make DOM::Document's
constructor private to avoid this issue. (I wish we could mark classes
as heap-only..)
This commit is contained in:
Andreas Kling 2020-10-23 08:31:26 +02:00
parent 691b105885
commit 46c15276e9
7 changed files with 11 additions and 9 deletions

View file

@ -63,7 +63,7 @@ static RefPtr<DOM::Document> create_markdown_document(const ByteBuffer& data, co
static RefPtr<DOM::Document> create_text_document(const ByteBuffer& data, const URL& url)
{
auto document = adopt(*new DOM::Document(url));
auto document = DOM::Document::create(url);
auto html_element = document->create_element("html");
document->append_child(html_element);
@ -88,7 +88,7 @@ static RefPtr<DOM::Document> create_text_document(const ByteBuffer& data, const
static RefPtr<DOM::Document> create_image_document(const ByteBuffer& data, const URL& url)
{
auto document = adopt(*new DOM::Document(url));
auto document = DOM::Document::create(url);
auto image_decoder = Gfx::ImageDecoder::create(data.data(), data.size());
auto bitmap = image_decoder->bitmap();