ladybird/Userland/Libraries/LibWebView/Attribute.cpp
Timothy Flynn 4cfeb41c4b LibWebView+WebContent: Add APIs to manipulate DOM nodes
This adds APIs to allow Ispector clients to:
* Change a DOM text or comment node's text data.
* Add, replace, or remove a DOM element's attribute.
* Change a DOM element's tag.
2023-12-04 01:33:57 +01:00

26 lines
626 B
C++

/*
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibIPC/Decoder.h>
#include <LibIPC/Encoder.h>
#include <LibWebView/Attribute.h>
template<>
ErrorOr<void> IPC::encode(Encoder& encoder, WebView::Attribute const& attribute)
{
TRY(encoder.encode(attribute.name));
TRY(encoder.encode(attribute.value));
return {};
}
template<>
ErrorOr<WebView::Attribute> IPC::decode(Decoder& decoder)
{
auto name = TRY(decoder.decode<String>());
auto value = TRY(decoder.decode<String>());
return WebView::Attribute { move(name), move(value) };
}