LibWeb: Stub out HTMLElement.outerText

This commit is contained in:
Andreas Kling 2024-04-14 18:26:44 +02:00
commit 4cc972a8ae
Notes: sideshowbarker 2024-07-17 06:51:10 +09:00
3 changed files with 31 additions and 2 deletions

View file

@ -146,8 +146,18 @@ void HTMLElement::set_inner_text(StringView text)
set_needs_style_update(true);
}
String HTMLElement::inner_text()
// https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute:dom-outertext-2
WebIDL::ExceptionOr<void> HTMLElement::set_outer_text(String)
{
dbgln("FIXME: Implement HTMLElement::set_outer_text()");
return {};
}
// https://html.spec.whatwg.org/multipage/dom.html#get-the-text-steps
String HTMLElement::get_the_text_steps()
{
// FIXME: Implement this according to spec.
StringBuilder builder;
// innerText for element being rendered takes visibility into account, so force a layout and then walk the layout tree.
@ -169,6 +179,20 @@ String HTMLElement::inner_text()
return MUST(builder.to_string());
}
// https://html.spec.whatwg.org/multipage/dom.html#dom-innertext
String HTMLElement::inner_text()
{
// The innerText and outerText getter steps are to return the result of running get the text steps with this.
return get_the_text_steps();
}
// https://html.spec.whatwg.org/multipage/dom.html#dom-outertext
String HTMLElement::outer_text()
{
// The innerText and outerText getter steps are to return the result of running get the text steps with this.
return get_the_text_steps();
}
// https://www.w3.org/TR/cssom-view-1/#dom-htmlelement-offsetparent
JS::GCPtr<DOM::Element> HTMLElement::offset_parent() const
{

View file

@ -42,6 +42,9 @@ public:
String inner_text();
void set_inner_text(StringView);
[[nodiscard]] String outer_text();
WebIDL::ExceptionOr<void> set_outer_text(String);
int offset_top() const;
int offset_left() const;
int offset_width() const;
@ -87,6 +90,8 @@ private:
virtual JS::GCPtr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const&) override { return *this; }
virtual void did_receive_focus() override;
[[nodiscard]] String get_the_text_steps();
JS::GCPtr<DOMStringMap> m_dataset;
enum class ContentEditableState {

View file

@ -26,7 +26,7 @@ interface HTMLElement : Element {
// FIXME: [CEReactions] attribute DOMString autocapitalize;
[LegacyNullToEmptyString, CEReactions] attribute DOMString innerText;
// FIXME: [LegacyNullToEmptyString, CEReactions] attribute DOMString outerText;
[LegacyNullToEmptyString, CEReactions] attribute DOMString outerText;
// FIXME: ElementInternals attachInternals();