Retire some instanceOf usage.

More can be retired.  Eventually, I think I can eliminate
the poor-man's RTTI in `Identity::Class`.
This commit is contained in:
2025-08-09 05:44:53 -04:00
parent 6ec7e50758
commit 0bf153b049
2 changed files with 10 additions and 9 deletions

View File

@ -2523,9 +2523,9 @@ void Textblock::addWidget (core::Widget *widget, core::style::Style *style)
widget->setParent (this);
// TODO Replace (perhaps) later "textblock" by "OOF aware widget".
if (widget->instanceOf <Textblock>()) {
if (auto *const tb= dynamic_cast< Textblock * >( widget )) {
for (int i = 0; i < NUM_OOFM; i++)
searchOutOfFlowMgr(i)->addWidgetInFlow ((Textblock*)widget, this,
searchOutOfFlowMgr(i)->addWidgetInFlow (tb, this,
words->size ());
}
@ -2958,10 +2958,10 @@ void Textblock::handOverBreak (core::style::Style *style)
Widget *parent;
Line *lastLine = lines->getRef (lines->size () - 1);
if (lastLine->breakSpace != 0 && (parent = getParent()) &&
parent->instanceOf <Textblock>() &&
if (Textblock *textblock2;
lastLine->breakSpace != 0 && (parent = getParent()) &&
( textblock2= dynamic_cast< Textblock * >( parent ) ) &&
parent->getStyle()->display != core::style::DISPLAY_BLOCK) {
Textblock *textblock2 = (Textblock*) parent;
textblock2->addParbreak(lastLine->breakSpace, style);
}
}
@ -3291,11 +3291,12 @@ RegardingBorder *Textblock::getWidgetRegardingBorderForLine (int firstWord,
if (word->content.type == core::Content::WIDGET_IN_FLOW) {
Widget *widget = word->content.widget;
if (widget->instanceOf <RegardingBorder>() &&
if (auto *const rb= dynamic_cast< RegardingBorder * >( widget );
rb &&
// Exclude cases where a textblock constitutes a new floats
// container.
!isOOFContainer (widget, OOFM_FLOATS))
widgetRegardingBorder = (RegardingBorder*)widget;
widgetRegardingBorder = rb;
}
}

View File

@ -798,8 +798,8 @@ bool DilloHtml::HtmlLinkReceiver::click (Widget *widget, int link, int img,
/* Change the link color to "visited" as visual feedback */
for (Widget *w = widget; w; w = w->getParent()) {
_MSG(" ->%s\n", w->getClassName());
if (w->instanceOf<dw::Textblock>()) {
((Textblock*)w)->changeLinkColor (link, html->visited_color);
if (auto *tb= dynamic_cast< Textblock *>( w )) {
tb->changeLinkColor (link, html->visited_color);
break;
}
}