2022-07-05 18:59:45 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-09-03 00:22:54 +02:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2022-07-05 18:59:45 +01:00
|
|
|
|
2025-03-03 13:04:14 +00:00
|
|
|
namespace Web::HTML {
|
2022-07-05 18:59:45 +01:00
|
|
|
|
2025-03-03 13:04:14 +00:00
|
|
|
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#xmlserializer
|
2022-09-03 00:22:54 +02:00
|
|
|
class XMLSerializer final : public Bindings::PlatformObject {
|
|
|
|
WEB_PLATFORM_OBJECT(XMLSerializer, Bindings::PlatformObject);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(XMLSerializer);
|
2022-07-05 18:59:45 +01:00
|
|
|
|
2022-09-03 00:22:54 +02:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
static WebIDL::ExceptionOr<GC::Ref<XMLSerializer>> construct_impl(JS::Realm&);
|
2022-07-05 18:59:45 +01:00
|
|
|
|
|
|
|
virtual ~XMLSerializer() override;
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
WebIDL::ExceptionOr<String> serialize_to_string(GC::Ref<DOM::Node const> root);
|
2022-07-05 18:59:45 +01:00
|
|
|
|
|
|
|
private:
|
2022-09-25 16:15:49 -06:00
|
|
|
explicit XMLSerializer(JS::Realm&);
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-07-05 18:59:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class RequireWellFormed {
|
|
|
|
No,
|
|
|
|
Yes,
|
|
|
|
};
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
WebIDL::ExceptionOr<String> serialize_node_to_xml_string(GC::Ref<DOM::Node const> root, RequireWellFormed require_well_formed);
|
2022-07-05 18:59:45 +01:00
|
|
|
}
|