Merge ElementContext
into WindowContext
(#10979)
The new `ElementContext` was originally introduced to ensure the element APIs could only be used inside of elements. Unfortunately, there were many places where some of those APIs needed to be used, so `WindowContext::with_element_context` was introduced, which defeated the original safety purposes of having a specific context for elements. This pull request merges `ElementContext` into `WindowContext` and adds (debug) runtime checks to APIs that can only be used during certain phases of element drawing. Release Notes: - N/A --------- Co-authored-by: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
031580f4dc
commit
6a7761e620
29 changed files with 2378 additions and 2367 deletions
|
@ -91,7 +91,7 @@ impl<E: IntoElement + 'static> Element for AnimationElement<E> {
|
|||
|
||||
fn request_layout(
|
||||
&mut self,
|
||||
cx: &mut crate::ElementContext,
|
||||
cx: &mut crate::WindowContext,
|
||||
) -> (crate::LayoutId, Self::RequestLayoutState) {
|
||||
cx.with_element_state(Some(self.id.clone()), |state, cx| {
|
||||
let state = state.unwrap().unwrap_or_else(|| AnimationState {
|
||||
|
@ -138,7 +138,7 @@ impl<E: IntoElement + 'static> Element for AnimationElement<E> {
|
|||
&mut self,
|
||||
_bounds: crate::Bounds<crate::Pixels>,
|
||||
element: &mut Self::RequestLayoutState,
|
||||
cx: &mut crate::ElementContext,
|
||||
cx: &mut crate::WindowContext,
|
||||
) -> Self::PrepaintState {
|
||||
element.prepaint(cx);
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ impl<E: IntoElement + 'static> Element for AnimationElement<E> {
|
|||
_bounds: crate::Bounds<crate::Pixels>,
|
||||
element: &mut Self::RequestLayoutState,
|
||||
_: &mut Self::PrepaintState,
|
||||
cx: &mut crate::ElementContext,
|
||||
cx: &mut crate::WindowContext,
|
||||
) {
|
||||
element.paint(cx);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue