diff options
author | Andreas Kling <kling@serenityos.org> | 2022-10-06 15:33:09 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-10-06 16:25:26 +0200 |
commit | 49eb32453552db668b2fe008ceea0b87ea7c4948 (patch) | |
tree | 578d721da962ee365b5bb71d1c90e5c35ef3d0fb | |
parent | 277465e69974cb8d73030fd155463d1cc5ef00bc (diff) | |
download | serenity-49eb32453552db668b2fe008ceea0b87ea7c4948.zip |
LibWeb: Add Layout::Node::display()
This will return something sensible for style-less nodes as well.
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/Node.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/Node.h | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 7d89ca0feb..1d9da526d7 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -579,6 +579,16 @@ String Node::debug_description() const return builder.to_string(); } +CSS::Display Node::display() const +{ + if (!has_style()) { + // NOTE: No style means this is dumb text content. + return CSS::Display(CSS::Display::Outside::Inline, CSS::Display::Inside::Flow); + } + + return computed_values().display(); +} + bool Node::is_inline() const { if (!has_style()) { diff --git a/Userland/Libraries/LibWeb/Layout/Node.h b/Userland/Libraries/LibWeb/Layout/Node.h index da476acf81..3a7b9db406 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.h +++ b/Userland/Libraries/LibWeb/Layout/Node.h @@ -68,6 +68,8 @@ public: virtual bool can_have_children() const { return true; } + CSS::Display display() const; + bool is_inline() const; bool is_inline_block() const; |