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,6 +1,6 @@
|
|||
use crate::{
|
||||
black, fill, point, px, size, Bounds, ElementContext, Hsla, LineLayout, Pixels, Point, Result,
|
||||
SharedString, StrikethroughStyle, UnderlineStyle, WrapBoundary, WrappedLineLayout,
|
||||
black, fill, point, px, size, Bounds, Hsla, LineLayout, Pixels, Point, Result, SharedString,
|
||||
StrikethroughStyle, UnderlineStyle, WindowContext, WrapBoundary, WrappedLineLayout,
|
||||
};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use smallvec::SmallVec;
|
||||
|
@ -48,7 +48,7 @@ impl ShapedLine {
|
|||
&self,
|
||||
origin: Point<Pixels>,
|
||||
line_height: Pixels,
|
||||
cx: &mut ElementContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> Result<()> {
|
||||
paint_line(
|
||||
origin,
|
||||
|
@ -86,7 +86,7 @@ impl WrappedLine {
|
|||
&self,
|
||||
origin: Point<Pixels>,
|
||||
line_height: Pixels,
|
||||
cx: &mut ElementContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> Result<()> {
|
||||
paint_line(
|
||||
origin,
|
||||
|
@ -107,7 +107,7 @@ fn paint_line(
|
|||
line_height: Pixels,
|
||||
decoration_runs: &[DecorationRun],
|
||||
wrap_boundaries: &[WrapBoundary],
|
||||
cx: &mut ElementContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> Result<()> {
|
||||
let line_bounds = Bounds::new(origin, size(layout.width, line_height));
|
||||
cx.paint_layer(line_bounds, |cx| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue