Check for type variations in inherited themes #82218
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #82199.
As I added theme contexts in #81130, I also reworked some code that looked up theme type variation chains. I noticed a gap in logic and decided to fix it. The issue that I'd noticed caused us to accept type variations even if we couldn't resolve them to a native type. I found it problematic, as that could mean that we would never inherit proper theme properties that match the control's type because the type chain would just end abruptly (or go into an unexpected direction).
So I fixed it, but as it turns out there was a benefit from the old approach. We only ever checked variations in global themes, and that was still true after my fix. But because previously we would allow variations which we could not resolve to native types, variations added by themes owned by controls would accidentally function correctly.
So this PR adds proper support for these type variations. Now all inherited themes are checked before the global themes are, just like with the theme items themselves. This may make things a bit slower than before, but unless themes are abused it shouldn't cause any noticeable issues.
Note, that a type variation must completely resolve to a native type within one single theme. You cannot extend type variations from another theme at this time. In most cases this should be fine though. Supporting something more complex would be way more expensive, so I'd rather stop here and live with this limitation.