Fixing mac issue with selection dragging not working when above or below single line text. aka URL. mac has a different preference now. this may be done with look and feel object later. hyatt,cmanske(19191)

This commit is contained in:
mjudge%netscape.com 1999-11-24 01:10:22 +00:00
Родитель 342bf1989c
Коммит a7cd9f0066
4 изменённых файлов: 328 добавлений и 196 удалений

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

@ -601,7 +601,7 @@ nsFrame::DisplaySelection(nsIPresContext& aPresContext, PRBool isOkToTurnOn)
mParent->GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct*&)userinterface);
}
}
if (userinterface->mUserSelect != NS_STYLE_USER_SELECT_NONE) {
if (userinterface->mUserSelect & NS_STYLE_USER_SELECT_NONE) {
result = PR_FALSE;
isOkToTurnOn = PR_FALSE;
}

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

@ -331,7 +331,7 @@ public:
#endif
NS_IMETHOD GetPosition(nsIPresContext& aCX,
nscoord aXCoord,
const nsPoint& aPoint,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd);
@ -345,7 +345,7 @@ public:
NS_IMETHOD GetPositionSlowly(nsIPresContext& aCX,
nsIRenderingContext * aRendContext,
nscoord aXCoord,
const nsPoint& aPoint,
nsIContent ** aNewContent,
PRInt32& aOffset);
@ -1294,7 +1294,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
nsresult
nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
nsIRenderingContext* aRendContext,
nscoord aXCoord,
const nsPoint& aPoint,
nsIContent** aNewContent,
PRInt32& aOffset)
@ -1312,7 +1312,7 @@ nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
GetView(&aPresContext, &view);
GetOffsetFromView(&aPresContext, origin, &view);
if (aXCoord - origin.x <0)
if (aPoint.x - origin.x < 0)
{
*aNewContent = mContent;
aOffset =0;
@ -1336,6 +1336,34 @@ nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
if (textLength <= 0) {
return NS_ERROR_FAILURE;
}
//IF SYLE SAYS TO SELCT TO END OF FRAME HERE...
nsCOMPtr<nsIPref> prefs;
PRInt32 prefInt = 0;
rv = nsServiceManager::GetService(kPrefCID,
nsIPref::GetIID(),
(nsISupports**)&prefs);
PRBool outofstylehandled = PR_FALSE;
if (NS_SUCCEEDED(rv) && prefs)
{
if (NS_SUCCEEDED(prefs->GetIntPref("browser.drag_out_of_frame_style", &prefInt)) && prefInt)
{
if (aPoint.y < mRect.y)//above rectangle
{
aOffset = mContentOffset;
outofstylehandled = PR_TRUE;
}
else if (aPoint.y > (mRect.y + mRect.height))
{
aOffset = mContentOffset + mContentLength;
outofstylehandled = PR_TRUE;
}
}
}
if (!outofstylehandled) //then we drag to closest X point and dont worry about the 'Y'
//END STYLE RULE
{
PRInt32 actualLength = textLength;
nscoord charWidth,widthsofar = 0;
@ -1376,8 +1404,8 @@ nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
aRendContext->GetWidth(ch, charWidth);
glyphWidth = charWidth + ts.mLetterSpacing;
}
if ((aXCoord - origin.x) >= widthsofar && (aXCoord - origin.x) <= (widthsofar + glyphWidth)){
if ( ((aXCoord - origin.x) - widthsofar) <= (glyphWidth /2)){
if ((aPoint.x - origin.x) >= widthsofar && (aPoint.x - origin.x) <= (widthsofar + glyphWidth)){
if ( ((aPoint.x - origin.x) - widthsofar) <= (glyphWidth /2)){
aOffset = indx;
found = PR_TRUE;
break;
@ -1408,6 +1436,7 @@ nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
break;
}
}
}
*aNewContent = mContent;
if (*aNewContent)
@ -1882,7 +1911,7 @@ BinarySearchForPosition(nsIRenderingContext* acx,
//---------------------------------------------------------------------------
NS_IMETHODIMP
nsTextFrame::GetPosition(nsIPresContext& aCX,
nscoord aXCoord,
const nsPoint& aPoint,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd)
@ -1897,7 +1926,7 @@ nsTextFrame::GetPosition(nsIPresContext& aCX,
TextStyle ts(&aCX, *acx, mStyleContext);
if (ts.mSmallCaps || ts.mWordSpacing || ts.mLetterSpacing) {
nsresult result = GetPositionSlowly(aCX, acx, aXCoord, aNewContent,
nsresult result = GetPositionSlowly(aCX, acx, aPoint, aNewContent,
aContentOffset);
aContentOffsetEnd = aContentOffset;
return result;
@ -1933,24 +1962,55 @@ nsTextFrame::GetPosition(nsIPresContext& aCX,
//invalid frame to get position on
return NS_ERROR_FAILURE;
}
nsPoint origin;
nsIView * view;
GetOffsetFromView(&aCX, origin, &view);
//IF SYLE SAYS TO SELCT TO END OF FRAME HERE...
nsCOMPtr<nsIPref> prefs;
PRInt32 prefInt = 0;
rv = nsServiceManager::GetService(kPrefCID,
nsIPref::GetIID(),
(nsISupports**)&prefs);
PRBool outofstylehandled = PR_FALSE;
if (NS_SUCCEEDED(rv) && prefs)
{
if (NS_SUCCEEDED(prefs->GetIntPref("browser.drag_out_of_frame_style", &prefInt)) && prefInt)
{
if ((aPoint.y - origin.y) < 0)//above rectangle
{
aContentOffset = mContentOffset;
aContentOffsetEnd = aContentOffset;
outofstylehandled = PR_TRUE;
}
else if ((aPoint.y - origin.y) > mRect.height)
{
aContentOffset = mContentOffset + mContentLength;
aContentOffsetEnd = aContentOffset;
outofstylehandled = PR_TRUE;
}
}
}
if (!outofstylehandled) //then we need to track based on the X coord only
{
//END STYLE IF
PRInt32* ip = indexBuffer.mBuffer;
PRInt32 indx;
PRInt32 textWidth = 0;
PRUnichar* text = paintBuffer.mBuffer;
nsPoint origin;
nsIView * view;
GetOffsetFromView(&aCX, origin, &view);
PRBool found = BinarySearchForPosition(acx, text, origin.x, 0, 0,
PRInt32(textLength),
PRInt32(aXCoord) , //go to local coordinates
PRInt32(aPoint.x) , //go to local coordinates
indx, textWidth);
if (found) {
PRInt32 charWidth;
acx->GetWidth(text[indx], charWidth);
charWidth /= 2;
if (PR_ABS(PRInt32(aXCoord) - origin.x) > textWidth+charWidth) {
if (PR_ABS(PRInt32(aPoint.x) - origin.x) > textWidth+charWidth) {
indx++;
}
}
@ -1966,7 +2026,7 @@ nsTextFrame::GetPosition(nsIPresContext& aCX,
}
aContentOffsetEnd = aContentOffset;
NS_ASSERTION(i<= mContentLength, "offset we got from binary search is messed up");
}
*aNewContent = mContent;
if (*aNewContent) {
(*aNewContent)->AddRef();
@ -1984,7 +2044,14 @@ nsTextFrame::GetContentAndOffsetsFromPoint(nsIPresContext& aCX,
PRInt32& aContentOffsetEnd,
PRBool& aBeginFrameContent)
{
nsresult rv = GetPosition(aCX, (aPoint.x < 0) ? 0 : aPoint.x, aNewContent, aContentOffset, aContentOffsetEnd);
nsPoint newPoint;
newPoint.y = aPoint.y;
if (aPoint.x < 0)
newPoint.x = 0;
else
newPoint.x = aPoint.x;
nsresult rv = GetPosition(aCX, newPoint, aNewContent, aContentOffset, aContentOffsetEnd);
if (aContentOffset == mContentOffset)
aBeginFrameContent = PR_TRUE;
else
@ -2522,7 +2589,7 @@ nsTextFrame::HandleMultiplePress(nsIPresContext& aPresContext,
if (NS_SUCCEEDED(rv) && mPrefs)
{
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.triple_click_style", &prefInt)) && prefInt)
if (NS_FAILED(mPrefs->GetIntPref("browser.triple_click_style", &prefInt)) || !prefInt)
return nsFrame::HandleMultiplePress(aPresContext, aEvent, aEventStatus);
}
//THIS NEXT CODE IS FOR PARAGRAPH
@ -2602,7 +2669,7 @@ nsTextFrame::HandleMultiplePress(nsIPresContext& aPresContext,
//find which word needs to be selected! use peek offset one way then the other
nsCOMPtr<nsIDOMNode> startNode;
nsCOMPtr<nsIDOMNode> endNode;
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x,
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point,
getter_AddRefs(newContent), startPos, contentOffsetEnd))){
//peeks{}
nsPeekOffsetStruct startpos;
@ -3507,4 +3574,3 @@ nsTextFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) cons
return NS_OK;
}
#endif

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

@ -601,7 +601,7 @@ nsFrame::DisplaySelection(nsIPresContext& aPresContext, PRBool isOkToTurnOn)
mParent->GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct*&)userinterface);
}
}
if (userinterface->mUserSelect != NS_STYLE_USER_SELECT_NONE) {
if (userinterface->mUserSelect & NS_STYLE_USER_SELECT_NONE) {
result = PR_FALSE;
isOkToTurnOn = PR_FALSE;
}

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

@ -331,7 +331,7 @@ public:
#endif
NS_IMETHOD GetPosition(nsIPresContext& aCX,
nscoord aXCoord,
const nsPoint& aPoint,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd);
@ -345,7 +345,7 @@ public:
NS_IMETHOD GetPositionSlowly(nsIPresContext& aCX,
nsIRenderingContext * aRendContext,
nscoord aXCoord,
const nsPoint& aPoint,
nsIContent ** aNewContent,
PRInt32& aOffset);
@ -1294,7 +1294,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
nsresult
nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
nsIRenderingContext* aRendContext,
nscoord aXCoord,
const nsPoint& aPoint,
nsIContent** aNewContent,
PRInt32& aOffset)
@ -1312,7 +1312,7 @@ nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
GetView(&aPresContext, &view);
GetOffsetFromView(&aPresContext, origin, &view);
if (aXCoord - origin.x <0)
if (aPoint.x - origin.x < 0)
{
*aNewContent = mContent;
aOffset =0;
@ -1336,6 +1336,34 @@ nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
if (textLength <= 0) {
return NS_ERROR_FAILURE;
}
//IF SYLE SAYS TO SELCT TO END OF FRAME HERE...
nsCOMPtr<nsIPref> prefs;
PRInt32 prefInt = 0;
rv = nsServiceManager::GetService(kPrefCID,
nsIPref::GetIID(),
(nsISupports**)&prefs);
PRBool outofstylehandled = PR_FALSE;
if (NS_SUCCEEDED(rv) && prefs)
{
if (NS_SUCCEEDED(prefs->GetIntPref("browser.drag_out_of_frame_style", &prefInt)) && prefInt)
{
if (aPoint.y < mRect.y)//above rectangle
{
aOffset = mContentOffset;
outofstylehandled = PR_TRUE;
}
else if (aPoint.y > (mRect.y + mRect.height))
{
aOffset = mContentOffset + mContentLength;
outofstylehandled = PR_TRUE;
}
}
}
if (!outofstylehandled) //then we drag to closest X point and dont worry about the 'Y'
//END STYLE RULE
{
PRInt32 actualLength = textLength;
nscoord charWidth,widthsofar = 0;
@ -1376,8 +1404,8 @@ nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
aRendContext->GetWidth(ch, charWidth);
glyphWidth = charWidth + ts.mLetterSpacing;
}
if ((aXCoord - origin.x) >= widthsofar && (aXCoord - origin.x) <= (widthsofar + glyphWidth)){
if ( ((aXCoord - origin.x) - widthsofar) <= (glyphWidth /2)){
if ((aPoint.x - origin.x) >= widthsofar && (aPoint.x - origin.x) <= (widthsofar + glyphWidth)){
if ( ((aPoint.x - origin.x) - widthsofar) <= (glyphWidth /2)){
aOffset = indx;
found = PR_TRUE;
break;
@ -1408,6 +1436,7 @@ nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
break;
}
}
}
*aNewContent = mContent;
if (*aNewContent)
@ -1882,7 +1911,7 @@ BinarySearchForPosition(nsIRenderingContext* acx,
//---------------------------------------------------------------------------
NS_IMETHODIMP
nsTextFrame::GetPosition(nsIPresContext& aCX,
nscoord aXCoord,
const nsPoint& aPoint,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd)
@ -1897,7 +1926,7 @@ nsTextFrame::GetPosition(nsIPresContext& aCX,
TextStyle ts(&aCX, *acx, mStyleContext);
if (ts.mSmallCaps || ts.mWordSpacing || ts.mLetterSpacing) {
nsresult result = GetPositionSlowly(aCX, acx, aXCoord, aNewContent,
nsresult result = GetPositionSlowly(aCX, acx, aPoint, aNewContent,
aContentOffset);
aContentOffsetEnd = aContentOffset;
return result;
@ -1933,24 +1962,55 @@ nsTextFrame::GetPosition(nsIPresContext& aCX,
//invalid frame to get position on
return NS_ERROR_FAILURE;
}
nsPoint origin;
nsIView * view;
GetOffsetFromView(&aCX, origin, &view);
//IF SYLE SAYS TO SELCT TO END OF FRAME HERE...
nsCOMPtr<nsIPref> prefs;
PRInt32 prefInt = 0;
rv = nsServiceManager::GetService(kPrefCID,
nsIPref::GetIID(),
(nsISupports**)&prefs);
PRBool outofstylehandled = PR_FALSE;
if (NS_SUCCEEDED(rv) && prefs)
{
if (NS_SUCCEEDED(prefs->GetIntPref("browser.drag_out_of_frame_style", &prefInt)) && prefInt)
{
if ((aPoint.y - origin.y) < 0)//above rectangle
{
aContentOffset = mContentOffset;
aContentOffsetEnd = aContentOffset;
outofstylehandled = PR_TRUE;
}
else if ((aPoint.y - origin.y) > mRect.height)
{
aContentOffset = mContentOffset + mContentLength;
aContentOffsetEnd = aContentOffset;
outofstylehandled = PR_TRUE;
}
}
}
if (!outofstylehandled) //then we need to track based on the X coord only
{
//END STYLE IF
PRInt32* ip = indexBuffer.mBuffer;
PRInt32 indx;
PRInt32 textWidth = 0;
PRUnichar* text = paintBuffer.mBuffer;
nsPoint origin;
nsIView * view;
GetOffsetFromView(&aCX, origin, &view);
PRBool found = BinarySearchForPosition(acx, text, origin.x, 0, 0,
PRInt32(textLength),
PRInt32(aXCoord) , //go to local coordinates
PRInt32(aPoint.x) , //go to local coordinates
indx, textWidth);
if (found) {
PRInt32 charWidth;
acx->GetWidth(text[indx], charWidth);
charWidth /= 2;
if (PR_ABS(PRInt32(aXCoord) - origin.x) > textWidth+charWidth) {
if (PR_ABS(PRInt32(aPoint.x) - origin.x) > textWidth+charWidth) {
indx++;
}
}
@ -1966,7 +2026,7 @@ nsTextFrame::GetPosition(nsIPresContext& aCX,
}
aContentOffsetEnd = aContentOffset;
NS_ASSERTION(i<= mContentLength, "offset we got from binary search is messed up");
}
*aNewContent = mContent;
if (*aNewContent) {
(*aNewContent)->AddRef();
@ -1984,7 +2044,14 @@ nsTextFrame::GetContentAndOffsetsFromPoint(nsIPresContext& aCX,
PRInt32& aContentOffsetEnd,
PRBool& aBeginFrameContent)
{
nsresult rv = GetPosition(aCX, (aPoint.x < 0) ? 0 : aPoint.x, aNewContent, aContentOffset, aContentOffsetEnd);
nsPoint newPoint;
newPoint.y = aPoint.y;
if (aPoint.x < 0)
newPoint.x = 0;
else
newPoint.x = aPoint.x;
nsresult rv = GetPosition(aCX, newPoint, aNewContent, aContentOffset, aContentOffsetEnd);
if (aContentOffset == mContentOffset)
aBeginFrameContent = PR_TRUE;
else
@ -2522,7 +2589,7 @@ nsTextFrame::HandleMultiplePress(nsIPresContext& aPresContext,
if (NS_SUCCEEDED(rv) && mPrefs)
{
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.triple_click_style", &prefInt)) && prefInt)
if (NS_FAILED(mPrefs->GetIntPref("browser.triple_click_style", &prefInt)) || !prefInt)
return nsFrame::HandleMultiplePress(aPresContext, aEvent, aEventStatus);
}
//THIS NEXT CODE IS FOR PARAGRAPH
@ -2602,7 +2669,7 @@ nsTextFrame::HandleMultiplePress(nsIPresContext& aPresContext,
//find which word needs to be selected! use peek offset one way then the other
nsCOMPtr<nsIDOMNode> startNode;
nsCOMPtr<nsIDOMNode> endNode;
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x,
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point,
getter_AddRefs(newContent), startPos, contentOffsetEnd))){
//peeks{}
nsPeekOffsetStruct startpos;
@ -3507,4 +3574,3 @@ nsTextFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) cons
return NS_OK;
}
#endif