зеркало из https://github.com/mozilla/pjs.git
Bug 696746, round width rather than adding one to prevent an extra reflow, r=roc
This commit is contained in:
Родитель
ead3336a32
Коммит
0f5c960d2e
|
@ -3272,23 +3272,19 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent()
|
||||||
NS_ENSURE_TRUE(shellArea.width != NS_UNCONSTRAINEDSIZE &&
|
NS_ENSURE_TRUE(shellArea.width != NS_UNCONSTRAINEDSIZE &&
|
||||||
shellArea.height != NS_UNCONSTRAINEDSIZE,
|
shellArea.height != NS_UNCONSTRAINEDSIZE,
|
||||||
NS_ERROR_FAILURE);
|
NS_ERROR_FAILURE);
|
||||||
width = presContext->AppUnitsToDevPixels(shellArea.width);
|
|
||||||
|
// Sometimes wrapped lines can create a situation where the width is a
|
||||||
|
// non-integer. Rather than figure out why now, we just round the width up
|
||||||
|
// to take this extra width into account. This makes the shell one pixel
|
||||||
|
// wider and causes an extra reflow.
|
||||||
|
width = NSToIntRoundUp(float(shellArea.width) / mDeviceContext->AppUnitsPerDevPixel());
|
||||||
height = presContext->AppUnitsToDevPixels(shellArea.height);
|
height = presContext->AppUnitsToDevPixels(shellArea.height);
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
||||||
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
||||||
NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
/* presContext's size was calculated in app units and has already been
|
NS_ENSURE_SUCCESS(treeOwner->SizeShellTo(docShellAsItem, width, height),
|
||||||
rounded to the equivalent pixels (so the width/height calculation
|
|
||||||
we just performed was probably exact, though it was based on
|
|
||||||
values already rounded during ResizeReflow). In a surprising
|
|
||||||
number of instances, this rounding makes a window which for want
|
|
||||||
of one extra pixel's width ends up wrapping the longest line of
|
|
||||||
text during actual window layout. This makes the window too short,
|
|
||||||
generally clipping the OK/Cancel buttons. Here we add one pixel
|
|
||||||
to the calculated width, to circumvent this problem. */
|
|
||||||
NS_ENSURE_SUCCESS(treeOwner->SizeShellTo(docShellAsItem, width+1, height),
|
|
||||||
NS_ERROR_FAILURE);
|
NS_ERROR_FAILURE);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче