mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibWeb: Don't crash if the document element is not visible
Previously, setting the `hidden` property on the `<html>` element would cause a crash.
This commit is contained in:
parent
dd73cccf8f
commit
3aea14093f
Notes:
sideshowbarker
2024-07-16 21:42:29 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/3aea14093f Pull-request: https://github.com/SerenityOS/serenity/pull/24075
3
Tests/LibWeb/Layout/expected/hidden-root-element.txt
Normal file
3
Tests/LibWeb/Layout/expected/hidden-root-element.txt
Normal file
@ -0,0 +1,3 @@
|
||||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
|
||||
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
5
Tests/LibWeb/Layout/input/hidden-root-element.html
Normal file
5
Tests/LibWeb/Layout/input/hidden-root-element.html
Normal file
@ -0,0 +1,5 @@
|
||||
<html hidden>
|
||||
<body>
|
||||
<div>Test passes if we don't crash</div>
|
||||
</body>
|
||||
</html>
|
@ -1058,13 +1058,14 @@ void Document::update_layout()
|
||||
if (!navigable)
|
||||
return;
|
||||
|
||||
auto* document_element = this->document_element();
|
||||
auto viewport_rect = this->viewport_rect();
|
||||
|
||||
if (!m_layout_root) {
|
||||
Layout::TreeBuilder tree_builder;
|
||||
m_layout_root = verify_cast<Layout::Viewport>(*tree_builder.build(*this));
|
||||
|
||||
if (auto* document_element = this->document_element()) {
|
||||
if (document_element && document_element->layout_node()) {
|
||||
propagate_overflow_to_viewport(*document_element, *m_layout_root);
|
||||
}
|
||||
}
|
||||
@ -1079,8 +1080,7 @@ void Document::update_layout()
|
||||
viewport_state.set_content_width(viewport_rect.width());
|
||||
viewport_state.set_content_height(viewport_rect.height());
|
||||
|
||||
if (auto* document_element = this->document_element()) {
|
||||
VERIFY(document_element->layout_node());
|
||||
if (document_element && document_element->layout_node()) {
|
||||
auto& icb_state = layout_state.get_mutable(verify_cast<Layout::NodeWithStyleAndBoxModelMetrics>(*document_element->layout_node()));
|
||||
icb_state.set_content_width(viewport_rect.width());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user