Truly independent web browser
LibWeb: Render frameset and frame elements
Andreas Klinged020f57aa19
diff --git a/Libraries/LibWeb/CSS/Default.css b/Libraries/LibWeb/CSS/Default.cssindex 179648d920e..8ceb3d7218b 100644--- a/Libraries/LibWeb/CSS/Default.css+++ b/Libraries/LibWeb/CSS/Default.css@@ -859,6 +859,33 @@ iframe {border: 2px inset;}+/* INTEROP: Other browsers do not honor these properties on frameset and frame elements, even for display: none. */+frameset, frame {+ display: block !important;+ position: static !important;+ float: none !important;+ writing-mode: horizontal-tb !important;+ direction: ltr !important;+}++/* https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets+ User agents are expected to render frameset elements as a box with the height and width of the viewport+ INTEROP: Other browsers do not let any of these properties change the size of that box, or paint its background. */+frameset {+ width: 100vw !important;+ height: 100vh !important;+ flex: none !important;+ padding: 0 !important;+ border: none !important;+ background: none !important;+ min-width: auto !important;+ max-width: none !important;+ min-height: auto !important;+ max-height: none !important;+ contain: none !important;+ content-visibility: visible !important;+}+video {object-fit: contain;}diff --git a/Libraries/LibWeb/CSS/ElementBoxKind.h b/Libraries/LibWeb/CSS/ElementBoxKind.hindex eea22aebf50..a61656ffe62 100644--- a/Libraries/LibWeb/CSS/ElementBoxKind.h+++ b/Libraries/LibWeb/CSS/ElementBoxKind.h@@ -42,7 +42,10 @@ enum class ElementBoxKind : u8 {InputRadioButton,InputRange,InputText,+ // A frame element whose parent is a frameset.+ Frame,+ FrameSet,};-static_assert(to_underlying(ElementBoxKind::InputText) == 22, "Rust's ElementBoxKind lists the same kinds in the same order");+static_assert(to_underlying(ElementBoxKind::FrameSet) == 24, "Rust's ElementBoxKind lists the same kinds in the same order");}diff --git a/Libraries/LibWeb/CSS/StyleEngineBridge.h b/Libraries/LibWeb/CSS/StyleEngineBridge.hindex 1e55fcf1223..7791923fb22 100644--- a/Libraries/LibWeb/CSS/StyleEngineBridge.h+++ b/Libraries/LibWeb/CSS/StyleEngineBridge.h@@ -54,6 +54,7 @@ void style_engine_set_text_is_ascii_whitespace(DocumentHost const*, StyleNodeIDvoid style_engine_set_node_dom_paint_facts(DocumentHost const*, StyleNodeID node, u8 facts);void style_engine_set_element_unique_node_id(DocumentHost const*, StyleNodeID node, u64 unique_node_id);void style_engine_set_element_table_spans(DocumentHost const*, StyleNodeID node, u32 column_span, u32 row_span);+void style_engine_set_element_frameset_layout(DocumentHost const*, StyleNodeID node, ReadonlySpan<FfiFrameSetDimension> columns, ReadonlySpan<FfiFrameSetDimension> rows, ReadonlySpan<FfiFrameSetBorder> borders, u32 border_thickness);void style_engine_set_element_id_name(DocumentHost const*, StyleNodeID node, StyleAtomID name);void style_engine_set_shadow_root(DocumentHost const*, StyleNodeID shadow_host, StyleNodeID shadow_root);void style_engine_record_environment_change(DocumentHost const*, u8 changes);diff --git a/Libraries/LibWeb/CSS/StyleEngineInput.cpp b/Libraries/LibWeb/CSS/StyleEngineInput.cppindex 0ce8560182c..5887bc51dbf 100644--- a/Libraries/LibWeb/CSS/StyleEngineInput.cpp+++ b/Libraries/LibWeb/CSS/StyleEngineInput.cpp@@ -954,6 +954,8 @@ static void record_subtree_arrivals(DOM::Document& document, ReadonlySpan<Pendinelement->set_style_node_id(identity);style_computer.register_style_node(identity, *element);Layout::publish_table_spans(*element);+ if (auto* frameset = as_if<HTML::HTMLFrameSetElement>(*element))+ frameset->publish_layout_data();if (element->is_size_query_container() || element->style_depends_on_size_container_query())element->publish_size_container_query_facts();} else {diff --git a/Libraries/LibWeb/HTML/HTMLFrameElement.cpp b/Libraries/LibWeb/HTML/HTMLFrameElement.cppindex 50ebd36cea8..06b866a11b1 100644--- a/Libraries/LibWeb/HTML/HTMLFrameElement.cpp+++ b/Libraries/LibWeb/HTML/HTMLFrameElement.cpp@@ -4,12 +4,14 @@* SPDX-License-Identifier: BSD-2-Clause*/+#include <LibWeb/CSS/ElementBoxKind.h>#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>#include <LibWeb/DOM/Document.h>#include <LibWeb/DOM/Event.h>#include <LibWeb/HTML/BrowsingContext.h>#include <LibWeb/HTML/EventNames.h>#include <LibWeb/HTML/HTMLFrameElement.h>+#include <LibWeb/HTML/HTMLFrameSetElement.h>#include <LibWeb/HTML/Scripting/Environments.h>#include <LibWeb/HighResolutionTime/TimeOrigin.h>#include <LibWebCommon/ReferrerPolicy/ReferrerPolicy.h>@@ -33,6 +35,17 @@ HTMLFrameElement::HTMLFrameElement(DOM::Document& document, DOM::QualifiedName qHTMLFrameElement::~HTMLFrameElement() = default;+// https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets+CSS::ElementBoxKind HTMLFrameElement::box_kind() const+{+ // The contents of a frame element that does not have a frameset parent are expected to be rendered as transparent+ // black; the user agent is expected to not render its content navigable in this case, and its content navigable is+ // expected to have a viewport with zero width and zero height.+ if (is<HTMLFrameSetElement>(parent()))+ return CSS::ElementBoxKind::Frame;+ return CSS::ElementBoxKind::FromDisplay;+}+// https://html.spec.whatwg.org/multipage/obsolete.html#frames:html-element-post-connection-stepsvoid HTMLFrameElement::post_connection(){@@ -65,6 +78,11 @@ void HTMLFrameElement::attribute_changed(Utf16FlyString const& name, Optional<Ut// user agent must process the frame attributes.if (content_navigable() && name == HTML::AttributeNames::src)process_the_frame_attributes();++ if (first_is_one_of(name, HTML::AttributeNames::frameborder, HTML::AttributeNames::bordercolor)) {+ if (auto* frameset = as_if<HTMLFrameSetElement>(parent()))+ frameset->layout_data_changed();+ }}// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindexdiff --git a/Libraries/LibWeb/HTML/HTMLFrameElement.h b/Libraries/LibWeb/HTML/HTMLFrameElement.hindex a8d95f78cb4..7a647a31a96 100644--- a/Libraries/LibWeb/HTML/HTMLFrameElement.h+++ b/Libraries/LibWeb/HTML/HTMLFrameElement.h@@ -19,6 +19,8 @@ class WEB_API HTMLFrameElement final : public NavigableContainer {public:virtual ~HTMLFrameElement() override;+ virtual CSS::ElementBoxKind box_kind() const override;+private:HTMLFrameElement(DOM::Document&, DOM::QualifiedName);diff --git a/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp b/Libraries/LibWeb/HTML/HTMLFrameSetElement.cppindex 5fb88e84590..2137f3fd7d5 100644--- a/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp+++ b/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp@@ -4,11 +4,21 @@* SPDX-License-Identifier: BSD-2-Clause*/+#include <AK/CharacterTypes.h>+#include <LibGfx/Color.h>+#include <LibWeb/CSS/ElementBoxKind.h>+#include <LibWeb/CSS/StyleComputer.h>+#include <LibWeb/CSS/StyleEngineBridge.h>#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>#include <LibWeb/DOM/Document.h>#include <LibWeb/Gamepad/EventNames.h>+#include <LibWeb/HTML/HTMLFrameElement.h>#include <LibWeb/HTML/HTMLFrameSetElement.h>+#include <LibWeb/HTML/Numbers.h>+#include <LibWeb/HTML/Parser/HTMLParser.h>#include <LibWeb/HTML/Window.h>+#include <LibWeb/Layout/Node.h>+#include <LibWeb/Layout/RenderDocument.h>namespace Web::HTML {@@ -21,6 +31,281 @@ HTMLFrameSetElement::HTMLFrameSetElement(DOM::Document& document, DOM::QualifiedHTMLFrameSetElement::~HTMLFrameSetElement() = default;+CSS::ElementBoxKind HTMLFrameSetElement::box_kind() const+{+ return CSS::ElementBoxKind::FrameSet;+}++using Dimension = CSS::StyleEngineFFI::FfiFrameSetDimension;+using DimensionUnit = CSS::StyleEngineFFI::FfiFrameSetDimensionUnit;+using Border = CSS::StyleEngineFFI::FfiFrameSetBorder;++// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-a-list-of-dimensions+static Vector<Dimension> parse_a_list_of_dimensions(Utf16View raw_input)+{+ // 1. Let raw input be the string being parsed.+ // 2. If the last character in raw input is a U+002C COMMA character (,), then remove that character from raw input.+ if (!raw_input.is_empty() && raw_input.code_unit_at(raw_input.length_in_code_units() - 1) == ',')+ raw_input = raw_input.substring_view(0, raw_input.length_in_code_units() - 1);++ // 3. Split the string raw input on commas. Let raw tokens be the resulting list of tokens.+ Vector<Utf16View> raw_tokens;+ for (size_t start = 0; start < raw_input.length_in_code_units();) {+ size_t end = start;+ while (end < raw_input.length_in_code_units() && raw_input.code_unit_at(end) != ',')+ ++end;+ raw_tokens.append(raw_input.substring_view(start, end - start).trim_ascii_whitespace());+ start = end + 1;+ }++ // 4. Let result be an empty list of number/unit pairs.+ Vector<Dimension> result;++ // 5. For each token in raw tokens, run the following substeps:+ for (auto input : raw_tokens) {+ // 1. Let input be the token.+ // 2. Let position be a pointer into input, initially pointing at the start of the string.+ size_t position = 0;+ auto const length = input.length_in_code_units();++ // 3. Let value be the number 0.+ double value = 0;++ // 4. Let unit be absolute.+ auto unit = DimensionUnit::Absolute;++ // 5. If position is past the end of input, set unit to relative and jump to the last substep.+ if (position >= length) {+ unit = DimensionUnit::Relative;+ } else {+ // 6. If the character at position is an ASCII digit, collect a sequence of code points that are ASCII digits+ // from input given position, interpret the resulting sequence as an integer in base ten, and increment+ // value by that integer.+ while (position < length && is_ascii_digit(input.code_unit_at(position))) {+ value = value * 10 + (input.code_unit_at(position) - '0');+ ++position;+ }++ // 7. If the character at position is U+002E (.):+ if (position < length && input.code_unit_at(position) == '.') {+ ++position;++ // 1. Collect a sequence of code points consisting of ASCII whitespace and ASCII digits from input given+ // position. Let s be the resulting sequence.+ // 2. Remove all ASCII whitespace in s.+ // 3. If s is not the empty string:+ // 1. Let length be the number of characters in s (after the spaces were removed).+ // 2. Let fraction be the result of interpreting s as a base-ten integer, and then dividing that+ // number by 10^length.+ // 3. Increment value by fraction.+ double scale = 0.1;+ while (position < length && (is_ascii_digit(input.code_unit_at(position)) || is_ascii_space(input.code_unit_at(position)))) {+ if (is_ascii_digit(input.code_unit_at(position))) {+ value += (input.code_unit_at(position) - '0') * scale;+ scale /= 10;+ }+ ++position;+ }+ }++ // 8. Skip ASCII whitespace within input given position.+ while (position < length && is_ascii_space(input.code_unit_at(position)))+ ++position;++ // 9. If the character at position is a U+0025 PERCENT SIGN character (%), then set unit to percentage.+ // Otherwise, if the character at position is a U+002A ASTERISK character (*), then set unit to relative.+ if (position < length && input.code_unit_at(position) == '%')+ unit = DimensionUnit::Percentage;+ else if (position < length && input.code_unit_at(position) == '*')+ unit = DimensionUnit::Relative;+ }++ // 10. Add an entry to result consisting of the number given by value and the unit given by unit.+ result.append({ .value = value, .unit = unit });+ }++ // 6. Return the list result.+ return result;+}++// https://html.spec.whatwg.org/multipage/rendering.html#has-a-border+static bool has_a_border(DOM::Element const& element)+{+ // 1. If the element has a frameborder attribute whose value is not the empty string and whose first character is+ // either a U+0031 DIGIT ONE (1) character, a U+0079 LATIN SMALL LETTER Y character (y), or a U+0059 LATIN CAPITAL+ // LETTER Y character (Y), then return true.+ // 2. Otherwise, if the element has a frameborder attribute, return false.+ auto frameborder = element.attribute(AttributeNames::frameborder);++ // INTEROP: On a frameset element, other browsers treat every value but "yes", "1", "no" and "0" as a missing attribute.+ if (is<HTMLFrameSetElement>(element) && frameborder.has_value()) {+ auto value = frameborder->utf16_view();+ if (!value.equals_ignoring_ascii_case("yes"sv) && !value.equals_ignoring_ascii_case("no"sv) && value != "1"sv && value != "0"sv)+ frameborder.clear();+ }++ if (frameborder.has_value()) {+ auto value = frameborder->utf16_view();+ return !value.is_empty() && first_is_one_of(value.code_unit_at(0), '1', 'y', 'Y');+ }++ // 3. Otherwise, if the element has a parent element that is a frameset element, then return true if that element+ // has a border, and false if it does not.+ if (auto const* parent_frameset = as_if<HTMLFrameSetElement>(element.parent()))+ return has_a_border(*parent_frameset);++ // 4. Otherwise, return true.+ return true;+}++// https://html.spec.whatwg.org/multipage/rendering.html#frame-border-colour+static Color frame_border_color(DOM::Element const& element)+{+ // 1. If the element has a bordercolor attribute, and applying the rules for parsing a legacy color value to that+ // attribute's value does not return failure, then return the color so obtained.+ if (auto bordercolor = element.attribute(AttributeNames::bordercolor); bordercolor.has_value()) {+ if (auto color = parse_legacy_color_value(bordercolor->utf16_view()); color.has_value())+ return *color;+ }++ // 2. Otherwise, if the element has a parent element that is a frameset element, then return the frame border color+ // of that element.+ if (auto const* parent_frameset = as_if<HTMLFrameSetElement>(element.parent()))+ return frame_border_color(*parent_frameset);++ // 3. Otherwise, return gray.+ return Color { 128, 128, 128 };+}++// INTEROP: The specification does not define how thick a border is. Other browsers default to 6 pixels, honor a border+// attribute that a nested frameset inherits, and make a border with a negative thickness 1 pixel thick.+u32 HTMLFrameSetElement::frame_border_thickness() const+{+ static constexpr u32 default_border_thickness = 6;++ if (!has_a_border(*this))+ return 0;+ if (auto border = attribute(AttributeNames::border); border.has_value()) {+ auto thickness = parse_integer(border->utf16_view()).value_or(0);+ return thickness < 0 ? 1 : static_cast<u32>(thickness);+ }+ if (auto const* parent_frameset = as_if<HTMLFrameSetElement>(parent()))+ return parent_frameset->frame_border_thickness();+ return default_border_thickness;+}++// https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets+void HTMLFrameSetElement::publish_layout_data() const+{+ if (style_node_id().value() == 0)+ return;++ // 1. The cols and rows variables are lists of zero or more pairs consisting of a number and a unit, the unit being+ // one of percentage, relative, and absolute.+ // Use the rules for parsing a list of dimensions to parse the value of the element's cols attribute, if there is+ // one. Let cols be the result, or an empty list if there is no such attribute.+ // Use the rules for parsing a list of dimensions to parse the value of the element's rows attribute, if there is+ // one. Let rows be the result, or an empty list if there is no such attribute.+ auto parse_attribute = [&](Utf16FlyString const& name) {+ auto value = attribute(name);+ return value.has_value() ? parse_a_list_of_dimensions(value->utf16_view()) : Vector<Dimension> {};+ };+ auto cols = parse_attribute(AttributeNames::cols);+ auto rows = parse_attribute(AttributeNames::rows);++ auto finish_list = [](Vector<Dimension>& list) {+ // 2. For any of the entries in cols or rows that have the number zero and the unit relative, change the entry's+ // number to one.+ for (auto& entry : list) {+ if (entry.value == 0 && entry.unit == DimensionUnit::Relative)+ entry.value = 1;+ }++ // 3. If cols has no entries, then add a single entry consisting of the value 1 and the unit relative to cols.+ // If rows has no entries, then add a single entry consisting of the value 1 and the unit relative to rows.+ if (list.is_empty())+ list.append({ .value = 1, .unit = DimensionUnit::Relative });+ };+ finish_list(cols);+ finish_list(rows);++ // If the frameset element has a border, draw an outer set of borders around the rectangles, using the element's+ // frame border color.+ // INTEROP: Other browsers do not draw an outer set of borders.++ // For each rectangle, if there is an element assigned to that rectangle, and that element has a border, draw an+ // inner set of borders around that rectangle, using the element's frame border color.+ // NB: Neighboring rectangles share the border between them, so this records which of the borders between tracks are+ // drawn. Where two elements have a border in common, the color of the later one is used.+ Vector<Border> borders;+ borders.resize(cols.size() + rows.size());+ auto column_borders = borders.span().slice(0, cols.size());+ auto row_borders = borders.span().slice(cols.size());+ size_t child_index = 0;+ for_each_child_of_type<HTMLElement>([&](HTMLElement const& child) {+ if (!is<HTMLFrameElement>(child) && !is<HTMLFrameSetElement>(child))+ return IterationDecision::Continue;+ auto column = child_index % cols.size();+ auto row = child_index / cols.size();+ if (row >= rows.size())+ return IterationDecision::Break;+ if (has_a_border(child)) {+ auto const color = frame_border_color(child).value();+ auto draw = [color](Border& border) {+ border.is_drawn = true;+ border.color = color;+ };+ if (column > 0)+ draw(column_borders[column - 1]);+ if (column + 1 < cols.size())+ draw(column_borders[column]);+ if (row > 0)+ draw(row_borders[row - 1]);+ if (row + 1 < rows.size())+ draw(row_borders[row]);+ }+ ++child_index;+ return IterationDecision::Continue;+ });++ CSS::StyleEngineFFI::style_engine_set_element_frameset_layout(+ document().style_computer().style_engine().host(),+ style_node_id(),+ cols.span(),+ rows.span(),+ borders.span(),+ frame_border_thickness());+}++void HTMLFrameSetElement::own_layout_data_changed()+{+ publish_layout_data();+ Layout::ForcedReadScope read { document() };+ if (auto* layout_node = unsafe_layout_node(read))+ Layout::RustFFI::render_state_restamp_frameset_layout(layout_node->document_host(), Layout::Node::slot_id(layout_node));+}++void HTMLFrameSetElement::layout_data_changed()+{+ own_layout_data_changed();++ // NB: A nested frameset inherits whether it has a border, and the thickness and color of its borders.+ for_each_child_of_type<HTMLFrameSetElement>([](HTMLFrameSetElement& child) {+ child.layout_data_changed();+ return IterationDecision::Continue;+ });+}++void HTMLFrameSetElement::children_changed(ChildrenChangedMetadata const& metadata)+{+ Base::children_changed(metadata);+ own_layout_data_changed();++ // NB: Only a frameset that just arrived can have inherited something else.+ if (auto* frameset = as_if<HTMLFrameSetElement>(*metadata.node); frameset && metadata.type == ChildrenChangedMetadata::Type::Inserted)+ frameset->layout_data_changed();+}+void HTMLFrameSetElement::attribute_changed(Utf16FlyString const& name, Optional<Utf16String> const& old_value, Optional<Utf16String> const& value, Optional<Utf16FlyString> const& namespace_){Base::attribute_changed(name, old_value, value, namespace_);@@ -32,6 +317,16 @@ void HTMLFrameSetElement::attribute_changed(Utf16FlyString const& name, Optional}ENUMERATE_WINDOW_EVENT_HANDLERS(__ENUMERATE)#undef __ENUMERATE++ if (!namespace_.has_value() && first_is_one_of(name, AttributeNames::cols, AttributeNames::rows, AttributeNames::frameborder, AttributeNames::border, AttributeNames::bordercolor)) {+ layout_data_changed();++ // NB: A parent frameset draws the borders of this frameset's rectangle from its frameborder and bordercolor.+ if (first_is_one_of(name, AttributeNames::frameborder, AttributeNames::bordercolor)) {+ if (auto* parent_frameset = as_if<HTMLFrameSetElement>(parent()))+ parent_frameset->own_layout_data_changed();+ }+ }}GC::Ptr<DOM::EventTarget> HTMLFrameSetElement::global_event_handlers_to_event_target(Utf16FlyString const& event_name)diff --git a/Libraries/LibWeb/HTML/HTMLFrameSetElement.h b/Libraries/LibWeb/HTML/HTMLFrameSetElement.hindex eb2fd35258a..2b0d2b05f76 100644--- a/Libraries/LibWeb/HTML/HTMLFrameSetElement.h+++ b/Libraries/LibWeb/HTML/HTMLFrameSetElement.h@@ -21,12 +21,22 @@ class HTMLFrameSetElement finalpublic:virtual ~HTMLFrameSetElement() override;+ virtual CSS::ElementBoxKind box_kind() const override;++ // Gives the style engine what layout and painting need from this element's attributes and children.+ void publish_layout_data() const;+ void layout_data_changed();+private:HTMLFrameSetElement(DOM::Document&, DOM::QualifiedName);virtual bool is_html_frameset_element() const override { return true; }virtual void attribute_changed(Utf16FlyString const& name, Optional<Utf16String> const& old_value, Optional<Utf16String> const& value, Optional<Utf16FlyString> const& namespace_) override;+ virtual void children_changed(ChildrenChangedMetadata const&) override;++ void own_layout_data_changed();+ u32 frame_border_thickness() const;// ^HTML::GlobalEventHandlersvirtual GC::Ptr<EventTarget> global_event_handlers_to_event_target(Utf16FlyString const& event_name) override;diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cppindex c114dbcac1a..bf9092b8271 100644--- a/Libraries/LibWeb/Layout/Node.cpp+++ b/Libraries/LibWeb/Layout/Node.cpp@@ -113,6 +113,7 @@ StringView Node::class_name() constLAYOUT_NODE_KIND_NAME_CASE(CanvasBox)LAYOUT_NODE_KIND_NAME_CASE(CheckBox)LAYOUT_NODE_KIND_NAME_CASE(FieldSetBox)+ LAYOUT_NODE_KIND_NAME_CASE(FrameSetBox)LAYOUT_NODE_KIND_NAME_CASE(GeneratedTextNode)LAYOUT_NODE_KIND_NAME_CASE(ImageBox)LAYOUT_NODE_KIND_NAME_CASE(InlineNode)diff --git a/Libraries/LibWeb/Rust/build.rs b/Libraries/LibWeb/Rust/build.rsindex 395a75fc4c3..2f754d65abb 100644--- a/Libraries/LibWeb/Rust/build.rs+++ b/Libraries/LibWeb/Rust/build.rs@@ -2761,6 +2761,8 @@ fn main() -> Result<(), Box<dyn Error>> {style_engine_config.export.include = vec![// Taken only by an entry of the boundary table, which cbindgen does not see."FfiAppliedAnimationDefinition".to_string(),+ "FfiFrameSetDimension".to_string(),+ "FfiFrameSetBorder".to_string(),// Named by no exported signature: a replaced content input crosses as its raw values."FfiReplacedContentInputKind".to_string(),"FfiReplacedContentInputPresent".to_string(),diff --git a/Libraries/LibWeb/Rust/src/css/style/boundary.rs b/Libraries/LibWeb/Rust/src/css/style/boundary.rsindex 4232b1151ac..c43323b7084 100644--- a/Libraries/LibWeb/Rust/src/css/style/boundary.rs+++ b/Libraries/LibWeb/Rust/src/css/style/boundary.rs@@ -16,11 +16,12 @@ use super::ReplacedContentInput;use super::StyleEngine;use super::animations::HeldAppliedAnimationDefinition;use super::bridge::{ElementBoxKind, FfiAppliedAnimationDefinition, borrow};+use super::bridge::{FfiFrameSetBorder, FfiFrameSetDimension};use super::engine_calls::EngineWrite;use super::engine_calls::with_engine;use super::index::StyleAtomID;use super::pipeline::rule_store::{CascadeLayerID, SheetID};-use super::tree::{StyleNodeID, TableSpans, TreeScopeID};+use super::tree::{FrameSetLayout, StyleNodeID, TableSpans, TreeScopeID};use crate::abort_on_panic;use crate::css::css_string::CssString;use crate::render_state::{ArenaChange, BegunRead, DocumentHost};@@ -89,6 +90,10 @@ carried! {|span| unsafe { borrow(span.data, span.size) }.iter().map(|&raw| unsafe { CssString::from_borrowed_raw(raw) }).collect();Box<[u32]>: FfiSpan<u32> as "ReadonlySpan<u32>" = |span| unsafe { borrow(span.data, span.size) }.into();Box<[u64]>: FfiSpan<u64> as "ReadonlySpan<u64>" = |span| unsafe { borrow(span.data, span.size) }.into();+ Box<[FfiFrameSetDimension]>: FfiSpan<FfiFrameSetDimension> as "ReadonlySpan<FfiFrameSetDimension>" =+ |span| unsafe { borrow(span.data, span.size) }.into();+ Box<[FfiFrameSetBorder]>: FfiSpan<FfiFrameSetBorder> as "ReadonlySpan<FfiFrameSetBorder>" =+ |span| unsafe { borrow(span.data, span.size) }.into();Box<[StyleAtomID]>: FfiSpan<u32> as "ReadonlySpan<StyleAtomID>" =|span| unsafe { borrow(span.data, span.size) }.iter().copied().map(StyleAtomID).collect();Box<[StyleNodeID]>: FfiSpan<u32> as "ReadonlySpan<StyleNodeID>" =@@ -352,6 +357,18 @@ style_boundary! {column_span: u16::try_from(column_span).expect("a column span is clamped to 1000"),row_span: u16::try_from(row_span).expect("a row span is clamped to 65534"),});+ set_element_frameset_layout => SetElementFrameSetLayout {+ node: StyleNodeID,+ columns: Box<[FfiFrameSetDimension]>,+ rows: Box<[FfiFrameSetDimension]>,+ borders: Box<[FfiFrameSetBorder]>,+ border_thickness: u32+ } =>+ {+ let (column_borders, row_borders) = borders.split_at(columns.len());+ let (column_borders, row_borders) = (column_borders.into(), row_borders.into());+ engine.set_element_frameset_layout(node, FrameSetLayout { columns, rows, column_borders, row_borders, border_thickness });+ };set_element_id_name => SetElementIdName { node: StyleNodeID, name: StyleAtomID };record_environment_change => RecordEnvironmentChange { changes: u8 };record_custom_property_registration_change => RecordCustomPropertyRegistrationChange => engine.record_custom_property_registration_change();diff --git a/Libraries/LibWeb/Rust/src/css/style/bridge.rs b/Libraries/LibWeb/Rust/src/css/style/bridge.rsindex 9565f0a174c..5da09184189 100644--- a/Libraries/LibWeb/Rust/src/css/style/bridge.rs+++ b/Libraries/LibWeb/Rust/src/css/style/bridge.rs@@ -823,6 +823,9 @@ pub enum ElementBoxKind {InputRadioButton = 20,InputRange = 21,InputText = 22,+ /// A `<frame>` whose parent is a `<frameset>`.+ Frame = 23,+ FrameSet = 24,}impl ElementBoxKind {@@ -838,6 +841,32 @@ impl ElementBoxKind {}}+/// The unit of an entry in the parsed `cols` or `rows` of a `<frameset>`.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+#[repr(u8)]+pub enum FfiFrameSetDimensionUnit {+ Percentage = 0,+ Relative = 1,+ Absolute = 2,+}++/// An entry in the parsed `cols` or `rows` of a `<frameset>`.+#[derive(Clone, Copy, Debug, PartialEq)]+#[repr(C)]+pub struct FfiFrameSetDimension {+ pub value: f64,+ pub unit: FfiFrameSetDimensionUnit,+}++/// The border between a track of a `<frameset>` and the next track.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+#[repr(C)]+pub struct FfiFrameSetBorder {+ pub is_drawn: bool,+ /// The color of the border, as ARGB.+ pub color: u32,+}+/// Which element the values of a replaced content input are of. See/// `inputs::ReplacedContentInput`.#[derive(Clone, Copy, Debug, PartialEq, Eq)]diff --git a/Libraries/LibWeb/Rust/src/css/style/inputs.rs b/Libraries/LibWeb/Rust/src/css/style/inputs.rsindex b1e35367461..e01d16a8ed0 100644--- a/Libraries/LibWeb/Rust/src/css/style/inputs.rs+++ b/Libraries/LibWeb/Rust/src/css/style/inputs.rs@@ -804,6 +804,15 @@ impl RetainedState {self.tree.set_dom_paint_facts(node, facts);}+ #[must_use]+ pub fn element_frameset_layout(&self, node: StyleNodeID) -> Option<std::sync::Arc<super::tree::FrameSetLayout>> {+ self.tree.frameset_layout(node)+ }++ pub fn set_element_frameset_layout(&mut self, node: StyleNodeID, layout: super::tree::FrameSetLayout) {+ self.tree.set_frameset_layout(node, layout);+ }+/// The spans a row built for the element takes from its attributes.#[must_use]pub fn element_table_spans(&self, node: StyleNodeID) -> super::tree::TableSpans {@@ -1357,6 +1366,7 @@ impl RetainedState {| ElementBoxKind::Video| ElementBoxKind::Canvas| ElementBoxKind::NavigableContainerViewport+ | ElementBoxKind::Frame| ElementBoxKind::TextArea| ElementBoxKind::Image| ElementBoxKind::SvgSvgdiff --git a/Libraries/LibWeb/Rust/src/css/style/tree.rs b/Libraries/LibWeb/Rust/src/css/style/tree.rsindex d95363c4f00..808611d61ad 100644--- a/Libraries/LibWeb/Rust/src/css/style/tree.rs+++ b/Libraries/LibWeb/Rust/src/css/style/tree.rs@@ -285,6 +285,19 @@ impl ElementIdIndex {}}+/// What a `<frameset>` gives layout and painting from its attributes and children.+#[derive(Debug, PartialEq)]+pub struct FrameSetLayout {+ pub columns: Box<[super::bridge::FfiFrameSetDimension]>,+ pub rows: Box<[super::bridge::FfiFrameSetDimension]>,+ /// The border after each column.+ pub column_borders: Box<[super::bridge::FfiFrameSetBorder]>,+ /// The border after each row.+ pub row_borders: Box<[super::bridge::FfiFrameSetBorder]>,+ /// The thickness of the borders between tracks, in CSS pixels.+ pub border_thickness: u32,+}+/// The spans a table cell or table column takes from its attributes.#[derive(Clone, Copy, Debug, PartialEq, Eq)]pub struct TableSpans {@@ -344,6 +357,7 @@ pub struct HostTree {/// context's column handling reads. Every other element spans one of each, which is what the/// absence of an entry means.table_spans: crate::cow_map::CowMap<StyleNodeID, TableSpans>,+ frameset_layouts: crate::cow_map::CowMap<StyleNodeID, std::sync::Arc<FrameSetLayout>>,/// The document's top layer, in the order its members were added. The order is the order their/// boxes are built in and belongs to the document, so no per-element fact can carry it.top_layer: crate::fork::ForkShared<Vec<StyleNodeID>>,@@ -439,6 +453,7 @@ impl HostTree {+ text_bytes+ self.dom_paint_facts.heap_size()+ self.table_spans.heap_size()+ + self.frameset_layouts.heap_size()+ vec_bytes(&self.top_layer)}@@ -468,6 +483,7 @@ impl HostTree {text: TextRows::default(),dom_paint_facts: Default::default(),table_spans: Default::default(),+ frameset_layouts: Default::default(),top_layer: Default::default(),dom_order_version: 0,dom_paint_facts_version: 0,@@ -601,6 +617,7 @@ impl HostTree {self.live.set(index as usize, false);self.dom_paint_facts.remove(&node);self.table_spans.remove(&node);+ self.frameset_layouts.remove(&node);self.top_layer.retain(|&member| member != node);if !self.relation_only.set(index as usize, false).0 {self.connected_element_count -= 1;@@ -766,6 +783,15 @@ impl HostTree {.map_or(0, |row| row.unique_node_id.into())}+ #[must_use]+ pub fn frameset_layout(&self, node: StyleNodeID) -> Option<std::sync::Arc<FrameSetLayout>> {+ self.frameset_layouts.get(&node).cloned()+ }++ pub fn set_frameset_layout(&mut self, node: StyleNodeID, layout: FrameSetLayout) {+ self.frameset_layouts.insert(node, std::sync::Arc::new(layout));+ }+/// The spans a row built for the element takes from its attributes.#[must_use]pub fn table_spans(&self, node: StyleNodeID) -> TableSpans {diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex 8a0590c6b6f..b0fcd465d67 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -964,6 +964,7 @@ pub enum FormattingContextType {Math,ReplacedWithChildren,InternalReplaced,+ FrameSet,}impl FormattingContextType {@@ -972,7 +973,7 @@ impl FormattingContextType {}fn lays_out_inside_its_root_as_definite_in_both_axes(self) -> bool {- matches!(self, Self::Svg | Self::ReplacedWithChildren)+ matches!(self, Self::Svg | Self::ReplacedWithChildren | Self::FrameSet)}}@@ -1395,6 +1396,7 @@ enum FormattingContextImplementation<'pass> {Math(math_formatting_context::MathFormattingContext<'pass>),ReplacedWithChildren,InternalReplaced,+ FrameSet,}pub(crate) fn formatting_context_type_created_by_node_data(@@ -1406,6 +1408,9 @@ pub(crate) fn formatting_context_type_created_by_node_data(if data.kind.get() == crate::layout::node_data::NodeKind::SVGSVGBox {return Some(FormattingContextType::Svg);}+ if data.kind.get() == crate::layout::node_data::NodeKind::FrameSetBox {+ return Some(FormattingContextType::FrameSet);+ }let is_replaced_box = node_facts::kind_is_replaced_box(data.kind.get());let can_have_children = node_facts::node_can_have_children(data);if is_replaced_box && can_have_children {@@ -1511,6 +1516,7 @@ fn create_formatting_context_implementation<'pass>(),FormattingContextType::ReplacedWithChildren => FormattingContextImplementation::ReplacedWithChildren,FormattingContextType::InternalReplaced => FormattingContextImplementation::InternalReplaced,+ FormattingContextType::FrameSet => FormattingContextImplementation::FrameSet,}}@@ -2459,6 +2465,11 @@ fn lay_out_run_root_and_contents<'pass>((result, root_after_body)}FormattingContextImplementation::InternalReplaced => (ChildLayoutResult::default(), own_root.get()),+ FormattingContextImplementation::FrameSet => {+ let mut root_after_body = own_root.get();+ let result = frameset_formatting_context::layout_frameset(body_run, &mut root_after_body);+ (result, root_after_body)+ }}};let baselines_in_own_frame = result.baselines;@@ -2671,7 +2682,9 @@ fn lay_out_run_root_and_contents<'pass>(FormattingContextImplementation::Math(context) => {context.parent_did_dimension(root_in_own_frame_left_by_run);}- FormattingContextImplementation::Svg(_) | FormattingContextImplementation::ReplacedWithChildren => {}+ FormattingContextImplementation::Svg(_)+ | FormattingContextImplementation::ReplacedWithChildren+ | FormattingContextImplementation::FrameSet => {}FormattingContextImplementation::InternalReplaced => {let outputs = run.outputs(result,diff --git a/Libraries/LibWeb/Rust/src/layout/frameset_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/frameset_formatting_context.rsnew file mode 100644index 00000000000..97fe97b8e8a--- /dev/null+++ b/Libraries/LibWeb/Rust/src/layout/frameset_formatting_context.rs@@ -0,0 +1,313 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++use super::*;+use crate::css::css_pixels::CssPixels;+use crate::css::style::bridge::{FfiFrameSetDimension, FfiFrameSetDimensionUnit};++// NB: Pixel values are integers, as in other browsers. This bound keeps the products below in range of an i64.+const MAXIMUM_PIXEL_VALUE: i64 = i32::MAX as i64;++fn integer_pixels(value: f64) -> i64 {+ value.floor().clamp(0.0, MAXIMUM_PIXEL_VALUE as f64) as i64+}++fn indices_with_unit(input_list: &[FfiFrameSetDimension], unit: FfiFrameSetDimensionUnit) -> Vec<usize> {+ (0..input_list.len())+ .filter(|&index| input_list[index].unit == unit)+ .collect()+}++/// Sets the entries to their share of `space`, in proportion to their values, and answers how much of it they took.+fn scale_entries_to_space(output_list: &mut [i64], indices: &[usize], total: i64, space: i64) -> i64 {+ let mut taken = 0;+ for &index in indices {+ output_list[index] = output_list[index] * space / total;+ taken += output_list[index];+ }+ taken+}++/// Grows the entries by their share of `space`, in proportion to their values, and answers how much of it they took.+fn grow_entries_by_share_of_space(output_list: &mut [i64], indices: &[usize], total: i64, space: i64) -> i64 {+ let mut taken = 0;+ for &index in indices {+ let growth = output_list[index] * space / total;+ output_list[index] += growth;+ taken += growth;+ }+ taken+}++/// Grows each entry by the same amount, and answers how much of `space` they took.+fn grow_entries_equally(output_list: &mut [i64], indices: &[usize], space: i64) -> i64 {+ let growth = space / indices.len() as i64;+ for &index in indices {+ output_list[index] += growth;+ }+ growth * indices.len() as i64+}++// https://html.spec.whatwg.org/multipage/rendering.html#convert-a-list-of-dimensions-to-a-list-of-pixel-values+fn convert_a_list_of_dimensions_to_a_list_of_pixel_values(+ input_list: &[FfiFrameSetDimension],+ input_dimension: i64,+) -> Vec<i64> {+ // 1. Let input list be the list of numbers and units passed to the algorithm.+ // Let output list be a list of numbers the same length as input list, all zero.+ // Entries in output list correspond to the entries in input list that have the same position.+ let mut output_list = vec![0i64; input_list.len()];++ // 2. Let input dimension be the size passed to the algorithm.+ let absolute_indices = indices_with_unit(input_list, FfiFrameSetDimensionUnit::Absolute);+ let percentage_indices = indices_with_unit(input_list, FfiFrameSetDimensionUnit::Percentage);+ let relative_indices = indices_with_unit(input_list, FfiFrameSetDimensionUnit::Relative);++ // 3. Let total percentage be the sum of all the numbers in input list whose unit is percentage.+ // Let total relative be the sum of all the numbers in input list whose unit is relative.+ // Let total absolute be the sum of all the numbers in input list whose unit is absolute.+ // Let remaining space be the value of input dimension.+ // INTEROP: The totals of absolute and percentage entries are totals of their sizes in integer pixels, and each+ // relative entry weighs at least one.+ for &index in &absolute_indices {+ output_list[index] = integer_pixels(input_list[index].value);+ }+ for &index in &percentage_indices {+ output_list[index] = integer_pixels(input_list[index].value * input_dimension as f64 / 100.0);+ }+ let relative_weight = |index: usize| integer_pixels(input_list[index].value.max(1.0));+ let total_absolute: i64 = absolute_indices.iter().map(|&index| output_list[index]).sum();+ let total_percentage: i64 = percentage_indices.iter().map(|&index| output_list[index]).sum();+ let total_relative: i64 = relative_indices.iter().map(|&index| relative_weight(index)).sum();+ let mut remaining_space = input_dimension;++ // 4. If total absolute is greater than remaining space, then for each entry in input list whose unit is absolute,+ // set the corresponding value in output list to the number of the entry in input list multiplied by remaining+ // space and divided by total absolute. Then, set remaining space to zero.+ // Otherwise, for each entry in input list whose unit is absolute, set the corresponding value in output list to+ // the number of the entry in input list. Then, decrement remaining space by total absolute.+ if total_absolute > remaining_space {+ remaining_space -= scale_entries_to_space(&mut output_list, &absolute_indices, total_absolute, remaining_space);+ } else {+ remaining_space -= total_absolute;+ }++ // 5. If total percentage multiplied by the input dimension and divided by 100 is greater than remaining space, then+ // for each entry in input list whose unit is percentage, set the corresponding value in output list to the+ // number of the entry in input list multiplied by remaining space and divided by total percentage. Then, set+ // remaining space to zero.+ // Otherwise, for each entry in input list whose unit is percentage, set the corresponding value in output list+ // to the number of the entry in input list multiplied by the input dimension and divided by 100. Then, decrement+ // remaining space by total percentage multiplied by the input dimension and divided by 100.+ if total_percentage > remaining_space {+ remaining_space -=+ scale_entries_to_space(&mut output_list, &percentage_indices, total_percentage, remaining_space);+ } else {+ remaining_space -= total_percentage;+ }++ // 6. For each entry in input list whose unit is relative, set the corresponding value in output list to the number+ // of the entry in input list multiplied by remaining space and divided by total relative.+ if let Some(&last_relative_index) = relative_indices.last() {+ let space_for_relative_entries = remaining_space;+ for &index in &relative_indices {+ output_list[index] = relative_weight(index) * space_for_relative_entries / total_relative;+ remaining_space -= output_list[index];+ }+ // User agents working with integer values for frame widths (as opposed to user agents that can lay frames out+ // with subpixel accuracy) are expected to distribute the remainder first to the last entry whose unit is+ // relative, then equally (not proportionally) to each entry whose unit is percentage, then equally (not+ // proportionally) to each entry whose unit is absolute, and finally, failing all else, to the last entry.+ output_list[last_relative_index] += remaining_space;+ remaining_space = 0;+ }++ // INTEROP: Space that no relative entry takes goes to the percentage entries in proportion to their sizes, or+ // failing that, to the absolute entries in proportion to theirs. Only what rounding leaves over is+ // distributed equally.+ if remaining_space > 0 && total_percentage > 0 {+ let space = remaining_space;+ remaining_space -=+ grow_entries_by_share_of_space(&mut output_list, &percentage_indices, total_percentage, space);+ } else if remaining_space > 0 && total_absolute > 0 {+ let space = remaining_space;+ remaining_space -= grow_entries_by_share_of_space(&mut output_list, &absolute_indices, total_absolute, space);+ }+ if remaining_space > 0 && !percentage_indices.is_empty() {+ remaining_space -= grow_entries_equally(&mut output_list, &percentage_indices, remaining_space);+ } else if remaining_space > 0 && !absolute_indices.is_empty() {+ remaining_space -= grow_entries_equally(&mut output_list, &absolute_indices, remaining_space);+ }+ if remaining_space > 0+ && let Some(last) = output_list.last_mut()+ {+ *last += remaining_space;+ }++ // 7. Return output list.+ output_list+}++/// The sizes of a frameset's tracks along an axis of its surface.+// INTEROP: The specification draws borders on the rectangles. In other browsers, the borders between tracks take their+// space from the tracks.+pub(crate) fn frameset_track_sizes(+ dimensions: &[FfiFrameSetDimension],+ surface_size: CssPixels,+ border_thickness: u32,+) -> Vec<CssPixels> {+ let borders = (dimensions.len() as i64 - 1).max(0) * i64::from(border_thickness);+ let input_dimension = (i64::from(surface_size.to_int()) - borders).max(0);+ convert_a_list_of_dimensions_to_a_list_of_pixel_values(dimensions, input_dimension)+ .into_iter()+ .map(CssPixels::from_integer)+ .collect()+}++fn layout_frameset_child(+ run: &formatting_context::FormattingContextRun,+ child: Node,+ size: (CssPixels, CssPixels),+ offset: used_values::FfiCssPixelPoint,+) {+ let (inline_size, block_size) = size;+ let constraints = geometry::ContainingBlockConstraints {+ percentage_basis_inline_size: Some(inline_size),+ percentage_basis_block_size: Some(block_size),+ quirks_mode_percentage_basis_block_size: None,+ };+ let mut cells = used_values::cells_before_sizing(&run.pass, child, constraints);+ let style = StyleValues::for_node(&run.pass, child);+ cells.border_left = style.border_left_width();+ cells.border_right = style.border_right_width();+ cells.border_top = style.border_top_width();+ cells.border_bottom = style.border_bottom_width();+ cells.padding_left = style.padding_left().to_px(inline_size);+ cells.padding_right = style.padding_right().to_px(inline_size);+ cells.padding_top = style.padding_top().to_px(inline_size);+ cells.padding_bottom = style.padding_bottom().to_px(inline_size);+ cells.set_content_inline_size(+ (inline_size - cells.border_left - cells.padding_left - cells.padding_right - cells.border_right)+ .max(CssPixels::default()),+ );+ cells.set_content_block_size(+ (block_size - cells.border_top - cells.padding_top - cells.padding_bottom - cells.border_bottom)+ .max(CssPixels::default()),+ );+ let offset = used_values::FfiCssPixelPoint {+ x: offset.x + cells.border_left + cells.padding_left,+ y: offset.y + cells.border_top + cells.padding_top,+ };+ let outcome = formatting_context::run_formatting_context(+ run.fragments.is_some(),+ cells,+ child,+ run.pass.in_flow_containing_block(child),+ None,+ formatting_context::independent_formatting_context_type(child, &run.pass),+ run.should_collect_devtools_layout_data,+ run.pass,+ geometry::LayoutInput {+ available_space: geometry::AvailableSpace {+ inline_size: geometry::AvailableSize::definite(inline_size),+ block_size: geometry::AvailableSize::definite(block_size),+ },+ containing_block_constraints: constraints,+ sizing: geometry::RootSizingDirectives::default(),+ participation: geometry::ParticipationInParentFormattingContext::Item,+ },+ None,+ );+ formatting_context::place_child(+ run,+ child,+ outcome.placed_child(),+ offset,+ None,+ outcome.fragment_arrival,+ );+}++// https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets+pub(super) fn layout_frameset(+ run: &formatting_context::FormattingContextRun,+ root: &mut used_values::RootInputCells,+) -> formatting_context::ChildLayoutResult {+ // NB: The UA style sheet gives a frameset the size of the viewport, and a nested frameset has both sizes from its+ // rectangle.+ let (surface_inline_size, surface_block_size) = (root.content_inline_size, root.content_block_size);+ root.has_definite_inline_size = true;+ root.has_definite_block_size = true;+ let result = formatting_context::ChildLayoutResult {+ automatic_content_block_size: surface_block_size,+ ..formatting_context::ChildLayoutResult::default()+ };++ let layout = run+ .pass+ .arena()+ .replaced_paint_facts(run.box_)+ .and_then(|facts| facts.frameset());+ let mut children = run.pass.children(run.box_);++ if let Some(layout) = layout {+ // 4. Invoke the algorithm defined below to convert a list of dimensions to a list of pixel values using cols as+ // the input list, and the width of the surface that the frameset is being rendered into, in CSS pixels, as+ // the input dimension. Let sized cols be the resulting list.+ // Invoke the algorithm defined below to convert a list of dimensions to a list of pixel values using rows as+ // the input list, and the height of the surface that the frameset is being rendered into, in CSS pixels, as+ // the input dimension. Let sized rows be the resulting list.+ let sized_cols = frameset_track_sizes(&layout.columns, surface_inline_size, layout.border_thickness);+ let sized_rows = frameset_track_sizes(&layout.rows, surface_block_size, layout.border_thickness);+ let border_thickness = CssPixels::from_integer(i64::from(layout.border_thickness));++ // 5. Split the surface into a grid of w×h rectangles, where w is the number of entries in sized cols and h is+ // the number of entries in sized rows.+ // Size the columns so that each column in the grid is as many CSS pixels wide as the corresponding entry in+ // the sized cols list.+ // Size the rows so that each row in the grid is as many CSS pixels high as the corresponding entry in the+ // sized rows list.+ // 6. Let children be the list of frame and frameset elements that are children of the frameset element for which+ // the algorithm was invoked.+ // 7. For each row of the grid of rectangles created in the previous step, from top to bottom, run these substeps:+ let mut y = CssPixels::default();+ 'rows: for &row_size in &sized_rows {+ // 1. For each rectangle in the row, from left to right, run these substeps:+ let mut x = CssPixels::default();+ for &column_size in &sized_cols {+ // 1. If there are any elements left in children, take the first element in the list, and assign it to+ // the rectangle.+ // If this is a frameset element, then recurse the entire frameset layout algorithm for that frameset+ // element, with the rectangle as the surface.+ // Otherwise, it is a frame element; render its content navigable, positioned and sized to fit the+ // rectangle.+ // 2. If there are any elements left in children, remove the first element from children.+ let Some(child) = children.next() else {+ break 'rows;+ };+ layout_frameset_child(+ run,+ child,+ (column_size, row_size),+ used_values::FfiCssPixelPoint { x, y },+ );+ x += column_size + border_thickness;+ }+ y += row_size + border_thickness;+ }+ }++ // NB: Children that the grid has no rectangle for are not rendered. They still get a box, of no size.+ for child in children {+ layout_frameset_child(+ run,+ child,+ (CssPixels::default(), CssPixels::default()),+ used_values::FfiCssPixelPoint::default(),+ );+ }+ result+}diff --git a/Libraries/LibWeb/Rust/src/layout/layout_changes.rs b/Libraries/LibWeb/Rust/src/layout/layout_changes.rsindex 2b3187da358..c416164c59d 100644--- a/Libraries/LibWeb/Rust/src/layout/layout_changes.rs+++ b/Libraries/LibWeb/Rust/src/layout/layout_changes.rs@@ -119,6 +119,11 @@ pub(crate) enum LayoutChange {},/// A layout committed: the text find in page searches is mapped again.InvalidateSearchableText,+ /// The frameset the row was built for published another layout: the row takes it, and lays out again where it+ /// changed.+ RestampFrameSetLayout {+ node: NodeSlotId,+ },/// The element the row was built for published other table spans: the row takes them, and lays out again where/// they changed.RestampTableSpans {@@ -196,6 +201,7 @@ impl LayoutChange {| Self::HandOverOwnedProvider { .. }| Self::SetOwnedImageNaturalSize { .. }| Self::RestampTableSpans { .. }+ | Self::RestampFrameSetLayout { .. }| Self::SetNodeNeedsCompositorAnimationFrame { .. }| Self::PinBoundBoxStyleRecordForDetachment { .. }| Self::PinNodeStyleRecordForHost { .. }@@ -303,6 +309,11 @@ impl LayoutChange {}}Self::InvalidateSearchableText => arena.invalidate_searchable_text(),+ Self::RestampFrameSetLayout { node } => {+ if arena.slot_is_live(node) && arena.restamp_frameset_layout(node) {+ arena.set_needs_layout_update(node, true);+ }+ }Self::RestampTableSpans { node } => {if arena.slot_is_live(node) && arena.restamp_table_spans(node) {arena.set_needs_layout_update(node, true);@@ -734,6 +745,11 @@ pub extern "C" fn render_state_invalidate_searchable_text(host: &DocumentHost) {queue(host, LayoutChange::InvalidateSearchableText);}+#[unsafe(no_mangle)]+pub extern "C" fn render_state_restamp_frameset_layout(host: &DocumentHost, node: NodeSlotId) {+ queue(host, LayoutChange::RestampFrameSetLayout { node });+}+#[unsafe(no_mangle)]pub extern "C" fn render_state_restamp_table_spans(host: &DocumentHost, node: NodeSlotId) {queue(host, LayoutChange::RestampTableSpans { node });diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rsindex 428492beeda..78eb66b5a61 100644--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs@@ -4206,6 +4206,9 @@ impl LayoutNodeArena {self.set_table_spans(slot, spans);}self.set_node_style_node(slot, style_node);+ if kind == NodeKind::FrameSetBox {+ self.restamp_frameset_layout(slot);+ }self.refresh_has_scroll_offset_flag(slot);self.enroll_node_for_replaced_content_facts_sync_if_eligible(slot);// A text row renders what the mirror publishes for its node, synced before layout.@@ -4523,6 +4526,7 @@ impl LayoutNodeArena {}}ReplacedPaintFacts::Video(_) => kind == NodeKind::VideoBox,+ ReplacedPaintFacts::FrameSet(_) => kind == NodeKind::FrameSetBox,};if !shows {return;@@ -5556,6 +5560,23 @@ impl LayoutNodeArena {self.set_table_spans(id, spans)}+ /// Gives a frameset's row what its element published, and answers whether that changed.+ pub(crate) fn restamp_frameset_layout(&mut self, id: NodeSlotId) -> bool {+ use crate::painting::replaced_paint_facts::ReplacedPaintFacts;+ let Some(element) = self.node_style_node(id) else {+ return false;+ };+ let Some(layout) = self.with_style_store(|engine| engine.element_frameset_layout(element)) else {+ return false;+ };+ let facts = ReplacedPaintFacts::FrameSet(layout);+ if self.replaced_paint_facts.get(&id) == Some(&facts) {+ return false;+ }+ self.set_replaced_paint_facts(super::tree_update_marks::MarkedBox::Row(id), facts);+ true+ }+/// Gives the row the spans its table cell or table column element has, and answers whether/// they changed.pub(crate) fn set_table_spans(&mut self, id: NodeSlotId, spans: TableSpans) -> bool {diff --git a/Libraries/LibWeb/Rust/src/layout/mod.rs b/Libraries/LibWeb/Rust/src/layout/mod.rsindex eef55a193d2..e5692ee460e 100644--- a/Libraries/LibWeb/Rust/src/layout/mod.rs+++ b/Libraries/LibWeb/Rust/src/layout/mod.rs@@ -46,6 +46,7 @@ mod parallel_layout;mod pass_column;pub(crate) mod tree_shape;pub use libcompositing_rust::node_slot_id;+pub(crate) mod frameset_formatting_context;mod partial_relayout;pub(crate) mod prepared_inline_content;pub(crate) mod quote_depth;diff --git a/Libraries/LibWeb/Rust/src/layout/node_data.rs b/Libraries/LibWeb/Rust/src/layout/node_data.rsindex 4a7769be607..a0217099221 100644--- a/Libraries/LibWeb/Rust/src/layout/node_data.rs+++ b/Libraries/LibWeb/Rust/src/layout/node_data.rs@@ -167,6 +167,7 @@ pub enum NodeKind {TextNode = 35,VideoBox = 37,Viewport = 38,+ FrameSetBox = 39,}#[derive(Clone, Copy, Debug, Eq, PartialEq)]diff --git a/Libraries/LibWeb/Rust/src/layout/node_facts.rs b/Libraries/LibWeb/Rust/src/layout/node_facts.rsindex a1f7c90fdf4..db16a100980 100644--- a/Libraries/LibWeb/Rust/src/layout/node_facts.rs+++ b/Libraries/LibWeb/Rust/src/layout/node_facts.rs@@ -743,6 +743,7 @@ pub(crate) fn kind_is_block_container(kind: NodeKind) -> bool {kind,NodeKind::BlockContainer| NodeKind::FieldSetBox+ | NodeKind::FrameSetBox| NodeKind::LegendBox| NodeKind::ListItemBox| NodeKind::ListItemMarkerBoxdiff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rsindex ca7bd912710..3490b748fd5 100644--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs@@ -3351,7 +3351,8 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {),formatting_context::FormattingContextType::Svg| formatting_context::FormattingContextType::InternalReplaced- | formatting_context::FormattingContextType::ReplacedWithChildren => (+ | formatting_context::FormattingContextType::ReplacedWithChildren+ | formatting_context::FormattingContextType::FrameSet => ("REPLACED CONTENT",intrinsic_sizing::content_sizes_of_replaced_content(self.pass, &scope()),),diff --git a/Libraries/LibWeb/Rust/src/layout/trace.rs b/Libraries/LibWeb/Rust/src/layout/trace.rsindex 78e1d474080..2342c71b4a5 100644--- a/Libraries/LibWeb/Rust/src/layout/trace.rs+++ b/Libraries/LibWeb/Rust/src/layout/trace.rs@@ -253,6 +253,7 @@ impl<'a> LayoutTraceTarget<'a> {FormattingContextType::Math => "math",FormattingContextType::ReplacedWithChildren => "replaced-with-children",FormattingContextType::InternalReplaced => "internal-replaced",+ FormattingContextType::FrameSet => "frameset",};format!("/{context} {}", action())})diff --git a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs b/Libraries/LibWeb/Rust/src/layout/tree_builder.rsindex 5b5d48a229d..9469369a64c 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs@@ -248,7 +248,8 @@ fn node_kind_for_element_box_kind(box_kind: ElementBoxKind, display: FfiDisplay,ElementBoxKind::Audio => NodeKind::AudioBox,ElementBoxKind::Video => NodeKind::VideoBox,ElementBoxKind::Canvas => NodeKind::CanvasBox,- ElementBoxKind::NavigableContainerViewport => NodeKind::NavigableContainerViewport,+ ElementBoxKind::NavigableContainerViewport | ElementBoxKind::Frame => NodeKind::NavigableContainerViewport,+ ElementBoxKind::FrameSet => NodeKind::FrameSetBox,ElementBoxKind::TextArea => NodeKind::TextAreaBox,ElementBoxKind::Image => NodeKind::ImageBox,ElementBoxKind::SvgGraphics => NodeKind::SVGGraphicsBox,@@ -1648,6 +1649,17 @@ fn update_layout_tree_for_dom_children(}}+fn layout_parent_is_frameset(host: &TreeBuilderHost<'_>, parent: LayoutNode) -> bool {+ !parent.is_invalid() && host.data(parent).kind.get() == NodeKind::FrameSetBox+}++/// https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets+/// A frameset's grid holds only the frame and frameset elements that are its children.+fn frameset_refuses_child(host: &TreeBuilderHost<'_>, parent: LayoutNode, child_box_kind: ElementBoxKind) -> bool {+ layout_parent_is_frameset(host, parent)+ && !matches!(child_box_kind, ElementBoxKind::Frame | ElementBoxKind::FrameSet)+}+/// A walk that keeps the box of a white space text's layout parent never gives the text a box or takes its box away/// where it sits: the anonymous wrappers around the text, and the boxes after it, would have to change with it, which/// only a build of the parent's child list gets right. Asks for that build when the text's box has to change, and@@ -2813,7 +2825,13 @@ fn construct_principal_layout_node(let display = host.published_display(update.style_node);let generation = principal_box_generation_decision(true,- should_create_layout_node && display.is_none(),+ should_create_layout_node+ && (display.is_none()+ || frameset_refuses_child(+ host,+ update.state.current_parent(),+ host.arena().element_box_kind(update.style_node),+ )),display.is_contents(),);if generation == PrincipalBoxGenerationDecision::Suppress {@@ -2905,6 +2923,9 @@ fn construct_principal_layout_node(layout_node = created;created_box = Some(host.created(created));} else if update.kind.is_text() {+ if layout_parent_is_frameset(host, update.state.current_parent()) {+ return PrincipalBoxConstruction::none();+ }let text_is_ascii_whitespace = host.arena().text_is_ascii_whitespace(update.style_node);if text_is_ascii_whitespace&& !whitespace_text_needs_box(host, update.state.current_parent(), update.identity)@@ -3747,6 +3768,9 @@ fn create_pseudo_element(// whether it gets a new one.host.arena_mut().clear_pseudo_element_box(element_identity, generated_for_of(pseudo_element));+ if host.arena().element_box_kind(Some(element_identity)) == ElementBoxKind::FrameSet {+ return None;+ }let facts = published_pseudo_element_facts(host, element_identity, pseudo_element);let decision = pseudo_element_decision(facts);if decision == FfiPseudoElementDecision::None {diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/frameset.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/frameset.rsnew file mode 100644index 00000000000..5ca99b0b71f--- /dev/null+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/frameset.rs@@ -0,0 +1,67 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++use crate::css::css_pixels::{CssPixelRect, CssPixels};+use crate::css::style::bridge::FfiFrameSetBorder;+use crate::layout::frameset_formatting_context::frameset_track_sizes;+use crate::layout::node_data::NodeSlotId;+use crate::painting::force_dark::ForceDarkRole;+use crate::painting::paint_read::PaintRead;+use crate::painting::paintable_geometry::absolute_rect;+use crate::painting::record::PaintRecorder;+use crate::painting::record::trace::Observer;+use libgfx_rust::Color;++// https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets+// FIXME: For each (visible) border that does not abut a rectangle that is assigned a frame element with a noresize+// attribute (including rectangles in further nested frameset elements), the user agent is expected to allow the+// user to move the border, resizing the rectangles within, keeping the proportions of any nested frameset grids.+pub(crate) fn paint_frameset_borders<O: Observer>(recorder: &mut PaintRecorder<'_, O>, paintable: NodeSlotId) {+ let Some(layout) = recorder+ .source+ .replaced_paint_facts(paintable)+ .and_then(|facts| facts.frameset())+ else {+ return;+ };+ if layout.border_thickness == 0 {+ return;+ }+ let border_color = |border: &FfiFrameSetBorder| {+ let [alpha, red, green, blue] = border.color.to_be_bytes();+ Color::from_rgba(red, green, blue, alpha)+ };+ let thickness = CssPixels::from_integer(i64::from(layout.border_thickness));+ let frameset_rect = absolute_rect(recorder.source, paintable);++ let sized_cols = frameset_track_sizes(&layout.columns, frameset_rect.width, layout.border_thickness);+ let mut x = frameset_rect.x;+ for (border_after, size) in layout.column_borders.iter().zip(sized_cols) {+ x += size;+ if border_after.is_drawn {+ let border = CssPixelRect::new(x, frameset_rect.y, thickness, frameset_rect.height);+ let border = recorder.converter.rounded_device_rect(border);+ recorder+ .recorder+ .fill_rect(border, border_color(border_after), ForceDarkRole::Background);+ }+ x += thickness;+ }++ let sized_rows = frameset_track_sizes(&layout.rows, frameset_rect.height, layout.border_thickness);+ let mut y = frameset_rect.y;+ for (border_after, size) in layout.row_borders.iter().zip(sized_rows) {+ y += size;+ if border_after.is_drawn {+ let border = CssPixelRect::new(frameset_rect.x, y, frameset_rect.width, thickness);+ let border = recorder.converter.rounded_device_rect(border);+ recorder+ .recorder+ .fill_rect(border, border_color(border_after), ForceDarkRole::Background);+ }+ y += thickness;+ }+}diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rsindex f2b5b53176b..43658a89924 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs@@ -14,6 +14,7 @@ pub mod border_image;pub mod column_rule;pub mod fieldset;pub mod form_controls;+pub mod frameset;pub mod gradient_resolution;pub mod inline_box;pub mod inspector_overlay;@@ -166,6 +167,12 @@ pub(crate) fn paint<O: Observer>(recorder: &mut PaintRecorder<'_, O>, paintable:}}}+ NodeKind::FrameSetBox => {+ paint_base(recorder, paintable, phase);+ if phase == PaintPhase::Foreground && recorder.is_visible(paintable) {+ frameset::paint_frameset_borders(recorder, paintable);+ }+ }NodeKind::FieldSetBox => {if !recorder.is_visible(paintable) {return;diff --git a/Libraries/LibWeb/Rust/src/painting/replaced_paint_facts.rs b/Libraries/LibWeb/Rust/src/painting/replaced_paint_facts.rsindex 34924f92ce7..e39a188743c 100644--- a/Libraries/LibWeb/Rust/src/painting/replaced_paint_facts.rs+++ b/Libraries/LibWeb/Rust/src/painting/replaced_paint_facts.rs@@ -101,6 +101,7 @@ pub(crate) enum ReplacedPaintFacts {NavigableContainer(FfiNavigableContainerPaintFacts),Image(ImagePaintFacts),Video(VideoPaintFacts),+ FrameSet(std::sync::Arc<crate::css::style::tree::FrameSetLayout>),}impl ReplacedPaintFacts {@@ -112,7 +113,14 @@ impl ReplacedPaintFacts {Self::FormControl(_) => PaintDamage::DRAW_FOREGROUND,Self::Canvas(_) => PaintDamage::ALL_DRAW | PaintDamage::ALL_HIT,Self::NavigableContainer(_) => PaintDamage::ALL_DRAW | PaintDamage::ALL_HIT | PaintDamage::SCROLL_METADATA,- Self::Image(_) | Self::Video(_) => PaintDamage::ALL_DRAW,+ Self::Image(_) | Self::Video(_) | Self::FrameSet(_) => PaintDamage::ALL_DRAW,+ }+ }++ pub(crate) fn frameset(self) -> Option<std::sync::Arc<crate::css::style::tree::FrameSetLayout>> {+ match self {+ Self::FrameSet(layout) => Some(layout),+ _ => None,}}diff --git a/Tests/LibWeb/Crash/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/frame-no-frameset-crash.html b/Tests/LibWeb/Crash/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/frame-no-frameset-crash.htmlnew file mode 100644index 00000000000..b032cab90d3--- /dev/null+++ b/Tests/LibWeb/Crash/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/frame-no-frameset-crash.html@@ -0,0 +1,11 @@+<!doctype html>+<link rel=help href="https://bugzilla.mozilla.org/show_bug.cgi?id=1917361">+<script>+document.addEventListener("DOMContentLoaded", () => {+ const a = new Document()+ const b = a.createElementNS("http://www.w3.org/1999/xhtml", "frame")+ document.documentElement.appendChild(b)+ try { b.contentWindow.history.replaceState(undefined, "") } catch (e) {}+ b.contentWindow.history.go()+})+</script>diff --git a/Tests/LibWeb/Crash/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/multicol-table-crash.html b/Tests/LibWeb/Crash/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/multicol-table-crash.htmlnew file mode 100644index 00000000000..adfb76e15a4--- /dev/null+++ b/Tests/LibWeb/Crash/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/multicol-table-crash.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<link rel="help" href="http://crbug.com/1383361">+<body style="columns:2">+<div id="parent" style="display:table-caption"></div>+<script>+const caption = document.querySelector('#parent');+const frameset = caption.appendChild(document.createElement('frameset'));+frameset.setAttribute('rows', '100%');+frameset.setAttribute('cols', '100%');+frameset.innerHTML = '<frame srcdoc=""></frame><frame srcdoc=""></frame>';+</script>+</body>diff --git a/Tests/LibWeb/Ref/expected/HTML/frameset-background-ignored-ref.html b/Tests/LibWeb/Ref/expected/HTML/frameset-background-ignored-ref.htmlnew file mode 100644index 00000000000..4dee827d167--- /dev/null+++ b/Tests/LibWeb/Ref/expected/HTML/frameset-background-ignored-ref.html@@ -0,0 +1,6 @@+<!DOCTYPE html>+<style>+ html {+ background: white;+ }+</style>diff --git a/Tests/LibWeb/Ref/expected/HTML/frameset-border-color-ref.html b/Tests/LibWeb/Ref/expected/HTML/frameset-border-color-ref.htmlnew file mode 100644index 00000000000..7c3bc4bb7c7--- /dev/null+++ b/Tests/LibWeb/Ref/expected/HTML/frameset-border-color-ref.html@@ -0,0 +1,15 @@+<!DOCTYPE html>+<style>+ html {+ background: white;+ }+ div {+ position: absolute;+ top: 0;+ left: 397px;+ width: 6px;+ height: 100vh;+ background: lime;+ }+</style>+<div></div>diff --git a/Tests/LibWeb/Ref/expected/HTML/frameset-frame-border-color-ref.html b/Tests/LibWeb/Ref/expected/HTML/frameset-frame-border-color-ref.htmlnew file mode 100644index 00000000000..0b060b46661--- /dev/null+++ b/Tests/LibWeb/Ref/expected/HTML/frameset-frame-border-color-ref.html@@ -0,0 +1,15 @@+<!DOCTYPE html>+<style>+ html {+ background: white;+ }+ div {+ position: absolute;+ top: 0;+ left: 397px;+ width: 6px;+ height: 100vh;+ background: blue;+ }+</style>+<div></div>diff --git a/Tests/LibWeb/Ref/expected/HTML/frameset-frame-without-border-paints-none-ref.html b/Tests/LibWeb/Ref/expected/HTML/frameset-frame-without-border-paints-none-ref.htmlnew file mode 100644index 00000000000..4dee827d167--- /dev/null+++ b/Tests/LibWeb/Ref/expected/HTML/frameset-frame-without-border-paints-none-ref.html@@ -0,0 +1,6 @@+<!DOCTYPE html>+<style>+ html {+ background: white;+ }+</style>diff --git a/Tests/LibWeb/Ref/expected/HTML/frameset-nested-frameborder-change-ref.html b/Tests/LibWeb/Ref/expected/HTML/frameset-nested-frameborder-change-ref.htmlnew file mode 100644index 00000000000..4dee827d167--- /dev/null+++ b/Tests/LibWeb/Ref/expected/HTML/frameset-nested-frameborder-change-ref.html@@ -0,0 +1,6 @@+<!DOCTYPE html>+<style>+ html {+ background: white;+ }+</style>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/different-writing-modes-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/different-writing-modes-ref.htmlnew file mode 100644index 00000000000..6f1e1e3c1bd--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/different-writing-modes-ref.html@@ -0,0 +1,6 @@+<!DOCTYPE html>+<frameset cols="50%,*" rows="50%,*">+ <frame src="../resources/green.html">+ <frame src="../resources/green.html">+ <frame>+</frameset>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/empty-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/empty-ref.htmlnew file mode 100644index 00000000000..0e76edd65b7--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/empty-ref.html@@ -0,0 +1 @@+<!DOCTYPE html>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/green-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/green-ref.htmlnew file mode 100644index 00000000000..62208d72c91--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/green-ref.html@@ -0,0 +1,5 @@+<!DOCTYPE html>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<style>+ body { background: green; }+</style>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/resources/green.html b/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/resources/green.htmlnew file mode 100644index 00000000000..62208d72c91--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/resources/green.html@@ -0,0 +1,5 @@+<!DOCTYPE html>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<style>+ body { background: green; }+</style>diff --git a/Tests/LibWeb/Ref/input/HTML/frameset-background-ignored.html b/Tests/LibWeb/Ref/input/HTML/frameset-background-ignored.htmlnew file mode 100644index 00000000000..08efe1495b9--- /dev/null+++ b/Tests/LibWeb/Ref/input/HTML/frameset-background-ignored.html@@ -0,0 +1,11 @@+<!DOCTYPE html>+<link rel="match" href="../../expected/HTML/frameset-background-ignored-ref.html">+<style>+ frameset {+ background: red;+ }+</style>+<frameset cols="*,*" frameborder="0">+ <frame>+ <frame>+</frameset>diff --git a/Tests/LibWeb/Ref/input/HTML/frameset-border-color.html b/Tests/LibWeb/Ref/input/HTML/frameset-border-color.htmlnew file mode 100644index 00000000000..f2d96521e5e--- /dev/null+++ b/Tests/LibWeb/Ref/input/HTML/frameset-border-color.html@@ -0,0 +1,6 @@+<!DOCTYPE html>+<link rel="match" href="../../expected/HTML/frameset-border-color-ref.html">+<frameset cols="*,*" bordercolor="lime">+ <frame>+ <frame>+</frameset>diff --git a/Tests/LibWeb/Ref/input/HTML/frameset-frame-border-color.html b/Tests/LibWeb/Ref/input/HTML/frameset-frame-border-color.htmlnew file mode 100644index 00000000000..1a51c05a1fa--- /dev/null+++ b/Tests/LibWeb/Ref/input/HTML/frameset-frame-border-color.html@@ -0,0 +1,6 @@+<!DOCTYPE html>+<link rel="match" href="../../expected/HTML/frameset-frame-border-color-ref.html">+<frameset cols="*,*" bordercolor="lime">+ <frame bordercolor="blue">+ <frame frameborder="0">+</frameset>diff --git a/Tests/LibWeb/Ref/input/HTML/frameset-frame-without-border-paints-none.html b/Tests/LibWeb/Ref/input/HTML/frameset-frame-without-border-paints-none.htmlnew file mode 100644index 00000000000..848ce6bcd58--- /dev/null+++ b/Tests/LibWeb/Ref/input/HTML/frameset-frame-without-border-paints-none.html@@ -0,0 +1,6 @@+<!DOCTYPE html>+<link rel="match" href="../../expected/HTML/frameset-frame-without-border-paints-none-ref.html">+<frameset cols="*,*" bordercolor="lime">+ <frame frameborder="0">+ <frame frameborder="0">+</frameset>diff --git a/Tests/LibWeb/Ref/input/HTML/frameset-nested-frameborder-change.html b/Tests/LibWeb/Ref/input/HTML/frameset-nested-frameborder-change.htmlnew file mode 100644index 00000000000..18f2eba0ad1--- /dev/null+++ b/Tests/LibWeb/Ref/input/HTML/frameset-nested-frameborder-change.html@@ -0,0 +1,18 @@+<!DOCTYPE html>+<html class="reftest-wait">+<link rel="match" href="../../expected/HTML/frameset-nested-frameborder-change-ref.html">+<script>+ addEventListener("load", () => {+ requestAnimationFrame(() => {+ document.querySelector("frameset frameset").setAttribute("frameborder", "0");+ requestAnimationFrame(() => document.documentElement.classList.remove("reftest-wait"));+ });+ });+</script>+<frameset cols="*,*">+ <frame frameborder="0">+ <frameset frameborder="1">+ <frame frameborder="0">+ </frameset>+</frameset>+</html>diff --git a/Tests/LibWeb/Ref/input/canvas-background-from-the-documents-body.html b/Tests/LibWeb/Ref/input/canvas-background-from-the-documents-body.htmlindex 7fedfde1811..da253e734b7 100644--- a/Tests/LibWeb/Ref/input/canvas-background-from-the-documents-body.html+++ b/Tests/LibWeb/Ref/input/canvas-background-from-the-documents-body.html@@ -27,6 +27,6 @@document.documentElement.append(second);</script>"></iframe><!-- A frameset before the body is the document's body: the body paints its own background. -->-<iframe srcdoc="<style>body { margin: 0; height: 50px; } frameset { display: none; }</style><body style='background: green'></body><script>+<iframe srcdoc="<style>body { margin: 0; height: 50px; } frameset { margin-bottom: -100vh; }</style><body style='background: green'></body><script>document.documentElement.insertBefore(document.createElement('frameset'), document.body);</script>"></iframe>diff --git a/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/different-writing-modes.html b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/different-writing-modes.htmlnew file mode 100644index 00000000000..32b0f46a8bb--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/different-writing-modes.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<link rel="match" href="../../../../../../expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/different-writing-modes-ref.html">+<style>+frame {+ writing-mode: vertical-rl;+}+</style>+<frameset cols="50%,*" rows="50%,*">+ <frame src="resources/green.html">+ <frame src="resources/green.html">+ <frame>+</frameset>diff --git a/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/frameset-visibility-hidden.html b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/frameset-visibility-hidden.htmlnew file mode 100644index 00000000000..4017db9f8cc--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/frameset-visibility-hidden.html@@ -0,0 +1,7 @@+<!DOCTYPE html>+<link rel="author" title="Xianzhu Wang" href="mailto:[email protected]">+<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets">+<link rel="match" href="../../../../../../expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/empty-ref.html">+<frameset cols="100%" style="visibility: hidden">+ <frame src="resources/red.html">+</frameset>diff --git a/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-cols-abssize.html b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-cols-abssize.htmlnew file mode 100644index 00000000000..6b2a3a79d49--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-cols-abssize.html@@ -0,0 +1,9 @@+<!DOCTYPE html>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets">+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1116832">+<link rel="match" href="../../../../../../expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/green-ref.html">+<frameset cols="4294967227%,*" frameborder="0">+ <frame src="resources/green.html">+ <frame src="resources/red.html">+</frameset>diff --git a/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-cols-percentage.html b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-cols-percentage.htmlnew file mode 100644index 00000000000..6b2a3a79d49--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-cols-percentage.html@@ -0,0 +1,9 @@+<!DOCTYPE html>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets">+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1116832">+<link rel="match" href="../../../../../../expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/green-ref.html">+<frameset cols="4294967227%,*" frameborder="0">+ <frame src="resources/green.html">+ <frame src="resources/red.html">+</frameset>diff --git a/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-rows-abssize.html b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-rows-abssize.htmlnew file mode 100644index 00000000000..0f507e25daf--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-rows-abssize.html@@ -0,0 +1,9 @@+<!DOCTYPE html>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets">+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1116832">+<link rel="match" href="../../../../../../expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/green-ref.html">+<frameset rows="4294967227%,*" frameborder="0">+ <frame src="resources/green.html">+ <frame src="resources/red.html">+</frameset>diff --git a/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-rows-percentage.html b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-rows-percentage.htmlnew file mode 100644index 00000000000..0f507e25daf--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-rows-percentage.html@@ -0,0 +1,9 @@+<!DOCTYPE html>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets">+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1116832">+<link rel="match" href="../../../../../../expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/reference/green-ref.html">+<frameset rows="4294967227%,*" frameborder="0">+ <frame src="resources/green.html">+ <frame src="resources/red.html">+</frameset>diff --git a/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/resources/green.html b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/resources/green.htmlnew file mode 100644index 00000000000..62208d72c91--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/resources/green.html@@ -0,0 +1,5 @@+<!DOCTYPE html>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<style>+ body { background: green; }+</style>diff --git a/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/resources/red.html b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/resources/red.htmlnew file mode 100644index 00000000000..b5e7f79617d--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/resources/red.html@@ -0,0 +1,5 @@+<!DOCTYPE html>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<style>+ body { background: red; }+</style>diff --git a/Tests/LibWeb/Text/expected/HTML/frameset-layout.txt b/Tests/LibWeb/Text/expected/HTML/frameset-layout.txtnew file mode 100644index 00000000000..917373b6f08--- /dev/null+++ b/Tests/LibWeb/Text/expected/HTML/frameset-layout.txt@@ -0,0 +1,108 @@+--- absolute, relative+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=100 h=600+ frame x=100 y=0 w=233 h=600+ frame x=333 y=0 w=467 h=600+--- zero relative counts as one+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=400 h=600+ frame x=400 y=0 w=400 h=600+--- percentages grow to fill+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=200 h=600+ frame x=200 y=0 w=600 h=600+--- absolutes shrink to fit+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=200 h=600+ frame x=200 y=0 w=600 h=600+--- huge relative+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=799 h=600+ frame x=799 y=0 w=1 h=600+--- trailing comma and fractions+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=800 h=153+ frame x=0 y=153 w=800 h=447+--- grid fills row by row+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=400 h=300+ frame x=400 y=0 w=400 h=300+ frame x=0 y=300 w=400 h=300+--- children beyond the grid have no size+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=400 h=600+ frame x=400 y=0 w=400 h=600+ frame x=0 y=0 w=0 h=0+--- default border+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=397 h=600+ frame x=403 y=0 w=397 h=600+--- border attribute+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=399 h=299+ frame x=401 y=0 w=399 h=299+ frame x=0 y=301 w=399 h=299+ frame x=401 y=301 w=399 h=299+--- other children are not in the grid+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=400 h=600+ div x=0 y=0 w=0 h=0+ frame x=400 y=0 w=400 h=600+--- nested frameset+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=200 h=600+ frameset x=200 y=0 w=600 h=600+ frame x=200 y=0 w=600 h=100+ frame x=200 y=100 w=600 h=500+--- nested frameset in a row+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=800 h=100+ frameset x=0 y=100 w=800 h=500+ frame x=0 y=100 w=800 h=250+ frame x=0 y=350 w=800 h=250+--- own size and position are ignored+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=100 h=600+ frame x=100 y=0 w=700 h=600+--- float does not shrink+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=100 h=600+ frame x=100 y=0 w=700 h=600+--- writing mode after a restyle+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=100 h=600+ frame x=100 y=0 w=700 h=600+--- display after a restyle+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=100 h=600+ frame x=100 y=0 w=700 h=600+--- display none on a frame keeps its cell+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=266 h=600+ frame x=266 y=0 w=266 h=600+ frame x=532 y=0 w=268 h=600+--- display none on the frameset is ignored+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=100 h=600+ frame x=100 y=0 w=700 h=600+--- padding and border on the frameset are ignored+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=100 h=600+ frame x=100 y=0 w=700 h=600+--- min and max size on the frameset are ignored+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=800 h=100+ frame x=0 y=100 w=800 h=500+--- unknown frameborder on the frameset is ignored+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=397 h=600+ frame x=403 y=0 w=397 h=600+--- negative border is 1 pixel+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=399 h=600+ frame x=400 y=0 w=400 h=600+--- padding and border on a frame shrink its viewport+frameset x=0 y=0 w=800 h=600+ frame x=0 y=0 w=100 h=600+ frame x=100 y=0 w=700 h=600+first frame viewport width: 70diff --git a/Tests/LibWeb/Text/expected/HTML/frameset-viewport-resize.txt b/Tests/LibWeb/Text/expected/HTML/frameset-viewport-resize.txtnew file mode 100644index 00000000000..cc5e8e3f68e--- /dev/null+++ b/Tests/LibWeb/Text/expected/HTML/frameset-viewport-resize.txt@@ -0,0 +1,6 @@+frameset x=0 y=0 w=400 h=300+frame x=0 y=0 w=400 h=150+frame x=0 y=150 w=400 h=150+frameset x=0 y=0 w=400 h=500+frame x=0 y=0 w=400 h=250+frame x=0 y=250 w=400 h=250diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/exceed-then-not-exceed.txt b/Tests/LibWeb/Text/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/exceed-then-not-exceed.txtnew file mode 100644index 00000000000..dcf3da76e78--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/exceed-then-not-exceed.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass No crash when a dirty FRAMESET exceeds from the grid then fits in it again\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-cols-relsize.txt b/Tests/LibWeb/Text/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-cols-relsize.txtnew file mode 100644index 00000000000..ef749130099--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-cols-relsize.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass A large relative value should not produce weird sizes.\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-rows-relsize.txt b/Tests/LibWeb/Text/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-rows-relsize.txtnew file mode 100644index 00000000000..ef749130099--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-rows-relsize.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass A large relative value should not produce weird sizes.\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/HTML/frameset-layout.html b/Tests/LibWeb/Text/input/HTML/frameset-layout.htmlnew file mode 100644index 00000000000..b0507f16371--- /dev/null+++ b/Tests/LibWeb/Text/input/HTML/frameset-layout.html@@ -0,0 +1,88 @@+<!DOCTYPE html>+<html>+<head>+<script src="../include.js"></script>+<script>+ function dump(node, depth = 0) {+ const rect = node.getBoundingClientRect();+ println(`${" ".repeat(depth)}${node.localName} x=${rect.x} y=${rect.y} w=${rect.width} h=${rect.height}`);+ for (const child of node.children)+ dump(child, depth + 1);+ }++ function fill(frameset, count) {+ frameset.replaceChildren();+ for (let i = 0; i < count; ++i)+ frameset.appendChild(document.createElement("frame"));+ }++ async function scenario(title, attributes, populate, restyle = false) {+ const frameset = document.querySelector("frameset");+ for (const name of ["cols", "rows", "frameborder", "border", "style"])+ frameset.removeAttribute(name);+ for (const [name, value] of Object.entries(attributes))+ frameset.setAttribute(name, value);+ populate(frameset);+ await animationFrame();+ if (restyle) {+ frameset.style.color = "red";+ await animationFrame();+ }+ println(`--- ${title}`);+ dump(frameset);+ }++ promiseTest(async () => {+ const noBorder = { frameborder: "0" };+ await scenario("absolute, relative", { ...noBorder, cols: "100,*,2*" }, f => fill(f, 3));+ await scenario("zero relative counts as one", { ...noBorder, cols: "0*,*" }, f => fill(f, 2));+ await scenario("percentages grow to fill", { ...noBorder, cols: "10%,30%" }, f => fill(f, 2));+ await scenario("absolutes shrink to fit", { ...noBorder, cols: "1000,3000" }, f => fill(f, 2));+ await scenario("huge relative", { ...noBorder, cols: "4294967227*,*" }, f => fill(f, 2));+ await scenario("trailing comma and fractions", { ...noBorder, rows: "25.5%,*," }, f => fill(f, 2));+ await scenario("grid fills row by row", { ...noBorder, cols: "50%,*", rows: "50%,*" }, f => fill(f, 3));+ await scenario("children beyond the grid have no size", { ...noBorder, cols: "*,*" }, f => fill(f, 3));+ await scenario("default border", { cols: "*,*" }, f => fill(f, 2));+ await scenario("border attribute", { cols: "*,*", rows: "*,*", border: "2" }, f => fill(f, 4));+ await scenario("other children are not in the grid", { ...noBorder, cols: "*,*" }, f => {+ fill(f, 2);+ f.insertBefore(document.createElement("div"), f.lastChild);+ f.insertBefore(document.createTextNode("text"), f.lastChild);+ });+ await scenario("nested frameset", { ...noBorder, cols: "200,*" }, f => {+ fill(f, 1);+ const nested = document.createElement("frameset");+ nested.setAttribute("rows", "100,*");+ fill(nested, 2);+ f.appendChild(nested);+ });+ await scenario("nested frameset in a row", { ...noBorder, rows: "100,*" }, f => {+ fill(f, 1);+ const nested = document.createElement("frameset");+ nested.setAttribute("rows", "50%,*");+ fill(nested, 2);+ f.appendChild(nested);+ });+ await scenario("own size and position are ignored", { ...noBorder, cols: "100,*", style: "position: absolute; left: 50px; width: 300px; height: 200px" }, f => fill(f, 2));+ await scenario("float does not shrink", { ...noBorder, cols: "100,*", style: "float: left" }, f => fill(f, 2));+ await scenario("writing mode after a restyle", { ...noBorder, cols: "100,*", style: "writing-mode: vertical-rl" }, f => fill(f, 2), true);+ await scenario("display after a restyle", { ...noBorder, cols: "100,*", style: "display: inline" }, f => fill(f, 2), true);+ await scenario("display none on a frame keeps its cell", { ...noBorder, cols: "*,*,*" }, f => {+ fill(f, 3);+ f.firstChild.style.display = "none";+ });+ await scenario("display none on the frameset is ignored", { ...noBorder, cols: "100,*", style: "display: none" }, f => fill(f, 2));+ await scenario("padding and border on the frameset are ignored", { ...noBorder, cols: "100,*", style: "padding: 10px; border: 5px solid" }, f => fill(f, 2));+ await scenario("min and max size on the frameset are ignored", { ...noBorder, rows: "100,*", style: "min-height: 1000px; max-width: 100px" }, f => fill(f, 2));+ await scenario("unknown frameborder on the frameset is ignored", { cols: "*,*", frameborder: "true" }, f => fill(f, 2));+ await scenario("negative border is 1 pixel", { cols: "*,*", border: "-5" }, f => fill(f, 2));+ await scenario("padding and border on a frame shrink its viewport", { ...noBorder, cols: "100,*" }, f => {+ fill(f, 2);+ f.firstChild.style.cssText = "padding: 10px; border: 5px solid";+ });+ println(`first frame viewport width: ${document.querySelector("frame").contentWindow.innerWidth}`);+ });+</script>+</head>+<frameset></frameset>+</html>diff --git a/Tests/LibWeb/Text/input/HTML/frameset-viewport-resize.html b/Tests/LibWeb/Text/input/HTML/frameset-viewport-resize.htmlnew file mode 100644index 00000000000..1d54b65b2dc--- /dev/null+++ b/Tests/LibWeb/Text/input/HTML/frameset-viewport-resize.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<iframe id="iframe" style="width: 400px; height: 300px" srcdoc='<frameset rows="*,*" frameborder="0"><frame><frame></frameset>'></iframe>+<script>+ function dump() {+ for (const node of iframe.contentDocument.querySelectorAll("frameset, frame")) {+ const rect = node.getBoundingClientRect();+ println(`${node.localName} x=${rect.x} y=${rect.y} w=${rect.width} h=${rect.height}`);+ }+ }++ promiseTest(async () => {+ await new Promise(resolve => (iframe.onload = resolve));+ await animationFrame();+ dump();+ iframe.style.height = "500px";+ await animationFrame();+ await animationFrame();+ dump();+ });+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/exceed-then-not-exceed.html b/Tests/LibWeb/Text/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/exceed-then-not-exceed.htmlnew file mode 100644index 00000000000..4ba733c0d35--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/exceed-then-not-exceed.html@@ -0,0 +1,32 @@+<!DOCTYPE html>+<html>+<head>+<script src="../../../../resources/testharness.js"></script>+<script src="../../../../resources/testharnessreport.js"></script>+<script>+promise_test(async () => {+ await new Promise(resolve => document.addEventListener('DOMContentLoaded', resolve, {once:true}));+ await new Promise(resolve => requestAnimationFrame(resolve));+ await new Promise(resolve => requestAnimationFrame(resolve));+ // #fs1, #container, and #child were laid out.++ // Move #child.+ // It makes #container dirty, and it exceeds from #fs1's 1x1 grid.+ document.querySelector('#fs1').insertBefore(+ document.querySelector('#child'), document.querySelector('#container'));+ await new Promise(resolve => requestAnimationFrame(resolve));+ await new Promise(resolve => requestAnimationFrame(resolve));++ // Removing #child makes #container visible again.+ document.querySelector('#child').remove();+ await new Promise(resolve => requestAnimationFrame(resolve));+ await new Promise(resolve => requestAnimationFrame(resolve));+}, 'No crash when a dirty FRAMESET exceeds from the grid then fits in it again');+</script>+</head>+<frameset id="fs1">+<frameset id="container">+<frameset id="child"></frameset>+</frameset>+</frameset>+</html>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-cols-relsize.html b/Tests/LibWeb/Text/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-cols-relsize.htmlnew file mode 100644index 00000000000..1cc6ff94ff6--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-cols-relsize.html@@ -0,0 +1,22 @@+<!DOCTYPE html>+<script src="../../../../resources/testharness.js"></script>+<script src="../../../../resources/testharnessreport.js"></script>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets">+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1116832">+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1353277">+<script>+window.onload = () => {+ test(() => {+ const frameSet = document.querySelector('frameset');+ const frames = document.querySelectorAll('frame');+ assert_less_than(frames[0].offsetWidth, frameSet.offsetWidth);+ assert_greater_than(frames[0].offsetWidth, frames[1].offsetWidth);+ assert_greater_than_equal(frames[1].offsetWidth, 0);+ }, 'A large relative value should not produce weird sizes.');+};+</script>+<frameset cols="4294967227*,*" frameborder="0">+ <frame src="resources/green.html">+ <frame src="resources/red.html">+</frameset>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-rows-relsize.html b/Tests/LibWeb/Text/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-rows-relsize.htmlnew file mode 100644index 00000000000..3ace5e834a6--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/rendering/non-replaced-elements/the-frameset-and-frame-elements/large-rows-relsize.html@@ -0,0 +1,22 @@+<!DOCTYPE html>+<script src="../../../../resources/testharness.js"></script>+<script src="../../../../resources/testharnessreport.js"></script>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#frames-and-framesets">+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1116832">+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1353277">+<script>+window.onload = () => {+ test(() => {+ const frameSet = document.querySelector('frameset');+ const frames = document.querySelectorAll('frame');+ assert_less_than(frames[0].offsetHeight, frameSet.offsetHeight);+ assert_greater_than(frames[0].offsetHeight, frames[1].offsetHeight);+ assert_greater_than_equal(frames[1].offsetHeight, 0);+ }, 'A large relative value should not produce weird sizes.');+};+</script>+<frameset rows="4294967227*,*" frameborder="0">+ <frame src="resources/green.html">+ <frame src="resources/red.html">+</frameset>