LibWeb: Dump layout node style properties in alphabetical order

This commit is contained in:
Andreas Kling 2020-06-14 18:47:21 +02:00
parent 332c471301
commit 2b47ba6c3f
Notes: sideshowbarker 2024-07-19 05:39:01 +09:00

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/QuickSort.h>
#include <AK/StringBuilder.h>
#include <AK/Utf8View.h>
#include <LibWeb/CSS/PropertyID.h>
@ -180,11 +181,21 @@ void dump_tree(const LayoutNode& layout_node)
}
}
struct NameAndValue {
String name;
String value;
};
Vector<NameAndValue> properties;
layout_node.style().for_each_property([&](auto property_id, auto& value) {
properties.append({ CSS::string_from_property_id(property_id), value.to_string() });
});
quick_sort(properties, [](auto& a, auto& b) { return a.name < b.name; });
for (auto& property : properties) {
for (size_t i = 0; i < indent; ++i)
dbgprintf(" ");
dbgprintf(" (%s: %s)\n", CSS::string_from_property_id(property_id), value.to_string().characters());
});
dbgprintf(" (%s: %s)\n", property.name.characters(), property.value.characters());
}
++indent;
layout_node.for_each_child([](auto& child) {