mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:08:11 +00:00
LibWeb: Add DOMParser
This allows you to invoke the HTML document parser and retrieve a document as though it was loaded as a web page, minus any scripting ability. This does not currently support XML parsing. This is used by YouTube (or more accurately, Web Components Polyfills) to polyfill templates.
This commit is contained in:
parent
0ea50d44bf
commit
f7ad8c0f94
6 changed files with 93 additions and 0 deletions
39
Userland/Libraries/LibWeb/HTML/DOMParser.h
Normal file
39
Userland/Libraries/LibWeb/HTML/DOMParser.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibWeb/Bindings/Wrappable.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparser
|
||||
class DOMParser final
|
||||
: public RefCounted<DOMParser>
|
||||
, public Weakable<DOMParser>
|
||||
, public Bindings::Wrappable {
|
||||
public:
|
||||
using WrapperType = Bindings::DOMParserWrapper;
|
||||
|
||||
static DOM::ExceptionOr<NonnullRefPtr<DOMParser>> create_with_global_object(Bindings::WindowObject&)
|
||||
{
|
||||
return adopt_ref(*new DOMParser());
|
||||
}
|
||||
|
||||
virtual ~DOMParser() override;
|
||||
|
||||
NonnullRefPtr<DOM::Document> parse_from_string(String const&, String const&);
|
||||
|
||||
private:
|
||||
DOMParser();
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue