diff --git a/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp b/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp index 131f7353e744..8b9733c8dff7 100644 --- a/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp +++ b/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp @@ -26,6 +26,7 @@ * Jan Varga * Dean Tessman * Brian Ryner + * Blake Ross * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -2459,7 +2460,28 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex, case 1: { - // XXX Not yet implemented. + // Crop center. + nsAutoString leftStr, rightStr; + nscoord cwidth, twidth = 0; + int length = text.Length(); + int rightPos = length - 1; + for (int leftPos = 0; leftPos < rightPos; ++leftPos) { + PRUnichar ch = text[leftPos]; + aRenderingContext.GetWidth(ch, cwidth); + twidth += cwidth; + if (twidth > width) + break; + leftStr.Append(ch); + + ch = text[rightPos]; + aRenderingContext.GetWidth(ch, cwidth); + twidth += cwidth; + if (twidth > width) + break; + rightStr.Insert(ch, 0); + --rightPos; + } + text = leftStr + NS_LITERAL_STRING(ELLIPSIS) + rightStr; } break; } diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 131f7353e744..8b9733c8dff7 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -26,6 +26,7 @@ * Jan Varga * Dean Tessman * Brian Ryner + * Blake Ross * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -2459,7 +2460,28 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex, case 1: { - // XXX Not yet implemented. + // Crop center. + nsAutoString leftStr, rightStr; + nscoord cwidth, twidth = 0; + int length = text.Length(); + int rightPos = length - 1; + for (int leftPos = 0; leftPos < rightPos; ++leftPos) { + PRUnichar ch = text[leftPos]; + aRenderingContext.GetWidth(ch, cwidth); + twidth += cwidth; + if (twidth > width) + break; + leftStr.Append(ch); + + ch = text[rightPos]; + aRenderingContext.GetWidth(ch, cwidth); + twidth += cwidth; + if (twidth > width) + break; + rightStr.Insert(ch, 0); + --rightPos; + } + text = leftStr + NS_LITERAL_STRING(ELLIPSIS) + rightStr; } break; }