ladybird/Libraries/LibWeb/HTML/HTMLIFrameElement.h
Andreas Kling 9340d2d1a3 LibWeb: Make layout nodes refcounted
Move the layout tree from GC allocation to refcounted ownership so
removed layout and paint subtrees are destroyed synchronously instead
of waiting for the next GC sweep. This dramatically reduces GC memory
usage peaks after layout tree churn and makes it easier for memory use
to fall back after large document updates.

Update layout factories, tree traversal, SVG layout node creation,
paintable back-pointers, and pseudo-element layout links to use RefPtr
ownership.

Make display: contents follow the same shape as Blink and WebKit: the
element itself does not create a layout node, and its children are
flattened into the nearest layout parent. Wrap direct non-whitespace
text in an anonymous inline node when the boxless element contributes
inherited style to that text.

Use an internal inline wrapper for display: contents pseudo-elements
so generated content can still participate in layout, painting, hit
testing, and pseudo-element queries. Keep CSSOM reporting the computed
display value from the pseudo style, not the internal wrapper.

Remove the retained out-of-tree layout node list and its testing hook,
since the flattened model does not need a side owner for boxless
elements. Add coverage for inherited text style, dynamic insertion
order, pseudo-element hit testing, and computed style queries.
2026-06-07 20:52:49 +02:00

98 lines
3.7 KiB
C++

/*
* Copyright (c) 2020-2021, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/HTML/LazyLoadingElement.h>
#include <LibWeb/HTML/NavigableContainer.h>
namespace Web::HTML {
class HTMLIFrameElement final
: public NavigableContainer
, public LazyLoadingElement<HTMLIFrameElement> {
WEB_PLATFORM_OBJECT(HTMLIFrameElement, NavigableContainer);
LAZY_LOADING_ELEMENT(HTMLIFrameElement);
GC_DECLARE_ALLOCATOR(HTMLIFrameElement);
public:
virtual ~HTMLIFrameElement() override;
virtual RefPtr<Layout::Node> create_layout_node(CSS::ComputedProperties const&) override;
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
// ^EventTarget
virtual bool is_focusable() const override
{
return meets_focusable_area_rendering_requirements();
}
void set_current_navigation_was_lazy_loaded(bool value);
Optional<HighResolutionTime::DOMHighResTimeStamp> const& pending_resource_start_time() const { return m_pending_resource_start_time; }
void set_pending_resource_start_time(Optional<HighResolutionTime::DOMHighResTimeStamp> time) { m_pending_resource_start_time = time; }
GC::Ref<DOM::DOMTokenList> sandbox();
SandboxingFlagSet iframe_sandboxing_flag_set() const { return m_iframe_sandboxing_flag_set; }
TrustedTypes::TrustedHTMLOrString srcdoc();
WebIDL::ExceptionOr<void> set_srcdoc(TrustedTypes::TrustedHTMLOrString const& value);
virtual void visit_edges(Cell::Visitor&) override;
void set_iframe_fullscreen_flag(bool iframe_fullscreen_flag) { m_iframe_fullscreen_flag = iframe_fullscreen_flag; }
bool iframe_fullscreen_flag() const { return m_iframe_fullscreen_flag; }
private:
HTMLIFrameElement(DOM::Document&, DOM::QualifiedName);
virtual void initialize(JS::Realm&) override;
// ^DOM::Node
virtual bool is_html_iframe_element() const override { return true; }
// ^DOM::Element
virtual void post_connection() override;
virtual void removed_from(IsSubtreeRoot, Node* old_ancestor, Node& old_root) override;
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
virtual i32 default_tab_index_value() const override;
virtual bool is_presentational_hint(FlyString const&) const override;
virtual void apply_presentational_hints(Vector<CSS::StyleProperty>&) const override;
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:dimension-attributes
virtual bool supports_dimension_attributes() const override { return true; }
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes
void process_the_iframe_attributes(InitialInsertion = InitialInsertion::No);
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#current-navigation-was-lazy-loaded
bool m_current_navigation_was_lazy_loaded { false };
// https://fullscreen.spec.whatwg.org/#iframe-fullscreen-flag
bool m_iframe_fullscreen_flag { false };
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#iframe-pending-resource-timing-start-time
Optional<HighResolutionTime::DOMHighResTimeStamp> m_pending_resource_start_time = {};
GC::Ptr<DOM::DOMTokenList> m_sandbox;
// https://html.spec.whatwg.org/multipage/browsers.html#iframe-sandboxing-flag-set
SandboxingFlagSet m_iframe_sandboxing_flag_set {};
};
void run_iframe_load_event_steps(HTML::HTMLIFrameElement&);
}
namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLIFrameElement>() const { return is_html_iframe_element(); }
}