summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-10-04 15:50:50 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-10-04 15:50:50 +0200
commit9c0e9a1a205a9ed32c9357070c9aede28f3bf741 (patch)
tree36a7f47a9680b4eb293a05c0c60a00a69582c572 /Libraries
parent7bc93101709026cc3c5e04f8e31bc876a28bc11a (diff)
downloadserenity-9c0e9a1a205a9ed32c9357070c9aede28f3bf741.zip
LibHTML: Rename ComputedStyle to BoxModelMetrics
There was nothing left in ComputedStyle except the box model metrics, so this patch gives it a more representative name. Note that style information is fetched directly from StyleProperties, which is basically the CSS property name/value pairs that apply to an element.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibHTML/Dump.cpp24
-rw-r--r--Libraries/LibHTML/Layout/BoxModelMetrics.cpp (renamed from Libraries/LibHTML/Layout/ComputedStyle.cpp)8
-rw-r--r--Libraries/LibHTML/Layout/BoxModelMetrics.h (renamed from Libraries/LibHTML/Layout/ComputedStyle.h)6
-rw-r--r--Libraries/LibHTML/Layout/LayoutBlock.cpp32
-rw-r--r--Libraries/LibHTML/Layout/LayoutNode.cpp8
-rw-r--r--Libraries/LibHTML/Layout/LayoutNode.h8
-rw-r--r--Libraries/LibHTML/Makefile.shared2
7 files changed, 44 insertions, 44 deletions
diff --git a/Libraries/LibHTML/Dump.cpp b/Libraries/LibHTML/Dump.cpp
index 5707042b28..a7fffdb3cd 100644
--- a/Libraries/LibHTML/Dump.cpp
+++ b/Libraries/LibHTML/Dump.cpp
@@ -62,23 +62,23 @@ void dump_tree(const LayoutNode& layout_node)
// Dump the horizontal box properties
dbgprintf(" [%d+%d+%d %d %d+%d+%d]",
- layout_node.style().margin().left.to_px(),
- layout_node.style().border().left.to_px(),
- layout_node.style().padding().left.to_px(),
+ layout_node.box_model().margin().left.to_px(),
+ layout_node.box_model().border().left.to_px(),
+ layout_node.box_model().padding().left.to_px(),
layout_node.rect().width(),
- layout_node.style().padding().right.to_px(),
- layout_node.style().border().right.to_px(),
- layout_node.style().margin().right.to_px());
+ layout_node.box_model().padding().right.to_px(),
+ layout_node.box_model().border().right.to_px(),
+ layout_node.box_model().margin().right.to_px());
// And the vertical box properties
dbgprintf(" [%d+%d+%d %d %d+%d+%d]",
- layout_node.style().margin().top.to_px(),
- layout_node.style().border().top.to_px(),
- layout_node.style().padding().top.to_px(),
+ layout_node.box_model().margin().top.to_px(),
+ layout_node.box_model().border().top.to_px(),
+ layout_node.box_model().padding().top.to_px(),
layout_node.rect().height(),
- layout_node.style().padding().bottom.to_px(),
- layout_node.style().border().bottom.to_px(),
- layout_node.style().margin().bottom.to_px());
+ layout_node.box_model().padding().bottom.to_px(),
+ layout_node.box_model().border().bottom.to_px(),
+ layout_node.box_model().margin().bottom.to_px());
dbgprintf("\n");
diff --git a/Libraries/LibHTML/Layout/ComputedStyle.cpp b/Libraries/LibHTML/Layout/BoxModelMetrics.cpp
index e5948039ae..13340c7378 100644
--- a/Libraries/LibHTML/Layout/ComputedStyle.cpp
+++ b/Libraries/LibHTML/Layout/BoxModelMetrics.cpp
@@ -1,14 +1,14 @@
-#include <LibHTML/Layout/ComputedStyle.h>
+#include <LibHTML/Layout/BoxModelMetrics.h>
-ComputedStyle::ComputedStyle()
+BoxModelMetrics::BoxModelMetrics()
{
}
-ComputedStyle::~ComputedStyle()
+BoxModelMetrics::~BoxModelMetrics()
{
}
-ComputedStyle::PixelBox ComputedStyle::full_margin() const
+BoxModelMetrics::PixelBox BoxModelMetrics::full_margin() const
{
return {
m_margin.top.to_px() + m_border.top.to_px() + m_padding.top.to_px(),
diff --git a/Libraries/LibHTML/Layout/ComputedStyle.h b/Libraries/LibHTML/Layout/BoxModelMetrics.h
index feaa8d9f97..7ed7bcb790 100644
--- a/Libraries/LibHTML/Layout/ComputedStyle.h
+++ b/Libraries/LibHTML/Layout/BoxModelMetrics.h
@@ -3,10 +3,10 @@
#include <LibDraw/Size.h>
#include <LibHTML/CSS/LengthBox.h>
-class ComputedStyle {
+class BoxModelMetrics {
public:
- ComputedStyle();
- ~ComputedStyle();
+ BoxModelMetrics();
+ ~BoxModelMetrics();
LengthBox& margin() { return m_margin; }
LengthBox& padding() { return m_padding; }
diff --git a/Libraries/LibHTML/Layout/LayoutBlock.cpp b/Libraries/LibHTML/Layout/LayoutBlock.cpp
index d2851879d6..5bf6470eac 100644
--- a/Libraries/LibHTML/Layout/LayoutBlock.cpp
+++ b/Libraries/LibHTML/Layout/LayoutBlock.cpp
@@ -39,7 +39,7 @@ void LayoutBlock::layout_block_children()
int content_height = 0;
for_each_child([&](auto& child) {
child.layout();
- content_height = child.rect().bottom() + child.style().full_margin().bottom - rect().top();
+ content_height = child.rect().bottom() + child.box_model().full_margin().bottom - rect().top();
});
rect().set_height(content_height);
}
@@ -139,12 +139,12 @@ void LayoutBlock::compute_width()
}
rect().set_width(width.to_px());
- style().margin().left = margin_left;
- style().margin().right = margin_right;
- style().border().left = border_left;
- style().border().right = border_right;
- style().padding().left = padding_left;
- style().padding().right = padding_right;
+ box_model().margin().left = margin_left;
+ box_model().margin().right = margin_right;
+ box_model().border().left = border_left;
+ box_model().border().right = border_right;
+ box_model().padding().left = padding_left;
+ box_model().padding().right = padding_right;
}
void LayoutBlock::compute_position()
@@ -156,24 +156,24 @@ void LayoutBlock::compute_position()
auto width = style_properties.length_or_fallback("width", auto_value);
- style().margin().top = style_properties.length_or_fallback("margin-top", zero_value);
- style().margin().bottom = style_properties.length_or_fallback("margin-bottom", zero_value);
- style().border().top = style_properties.length_or_fallback("border-top", zero_value);
- style().border().bottom = style_properties.length_or_fallback("border-bottom", zero_value);
- style().padding().top = style_properties.length_or_fallback("padding-top", zero_value);
- style().padding().bottom = style_properties.length_or_fallback("padding-bottom", zero_value);
- rect().set_x(containing_block()->rect().x() + style().margin().left.to_px() + style().border().left.to_px() + style().padding().left.to_px());
+ box_model().margin().top = style_properties.length_or_fallback("margin-top", zero_value);
+ box_model().margin().bottom = style_properties.length_or_fallback("margin-bottom", zero_value);
+ box_model().border().top = style_properties.length_or_fallback("border-top", zero_value);
+ box_model().border().bottom = style_properties.length_or_fallback("border-bottom", zero_value);
+ box_model().padding().top = style_properties.length_or_fallback("padding-top", zero_value);
+ box_model().padding().bottom = style_properties.length_or_fallback("padding-bottom", zero_value);
+ rect().set_x(containing_block()->rect().x() + box_model().margin().left.to_px() + box_model().border().left.to_px() + box_model().padding().left.to_px());
int top_border = -1;
if (previous_sibling() != nullptr) {
auto& previous_sibling_rect = previous_sibling()->rect();
- auto& previous_sibling_style = previous_sibling()->style();
+ auto& previous_sibling_style = previous_sibling()->box_model();
top_border = previous_sibling_rect.y() + previous_sibling_rect.height();
top_border += previous_sibling_style.full_margin().bottom;
} else {
top_border = containing_block()->rect().y();
}
- rect().set_y(top_border + style().full_margin().top);
+ rect().set_y(top_border + box_model().full_margin().top);
}
void LayoutBlock::compute_height()
diff --git a/Libraries/LibHTML/Layout/LayoutNode.cpp b/Libraries/LibHTML/Layout/LayoutNode.cpp
index f3b8946b3a..1640108b79 100644
--- a/Libraries/LibHTML/Layout/LayoutNode.cpp
+++ b/Libraries/LibHTML/Layout/LayoutNode.cpp
@@ -44,10 +44,10 @@ void LayoutNode::render(RenderingContext& context)
#endif
Rect padded_rect;
- padded_rect.set_x(rect().x() - style().padding().left.to_px());
- padded_rect.set_width(rect().width() + style().padding().left.to_px() + style().padding().right.to_px());
- padded_rect.set_y(rect().y() - style().padding().top.to_px());
- padded_rect.set_height(rect().height() + style().padding().top.to_px() + style().padding().bottom.to_px());
+ padded_rect.set_x(rect().x() - box_model().padding().left.to_px());
+ padded_rect.set_width(rect().width() + box_model().padding().left.to_px() + box_model().padding().right.to_px());
+ padded_rect.set_y(rect().y() - box_model().padding().top.to_px());
+ padded_rect.set_height(rect().height() + box_model().padding().top.to_px() + box_model().padding().bottom.to_px());
auto bgcolor = style_properties().property("background-color");
if (bgcolor.has_value() && bgcolor.value()->is_color()) {
diff --git a/Libraries/LibHTML/Layout/LayoutNode.h b/Libraries/LibHTML/Layout/LayoutNode.h
index b02acd2a92..9c1fa199b9 100644
--- a/Libraries/LibHTML/Layout/LayoutNode.h
+++ b/Libraries/LibHTML/Layout/LayoutNode.h
@@ -4,7 +4,7 @@
#include <AK/Vector.h>
#include <LibDraw/Rect.h>
#include <LibHTML/CSS/StyleProperties.h>
-#include <LibHTML/Layout/ComputedStyle.h>
+#include <LibHTML/Layout/BoxModelMetrics.h>
#include <LibHTML/RenderingContext.h>
#include <LibHTML/TreeNode.h>
@@ -26,8 +26,8 @@ public:
Rect& rect() { return m_rect; }
void set_rect(const Rect& rect) { m_rect = rect; }
- ComputedStyle& style() { return m_style; }
- const ComputedStyle& style() const { return m_style; }
+ BoxModelMetrics& box_model() { return m_style; }
+ const BoxModelMetrics& box_model() const { return m_style; }
virtual HitTestResult hit_test(const Point&) const;
@@ -79,6 +79,6 @@ private:
const Node* m_node { nullptr };
RefPtr<StyleProperties> m_style_properties;
- ComputedStyle m_style;
+ BoxModelMetrics m_style;
Rect m_rect;
};
diff --git a/Libraries/LibHTML/Makefile.shared b/Libraries/LibHTML/Makefile.shared
index 24d366362c..ebbaf69398 100644
--- a/Libraries/LibHTML/Makefile.shared
+++ b/Libraries/LibHTML/Makefile.shared
@@ -27,7 +27,7 @@ LIBHTML_OBJS = \
Layout/LayoutBlock.o \
Layout/LayoutInline.o \
Layout/LayoutDocument.o \
- Layout/ComputedStyle.o \
+ Layout/BoxModelMetrics.o \
Layout/LineBox.o \
Layout/LineBoxFragment.o \
HtmlView.o \