mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 14:27:35 +00:00
LibWeb: Implement the ::marker pseudo-element
This matches the marker boxes of list-items.
This commit is contained in:
parent
8411ff3f14
commit
817cd13d59
6 changed files with 10 additions and 3 deletions
|
@ -504,6 +504,8 @@ Result<Selector::SimpleSelector, Parser::ParsingResult> Parser::parse_simple_sel
|
||||||
simple_selector.pseudo_element = Selector::PseudoElement::FirstLetter;
|
simple_selector.pseudo_element = Selector::PseudoElement::FirstLetter;
|
||||||
} else if (pseudo_name.equals_ignoring_case("first-line")) {
|
} else if (pseudo_name.equals_ignoring_case("first-line")) {
|
||||||
simple_selector.pseudo_element = Selector::PseudoElement::FirstLine;
|
simple_selector.pseudo_element = Selector::PseudoElement::FirstLine;
|
||||||
|
} else if (pseudo_name.equals_ignoring_case("marker")) {
|
||||||
|
simple_selector.pseudo_element = Selector::PseudoElement::Marker;
|
||||||
} else {
|
} else {
|
||||||
dbgln_if(CSS_PARSER_DEBUG, "Unrecognized pseudo-element: '::{}'", pseudo_name);
|
dbgln_if(CSS_PARSER_DEBUG, "Unrecognized pseudo-element: '::{}'", pseudo_name);
|
||||||
return ParsingResult::SyntaxError;
|
return ParsingResult::SyntaxError;
|
||||||
|
|
|
@ -272,6 +272,8 @@ constexpr StringView pseudo_element_name(Selector::PseudoElement pseudo_element)
|
||||||
return "first-line"sv;
|
return "first-line"sv;
|
||||||
case Selector::PseudoElement::FirstLetter:
|
case Selector::PseudoElement::FirstLetter:
|
||||||
return "first-letter"sv;
|
return "first-letter"sv;
|
||||||
|
case Selector::PseudoElement::Marker:
|
||||||
|
return "marker"sv;
|
||||||
case Selector::PseudoElement::None:
|
case Selector::PseudoElement::None:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
After,
|
After,
|
||||||
FirstLine,
|
FirstLine,
|
||||||
FirstLetter,
|
FirstLetter,
|
||||||
|
Marker,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SimpleSelector {
|
struct SimpleSelector {
|
||||||
|
|
|
@ -453,6 +453,9 @@ void dump_selector(StringBuilder& builder, CSS::Selector const& selector)
|
||||||
case CSS::Selector::PseudoElement::FirstLetter:
|
case CSS::Selector::PseudoElement::FirstLetter:
|
||||||
pseudo_element_description = "first-letter";
|
pseudo_element_description = "first-letter";
|
||||||
break;
|
break;
|
||||||
|
case CSS::Selector::PseudoElement::Marker:
|
||||||
|
pseudo_element_description = "marker";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.appendff(" pseudo_element={}", pseudo_element_description);
|
builder.appendff(" pseudo_element={}", pseudo_element_description);
|
||||||
|
|
|
@ -66,8 +66,7 @@ void ListItemMarkerBox::paint(PaintContext& context, PaintPhase phase)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: It would be nicer to not have to go via the parent here to get our inherited style.
|
auto color = computed_values().color();
|
||||||
auto color = parent()->computed_values().color();
|
|
||||||
|
|
||||||
int marker_width = (int)enclosing.height() / 2;
|
int marker_width = (int)enclosing.height() / 2;
|
||||||
Gfx::IntRect marker_rect { 0, 0, marker_width, marker_width };
|
Gfx::IntRect marker_rect { 0, 0, marker_width, marker_width };
|
||||||
|
|
|
@ -202,7 +202,7 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context&
|
||||||
|
|
||||||
if (is<ListItemBox>(*layout_node)) {
|
if (is<ListItemBox>(*layout_node)) {
|
||||||
int child_index = layout_node->parent()->index_of_child<ListItemBox>(*layout_node).value();
|
int child_index = layout_node->parent()->index_of_child<ListItemBox>(*layout_node).value();
|
||||||
auto marker_style = static_cast<DOM::Element const&>(dom_node).specified_css_values();
|
auto marker_style = style_computer.compute_style(static_cast<DOM::Element&>(dom_node), CSS::Selector::PseudoElement::Marker);
|
||||||
auto list_item_marker = adopt_ref(*new ListItemMarkerBox(document, layout_node->computed_values().list_style_type(), child_index + 1, *marker_style));
|
auto list_item_marker = adopt_ref(*new ListItemMarkerBox(document, layout_node->computed_values().list_style_type(), child_index + 1, *marker_style));
|
||||||
if (layout_node->first_child())
|
if (layout_node->first_child())
|
||||||
list_item_marker->set_inline(layout_node->first_child()->is_inline());
|
list_item_marker->set_inline(layout_node->first_child()->is_inline());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue