зеркало из https://github.com/mozilla/pjs.git
Bug 422394. Fix tab width calculation so we never fail to advance. r=smontagu
This commit is contained in:
Родитель
2ab315e4db
Коммит
47095769b7
|
@ -2296,8 +2296,12 @@ PropertyProvider::GetTabWidths(PRUint32 aStart, PRUint32 aLength)
|
|||
if (!mTabWidths->AppendElements(aStart + aLength - tabsEnd))
|
||||
return nsnull;
|
||||
|
||||
gfxFloat tabWidth = NS_round(8*mTextRun->GetAppUnitsPerDevUnit()*
|
||||
GetFontMetrics(GetFontGroupForFrame(mLineContainer)).spaceWidth);
|
||||
// Round the space width when converting to appunits the same way
|
||||
// textruns do
|
||||
gfxFloat spaceWidthAppUnits =
|
||||
NS_roundf(GetFontMetrics(GetFontGroupForFrame(mLineContainer)).spaceWidth*
|
||||
mTextRun->GetAppUnitsPerDevUnit());
|
||||
gfxFloat tabWidth = 8*spaceWidthAppUnits;
|
||||
for (PRUint32 i = tabsEnd; i < aStart + aLength; ++i) {
|
||||
Spacing spacing;
|
||||
GetSpacingInternal(i, 1, &spacing, PR_TRUE);
|
||||
|
@ -2315,14 +2319,11 @@ PropertyProvider::GetTabWidths(PRUint32 aStart, PRUint32 aLength)
|
|||
mTextRun->GetAdvanceWidth(i, clusterEnd - i, nsnull);
|
||||
}
|
||||
} else {
|
||||
// Advance mOffsetFromBlockOriginForTabs to the next multiple of tabWidth
|
||||
// Ensure that if it's just epsilon less than a multiple of tabWidth, we still
|
||||
// advance by tabWidth.
|
||||
static const double EPSILON = 0.000001;
|
||||
double nextTab = NS_ceil(mOffsetFromBlockOriginForTabs/tabWidth)*tabWidth;
|
||||
if (nextTab < mOffsetFromBlockOriginForTabs + EPSILON) {
|
||||
nextTab += tabWidth;
|
||||
}
|
||||
// Advance mOffsetFromBlockOriginForTabs to the next multiple of
|
||||
// tabWidth. We must advance by at least 1 appunit.
|
||||
// XXX should we make this 1 CSS pixel?
|
||||
double nextTab =
|
||||
NS_ceil((mOffsetFromBlockOriginForTabs + 1)/tabWidth)*tabWidth;
|
||||
(*mTabWidths)[i - startOffset] = nextTab - mOffsetFromBlockOriginForTabs;
|
||||
mOffsetFromBlockOriginForTabs = nextTab;
|
||||
}
|
||||
|
|
|
@ -765,3 +765,5 @@ random == 403134-1.html 403134-1-ref.html # bug 405377
|
|||
== 420351-1.html 420351-1-ref.html
|
||||
== 421234-1.html 421234-1-ref.html
|
||||
== 421419-1.html 421419-1-ref.html
|
||||
== 422394-1.html 422394-1-ref.html
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче