diff --git a/content/base/src/nsDocumentViewer.cpp b/content/base/src/nsDocumentViewer.cpp index 4f7de216ffb..30161f1d73a 100644 --- a/content/base/src/nsDocumentViewer.cpp +++ b/content/base/src/nsDocumentViewer.cpp @@ -4981,7 +4981,16 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent() docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner)); NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(treeOwner->SizeShellTo(docShellAsItem, width, height), + /* presContext's size was calculated in twips and has already been + 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); return NS_OK; diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 4f7de216ffb..30161f1d73a 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -4981,7 +4981,16 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent() docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner)); NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(treeOwner->SizeShellTo(docShellAsItem, width, height), + /* presContext's size was calculated in twips and has already been + 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); return NS_OK;