TextMetrics::leftMargin(): Explain why the disabled code is wrong

This commit is contained in:
Vincent van Ravesteijn 2012-05-10 10:39:38 +02:00
parent 92ac678715
commit 6df750aa18

View File

@ -1980,16 +1980,18 @@ int TextMetrics::leftMargin(int max_width,
case MARGIN_RIGHT_ADDRESS_BOX: { case MARGIN_RIGHT_ADDRESS_BOX: {
#if 0 #if 0
// ok, a terrible hack. The left margin depends on the widest // The left margin depends on the widest row in this paragraph.
// row in this paragraph. // This code is wrong because it depends on the rows, but at the
RowList::iterator rit = par.rows().begin(); // same time this function is used in redoParagraph to construct
RowList::iterator end = par.rows().end(); // the rows.
// FIXME: This is wrong. ParagraphMetrics const & pm = par_metrics_[pit];
RowList::const_iterator rit = pm.rows().begin();
RowList::const_iterator end = pm.rows().end();
int minfill = max_width; int minfill = max_width;
for ( ; rit != end; ++rit) for ( ; rit != end; ++rit)
if (rit->fill() < minfill) if (rit->fill() < minfill)
minfill = rit->fill(); minfill = rit->fill();
l_margin += theFontMetrics(params.getFont()).signedWidth(layout.leftmargin); l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(layout.leftmargin);
l_margin += minfill; l_margin += minfill;
#endif #endif
// also wrong, but much shorter. // also wrong, but much shorter.