Remove a complex instanceOf usage.

The condition chain here is rather baroque, so I'm making
this its own commit for `git bisect` purposes.
This commit is contained in:
2025-08-09 05:54:51 -04:00
parent eda33f5097
commit 31531b6cba

View File

@ -129,12 +129,16 @@ bool OOFAwareWidget::isOOFContainer (Widget *widget, int oofmIndex)
// TODO The methods isPossibleContainer() and isPossibleContainerParent()
// are only used in few cases. Does not matter currently, however.
// This was created to cleanup the `instanceOf` calls in the
// complex conditionals, below. It relies upon certain
// sequence point and ordering rules of short-circuit evaluation.
OOFAwareWidget *oaw;
switch (oofmIndex) {
case OOFM_FLOATS:
return widget->instanceOf <OOFAwareWidget>() &&
return (oaw= dynamic_cast< OOFAwareWidget *>( widget )) &&
(// For floats, only some OOF aware widgets are considered as
// containers.
((OOFAwareWidget*)widget)->isPossibleOOFContainer (OOFM_FLOATS) &&
oaw->isPossibleOOFContainer (OOFM_FLOATS) &&
// The second condition: that this block is "out of flow", in a
// wider sense.
(// The toplevel widget is "out of flow", since there is no
@ -145,9 +149,8 @@ bool OOFAwareWidget::isOOFContainer (Widget *widget, int oofmIndex)
// is also a text block, so possible float container)
// within a table widget, which is not a suitable float
// container parent).
!(widget->getParent()->instanceOf <OOFAwareWidget>() &&
((OOFAwareWidget*)widget->getParent())
->isPossibleOOFContainerParent (OOFM_FLOATS)) ||
!((oaw= dynamic_cast <OOFAwareWidget * >( widget->getParent() )) &&
oaw->isPossibleOOFContainerParent (OOFM_FLOATS)) ||
// Inline blocks are containing blocks, too.
widget->getStyle()->display == DISPLAY_INLINE_BLOCK ||
// Same for blocks with 'overview' set to another value than
@ -163,7 +166,7 @@ bool OOFAwareWidget::isOOFContainer (Widget *widget, int oofmIndex)
case OOFM_RELATIVE:
case OOFM_ABSOLUTE:
return widget->instanceOf <OOFAwareWidget>() &&
return dynamic_cast< OOFAwareWidget * >( widget ) &&
(widget->getParent() == NULL ||
OOFAwareWidget::testWidgetPositioned (widget));