From d4b5205482cf5456259d6063d9cc1b019f8bcaeb Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Tue, 11 Jul 2023 12:28:47 +0200 Subject: [PATCH] Revert "LibWeb: Make TextNode::ChunkIterator emit an empty chunk for content:""" This reverts commit b062a0fb7cb44036d16a36269164c537b137c3a4. This made a calculation of pseudo-elements' height incorrect when they had `height` set to `auto` and used other techniques (like setting `padding-top`) to set height, as it was now also adding an empty line. Additionally, the case didn't work for content containing whitespace characters, so a pseudo-element with `content: " "` didn't have *this* particular problem. --- .../LibWeb/Layout/InlineLevelIterator.cpp | 2 +- Userland/Libraries/LibWeb/Layout/TextNode.cpp | 14 +------------- Userland/Libraries/LibWeb/Layout/TextNode.h | 3 +-- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp index 2b6d95429e..dd2cccb35d 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp +++ b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp @@ -266,7 +266,7 @@ void InlineLevelIterator::enter_text_node(Layout::TextNode const& text_node) .do_respect_linebreaks = do_respect_linebreaks, .is_first_chunk = true, .is_last_chunk = false, - .chunk_iterator = TextNode::ChunkIterator { text_node.text_for_rendering(), do_wrap_lines, do_respect_linebreaks, text_node.is_generated() && text_node.text_for_rendering().is_empty() }, + .chunk_iterator = TextNode::ChunkIterator { text_node.text_for_rendering(), do_wrap_lines, do_respect_linebreaks }, }; m_text_node_context->next_chunk = m_text_node_context->chunk_iterator.next(); } diff --git a/Userland/Libraries/LibWeb/Layout/TextNode.cpp b/Userland/Libraries/LibWeb/Layout/TextNode.cpp index d191072ad1..b3f11f7400 100644 --- a/Userland/Libraries/LibWeb/Layout/TextNode.cpp +++ b/Userland/Libraries/LibWeb/Layout/TextNode.cpp @@ -124,10 +124,9 @@ void TextNode::compute_text_for_rendering() m_text_for_rendering = builder.to_deprecated_string(); } -TextNode::ChunkIterator::ChunkIterator(StringView text, bool wrap_lines, bool respect_linebreaks, bool is_generated_empty_string) +TextNode::ChunkIterator::ChunkIterator(StringView text, bool wrap_lines, bool respect_linebreaks) : m_wrap_lines(wrap_lines) , m_respect_linebreaks(respect_linebreaks) - , m_should_emit_one_empty_chunk(is_generated_empty_string) , m_utf8_view(text) , m_iterator(m_utf8_view.begin()) { @@ -135,17 +134,6 @@ TextNode::ChunkIterator::ChunkIterator(StringView text, bool wrap_lines, bool re Optional TextNode::ChunkIterator::next() { - if (m_should_emit_one_empty_chunk) { - m_should_emit_one_empty_chunk = false; - return Chunk { - .view = {}, - .start = 0, - .length = 0, - .has_breaking_newline = false, - .is_all_whitespace = false, - }; - } - if (m_iterator == m_utf8_view.end()) return {}; diff --git a/Userland/Libraries/LibWeb/Layout/TextNode.h b/Userland/Libraries/LibWeb/Layout/TextNode.h index 0201973272..417baeadb2 100644 --- a/Userland/Libraries/LibWeb/Layout/TextNode.h +++ b/Userland/Libraries/LibWeb/Layout/TextNode.h @@ -35,7 +35,7 @@ public: class ChunkIterator { public: - ChunkIterator(StringView text, bool wrap_lines, bool respect_linebreaks, bool is_generated_empty_string); + ChunkIterator(StringView text, bool wrap_lines, bool respect_linebreaks); Optional next(); private: @@ -43,7 +43,6 @@ public: bool const m_wrap_lines; bool const m_respect_linebreaks; - bool m_should_emit_one_empty_chunk { false }; Utf8View m_utf8_view; Utf8View::Iterator m_iterator; };