MCPcopy Create free account
hub / github.com/dillo-browser/dillo / getNearestCommonAncestor

Method getNearestCommonAncestor

dw/widget.cc:1629–1657  ·  view source on GitHub ↗

* \brief Get the widget with the highest level, which is a direct ancestor of * widget1 and widget2. */

Source from the content-addressed store, hash-verified

1627 * widget1 and widget2.
1628 */
1629Widget *Widget::getNearestCommonAncestor (Widget *otherWidget)
1630{
1631 Widget *widget1 = this, *widget2 = otherWidget;
1632 int level1 = widget1->getLevel (), level2 = widget2->getLevel();
1633
1634 /* Get both widgets onto the same level.*/
1635 while (level1 > level2) {
1636 widget1 = widget1->parent;
1637 level1--;
1638 }
1639
1640 while (level2 > level1) {
1641 widget2 = widget2->parent;
1642 level2--;
1643 }
1644
1645 /* Search upwards. */
1646 while (widget1 != widget2) {
1647 if (widget1->parent == NULL) {
1648 MSG_WARN("widgets in different trees\n");
1649 return NULL;
1650 }
1651
1652 widget1 = widget1->parent;
1653 widget2 = widget2->parent;
1654 }
1655
1656 return widget1;
1657}
1658
1659void Widget::scrollTo (HPosition hpos, VPosition vpos,
1660 int x, int y, int width, int height)

Callers 1

moveToWidgetMethod · 0.80

Calls 1

getLevelMethod · 0.80

Tested by

no test coverage detected