Skip to content

Simply restyle damage macros (and convert them to be plain functions) - #222

Merged
Loirooriol merged 2 commits into
servo:mainfrom
nicoburns:simplify-restyle-damage-macros
Aug 7, 2025
Merged

Simply restyle damage macros (and convert them to be plain functions)#222
Loirooriol merged 2 commits into
servo:mainfrom
nicoburns:simplify-restyle-damage-macros

Conversation

@nicoburns

@nicoburns nicoburns commented Aug 4, 2025

Copy link
Copy Markdown
Collaborator

Changes made:

  • Convert restyle_damage_* macros to plain functions.
  • Rather than passing the damage object, a RestyleDamage flag to apply, and an optional extra condition, we make the return a boolean and handle the rest in regular code.
  • Use if-else instead of || for short-circuiting.

Servo PR servo/servo#38465

@nicoburns
nicoburns force-pushed the simplify-restyle-damage-macros branch from 5737647 to 9101e5a Compare August 4, 2025 16:04
@nicoburns
nicoburns force-pushed the simplify-restyle-damage-macros branch from a95f8a9 to 8a31d6b Compare August 4, 2025 19:08
@nicoburns nicoburns changed the title Simplify restyle damage macros Simply restyle damage macros (and convert them to be plain functions) Aug 4, 2025
Comment thread style/servo/restyle_damage.rs Outdated
@nicoburns
nicoburns force-pushed the simplify-restyle-damage-macros branch from 8a31d6b to 6cef25f Compare August 4, 2025 19:34
Comment thread style/servo/restyle_damage.rs Outdated
Signed-off-by: Nico Burns <nico@nicoburns.com>
@nicoburns
nicoburns force-pushed the simplify-restyle-damage-macros branch from 6cef25f to 5079b1d Compare August 5, 2025 12:52
Comment thread style/servo/restyle_damage.rs
Signed-off-by: Nico Burns <nico@nicoburns.com>
@Loirooriol
Loirooriol added this pull request to the merge queue Aug 7, 2025
Merged via the queue into servo:main with commit 092e34b Aug 7, 2025
10 checks passed
github-merge-queue Bot pushed a commit to servo/servo that referenced this pull request Aug 7, 2025
Servo PR for servo/stylo#222

Fixes: #38506
Testing: adding new tests

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
});
}
pub(crate) fn restyle_damage_${effect_name} (old: &ComputedValues, new: &ComputedValues) -> bool {
% for style_struct in data.active_style_structs():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW you really want to check arc::ptr_eq(old.get_${style_struct}(), new${style_struct}()) or so to avoid most of these comparisons. That's equivalent to what gecko does in CalcStyleDifference: https://searchfox.org/mozilla-central/rev/f6a806c38c459e0e0d797d264ca0e8ad46005105/layout/style/ComputedStyle.cpp#133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants