[poincare] Remove nullptr cases in CondensedSumLayoutNode

This commit is contained in:
Léa Saviot
2018-09-20 13:21:51 +02:00
parent dca209305d
commit 6f68ebcacb

View File

@@ -6,17 +6,14 @@ namespace Poincare {
static inline KDCoordinate max(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; }
// TODO remove nullptr in the code?
KDCoordinate CondensedSumLayoutNode::computeBaseline() {
KDSize superscriptSize = superscriptLayout() == nullptr ? KDSizeZero : superscriptLayout()->layoutSize();
return baseLayout()->baseline() + max(0, superscriptSize.height() - baseLayout()->layoutSize().height()/2);
return baseLayout()->baseline() + max(0, superscriptLayout()->layoutSize().height() - baseLayout()->layoutSize().height()/2);
}
KDSize CondensedSumLayoutNode::computeSize() {
KDSize baseSize = baseLayout()->layoutSize();
KDSize subscriptSize = subscriptLayout()->layoutSize();
KDSize superscriptSize = superscriptLayout() == nullptr ? KDSizeZero : superscriptLayout()->layoutSize();
KDSize superscriptSize = superscriptLayout()->layoutSize();
KDCoordinate sizeWidth = baseSize.width() + max(subscriptSize.width(), superscriptSize.width());
KDCoordinate sizeHeight = max(baseSize.height()/2, subscriptSize.height()) + max(baseSize.height()/2, superscriptSize.height());
return KDSize(sizeWidth, sizeHeight);
@@ -26,7 +23,7 @@ KDPoint CondensedSumLayoutNode::positionOfChild(LayoutNode * child) {
KDCoordinate x = 0;
KDCoordinate y = 0;
KDSize baseSize = baseLayout()->layoutSize();
KDSize superscriptSize = superscriptLayout() == nullptr ? KDSizeZero : superscriptLayout()->layoutSize();
KDSize superscriptSize = superscriptLayout()->layoutSize();
if (child == baseLayout()) {
y = max(0, superscriptSize.height() - baseSize.height()/2);
}