Skip to content

Commit

Permalink
Remove useless branches and fix order of invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
albyrock87 committed Sep 16, 2024
1 parent 4ed03d6 commit 6150cba
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/Controls/src/Core/VisualElement/VisualElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1378,20 +1378,11 @@ internal virtual void InvalidateMeasureInternal(InvalidationTrigger trigger)
return;
}

// When handler is set `RendererReady` is triggered to immediately invalidate native view
// Short-circuiting here to avoid unnecessary checks
if (trigger == InvalidationTrigger.RendererReady)
{
InvalidateMeasureCacheInternal();
((IView)this).InvalidateMeasure();
InvokeMeasureInvalidated(trigger);
return;
}

// We can ignore the request if we are either fully constrained or when the size request changes, and we were already fully constrained
// We skip invalidation if we are either fully constrained or when the size request changes, and we were already fully constrained
if ((trigger == InvalidationTrigger.MeasureChanged && Constraint == LayoutConstraint.Fixed) ||
(trigger == InvalidationTrigger.SizeRequestChanged && ComputedConstraint == LayoutConstraint.Fixed))
{
InvokeMeasureInvalidated(trigger);
return;
}

Expand All @@ -1402,15 +1393,15 @@ internal virtual void InvalidateMeasureInternal(InvalidationTrigger trigger)
{
parentElement.ComputeConstraintForView(thisView);
}
ParentView?.InvalidateMeasure();
InvokeMeasureInvalidated(trigger);
ParentView?.InvalidateMeasure();
return;
}

if (trigger == InvalidationTrigger.MarginChanged)
{
ParentView?.InvalidateMeasure();
InvokeMeasureInvalidated(trigger);
ParentView?.InvalidateMeasure();
return;
}

Expand Down

0 comments on commit 6150cba

Please sign in to comment.