mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:08:10 +00:00
LibWeb: Track quote-nesting level while building the layout tree
This makes multiple levels of quote actually use different quotation marks, instead of always the first available pair of them. Each Layout::Node remembers what the quote-nesting level was before its content was evaluated, so that we can re-use this number in `apply_style()`. This is a bit hacky, since we end up converting the `content` value into a string twice. `StyleProperties::content()` now takes an initial quote-nesting level, and returns the final level after that content.
This commit is contained in:
parent
493dd5d93c
commit
9e99368694
8 changed files with 372 additions and 14 deletions
|
@ -181,7 +181,9 @@ ErrorOr<void> TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element
|
|||
if (!pseudo_element_style)
|
||||
return {};
|
||||
|
||||
auto pseudo_element_content = pseudo_element_style->content();
|
||||
auto initial_quote_nesting_level = m_quote_nesting_level;
|
||||
auto [pseudo_element_content, final_quote_nesting_level] = pseudo_element_style->content(initial_quote_nesting_level);
|
||||
m_quote_nesting_level = final_quote_nesting_level;
|
||||
auto pseudo_element_display = pseudo_element_style->display();
|
||||
// ::before and ::after only exist if they have content. `content: normal` computes to `none` for them.
|
||||
// We also don't create them if they are `display: none`.
|
||||
|
@ -204,6 +206,7 @@ ErrorOr<void> TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element
|
|||
}
|
||||
|
||||
pseudo_element_node->set_generated_for(generated_for, element);
|
||||
pseudo_element_node->set_initial_quote_nesting_level(initial_quote_nesting_level);
|
||||
|
||||
// FIXME: Handle images, and multiple values
|
||||
if (pseudo_element_content.type == CSS::ContentData::Type::String) {
|
||||
|
@ -452,6 +455,7 @@ JS::GCPtr<Layout::Node> TreeBuilder::build(DOM::Node& dom_node)
|
|||
VERIFY(dom_node.is_document());
|
||||
|
||||
Context context;
|
||||
m_quote_nesting_level = 0;
|
||||
MUST(create_layout_tree(dom_node, context)); // FIXME propagate errors
|
||||
|
||||
if (auto* root = dom_node.document().layout_node())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue