From a38b2c61f4f561c78aaa3f320941c7aba3300a32 Mon Sep 17 00:00:00 2001 From: "smontagu%smontagu.org" Date: Sun, 30 Oct 2005 13:05:45 +0000 Subject: [PATCH] Caret skips blank line using down-arrow key in preformatted text (e.g. View Source). Bug 298690, patch by Uri Bernstein , r+sr=roc git-svn-id: svn://10.0.0.236/trunk@183253 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsFrame.cpp | 20 ++++++++------------ mozilla/layout/generic/nsLineBox.cpp | 2 +- mozilla/layout/generic/nsTextFrame.cpp | 11 +++++------ 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 4096354de69..0fc2b588aaa 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -3292,18 +3292,14 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext, if (!resultFrame->HasView()) { rect = resultFrame->GetRect(); - if (!rect.width || !rect.height) - result = NS_ERROR_FAILURE; - else { - nsIView* view; - nsPoint offset; - resultFrame->GetOffsetFromView(offset, &view); - result = resultFrame->GetContentAndOffsetsFromPoint(context,point - offset, - getter_AddRefs(aPos->mResultContent), - aPos->mContentOffset, - aPos->mContentOffsetEnd, - aPos->mPreferLeft); - } + nsIView* view; + nsPoint offset; + resultFrame->GetOffsetFromView(offset, &view); + result = resultFrame->GetContentAndOffsetsFromPoint(context,point - offset, + getter_AddRefs(aPos->mResultContent), + aPos->mContentOffset, + aPos->mContentOffsetEnd, + aPos->mPreferLeft); if (NS_SUCCEEDED(result)) { PRBool selectable; diff --git a/mozilla/layout/generic/nsLineBox.cpp b/mozilla/layout/generic/nsLineBox.cpp index 367e40e719b..0943fa44607 100644 --- a/mozilla/layout/generic/nsLineBox.cpp +++ b/mozilla/layout/generic/nsLineBox.cpp @@ -784,7 +784,7 @@ nsLineIterator::FindFrameAt(PRInt32 aLineNumber, return NS_OK; } - if (line->mBounds.width == 0) + if (line->mBounds.width == 0 && line->mBounds.height == 0) return NS_ERROR_FAILURE; nsIFrame* frame = line->mFirstChild; diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 65416578fd6..f59c968c346 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -3598,11 +3598,6 @@ nsTextFrame::GetPosition(nsPresContext* aPresContext, // no need to worry about justification, that's always on the slow path PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength); - if (textLength <=0) { - //invalid frame to get position on - return NS_ERROR_FAILURE; - } - //IF STYLE SAYS TO SELECT TO END OF FRAME HERE... PRInt32 prefInt = nsContentUtils::GetIntPref("browser.drag_out_of_frame_style"); @@ -3624,7 +3619,11 @@ nsTextFrame::GetPosition(nsPresContext* aPresContext, } } - if (!outofstylehandled) //then we need to track based on the X coord only + if (textLength <= 0) { + aContentOffset = mContentOffset; + aContentOffsetEnd = aContentOffset; + } + else if (!outofstylehandled) //then we need to track based on the X coord only { //END STYLE IF PRInt32* ip = indexBuffer.mBuffer;