summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-19 18:36:33 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-19 18:36:33 +0100
commit1fe2cca439d7b1481c5744c3f4b8022e5e59fa1f (patch)
tree209fd510dee40a2f700d23163aabbfaa7c846e57
parentdce76468821c5bfce1e99ee1d2889b6b79118a9f (diff)
downloadserenity-1fe2cca439d7b1481c5744c3f4b8022e5e59fa1f.zip
LibHTML: Use LayoutText::text_for_rendering() in layout tree dumps
This way the fragment offsets make a lot more sense, since they assume whitespace has already been collapsed.
-rw-r--r--Libraries/LibHTML/Dump.cpp4
-rw-r--r--Libraries/LibHTML/Layout/LayoutText.h1
2 files changed, 3 insertions, 2 deletions
diff --git a/Libraries/LibHTML/Dump.cpp b/Libraries/LibHTML/Dump.cpp
index ab17073da0..0327783be5 100644
--- a/Libraries/LibHTML/Dump.cpp
+++ b/Libraries/LibHTML/Dump.cpp
@@ -119,8 +119,8 @@ void dump_tree(const LayoutNode& layout_node)
for (int i = 0; i < indent; ++i)
dbgprintf(" ");
auto& layout_text = static_cast<const LayoutText&>(fragment.layout_node());
- dbgprintf(" text: \"%s\"\n",
- String(Utf8View(layout_text.node().data()).substring_view(fragment.start(), fragment.length()).as_string()).characters());
+ auto fragment_text = layout_text.text_for_rendering().substring(fragment.start(), fragment.length());
+ dbgprintf(" text: \"%s\"\n", fragment_text.characters());
}
}
}
diff --git a/Libraries/LibHTML/Layout/LayoutText.h b/Libraries/LibHTML/Layout/LayoutText.h
index bae226c11a..312824682e 100644
--- a/Libraries/LibHTML/Layout/LayoutText.h
+++ b/Libraries/LibHTML/Layout/LayoutText.h
@@ -13,6 +13,7 @@ public:
const Text& node() const { return static_cast<const Text&>(*LayoutNode::node()); }
const String& text_for_style(const StyleProperties&) const;
+ const String& text_for_rendering() const { return m_text_for_rendering; }
virtual const char* class_name() const override { return "LayoutText"; }
virtual bool is_text() const final { return true; }