summaryrefslogtreecommitdiff
path: root/Libraries/LibHTML/Layout/LayoutBlock.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-10-05 23:47:06 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-10-05 23:47:06 +0200
commit48f43a74298161cf54bdc5b4c27ca280e3422510 (patch)
tree5ee0da100f390056b05b6a9368de8dc465d81657 /Libraries/LibHTML/Layout/LayoutBlock.cpp
parent958b395418d1d5aa092c2a89278447ece2c9364e (diff)
downloadserenity-48f43a74298161cf54bdc5b4c27ca280e3422510.zip
LibHTML: Anonymous blocks *should* inherit some properties
Okay, I got that a bit wrong. Here's what CSS 2.1 says: "The properties of anonymous boxes are inherited from the enclosing non-anonymous box. Non-inherited properties have their initial value." This patch implements a better behavior by only copying the inherited properties from the parent style.
Diffstat (limited to 'Libraries/LibHTML/Layout/LayoutBlock.cpp')
-rw-r--r--Libraries/LibHTML/Layout/LayoutBlock.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/Libraries/LibHTML/Layout/LayoutBlock.cpp b/Libraries/LibHTML/Layout/LayoutBlock.cpp
index bd5dd57c82..a2a7bf9564 100644
--- a/Libraries/LibHTML/Layout/LayoutBlock.cpp
+++ b/Libraries/LibHTML/Layout/LayoutBlock.cpp
@@ -1,4 +1,5 @@
#include <LibGUI/GPainter.h>
+#include <LibHTML/CSS/StyleResolver.h>
#include <LibHTML/DOM/Element.h>
#include <LibHTML/Layout/LayoutBlock.h>
#include <LibHTML/Layout/LayoutInline.h>
@@ -15,7 +16,7 @@ LayoutBlock::~LayoutBlock()
LayoutNode& LayoutBlock::inline_wrapper()
{
if (!last_child() || !last_child()->is_block() || last_child()->node() != nullptr) {
- append_child(adopt(*new LayoutBlock(nullptr, StyleProperties::create())));
+ append_child(adopt(*new LayoutBlock(nullptr, style_for_anonymous_block())));
}
return *last_child();
}
@@ -236,3 +237,15 @@ HitTestResult LayoutBlock::hit_test(const Point& position) const
}
return {};
}
+
+NonnullRefPtr<StyleProperties> LayoutBlock::style_for_anonymous_block() const
+{
+ auto new_style = StyleProperties::create();
+
+ style().for_each_property([&](auto& name, auto& value) {
+ if (StyleResolver::is_inherited_property(name))
+ new_style->set_property(name, value);
+ });
+
+ return new_style;
+}