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
|
@ -1,4 +1,4 @@
|
|||
use crate::{AnyElement, Bounds, Element, ElementContext, IntoElement, LayoutId, Pixels};
|
||||
use crate::{AnyElement, Bounds, Element, IntoElement, LayoutId, Pixels, WindowContext};
|
||||
|
||||
/// Builds a `Deferred` element, which delays the layout and paint of its child.
|
||||
pub fn deferred(child: impl IntoElement) -> Deferred {
|
||||
|
@ -29,7 +29,7 @@ impl Element for Deferred {
|
|||
type RequestLayoutState = ();
|
||||
type PrepaintState = ();
|
||||
|
||||
fn request_layout(&mut self, cx: &mut ElementContext) -> (LayoutId, ()) {
|
||||
fn request_layout(&mut self, cx: &mut WindowContext) -> (LayoutId, ()) {
|
||||
let layout_id = self.child.as_mut().unwrap().request_layout(cx);
|
||||
(layout_id, ())
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ impl Element for Deferred {
|
|||
&mut self,
|
||||
_bounds: Bounds<Pixels>,
|
||||
_request_layout: &mut Self::RequestLayoutState,
|
||||
cx: &mut ElementContext,
|
||||
cx: &mut WindowContext,
|
||||
) {
|
||||
let child = self.child.take().unwrap();
|
||||
let element_offset = cx.element_offset();
|
||||
|
@ -50,7 +50,7 @@ impl Element for Deferred {
|
|||
_bounds: Bounds<Pixels>,
|
||||
_request_layout: &mut Self::RequestLayoutState,
|
||||
_prepaint: &mut Self::PrepaintState,
|
||||
_cx: &mut ElementContext,
|
||||
_cx: &mut WindowContext,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue