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

LibWeb: Clean up static function in header

'static' for a function means that the symbol shall not be made public
for the result of the current compilation unit. This does not make sense
in a header, especially not if it's a large function that is used in
more than one place and not that performance-sensitive.
This commit is contained in:
Ben Wiederhake 2021-10-02 22:45:37 +02:00 committed by Linus Groh
parent 21ba485fd3
commit 7619dbdbb4
6 changed files with 60 additions and 58 deletions

View file

@ -9,32 +9,11 @@
#include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/DOMParsing/Algorithms.h>
#include <LibWeb/HTML/HTMLTemplateElement.h>
namespace Web::DOMParsing::InnerHTML {
namespace Web::DOMParsing {
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
static DOM::ExceptionOr<void> inner_html_setter(NonnullRefPtr<DOM::Node> context_object, String const& value)
{
// 1. Let context element be the context object's host if the context object is a ShadowRoot object, or the context object otherwise.
// (This is handled in Element and ShadowRoot)
NonnullRefPtr<DOM::Element> context_element = is<DOM::ShadowRoot>(*context_object) ? *verify_cast<DOM::ShadowRoot>(*context_object).host() : verify_cast<DOM::Element>(*context_object);
// 2. Let fragment be the result of invoking the fragment parsing algorithm with the new value as markup, and with context element.
auto fragment_or_exception = parse_fragment(value, context_element);
if (fragment_or_exception.is_exception())
return fragment_or_exception.exception();
auto fragment = fragment_or_exception.release_value();
// 3. If the context object is a template element, then let context object be the template's template contents (a DocumentFragment).
if (is<HTML::HTMLTemplateElement>(*context_object))
context_object = verify_cast<HTML::HTMLTemplateElement>(*context_object).content();
// 4. Replace all with fragment within the context object.
context_object->replace_all(fragment);
return {};
}
DOM::ExceptionOr<void> inner_html_setter(NonnullRefPtr<DOM::Node> context_object, String const& value);
}