LibWeb: Avoid some layouts in getComputedStyle() property getter
For CSS properties that are known to not affect layout, we can avoid doing a layout before returning their current resolved value. It should be enough to only update style for the target element here, but we don't currently have a mechanism for that.
This commit is contained in:
parent
0998074230
commit
d7492927e9
Notes:
sideshowbarker
2024-07-17 17:01:32 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d7492927e9
1 changed files with 6 additions and 2 deletions
|
@ -768,8 +768,12 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
|
|||
|
||||
Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID property_id) const
|
||||
{
|
||||
// FIXME: Only update layout if required to resolve the property we're accessing.
|
||||
const_cast<DOM::Document&>(m_element->document()).update_layout();
|
||||
if (CSS::property_affects_layout(property_id)) {
|
||||
const_cast<DOM::Document&>(m_element->document()).update_layout();
|
||||
} else {
|
||||
// FIXME: If we had a way to update style for a single element, this would be a good place to use it.
|
||||
const_cast<DOM::Document&>(m_element->document()).update_style();
|
||||
}
|
||||
|
||||
if (!m_element->layout_node()) {
|
||||
auto style = m_element->document().style_computer().compute_style(const_cast<DOM::Element&>(*m_element));
|
||||
|
|
Loading…
Add table
Reference in a new issue