mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-23 23:09:42 +00:00
Reuse layout for view's element when it wasn't cached (#4156)
Refs https://github.com/zed-industries/zed/pull/4131 Refs https://github.com/zed-industries/community/issues/2415 Previously, when a view cache miss occurred during paint, we would either use the element produced during layout or create a new, detached node layout node. In both cases, we would issue a call to `draw`. The problem with this approach, however, is that `draw` would always paint the element at the given `bounds.origin`, which was required when the layout node was detached but harmful when the element was already embedded in the layout tree and already knew its bounds. In this second case, in fact, it was as if we were positioning the element "twice", which caused content to jump. Release Notes: - N/A
This commit is contained in:
commit
90c2da4dec
1 changed files with 6 additions and 2 deletions
|
@ -321,8 +321,12 @@ impl Element for AnyView {
|
|||
}
|
||||
}
|
||||
|
||||
let mut element = (self.request_layout)(self, cx).1;
|
||||
element.draw(bounds.origin, bounds.size.into(), cx);
|
||||
if let Some(mut element) = state.element.take() {
|
||||
element.paint(cx);
|
||||
} else {
|
||||
let mut element = (self.request_layout)(self, cx).1;
|
||||
element.draw(bounds.origin, bounds.size.into(), cx);
|
||||
}
|
||||
|
||||
state.cache_key = Some(ViewCacheKey {
|
||||
bounds,
|
||||
|
|
Loading…
Reference in a new issue