summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Libraries/LibHTML/CSS/StyleResolver.cpp2
-rw-r--r--Libraries/LibHTML/CSS/StyleResolver.h2
-rw-r--r--Libraries/LibHTML/Layout/LayoutBlock.cpp15
-rw-r--r--Libraries/LibHTML/Layout/LayoutBlock.h2
4 files changed, 19 insertions, 2 deletions
diff --git a/Libraries/LibHTML/CSS/StyleResolver.cpp b/Libraries/LibHTML/CSS/StyleResolver.cpp
index 081675a945..c4dca04b65 100644
--- a/Libraries/LibHTML/CSS/StyleResolver.cpp
+++ b/Libraries/LibHTML/CSS/StyleResolver.cpp
@@ -78,7 +78,7 @@ NonnullRefPtrVector<StyleRule> StyleResolver::collect_matching_rules(const Eleme
return matching_rules;
}
-static bool is_inherited_property(const StringView& name)
+bool StyleResolver::is_inherited_property(const StringView& name)
{
static HashTable<String> inherited_properties;
if (inherited_properties.is_empty()) {
diff --git a/Libraries/LibHTML/CSS/StyleResolver.h b/Libraries/LibHTML/CSS/StyleResolver.h
index 9056e130ba..d91470ccdf 100644
--- a/Libraries/LibHTML/CSS/StyleResolver.h
+++ b/Libraries/LibHTML/CSS/StyleResolver.h
@@ -22,6 +22,8 @@ public:
NonnullRefPtrVector<StyleRule> collect_matching_rules(const Element&) const;
+ static bool is_inherited_property(const StringView&);
+
private:
template<typename Callback>
void for_each_stylesheet(Callback) const;
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;
+}
diff --git a/Libraries/LibHTML/Layout/LayoutBlock.h b/Libraries/LibHTML/Layout/LayoutBlock.h
index ee1989d9cb..58a6f87055 100644
--- a/Libraries/LibHTML/Layout/LayoutBlock.h
+++ b/Libraries/LibHTML/Layout/LayoutBlock.h
@@ -27,6 +27,8 @@ public:
private:
virtual bool is_block() const override { return true; }
+ NonnullRefPtr<StyleProperties> style_for_anonymous_block() const;
+
void layout_inline_children();
void layout_block_children();