We've had a recurring problem of widget methods not having access to specific state that would be useful. For example, it'd be nice to have access to the LayoutDom in Widget::event.
One good solution would be to refactor all of these methods to take a context type specific to the method: LayoutContext, PaintContext, and EventContext, which can hold references to the DOM, Layout DOM, Paint DOM, and more. This helps with the mutability concerns we had before and is also a convenient place to put methods that only make sense in these contexts.
We've had a recurring problem of widget methods not having access to specific state that would be useful. For example, it'd be nice to have access to the
LayoutDom
inWidget::event
.One good solution would be to refactor all of these methods to take a context type specific to the method:
LayoutContext
,PaintContext
, andEventContext
, which can hold references to the DOM, Layout DOM, Paint DOM, and more. This helps with the mutability concerns we had before and is also a convenient place to put methods that only make sense in these contexts.