diff --git a/mozilla/layout/base/nsCaret.cpp b/mozilla/layout/base/nsCaret.cpp index e9bf1ffb623..cc6dffa79e5 100644 --- a/mozilla/layout/base/nsCaret.cpp +++ b/mozilla/layout/base/nsCaret.cpp @@ -589,14 +589,14 @@ void nsCaret::DrawCaretWithContext(nsIRenderingContext* inRendContext) // Avoid view redraw problems by making sure the // caret doesn't hang outside the right edge of - // the frame. This insures that the caret gets + // the frame. This ensures that the caret gets // erased properly if the frame's right edge gets // invalidated. nscoord cX = caretRect.x + caretRect.width; nscoord fX = frameRect.x + frameRect.width; - if (cX > fX) + if (caretRect.x <= fX && cX > fX) { caretRect.x -= cX - fX; diff --git a/mozilla/layout/base/src/nsCaret.cpp b/mozilla/layout/base/src/nsCaret.cpp index e9bf1ffb623..cc6dffa79e5 100644 --- a/mozilla/layout/base/src/nsCaret.cpp +++ b/mozilla/layout/base/src/nsCaret.cpp @@ -589,14 +589,14 @@ void nsCaret::DrawCaretWithContext(nsIRenderingContext* inRendContext) // Avoid view redraw problems by making sure the // caret doesn't hang outside the right edge of - // the frame. This insures that the caret gets + // the frame. This ensures that the caret gets // erased properly if the frame's right edge gets // invalidated. nscoord cX = caretRect.x + caretRect.width; nscoord fX = frameRect.x + frameRect.width; - if (cX > fX) + if (caretRect.x <= fX && cX > fX) { caretRect.x -= cX - fX; diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index f3d8974d4be..3e641079b7b 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -2159,6 +2159,18 @@ nsTextFrame::GetPointFromOffset(nsIPresContext* aPresContext, GetWidth(*inRendContext, ts, paintBuffer.mBuffer, ip[inOffset]-mContentOffset, &width); + + if (inOffset > textLength && (TEXT_TRIMMED_WS & mState)){ + // + // Offset must be after a space that has + // been trimmed off the end of the frame. + // Add the width of the trimmed space back + // to the total width, so the caret appears + // in the proper place! + // + width += ts.mSpaceWidth; + } + outPoint->x = width; outPoint->y = 0; diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index f3d8974d4be..3e641079b7b 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -2159,6 +2159,18 @@ nsTextFrame::GetPointFromOffset(nsIPresContext* aPresContext, GetWidth(*inRendContext, ts, paintBuffer.mBuffer, ip[inOffset]-mContentOffset, &width); + + if (inOffset > textLength && (TEXT_TRIMMED_WS & mState)){ + // + // Offset must be after a space that has + // been trimmed off the end of the frame. + // Add the width of the trimmed space back + // to the total width, so the caret appears + // in the proper place! + // + width += ts.mSpaceWidth; + } + outPoint->x = width; outPoint->y = 0;