instanceOf
now uses RTTI and checks its answer.
Some checks failed
CI / ubuntu-latest-html-tests (push) Has been cancelled
CI / ubuntu-latest-no-tls (push) Has been cancelled
CI / ubuntu-latest-mbedtls2 (push) Has been cancelled
CI / ubuntu-latest-openssl-3 (push) Has been cancelled
CI / ubuntu-latest-with-old-std (push) Has been cancelled
CI / ubuntu-20-04-openssl-1-1 (push) Has been cancelled
CI / alpine-mbedtls-3_6_0 (push) Has been cancelled
CI / macOS-13-openssl-1-1 (push) Has been cancelled
CI / macOS-13-openssl-3 (push) Has been cancelled
CI / freebsd-14-openssl-3 (push) Has been cancelled
CI / windows-mbedtls (push) Has been cancelled
Some checks failed
CI / ubuntu-latest-html-tests (push) Has been cancelled
CI / ubuntu-latest-no-tls (push) Has been cancelled
CI / ubuntu-latest-mbedtls2 (push) Has been cancelled
CI / ubuntu-latest-openssl-3 (push) Has been cancelled
CI / ubuntu-latest-with-old-std (push) Has been cancelled
CI / ubuntu-20-04-openssl-1-1 (push) Has been cancelled
CI / alpine-mbedtls-3_6_0 (push) Has been cancelled
CI / macOS-13-openssl-1-1 (push) Has been cancelled
CI / macOS-13-openssl-3 (push) Has been cancelled
CI / freebsd-14-openssl-3 (push) Has been cancelled
CI / windows-mbedtls (push) Has been cancelled
Next I'll just remove it, but this commit lets me have something in history such that I can fall back to check for bugs that might get introduced.
This commit is contained in:
@ -131,7 +131,7 @@ bool OOFAwareWidget::isOOFContainer (Widget *widget, int oofmIndex)
|
|||||||
|
|
||||||
switch (oofmIndex) {
|
switch (oofmIndex) {
|
||||||
case OOFM_FLOATS:
|
case OOFM_FLOATS:
|
||||||
return widget->instanceOf (OOFAwareWidget::CLASS_ID) &&
|
return widget->instanceOf <OOFAwareWidget>() &&
|
||||||
(// For floats, only some OOF aware widgets are considered as
|
(// For floats, only some OOF aware widgets are considered as
|
||||||
// containers.
|
// containers.
|
||||||
((OOFAwareWidget*)widget)->isPossibleOOFContainer (OOFM_FLOATS) &&
|
((OOFAwareWidget*)widget)->isPossibleOOFContainer (OOFM_FLOATS) &&
|
||||||
@ -145,7 +145,7 @@ bool OOFAwareWidget::isOOFContainer (Widget *widget, int oofmIndex)
|
|||||||
// is also a text block, so possible float container)
|
// is also a text block, so possible float container)
|
||||||
// within a table widget, which is not a suitable float
|
// within a table widget, which is not a suitable float
|
||||||
// container parent).
|
// container parent).
|
||||||
!(widget->getParent()->instanceOf (OOFAwareWidget::CLASS_ID) &&
|
!(widget->getParent()->instanceOf <OOFAwareWidget>() &&
|
||||||
((OOFAwareWidget*)widget->getParent())
|
((OOFAwareWidget*)widget->getParent())
|
||||||
->isPossibleOOFContainerParent (OOFM_FLOATS)) ||
|
->isPossibleOOFContainerParent (OOFM_FLOATS)) ||
|
||||||
// Inline blocks are containing blocks, too.
|
// Inline blocks are containing blocks, too.
|
||||||
@ -163,7 +163,7 @@ bool OOFAwareWidget::isOOFContainer (Widget *widget, int oofmIndex)
|
|||||||
|
|
||||||
case OOFM_RELATIVE:
|
case OOFM_RELATIVE:
|
||||||
case OOFM_ABSOLUTE:
|
case OOFM_ABSOLUTE:
|
||||||
return widget->instanceOf (OOFAwareWidget::CLASS_ID) &&
|
return widget->instanceOf <OOFAwareWidget>() &&
|
||||||
(widget->getParent() == NULL ||
|
(widget->getParent() == NULL ||
|
||||||
OOFAwareWidget::testWidgetPositioned (widget));
|
OOFAwareWidget::testWidgetPositioned (widget));
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ void OOFAwareWidget::notifySetParent ()
|
|||||||
widget != NULL && oofContainer[oofmIndex] == NULL;
|
widget != NULL && oofContainer[oofmIndex] == NULL;
|
||||||
widget = widget->getParent ())
|
widget = widget->getParent ())
|
||||||
if (isOOFContainer (widget, oofmIndex)) {
|
if (isOOFContainer (widget, oofmIndex)) {
|
||||||
assert (widget->instanceOf (OOFAwareWidget::CLASS_ID));
|
assert (widget->instanceOf <OOFAwareWidget>());
|
||||||
oofContainer[oofmIndex] = (OOFAwareWidget*)widget;
|
oofContainer[oofmIndex] = (OOFAwareWidget*)widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ void OOFPosRelMgr::calcWidgetRefSize (Widget *widget, Requisition *size)
|
|||||||
// (Notice also that Widget::sizeRequest has to be called in all
|
// (Notice also that Widget::sizeRequest has to be called in all
|
||||||
// cases.)
|
// cases.)
|
||||||
|
|
||||||
if (widget->instanceOf (OOFAwareWidget::CLASS_ID))
|
if (widget->instanceOf <OOFAwareWidget>())
|
||||||
*size = *((OOFAwareWidget*)widget)->getRequisitionWithoutOOF ();
|
*size = *((OOFAwareWidget*)widget)->getRequisitionWithoutOOF ();
|
||||||
|
|
||||||
|
|
||||||
|
@ -607,7 +607,7 @@ AlignedTableCell *Table::getCellRef ()
|
|||||||
int n = curCol + row * numCols;
|
int n = curCol + row * numCols;
|
||||||
if (childDefined (n)) {
|
if (childDefined (n)) {
|
||||||
child = children->get(n)->cell.widget;
|
child = children->get(n)->cell.widget;
|
||||||
if (child->instanceOf (AlignedTableCell::CLASS_ID))
|
if (child->instanceOf <AlignedTableCell>())
|
||||||
return (AlignedTableCell*)child;
|
return (AlignedTableCell*)child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2523,7 +2523,7 @@ void Textblock::addWidget (core::Widget *widget, core::style::Style *style)
|
|||||||
widget->setParent (this);
|
widget->setParent (this);
|
||||||
|
|
||||||
// TODO Replace (perhaps) later "textblock" by "OOF aware widget".
|
// TODO Replace (perhaps) later "textblock" by "OOF aware widget".
|
||||||
if (widget->instanceOf (Textblock::CLASS_ID)) {
|
if (widget->instanceOf <Textblock>()) {
|
||||||
for (int i = 0; i < NUM_OOFM; i++)
|
for (int i = 0; i < NUM_OOFM; i++)
|
||||||
searchOutOfFlowMgr(i)->addWidgetInFlow ((Textblock*)widget, this,
|
searchOutOfFlowMgr(i)->addWidgetInFlow ((Textblock*)widget, this,
|
||||||
words->size ());
|
words->size ());
|
||||||
@ -2765,7 +2765,7 @@ void Textblock::addParbreak (int space, core::style::Style *style)
|
|||||||
consider normal flow, no floats etc.) */
|
consider normal flow, no floats etc.) */
|
||||||
for (Widget *widget = this;
|
for (Widget *widget = this;
|
||||||
widget->getParent() != NULL &&
|
widget->getParent() != NULL &&
|
||||||
widget->getParent()->instanceOf (Textblock::CLASS_ID) &&
|
widget->getParent()->instanceOf <Textblock>() &&
|
||||||
!isWidgetOOF (widget);
|
!isWidgetOOF (widget);
|
||||||
widget = widget->getParent ()) {
|
widget = widget->getParent ()) {
|
||||||
Textblock *textblock2 = (Textblock*)widget->getParent ();
|
Textblock *textblock2 = (Textblock*)widget->getParent ();
|
||||||
@ -2959,7 +2959,7 @@ void Textblock::handOverBreak (core::style::Style *style)
|
|||||||
Line *lastLine = lines->getRef (lines->size () - 1);
|
Line *lastLine = lines->getRef (lines->size () - 1);
|
||||||
|
|
||||||
if (lastLine->breakSpace != 0 && (parent = getParent()) &&
|
if (lastLine->breakSpace != 0 && (parent = getParent()) &&
|
||||||
parent->instanceOf (Textblock::CLASS_ID) &&
|
parent->instanceOf <Textblock>() &&
|
||||||
parent->getStyle()->display != core::style::DISPLAY_BLOCK) {
|
parent->getStyle()->display != core::style::DISPLAY_BLOCK) {
|
||||||
Textblock *textblock2 = (Textblock*) parent;
|
Textblock *textblock2 = (Textblock*) parent;
|
||||||
textblock2->addParbreak(lastLine->breakSpace, style);
|
textblock2->addParbreak(lastLine->breakSpace, style);
|
||||||
@ -3193,7 +3193,7 @@ int Textblock::getGeneratorWidth ()
|
|||||||
// We only examine instances of dw::Textblock, since they are relevant
|
// We only examine instances of dw::Textblock, since they are relevant
|
||||||
// for floats, for which this method is only called.
|
// for floats, for which this method is only called.
|
||||||
if(word->content.type == core::Content::WIDGET_IN_FLOW &&
|
if(word->content.type == core::Content::WIDGET_IN_FLOW &&
|
||||||
word->content.widget->instanceOf(Textblock::CLASS_ID)) {
|
word->content.widget->instanceOf<Textblock>()) {
|
||||||
Textblock *tbChild = (Textblock*)word->content.widget;
|
Textblock *tbChild = (Textblock*)word->content.widget;
|
||||||
if(tbChild->findSizeRequestReference(this, &xRel, NULL))
|
if(tbChild->findSizeRequestReference(this, &xRel, NULL))
|
||||||
wChild = max(wChild, xRel + tbChild->getGeneratorWidth());
|
wChild = max(wChild, xRel + tbChild->getGeneratorWidth());
|
||||||
@ -3291,7 +3291,7 @@ RegardingBorder *Textblock::getWidgetRegardingBorderForLine (int firstWord,
|
|||||||
|
|
||||||
if (word->content.type == core::Content::WIDGET_IN_FLOW) {
|
if (word->content.type == core::Content::WIDGET_IN_FLOW) {
|
||||||
Widget *widget = word->content.widget;
|
Widget *widget = word->content.widget;
|
||||||
if (widget->instanceOf (RegardingBorder::CLASS_ID) &&
|
if (widget->instanceOf <RegardingBorder>() &&
|
||||||
// Exclude cases where a textblock constitutes a new floats
|
// Exclude cases where a textblock constitutes a new floats
|
||||||
// container.
|
// container.
|
||||||
!isOOFContainer (widget, OOFM_FLOATS))
|
!isOOFContainer (widget, OOFM_FLOATS))
|
||||||
|
@ -99,7 +99,7 @@ void IdentifiableObject::registerName (const char *className, const std::type_in
|
|||||||
* \brief Returns, whether this class is an instance of the class, given by
|
* \brief Returns, whether this class is an instance of the class, given by
|
||||||
* \em otherClassId, or of a sub class of this class.
|
* \em otherClassId, or of a sub class of this class.
|
||||||
*/
|
*/
|
||||||
bool IdentifiableObject::instanceOf (std::intptr_t otherClassId)
|
bool IdentifiableObject::instanceOf_impl (std::intptr_t otherClassId)
|
||||||
{
|
{
|
||||||
if (otherClassId == -1)
|
if (otherClassId == -1)
|
||||||
// Other class has not been registered yet, while it should have been,
|
// Other class has not been registered yet, while it should have been,
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <typeindex>
|
#include <typeindex>
|
||||||
|
#include <exception>
|
||||||
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@ -143,7 +145,19 @@ public:
|
|||||||
*/
|
*/
|
||||||
const char *getClassName() { return classesById.at( classId )->className; }
|
const char *getClassName() { return classesById.at( classId )->className; }
|
||||||
|
|
||||||
bool instanceOf (std::intptr_t otherClassId);
|
template< typename T >
|
||||||
|
[[deprecated]]
|
||||||
|
inline bool
|
||||||
|
instanceOf()
|
||||||
|
{
|
||||||
|
const bool expected= dynamic_cast< T * >( this );
|
||||||
|
const bool witness= instanceOf_impl( T::CLASS_ID );
|
||||||
|
if( witness != expected ) throw std::logic_error{ "RTTI based `instanceOf` disagrees with Dillo's lout:: impl." };
|
||||||
|
return expected;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool instanceOf_impl (std::intptr_t otherClassId);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace identity
|
} // namespace identity
|
||||||
|
@ -798,7 +798,7 @@ bool DilloHtml::HtmlLinkReceiver::click (Widget *widget, int link, int img,
|
|||||||
/* Change the link color to "visited" as visual feedback */
|
/* Change the link color to "visited" as visual feedback */
|
||||||
for (Widget *w = widget; w; w = w->getParent()) {
|
for (Widget *w = widget; w; w = w->getParent()) {
|
||||||
_MSG(" ->%s\n", w->getClassName());
|
_MSG(" ->%s\n", w->getClassName());
|
||||||
if (w->instanceOf(dw::Textblock::CLASS_ID)) {
|
if (w->instanceOf<dw::Textblock>()) {
|
||||||
((Textblock*)w)->changeLinkColor (link, html->visited_color);
|
((Textblock*)w)->changeLinkColor (link, html->visited_color);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user