ladybird/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp
Timothy Flynn dba261f79b LibWeb: Propagate body background properties to root HTML element
The Acid1 test has a bit of an unusual background - the html and body
tags have different background colors. Our painting order of the DOM was
such that the body background was painted first, then all other elements
were painted in-phase according to Appendix E of CSS 2.1. So the html
element's background color was painted over the body background.

This removes the special handling of the body background from
InitialContainingBlockBox and now all boxes are painted in-phase. Doing
this also exposed that we weren't handling Section 2.11.2 of the spec;
when the html background is unset, the body's background should be
propagated to the html element.
2021-05-13 16:16:25 +02:00

28 lines
667 B
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/HTML/HTMLHtmlElement.h>
namespace Web::HTML {
HTMLHtmlElement::HTMLHtmlElement(DOM::Document& document, QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
}
HTMLHtmlElement::~HTMLHtmlElement()
{
}
bool HTMLHtmlElement::should_use_body_background_properties() const
{
auto background_color = layout_node()->computed_values().background_color();
const auto* background_image = layout_node()->background_image();
return (background_color == Color::Transparent) && !background_image;
}
}