changes for bug fixes for dogfood. finding frames left and right should find the correct frame and not give up so easily. nsTextFrame needed to change getpositionslowly.

This commit is contained in:
mjudge%netscape.com 1999-09-15 01:57:50 +00:00
Родитель 5d23551b81
Коммит d71f4104da
4 изменённых файлов: 62 добавлений и 20 удалений

Просмотреть файл

@ -2045,16 +2045,30 @@ nsFrame::PeekOffset(nsPeekOffsetStruct *aPos)
{
if (firstFrame)
{
while (--lineFrameCount)
firstFrame->GetNextSibling(&firstFrame);
nsPoint offsetPoint; //used for offset of result frame
nsIView * view; //used for call of get offset from view
firstFrame->GetOffsetFromView(offsetPoint, &view);
usedRect.x = offsetPoint.x;
usedRect.y = offsetPoint.y;
PRBool found = PR_FALSE;
while(!found)
{
nsIFrame *nextFrame = firstFrame;;
for (PRInt32 i=1;i<lineFrameCount;i++)//allready have 1st frame
nextFrame->GetNextSibling(&nextFrame);
result = firstFrame->GetPosition(*(context.get()),2*usedRect.width,//2* just to be sure we are off the edge
getter_AddRefs(aPos->mResultContent),aPos->mContentOffset, aPos->mContentOffset);
nsPoint offsetPoint; //used for offset of result frame
nsIView * view; //used for call of get offset from view
nextFrame->GetOffsetFromView(offsetPoint, &view);
usedRect.x = offsetPoint.x;
usedRect.y = offsetPoint.y;
result = nextFrame->GetPosition(*(context.get()),2*usedRect.width,//2* just to be sure we are off the edge
getter_AddRefs(aPos->mResultContent),aPos->mContentOffset, aPos->mContentOffset);
if (NS_SUCCEEDED(result))
found = PR_TRUE;
else
{
lineFrameCount--;
if (lineFrameCount == 0)
break;//just fail out
}
}
}
}
}break;

Просмотреть файл

@ -58,6 +58,10 @@
#include "nsILineIterator.h"
#ifndef PR_ABS
#define PR_ABS(x) (x < 0 ? -x : x)
#endif
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
#ifdef NS_DEBUG
@ -1630,6 +1634,7 @@ BinarySearchForPosition(nsIRenderingContext* acx,
PRInt32 fullWidth = aBaseWidth + textWidth;
if (fullWidth == aCursorPos) {
aTextWidth = textWidth;
aIndex = inx;
return PR_TRUE;
} else if (aCursorPos < fullWidth) {
@ -1729,7 +1734,7 @@ nsTextFrame::GetPosition(nsIPresContext& aCX,
acx->GetWidth(text[indx], charWidth);
charWidth /= 2;
if (PRInt32(aXCoord) - origin.x > textWidth+charWidth) {
if (PR_ABS(PRInt32(aXCoord) - origin.x) > textWidth+charWidth) {
indx++;
}
}
@ -2034,6 +2039,7 @@ nsTextFrame::PeekOffset(nsPeekOffsetStruct *aPos)
PRInt32 start;
PRBool found = PR_TRUE;
if (aPos->mDirection == eDirPrevious){
aPos->mContentOffset = 0;
PRInt32 i;
for (i = aPos->mStartOffset -1 - mContentOffset; i >=0; i--){
if (ip[i] < ip[aPos->mStartOffset - mContentOffset]){
@ -2049,6 +2055,7 @@ nsTextFrame::PeekOffset(nsPeekOffsetStruct *aPos)
}
else if (aPos->mDirection == eDirNext){
PRInt32 i;
aPos->mContentOffset = mContentLength;
for (i = aPos->mStartOffset +1 - mContentOffset; i <= mContentLength; i++){
if (ip[i] > ip[aPos->mStartOffset - mContentOffset]){
aPos->mContentOffset = i + mContentOffset;

Просмотреть файл

@ -2045,16 +2045,30 @@ nsFrame::PeekOffset(nsPeekOffsetStruct *aPos)
{
if (firstFrame)
{
while (--lineFrameCount)
firstFrame->GetNextSibling(&firstFrame);
nsPoint offsetPoint; //used for offset of result frame
nsIView * view; //used for call of get offset from view
firstFrame->GetOffsetFromView(offsetPoint, &view);
usedRect.x = offsetPoint.x;
usedRect.y = offsetPoint.y;
PRBool found = PR_FALSE;
while(!found)
{
nsIFrame *nextFrame = firstFrame;;
for (PRInt32 i=1;i<lineFrameCount;i++)//allready have 1st frame
nextFrame->GetNextSibling(&nextFrame);
result = firstFrame->GetPosition(*(context.get()),2*usedRect.width,//2* just to be sure we are off the edge
getter_AddRefs(aPos->mResultContent),aPos->mContentOffset, aPos->mContentOffset);
nsPoint offsetPoint; //used for offset of result frame
nsIView * view; //used for call of get offset from view
nextFrame->GetOffsetFromView(offsetPoint, &view);
usedRect.x = offsetPoint.x;
usedRect.y = offsetPoint.y;
result = nextFrame->GetPosition(*(context.get()),2*usedRect.width,//2* just to be sure we are off the edge
getter_AddRefs(aPos->mResultContent),aPos->mContentOffset, aPos->mContentOffset);
if (NS_SUCCEEDED(result))
found = PR_TRUE;
else
{
lineFrameCount--;
if (lineFrameCount == 0)
break;//just fail out
}
}
}
}
}break;

Просмотреть файл

@ -58,6 +58,10 @@
#include "nsILineIterator.h"
#ifndef PR_ABS
#define PR_ABS(x) (x < 0 ? -x : x)
#endif
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
#ifdef NS_DEBUG
@ -1630,6 +1634,7 @@ BinarySearchForPosition(nsIRenderingContext* acx,
PRInt32 fullWidth = aBaseWidth + textWidth;
if (fullWidth == aCursorPos) {
aTextWidth = textWidth;
aIndex = inx;
return PR_TRUE;
} else if (aCursorPos < fullWidth) {
@ -1729,7 +1734,7 @@ nsTextFrame::GetPosition(nsIPresContext& aCX,
acx->GetWidth(text[indx], charWidth);
charWidth /= 2;
if (PRInt32(aXCoord) - origin.x > textWidth+charWidth) {
if (PR_ABS(PRInt32(aXCoord) - origin.x) > textWidth+charWidth) {
indx++;
}
}
@ -2034,6 +2039,7 @@ nsTextFrame::PeekOffset(nsPeekOffsetStruct *aPos)
PRInt32 start;
PRBool found = PR_TRUE;
if (aPos->mDirection == eDirPrevious){
aPos->mContentOffset = 0;
PRInt32 i;
for (i = aPos->mStartOffset -1 - mContentOffset; i >=0; i--){
if (ip[i] < ip[aPos->mStartOffset - mContentOffset]){
@ -2049,6 +2055,7 @@ nsTextFrame::PeekOffset(nsPeekOffsetStruct *aPos)
}
else if (aPos->mDirection == eDirNext){
PRInt32 i;
aPos->mContentOffset = mContentLength;
for (i = aPos->mStartOffset +1 - mContentOffset; i <= mContentLength; i++){
if (ip[i] > ip[aPos->mStartOffset - mContentOffset]){
aPos->mContentOffset = i + mContentOffset;