diff options
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibHTML/Dump.cpp | 12 | ||||
-rw-r--r-- | Libraries/LibHTML/HtmlView.cpp | 4 | ||||
-rw-r--r-- | Libraries/LibHTML/Layout/LayoutBlock.cpp | 12 | ||||
-rw-r--r-- | Libraries/LibHTML/Layout/LayoutListItem.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibHTML/Layout/LayoutNode.cpp | 8 | ||||
-rw-r--r-- | Libraries/LibHTML/Layout/LayoutNode.h | 4 | ||||
-rw-r--r-- | Libraries/LibHTML/Layout/LayoutText.cpp | 6 |
7 files changed, 26 insertions, 22 deletions
diff --git a/Libraries/LibHTML/Dump.cpp b/Libraries/LibHTML/Dump.cpp index 2857d43e31..c16d78f5cd 100644 --- a/Libraries/LibHTML/Dump.cpp +++ b/Libraries/LibHTML/Dump.cpp @@ -61,17 +61,17 @@ void dump_tree(const LayoutNode& layout_node) dbgprintf("%s {%s} at (%d,%d) size %dx%d", layout_node.class_name(), tag_name.characters(), - layout_node.rect().x(), - layout_node.rect().y(), - layout_node.rect().width(), - layout_node.rect().height()); + layout_node.x(), + layout_node.y(), + layout_node.width(), + layout_node.height()); // Dump the horizontal box properties dbgprintf(" [%d+%d+%d %d %d+%d+%d]", 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.width(), layout_node.box_model().padding().right.to_px(), layout_node.box_model().border().right.to_px(), layout_node.box_model().margin().right.to_px()); @@ -81,7 +81,7 @@ void dump_tree(const LayoutNode& layout_node) 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.height(), layout_node.box_model().padding().bottom.to_px(), layout_node.box_model().border().bottom.to_px(), layout_node.box_model().margin().bottom.to_px()); diff --git a/Libraries/LibHTML/HtmlView.cpp b/Libraries/LibHTML/HtmlView.cpp index 7dc89defa8..06eeaa1187 100644 --- a/Libraries/LibHTML/HtmlView.cpp +++ b/Libraries/LibHTML/HtmlView.cpp @@ -76,14 +76,14 @@ void HtmlView::layout_and_sync_size() main_frame().set_size(available_size()); document()->layout(); - set_content_size(layout_root()->rect().size()); + set_content_size(layout_root()->size()); // NOTE: If layout caused us to gain or lose scrollbars, we have to lay out again // since the scrollbars now take up some of the available space. if (had_vertical_scrollbar != vertical_scrollbar().is_visible() || had_horizontal_scrollbar != horizontal_scrollbar().is_visible()) { main_frame().set_size(available_size()); document()->layout(); - set_content_size(layout_root()->rect().size()); + set_content_size(layout_root()->size()); } #ifdef HTML_DEBUG diff --git a/Libraries/LibHTML/Layout/LayoutBlock.cpp b/Libraries/LibHTML/Layout/LayoutBlock.cpp index 5ca5f386b6..8cce2f9431 100644 --- a/Libraries/LibHTML/Layout/LayoutBlock.cpp +++ b/Libraries/LibHTML/Layout/LayoutBlock.cpp @@ -66,8 +66,8 @@ void LayoutBlock::layout_inline_children() for (auto& fragment : line_box.fragments()) { // Vertically align everyone's bottom to the line. // FIXME: Support other kinds of vertical alignment. - fragment.rect().set_x(rect().x() + fragment.rect().x()); - fragment.rect().set_y(rect().y() + content_height + (max_height - fragment.rect().height())); + fragment.rect().set_x(x() + fragment.rect().x()); + fragment.rect().set_y(y() + content_height + (max_height - fragment.rect().height())); if (fragment.layout_node().is_replaced()) const_cast<LayoutNode&>(fragment.layout_node()).set_rect(fragment.rect()); @@ -109,7 +109,7 @@ void LayoutBlock::compute_width() // 10.3.3 Block-level, non-replaced elements in normal flow // If 'width' is not 'auto' and 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' (plus any of 'margin-left' or 'margin-right' that are not 'auto') is larger than the width of the containing block, then any 'auto' values for 'margin-left' or 'margin-right' are, for the following rules, treated as zero. - if (width.is_auto() && total_px > containing_block()->rect().width()) { + if (width.is_auto() && total_px > containing_block()->width()) { if (margin_left.is_auto()) margin_left = zero_value; if (margin_right.is_auto()) @@ -117,7 +117,7 @@ void LayoutBlock::compute_width() } // 10.3.3 cont'd. - auto underflow_px = containing_block()->rect().width() - total_px; + auto underflow_px = containing_block()->width() - total_px; if (width.is_auto()) { if (margin_left.is_auto()) @@ -168,7 +168,7 @@ void LayoutBlock::compute_position() box_model().border().bottom = style.length_or_fallback(CSS::PropertyID::BorderBottomWidth, zero_value); box_model().padding().top = style.length_or_fallback(CSS::PropertyID::PaddingTop, zero_value); box_model().padding().bottom = style.length_or_fallback(CSS::PropertyID::PaddingBottom, 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()); + rect().set_x(containing_block()->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) { @@ -177,7 +177,7 @@ void LayoutBlock::compute_position() 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(); + top_border = containing_block()->y(); } rect().set_y(top_border + box_model().full_margin().top); } diff --git a/Libraries/LibHTML/Layout/LayoutListItem.cpp b/Libraries/LibHTML/Layout/LayoutListItem.cpp index 4c43f5eb7c..a0da9dc064 100644 --- a/Libraries/LibHTML/Layout/LayoutListItem.cpp +++ b/Libraries/LibHTML/Layout/LayoutListItem.cpp @@ -21,6 +21,6 @@ void LayoutListItem::layout() append_child(*m_marker); } - Rect marker_rect { rect().x() - 8, rect().y(), 4, rect().height() }; + Rect marker_rect { x() - 8, y(), 4, height() }; m_marker->set_rect(marker_rect); } diff --git a/Libraries/LibHTML/Layout/LayoutNode.cpp b/Libraries/LibHTML/Layout/LayoutNode.cpp index 1de30df602..6516c47cae 100644 --- a/Libraries/LibHTML/Layout/LayoutNode.cpp +++ b/Libraries/LibHTML/Layout/LayoutNode.cpp @@ -51,10 +51,10 @@ void LayoutNode::render(RenderingContext& context) #endif Rect padded_rect; - 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()); + padded_rect.set_x(x() - box_model().padding().left.to_px()); + padded_rect.set_width(width() + box_model().padding().left.to_px() + box_model().padding().right.to_px()); + padded_rect.set_y(y() - box_model().padding().top.to_px()); + padded_rect.set_height(height() + box_model().padding().top.to_px() + box_model().padding().bottom.to_px()); auto bgcolor = style().property(CSS::PropertyID::BackgroundColor); if (bgcolor.has_value() && bgcolor.value()->is_color()) { diff --git a/Libraries/LibHTML/Layout/LayoutNode.h b/Libraries/LibHTML/Layout/LayoutNode.h index 5ff6b65a18..b412e59370 100644 --- a/Libraries/LibHTML/Layout/LayoutNode.h +++ b/Libraries/LibHTML/Layout/LayoutNode.h @@ -28,8 +28,12 @@ public: Rect& rect() { return m_rect; } void set_rect(const Rect& rect) { m_rect = rect; } + int x() const { return rect().x(); } + int y() const { return rect().y(); } int width() const { return rect().width(); } int height() const { return rect().height(); } + Size size() const { return rect().size(); } + Point position() const { return rect().location(); } BoxModelMetrics& box_model() { return m_box_metrics; } const BoxModelMetrics& box_model() const { return m_box_metrics; } diff --git a/Libraries/LibHTML/Layout/LayoutText.cpp b/Libraries/LibHTML/Layout/LayoutText.cpp index 9bf6a6bc5b..9aff6a269d 100644 --- a/Libraries/LibHTML/Layout/LayoutText.cpp +++ b/Libraries/LibHTML/Layout/LayoutText.cpp @@ -128,7 +128,7 @@ void LayoutText::split_into_lines(LayoutBlock& container) auto& line_boxes = container.line_boxes(); if (line_boxes.is_empty()) line_boxes.append(LineBox()); - int available_width = container.rect().width() - line_boxes.last().width(); + int available_width = container.width() - line_boxes.last().width(); bool is_preformatted = style().string_or_fallback(CSS::PropertyID::WhiteSpace, "normal") == "pre"; if (is_preformatted) { @@ -179,7 +179,7 @@ void LayoutText::split_into_lines(LayoutBlock& container) if (word_width > available_width) { line_boxes.append(LineBox()); - available_width = container.rect().width(); + available_width = container.width(); } if (is_whitespace && line_boxes.last().fragments().is_empty()) @@ -190,7 +190,7 @@ void LayoutText::split_into_lines(LayoutBlock& container) if (available_width < 0) { line_boxes.append(LineBox()); - available_width = container.rect().width(); + available_width = container.width(); } } } |