[poincare] LayoutNode::changeGreySquaresOfAllMatrixAncestors uses Refs

This commit is contained in:
Léa Saviot
2018-07-31 18:02:54 +02:00
parent 5410755cee
commit 9a8ea25dab
2 changed files with 7 additions and 6 deletions

View File

@@ -44,6 +44,7 @@ public:
bool mustHaveLeftSibling() const { return const_cast<LayoutReference *>(this)->node()->mustHaveLeftSibling(); }
bool isEmpty() const { return const_cast<LayoutReference *>(this)->node()->isEmpty(); }
bool isHorizontal() const { return const_cast<LayoutReference *>(this)->node()->isHorizontal(); }
bool isMatrix() const { return const_cast<LayoutReference *>(this)->node()->isMatrix(); }
bool isVerticalOffset() const { return const_cast<LayoutReference *>(this)->node()->isVerticalOffset(); }
bool isLeftParenthesis() const { return const_cast<LayoutReference *>(this)->node()->isLeftParenthesis(); }
bool isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const { return const_cast<LayoutReference *>(this)->node()->isCollapsable(numberOfOpenParenthesis, goingLeft); }

View File

@@ -255,17 +255,17 @@ void LayoutNode::scoreCursorInDescendantsVertically (
bool LayoutNode::changeGreySquaresOfAllMatrixAncestors(bool add) {
bool changedSquares = false;
LayoutNode * currentAncestor = parent();
while (currentAncestor != nullptr) {
if (currentAncestor->isMatrix()) {
LayoutRef currentAncestor = LayoutRef(parent());
while (currentAncestor.isDefined()) {
if (currentAncestor.isMatrix()) {
if (add) {
static_cast<MatrixLayoutNode *>(currentAncestor)->addGreySquares();
static_cast<MatrixLayoutNode *>(currentAncestor.node())->addGreySquares();
} else {
static_cast<MatrixLayoutNode *>(currentAncestor)->removeGreySquares();
static_cast<MatrixLayoutNode *>(currentAncestor.node())->removeGreySquares();
}
changedSquares = true;
}
currentAncestor = currentAncestor->parent();
currentAncestor = currentAncestor.parent();
}
return changedSquares;
}