2020-06-05 23:36:02 +02:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2020-2021, Andreas Kling <andreas@ladybird.org>
|
2023-11-21 18:52:33 +00:00
|
|
|
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
2020-06-05 23:36:02 +02:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-05 23:36:02 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-11-21 18:52:33 +00:00
|
|
|
#include <LibWeb/HTML/LazyLoadingElement.h>
|
2022-12-12 12:20:02 +01:00
|
|
|
#include <LibWeb/HTML/NavigableContainer.h>
|
2020-06-05 23:36:02 +02:00
|
|
|
|
2020-07-28 18:20:36 +02:00
|
|
|
namespace Web::HTML {
|
2020-06-05 23:36:02 +02:00
|
|
|
|
2023-11-21 18:52:33 +00:00
|
|
|
class HTMLIFrameElement final
|
|
|
|
|
: public NavigableContainer
|
|
|
|
|
, public LazyLoadingElement<HTMLIFrameElement> {
|
|
|
|
|
|
2022-12-12 12:20:02 +01:00
|
|
|
WEB_PLATFORM_OBJECT(HTMLIFrameElement, NavigableContainer);
|
2023-11-21 18:52:33 +00:00
|
|
|
LAZY_LOADING_ELEMENT(HTMLIFrameElement);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(HTMLIFrameElement);
|
2020-07-27 05:04:26 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
public:
|
2020-06-05 23:36:02 +02:00
|
|
|
virtual ~HTMLIFrameElement() override;
|
|
|
|
|
|
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 17:50:33 +02:00
|
|
|
virtual RefPtr<Layout::Node> create_layout_node(CSS::ComputedProperties const&) override;
|
2024-12-20 11:32:17 +01:00
|
|
|
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
2020-06-05 23:36:02 +02:00
|
|
|
|
2025-08-22 11:04:24 +02:00
|
|
|
// ^EventTarget
|
2026-05-20 13:28:52 +02:00
|
|
|
virtual bool is_focusable() const override
|
|
|
|
|
{
|
|
|
|
|
return meets_focusable_area_rendering_requirements();
|
|
|
|
|
}
|
2025-08-22 11:04:24 +02:00
|
|
|
|
2023-11-24 15:54:57 +00:00
|
|
|
void set_current_navigation_was_lazy_loaded(bool value);
|
2022-09-19 13:34:36 +02:00
|
|
|
|
2023-09-21 13:47:19 -06:00
|
|
|
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; }
|
|
|
|
|
|
2024-11-18 07:16:26 +13:00
|
|
|
GC::Ref<DOM::DOMTokenList> sandbox();
|
|
|
|
|
|
2024-12-06 14:53:03 +00:00
|
|
|
SandboxingFlagSet iframe_sandboxing_flag_set() const { return m_iframe_sandboxing_flag_set; }
|
|
|
|
|
|
2025-10-31 11:51:57 +00:00
|
|
|
TrustedTypes::TrustedHTMLOrString srcdoc();
|
|
|
|
|
WebIDL::ExceptionOr<void> set_srcdoc(TrustedTypes::TrustedHTMLOrString const& value);
|
|
|
|
|
|
2023-11-21 18:52:33 +00:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
2025-03-31 19:38:15 +02:00
|
|
|
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; }
|
|
|
|
|
|
2020-06-05 23:36:02 +02:00
|
|
|
private:
|
2022-08-28 13:42:07 +02:00
|
|
|
HTMLIFrameElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2025-01-07 16:06:51 +00:00
|
|
|
// ^DOM::Node
|
|
|
|
|
virtual bool is_html_iframe_element() const override { return true; }
|
|
|
|
|
|
2022-11-05 03:58:14 +00:00
|
|
|
// ^DOM::Element
|
2024-12-15 02:59:23 +13:00
|
|
|
virtual void post_connection() override;
|
2026-04-16 20:04:54 +01:00
|
|
|
virtual void removed_from(IsSubtreeRoot, Node* old_ancestor, Node& old_root) override;
|
2024-11-14 08:14:16 -05:00
|
|
|
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
2022-11-05 03:58:14 +00:00
|
|
|
virtual i32 default_tab_index_value() const override;
|
2025-03-14 16:58:10 +00:00
|
|
|
virtual bool is_presentational_hint(FlyString const&) const override;
|
2026-04-30 10:44:26 +01:00
|
|
|
virtual void apply_presentational_hints(Vector<CSS::StyleProperty>&) const override;
|
2020-06-06 15:08:36 +02:00
|
|
|
|
2024-04-10 21:44:11 -04:00
|
|
|
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:dimension-attributes
|
|
|
|
|
virtual bool supports_dimension_attributes() const override { return true; }
|
|
|
|
|
|
2022-09-19 13:34:36 +02:00
|
|
|
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes
|
2025-05-15 12:28:53 +01:00
|
|
|
void process_the_iframe_attributes(InitialInsertion = InitialInsertion::No);
|
2022-09-19 13:34:36 +02:00
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#current-navigation-was-lazy-loaded
|
|
|
|
|
bool m_current_navigation_was_lazy_loaded { false };
|
2023-09-21 13:47:19 -06:00
|
|
|
|
2025-03-31 19:38:15 +02:00
|
|
|
// https://fullscreen.spec.whatwg.org/#iframe-fullscreen-flag
|
|
|
|
|
bool m_iframe_fullscreen_flag { false };
|
|
|
|
|
|
2023-09-21 13:47:19 -06:00
|
|
|
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#iframe-pending-resource-timing-start-time
|
|
|
|
|
Optional<HighResolutionTime::DOMHighResTimeStamp> m_pending_resource_start_time = {};
|
2024-11-18 07:16:26 +13:00
|
|
|
|
|
|
|
|
GC::Ptr<DOM::DOMTokenList> m_sandbox;
|
2024-12-06 14:53:03 +00:00
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/browsers.html#iframe-sandboxing-flag-set
|
|
|
|
|
SandboxingFlagSet m_iframe_sandboxing_flag_set {};
|
2020-06-05 23:36:02 +02:00
|
|
|
};
|
|
|
|
|
|
2021-09-26 02:25:02 +02:00
|
|
|
void run_iframe_load_event_steps(HTML::HTMLIFrameElement&);
|
|
|
|
|
|
2026-06-11 12:18:41 +01:00
|
|
|
ReferrerPolicy::ReferrerPolicy determine_iframe_element_referrer_policy(GC::Ptr<DOM::Element> embedder);
|
|
|
|
|
|
2020-06-05 23:36:02 +02:00
|
|
|
}
|
2025-04-18 10:27:59 +02:00
|
|
|
|
|
|
|
|
namespace Web::DOM {
|
2025-05-13 07:06:33 -04:00
|
|
|
|
2025-04-18 10:27:59 +02:00
|
|
|
template<>
|
|
|
|
|
inline bool Node::fast_is<HTML::HTMLIFrameElement>() const { return is_html_iframe_element(); }
|
2025-05-13 07:06:33 -04:00
|
|
|
|
2025-04-18 10:27:59 +02:00
|
|
|
}
|