|
@@ -7,6 +7,7 @@
|
|
#include <LibGfx/Painter.h>
|
|
#include <LibGfx/Painter.h>
|
|
#include <LibWeb/DOM/Document.h>
|
|
#include <LibWeb/DOM/Document.h>
|
|
#include <LibWeb/HTML/HTMLBodyElement.h>
|
|
#include <LibWeb/HTML/HTMLBodyElement.h>
|
|
|
|
+#include <LibWeb/HTML/HTMLHtmlElement.h>
|
|
#include <LibWeb/Layout/BlockBox.h>
|
|
#include <LibWeb/Layout/BlockBox.h>
|
|
#include <LibWeb/Layout/Box.h>
|
|
#include <LibWeb/Layout/Box.h>
|
|
#include <LibWeb/Page/Frame.h>
|
|
#include <LibWeb/Page/Frame.h>
|
|
@@ -25,13 +26,37 @@ void Box::paint(PaintContext& context, PaintPhase phase)
|
|
|
|
|
|
auto padded_rect = this->padded_rect();
|
|
auto padded_rect = this->padded_rect();
|
|
|
|
|
|
- if (phase == PaintPhase::Background && !is_body()) {
|
|
|
|
- auto background_rect = enclosing_int_rect(padded_rect);
|
|
|
|
- context.painter().fill_rect(background_rect, computed_values().background_color());
|
|
|
|
-
|
|
|
|
- if (background_image() && background_image()->bitmap()) {
|
|
|
|
- paint_background_image(context, *background_image()->bitmap(), computed_values().background_repeat_x(), computed_values().background_repeat_y(), move(background_rect));
|
|
|
|
|
|
+ if (phase == PaintPhase::Background) {
|
|
|
|
+ // If the body's background properties were propagated to the root element, do no re-paint the body's background.
|
|
|
|
+ if (is_body() && document().html_element()->should_use_body_background_properties())
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ Gfx::IntRect background_rect;
|
|
|
|
+
|
|
|
|
+ Color background_color = computed_values().background_color();
|
|
|
|
+ const Gfx::Bitmap* background_image = this->background_image() ? this->background_image()->bitmap() : nullptr;
|
|
|
|
+ CSS::Repeat background_repeat_x = computed_values().background_repeat_x();
|
|
|
|
+ CSS::Repeat background_repeat_y = computed_values().background_repeat_y();
|
|
|
|
+
|
|
|
|
+ if (is_root_element()) {
|
|
|
|
+ // CSS 2.1 Appendix E.2: If the element is a root element, paint the background over the entire canvas.
|
|
|
|
+ background_rect = context.viewport_rect();
|
|
|
|
+
|
|
|
|
+ // Section 2.11.2: If the computed value of background-image on the root element is none and its background-color is transparent,
|
|
|
|
+ // user agents must instead propagate the computed values of the background properties from that element’s first HTML BODY child element.
|
|
|
|
+ if (document().html_element()->should_use_body_background_properties()) {
|
|
|
|
+ background_color = document().background_color(context.palette());
|
|
|
|
+ background_image = document().background_image();
|
|
|
|
+ background_repeat_x = document().background_repeat_x();
|
|
|
|
+ background_repeat_y = document().background_repeat_y();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ background_rect = enclosing_int_rect(padded_rect);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ context.painter().fill_rect(background_rect, move(background_color));
|
|
|
|
+ if (background_image)
|
|
|
|
+ paint_background_image(context, *background_image, background_repeat_x, background_repeat_y, move(background_rect));
|
|
}
|
|
}
|
|
|
|
|
|
if (phase == PaintPhase::Border) {
|
|
if (phase == PaintPhase::Border) {
|