1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-19 02:07:36 +00:00

LibWeb: Remove hand-rolled is_foo() helpers in Layout::Node classes

This commit is contained in:
Andreas Kling 2021-01-01 18:55:47 +01:00
parent 3bb0cb2202
commit 07dd73c351
31 changed files with 39 additions and 82 deletions

View file

@ -29,6 +29,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/Text.h>
#include <LibWeb/Layout/InitialContainingBlockBox.h>
#include <LibWeb/Layout/TextNode.h>
#include <ctype.h>
#include <stdio.h>
@ -119,14 +120,14 @@ GUI::Variant LayoutTreeModel::data(const GUI::ModelIndex& index, GUI::ModelRole
{
auto& node = *static_cast<Layout::Node*>(index.internal_data());
if (role == GUI::ModelRole::Icon) {
if (node.is_initial_containing_block())
if (is<Layout::InitialContainingBlockBox>(node))
return m_document_icon;
if (node.is_text())
if (is<Layout::TextNode>(node))
return m_text_icon;
return m_element_icon;
}
if (role == GUI::ModelRole::Display) {
if (node.is_text())
if (is<Layout::TextNode>(node))
return String::format("TextNode: %s", with_whitespace_collapsed(downcast<Layout::TextNode>(node).text_for_rendering()).characters());
StringBuilder builder;
builder.append(node.class_name());