-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor style apply #9411
Refactor style apply #9411
Conversation
You can test this PR using the following package version. |
You can test this PR using the following package version. |
980560f
to
c691305
Compare
You can test this PR using the following package version. |
c691305
to
f1d0b64
Compare
Now tries to simulate an application with a lot of styles applied at different points in the logical tree. Make `StyledElement.ApplyStyling` a public API in order to do this.
- Removes the `IStyler` service and the `Styler` implementation - Moves the logic for applying styles and control themes into `StyledElement` - Removes the style `TryAttach` method from the public API - Removes style caching for now - this will need to be added back
f1d0b64
to
086c2c7
Compare
You can test this PR using the following package version. |
What does the pull request do?
Refactors how we attach styles:
IStyler
service and theStyler
implementationStyler
intoStyledElement
TryAttach
method from the public APIAlso adds a fix for #8549:
TopLevel
constructor. This isn't a good idea for a number of reasons, one of which is demonstrated by Window gets :is(Control) style applied twice #8549StyledElement.ApplyStyling
manually, e.g. in unit tests.Performance Regression
This PR removes style caching for now. This will need to be added back in future, but:
Style
/Styles
objects wasn't very efficient. We'll need to implement something better, that also helps speed up applying control themesI modified a benchmark in this PR to test this; it adds a lot of styles for various controls in a nested tree and instantiates and styles a single
TextBox
:Before:
After:
So we have a pretty serious performance regression in the worst case, though this only affects applications with a lot of styles. For typical applications which use mostly control themes it shouldn't be noticeable.
I don't want to address this in this PR as it's a separate feature, but will open a PR to add back style caching using a new method in the near future, which should improve things beyond what we had before.
Depends on #8600
Fixes #8549