mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Better CSS inheritance for nodes that represent a pseudo-element
When we compute style for elements inside a UA-internal shadow tree that represent a pseudo-element (e.g ::placeholder), we actually run the StyleComputer machinery for (host element :: pseudo-element). While that lets us match the correct selectors, it was incorrectly applying CSS inheritance, since we'd also then inherit from whatever was above the host element in the tree. This patch fixes the issue by introducing an inheritance override in AbstractElement and then using that to force inheritance from whatever is actually directly above in the DOM for these elements instead of jumping all the way up past the host. This fixes an issue where `text-align: center` on input type=text elements would render the main text centered but placeholder text was still left-aligned.
This commit is contained in:
parent
9e064bd3ff
commit
d17f666a8c
Notes:
github-actions[bot]
2025-10-21 14:43:14 +00:00
Author: https://github.com/awesomekling
Commit: d17f666a8c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6519
Reviewed-by: https://github.com/AtkinsSJ
8 changed files with 79 additions and 39 deletions
|
|
@ -35,6 +35,8 @@ public:
|
|||
Optional<AbstractElement> previous_sibling_in_tree_order() { return walk_layout_tree(WalkMethod::PreviousSibling); }
|
||||
bool is_before(AbstractElement const&) const;
|
||||
|
||||
void set_inheritance_override(GC::Ref<Element> element) { m_inheritance_override = element; }
|
||||
|
||||
GC::Ptr<CSS::ComputedProperties const> computed_properties() const;
|
||||
|
||||
void set_custom_properties(OrderedHashMap<FlyString, CSS::StyleProperty>&& custom_properties);
|
||||
|
|
@ -63,6 +65,8 @@ private:
|
|||
|
||||
GC::Ref<Element> m_element;
|
||||
Optional<CSS::PseudoElement> m_pseudo_element;
|
||||
|
||||
GC::Ptr<Element> m_inheritance_override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue