Clean up nsPeekOffsetStruct. bug=343763. r+sr=roc
This commit is contained in:
@@ -3436,11 +3436,7 @@ PresShell::CompleteMove(PRBool aForward, PRBool aExtend)
|
|||||||
|
|
||||||
nsPeekOffsetStruct pos = frame->GetExtremeCaretPosition(!aForward);
|
nsPeekOffsetStruct pos = frame->GetExtremeCaretPosition(!aForward);
|
||||||
|
|
||||||
// we 'prefer left' (i.e. prefer the beginning of the next line)
|
mSelection->HandleClick(pos.mResultContent ,pos.mContentOffset ,pos.mContentOffset/*End*/ ,aExtend, PR_FALSE, aForward);
|
||||||
// iff we're moving to the end of the content
|
|
||||||
pos.mPreferLeft = aForward;
|
|
||||||
|
|
||||||
mSelection->HandleClick(pos.mResultContent ,pos.mContentOffset ,pos.mContentOffset/*End*/ ,aExtend, PR_FALSE, pos.mPreferLeft);
|
|
||||||
return ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL, nsISelectionController::SELECTION_FOCUS_REGION, PR_TRUE);
|
return ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL, nsISelectionController::SELECTION_FOCUS_REGION, PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1992,8 +1992,7 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack,
|
|||||||
nsresult rv = GetSelectionController(aPresContext, getter_AddRefs(selcon));
|
nsresult rv = GetSelectionController(aPresContext, getter_AddRefs(selcon));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
nsIPresShell *shell = aPresContext->GetPresShell();
|
if (!selcon)
|
||||||
if (!shell || !selcon)
|
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
// Use peek offset one way then the other:
|
// Use peek offset one way then the other:
|
||||||
@@ -2002,13 +2001,10 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack,
|
|||||||
nsCOMPtr<nsIContent> endContent;
|
nsCOMPtr<nsIContent> endContent;
|
||||||
nsCOMPtr<nsIDOMNode> endNode;
|
nsCOMPtr<nsIDOMNode> endNode;
|
||||||
nsPeekOffsetStruct startpos;
|
nsPeekOffsetStruct startpos;
|
||||||
startpos.SetData(shell,
|
startpos.SetData(aAmountBack,
|
||||||
0,
|
|
||||||
aAmountBack,
|
|
||||||
eDirPrevious,
|
eDirPrevious,
|
||||||
aStartPos,
|
aStartPos,
|
||||||
PR_FALSE,
|
0,
|
||||||
PR_TRUE,
|
|
||||||
aJumpLines,
|
aJumpLines,
|
||||||
PR_TRUE, //limit on scrolled views
|
PR_TRUE, //limit on scrolled views
|
||||||
PR_FALSE,
|
PR_FALSE,
|
||||||
@@ -2017,13 +2013,10 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack,
|
|||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
nsPeekOffsetStruct endpos;
|
nsPeekOffsetStruct endpos;
|
||||||
endpos.SetData(shell,
|
endpos.SetData(aAmountForward,
|
||||||
0,
|
|
||||||
aAmountForward,
|
|
||||||
eDirNext,
|
eDirNext,
|
||||||
aStartPos,
|
aStartPos,
|
||||||
PR_FALSE,
|
0,
|
||||||
PR_FALSE,
|
|
||||||
aJumpLines,
|
aJumpLines,
|
||||||
PR_TRUE, //limit on scrolled views
|
PR_TRUE, //limit on scrolled views
|
||||||
PR_FALSE,
|
PR_FALSE,
|
||||||
@@ -3823,7 +3816,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
|
|||||||
|
|
||||||
aPos->mResultFrame = nsnull;
|
aPos->mResultFrame = nsnull;
|
||||||
aPos->mResultContent = nsnull;
|
aPos->mResultContent = nsnull;
|
||||||
aPos->mPreferLeft = (aPos->mDirection == eDirNext);
|
aPos->mAttachForward = (aPos->mDirection == eDirNext);
|
||||||
|
|
||||||
nsresult result;
|
nsresult result;
|
||||||
nsCOMPtr<nsILineIteratorNavigator> it;
|
nsCOMPtr<nsILineIteratorNavigator> it;
|
||||||
@@ -3951,13 +3944,12 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
|
|||||||
{
|
{
|
||||||
aPos->mResultContent = parent;
|
aPos->mResultContent = parent;
|
||||||
aPos->mContentOffset = parent->IndexOf(content);
|
aPos->mContentOffset = parent->IndexOf(content);
|
||||||
aPos->mPreferLeft = PR_FALSE;
|
aPos->mAttachForward = PR_FALSE;
|
||||||
if ((point.x - offset.x+ tempRect.x)>tempRect.width)
|
if ((point.x - offset.x+ tempRect.x)>tempRect.width)
|
||||||
{
|
{
|
||||||
aPos->mContentOffset++;//go to end of this frame
|
aPos->mContentOffset++;//go to end of this frame
|
||||||
aPos->mPreferLeft = PR_TRUE;
|
aPos->mAttachForward = PR_TRUE;
|
||||||
}
|
}
|
||||||
aPos->mContentOffsetEnd = aPos->mContentOffset;
|
|
||||||
//result frame is the result frames parent.
|
//result frame is the result frames parent.
|
||||||
aPos->mResultFrame = resultFrame->GetParent();
|
aPos->mResultFrame = resultFrame->GetParent();
|
||||||
return NS_POSITION_BEFORE_TABLE;
|
return NS_POSITION_BEFORE_TABLE;
|
||||||
@@ -3976,7 +3968,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
|
|||||||
resultFrame->GetContentOffsetsFromPoint(point - offset);
|
resultFrame->GetContentOffsetsFromPoint(point - offset);
|
||||||
aPos->mResultContent = offsets.content;
|
aPos->mResultContent = offsets.content;
|
||||||
aPos->mContentOffset = offsets.offset;
|
aPos->mContentOffset = offsets.offset;
|
||||||
aPos->mPreferLeft = offsets.associateWithNext;
|
aPos->mAttachForward = offsets.associateWithNext;
|
||||||
if (offsets.content)
|
if (offsets.content)
|
||||||
{
|
{
|
||||||
PRBool selectable;
|
PRBool selectable;
|
||||||
@@ -4018,7 +4010,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
|
|||||||
resultFrame->GetContentOffsetsFromPoint(point - offset);
|
resultFrame->GetContentOffsetsFromPoint(point - offset);
|
||||||
aPos->mResultContent = offsets.content;
|
aPos->mResultContent = offsets.content;
|
||||||
aPos->mContentOffset = offsets.offset;
|
aPos->mContentOffset = offsets.offset;
|
||||||
aPos->mPreferLeft = offsets.associateWithNext;
|
aPos->mAttachForward = offsets.associateWithNext;
|
||||||
if (offsets.content)
|
if (offsets.content)
|
||||||
{
|
{
|
||||||
PRBool selectable;
|
PRBool selectable;
|
||||||
@@ -4027,9 +4019,9 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
|
|||||||
{
|
{
|
||||||
found = PR_TRUE;
|
found = PR_TRUE;
|
||||||
if (resultFrame == farStoppingFrame)
|
if (resultFrame == farStoppingFrame)
|
||||||
aPos->mPreferLeft = PR_FALSE;
|
aPos->mAttachForward = PR_FALSE;
|
||||||
else
|
else
|
||||||
aPos->mPreferLeft = PR_TRUE;
|
aPos->mAttachForward = PR_TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4054,7 +4046,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
|
|||||||
aPos->mAmount = eSelectLine;
|
aPos->mAmount = eSelectLine;
|
||||||
aPos->mStartOffset = 0;
|
aPos->mStartOffset = 0;
|
||||||
aPos->mEatingWS = PR_FALSE;
|
aPos->mEatingWS = PR_FALSE;
|
||||||
aPos->mPreferLeft = !(aPos->mDirection == eDirNext);
|
aPos->mAttachForward = !(aPos->mDirection == eDirNext);
|
||||||
if (aPos->mDirection == eDirPrevious)
|
if (aPos->mDirection == eDirPrevious)
|
||||||
aPos->mStartOffset = -1;//start from end
|
aPos->mStartOffset = -1;//start from end
|
||||||
return aBlockFrame->PeekOffset(aPresContext, aPos);
|
return aBlockFrame->PeekOffset(aPresContext, aPos);
|
||||||
@@ -4071,7 +4063,7 @@ nsPeekOffsetStruct nsIFrame::GetExtremeCaretPosition(PRBool aStart)
|
|||||||
FrameContentRange range = GetRangeForFrame(targetFrame.frame);
|
FrameContentRange range = GetRangeForFrame(targetFrame.frame);
|
||||||
result.mResultContent = range.content;
|
result.mResultContent = range.content;
|
||||||
result.mContentOffset = aStart ? range.start : range.end;
|
result.mContentOffset = aStart ? range.start : range.end;
|
||||||
result.mPreferLeft = (result.mContentOffset == range.start);
|
result.mAttachForward = (result.mContentOffset == range.start);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4208,7 +4200,7 @@ nsFrame::PeekOffsetParagraph(nsPresContext* aPresContext,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
nsFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
||||||
{
|
{
|
||||||
if (!aPos || !aPos->mShell)
|
if (!aPos)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
nsresult result = NS_ERROR_FAILURE;
|
nsresult result = NS_ERROR_FAILURE;
|
||||||
nsPoint point;
|
nsPoint point;
|
||||||
@@ -4260,16 +4252,13 @@ nsFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
|||||||
}//drop into no amount
|
}//drop into no amount
|
||||||
case eSelectNoAmount:
|
case eSelectNoAmount:
|
||||||
{
|
{
|
||||||
nsPresContext *context = aPos->mShell->GetPresContext();
|
|
||||||
if (!context)
|
|
||||||
return NS_OK;
|
|
||||||
nsIView* view;
|
nsIView* view;
|
||||||
nsPoint offset;
|
nsPoint offset;
|
||||||
GetOffsetFromView(offset, &view);
|
GetOffsetFromView(offset, &view);
|
||||||
ContentOffsets offsets = GetContentOffsetsFromPoint(point - offset);
|
ContentOffsets offsets = GetContentOffsetsFromPoint(point - offset);
|
||||||
aPos->mResultContent = offsets.content;
|
aPos->mResultContent = offsets.content;
|
||||||
aPos->mContentOffset = offsets.offset;
|
aPos->mContentOffset = offsets.offset;
|
||||||
aPos->mPreferLeft = offsets.associateWithNext;
|
aPos->mAttachForward = offsets.associateWithNext;
|
||||||
result = offsets.content ? NS_OK : NS_ERROR_FAILURE;
|
result = offsets.content ? NS_OK : NS_ERROR_FAILURE;
|
||||||
}break;
|
}break;
|
||||||
case eSelectLine :
|
case eSelectLine :
|
||||||
@@ -4401,7 +4390,7 @@ nsFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
|||||||
FrameContentRange range = GetRangeForFrame(targetFrame.frame);
|
FrameContentRange range = GetRangeForFrame(targetFrame.frame);
|
||||||
aPos->mResultContent = range.content;
|
aPos->mResultContent = range.content;
|
||||||
aPos->mContentOffset = endOfLine ? range.end : range.start;
|
aPos->mContentOffset = endOfLine ? range.end : range.start;
|
||||||
aPos->mPreferLeft = (aPos->mContentOffset == range.start);
|
aPos->mAttachForward = (aPos->mContentOffset == range.start);
|
||||||
if (!range.content)
|
if (!range.content)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -61,68 +61,105 @@ class nsIPresShell;
|
|||||||
|
|
||||||
enum EWordMovementType { eStartWord, eEndWord, eDefaultBehavior };
|
enum EWordMovementType { eStartWord, eEndWord, eDefaultBehavior };
|
||||||
|
|
||||||
/*PeekOffsetStruct
|
/** PeekOffsetStruct is used to group various arguments (both input and output)
|
||||||
* @param mShell is used to get the PresContext useful for measuring text etc.
|
* that are passed to nsFrame::PeekOffset(). See below for the description of
|
||||||
* @param mDesiredX is the "desired" location of the new caret
|
* individual arguments.
|
||||||
* @param mAmount eWord, eCharacter, eLine
|
*/
|
||||||
* @param mDirection enum defined in this file to be eForward or eBackward
|
|
||||||
* @param mStartOffset start offset to start the peek. 0 == beginning -1 = end
|
|
||||||
* @param mResultContent content that actually is the next/previous
|
|
||||||
* @param mResultOffset offset for result content
|
|
||||||
* @param mResultFrame resulting frame for peeking
|
|
||||||
* @param mEatingWS boolean to tell us the state of our search for Next/Prev
|
|
||||||
* @param mPreferLeft true = prev line end, false = next line begin
|
|
||||||
* @param mJumpLines if this is true then it's ok to cross lines while peeking
|
|
||||||
* @param mScrollViewStop if this is true then stop peeking across scroll view boundary
|
|
||||||
* @param mWordMovementType an enum that determines whether to prefer the start or end of a word
|
|
||||||
* or to use the default beahvior, which is a combination of
|
|
||||||
* direction and the platform-based pref
|
|
||||||
* "layout.word_select.eat_space_to_next_word"
|
|
||||||
*/
|
|
||||||
struct nsPeekOffsetStruct
|
struct nsPeekOffsetStruct
|
||||||
{
|
{
|
||||||
void SetData(nsIPresShell *aShell,
|
void SetData(nsSelectionAmount aAmount,
|
||||||
nscoord aDesiredX,
|
|
||||||
nsSelectionAmount aAmount,
|
|
||||||
nsDirection aDirection,
|
nsDirection aDirection,
|
||||||
PRInt32 aStartOffset,
|
PRInt32 aStartOffset,
|
||||||
PRBool aEatingWS,
|
nscoord aDesiredX,
|
||||||
PRBool aPreferLeft,
|
|
||||||
PRBool aJumpLines,
|
PRBool aJumpLines,
|
||||||
PRBool aScrollViewStop,
|
PRBool aScrollViewStop,
|
||||||
PRBool aIsKeyboardSelect,
|
PRBool aIsKeyboardSelect,
|
||||||
PRBool aVisual,
|
PRBool aVisual,
|
||||||
EWordMovementType aWordMovementType = eDefaultBehavior )
|
EWordMovementType aWordMovementType = eDefaultBehavior)
|
||||||
{
|
|
||||||
mShell=aShell;
|
{
|
||||||
mDesiredX=aDesiredX;
|
mAmount = aAmount;
|
||||||
mAmount=aAmount;
|
mDirection = aDirection;
|
||||||
mDirection=aDirection;
|
mStartOffset = aStartOffset;
|
||||||
mStartOffset=aStartOffset;
|
mDesiredX = aDesiredX;
|
||||||
mEatingWS=aEatingWS;
|
mJumpLines = aJumpLines;
|
||||||
mPreferLeft=aPreferLeft;
|
mScrollViewStop = aScrollViewStop;
|
||||||
mJumpLines = aJumpLines;
|
mIsKeyboardSelect = aIsKeyboardSelect;
|
||||||
mScrollViewStop = aScrollViewStop;
|
mVisual = aVisual;
|
||||||
mIsKeyboardSelect = aIsKeyboardSelect;
|
mWordMovementType = aWordMovementType;
|
||||||
mVisual = aVisual;
|
mEatingWS = PR_FALSE;
|
||||||
mWordMovementType = aWordMovementType;
|
}
|
||||||
}
|
|
||||||
nsIPresShell *mShell;
|
// Note: Most arguments (input and output) are only used with certain values
|
||||||
nscoord mDesiredX;
|
// of mAmount. These values are indicated for each argument below.
|
||||||
|
// Arguments with no such indication are used with all values of mAmount.
|
||||||
|
|
||||||
|
/*** Input arguments ***/
|
||||||
|
// Note: The value of some of the input arguments may be changed upon exit.
|
||||||
|
|
||||||
|
// mAmount: The type of movement requested (by character, word, line, etc.)
|
||||||
nsSelectionAmount mAmount;
|
nsSelectionAmount mAmount;
|
||||||
|
|
||||||
|
// mDirection: eDirPrevious or eDirNext.
|
||||||
|
// Used with: eSelectCharacter, eSelectWord, eSelectLine, eSelectParagraph.
|
||||||
nsDirection mDirection;
|
nsDirection mDirection;
|
||||||
|
|
||||||
|
// mStartOffset: Offset into the content of the current frame where the peek starts.
|
||||||
|
// Used with: eSelectCharacter, eSelectWord
|
||||||
PRInt32 mStartOffset;
|
PRInt32 mStartOffset;
|
||||||
nsCOMPtr<nsIContent> mResultContent;
|
|
||||||
PRInt32 mContentOffset;
|
// mDesiredX: The desired x coordinate for the caret.
|
||||||
PRInt32 mContentOffsetEnd;
|
// Used with: eSelectLine.
|
||||||
nsIFrame *mResultFrame;
|
nscoord mDesiredX;
|
||||||
PRBool mEatingWS;
|
|
||||||
PRBool mPreferLeft;
|
// mJumpLines: Whether to allow jumping across line boundaries.
|
||||||
|
// Used with: eSelectCharacter, eSelectWord.
|
||||||
PRBool mJumpLines;
|
PRBool mJumpLines;
|
||||||
|
|
||||||
|
// mScrollViewStop: Whether to stop when reaching a scroll view boundary.
|
||||||
|
// Used with: eSelectCharacter, eSelectWord, eSelectLine.
|
||||||
PRBool mScrollViewStop;
|
PRBool mScrollViewStop;
|
||||||
|
|
||||||
|
// mIsKeyboardSelect: Whether the peeking is done in response to a keyboard action.
|
||||||
|
// Used with: eSelectWord.
|
||||||
PRBool mIsKeyboardSelect;
|
PRBool mIsKeyboardSelect;
|
||||||
|
|
||||||
|
// mVisual: Whether bidi caret behavior is visual (PR_TRUE) or logical (PR_FALSE).
|
||||||
|
// Used with: eSelectCharacter, eSelectWord.
|
||||||
PRBool mVisual;
|
PRBool mVisual;
|
||||||
|
|
||||||
|
// mWordMovementType: An enum that determines whether to prefer the start or end of a word
|
||||||
|
// or to use the default beahvior, which is a combination of
|
||||||
|
// direction and the platform-based pref
|
||||||
|
// "layout.word_select.eat_space_to_next_word"
|
||||||
EWordMovementType mWordMovementType;
|
EWordMovementType mWordMovementType;
|
||||||
|
|
||||||
|
/*** Output arguments ***/
|
||||||
|
|
||||||
|
// mResultContent: Content reached as a result of the peek.
|
||||||
|
nsCOMPtr<nsIContent> mResultContent;
|
||||||
|
|
||||||
|
// mContentOffset: Offset into content reached as a result of the peek.
|
||||||
|
PRInt32 mContentOffset;
|
||||||
|
|
||||||
|
// mResultFrame: Frame reached as a result of the peek.
|
||||||
|
// Used with: eSelectCharacter, eSelectWord.
|
||||||
|
nsIFrame *mResultFrame;
|
||||||
|
|
||||||
|
// mAttachForward: When the result position is between two frames,
|
||||||
|
// indicates which of the two frames the caret should be painted in.
|
||||||
|
// PR_FALSE means "the end of the frame logically before the caret",
|
||||||
|
// PR_TRUE means "the beginning of the frame logically after the caret".
|
||||||
|
// Used with: eSelectLine, eSelectBeginLine, eSelectEndLine.
|
||||||
|
PRBool mAttachForward;
|
||||||
|
|
||||||
|
/*** Arguments only used internally ***/
|
||||||
|
|
||||||
|
// mEatingWS: Used only internally, for recursive calls into PeekOffset.
|
||||||
|
// Shold be PR_FALSE upon initial call to PeekOffset.
|
||||||
|
// Used with: eSelectWord.
|
||||||
|
PRBool mEatingWS;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nsPrevNextBidiLevels
|
struct nsPrevNextBidiLevels
|
||||||
|
|||||||
@@ -1208,8 +1208,8 @@ nsFrameSelection::MoveCaret(PRUint32 aKeycode,
|
|||||||
|
|
||||||
//set data using mLimiter to stop on scroll views. If we have a limiter then we stop peeking
|
//set data using mLimiter to stop on scroll views. If we have a limiter then we stop peeking
|
||||||
//when we hit scrollable views. If no limiter then just let it go ahead
|
//when we hit scrollable views. If no limiter then just let it go ahead
|
||||||
pos.SetData(mShell, desiredX, aAmount, eDirPrevious, offsetused, PR_FALSE,
|
pos.SetData(aAmount, eDirPrevious, offsetused, desiredX,
|
||||||
PR_TRUE, PR_TRUE, mLimiter != nsnull, PR_TRUE, visualMovement);
|
PR_TRUE, mLimiter != nsnull, PR_TRUE, visualMovement);
|
||||||
|
|
||||||
nsBidiLevel baseLevel = nsBidiPresUtils::GetFrameBaseLevel(frame);
|
nsBidiLevel baseLevel = nsBidiPresUtils::GetFrameBaseLevel(frame);
|
||||||
|
|
||||||
@@ -1218,37 +1218,29 @@ nsFrameSelection::MoveCaret(PRUint32 aKeycode,
|
|||||||
case nsIDOMKeyEvent::DOM_VK_RIGHT :
|
case nsIDOMKeyEvent::DOM_VK_RIGHT :
|
||||||
InvalidateDesiredX();
|
InvalidateDesiredX();
|
||||||
pos.mDirection = (baseLevel & 1) ? eDirPrevious : eDirNext;
|
pos.mDirection = (baseLevel & 1) ? eDirPrevious : eDirNext;
|
||||||
PostReason(nsISelectionListener::KEYPRESS_REASON);
|
|
||||||
break;
|
break;
|
||||||
case nsIDOMKeyEvent::DOM_VK_LEFT : //no break
|
case nsIDOMKeyEvent::DOM_VK_LEFT : //no break
|
||||||
InvalidateDesiredX();
|
InvalidateDesiredX();
|
||||||
pos.mDirection = (baseLevel & 1) ? eDirNext : eDirPrevious;
|
pos.mDirection = (baseLevel & 1) ? eDirNext : eDirPrevious;
|
||||||
PostReason(nsISelectionListener::KEYPRESS_REASON);
|
|
||||||
break;
|
break;
|
||||||
case nsIDOMKeyEvent::DOM_VK_DOWN :
|
case nsIDOMKeyEvent::DOM_VK_DOWN :
|
||||||
pos.mAmount = eSelectLine;
|
pos.mAmount = eSelectLine;
|
||||||
pos.mDirection = eDirNext;//no break here
|
pos.mDirection = eDirNext;//no break here
|
||||||
PostReason(nsISelectionListener::KEYPRESS_REASON);
|
|
||||||
break;
|
break;
|
||||||
case nsIDOMKeyEvent::DOM_VK_UP :
|
case nsIDOMKeyEvent::DOM_VK_UP :
|
||||||
pos.mAmount = eSelectLine;
|
pos.mAmount = eSelectLine;
|
||||||
PostReason(nsISelectionListener::KEYPRESS_REASON);
|
|
||||||
break;
|
break;
|
||||||
case nsIDOMKeyEvent::DOM_VK_HOME :
|
case nsIDOMKeyEvent::DOM_VK_HOME :
|
||||||
InvalidateDesiredX();
|
InvalidateDesiredX();
|
||||||
pos.mAmount = eSelectBeginLine;
|
pos.mAmount = eSelectBeginLine;
|
||||||
tHint = HINTRIGHT;//stick to opposite of movement
|
|
||||||
PostReason(nsISelectionListener::KEYPRESS_REASON);
|
|
||||||
break;
|
break;
|
||||||
case nsIDOMKeyEvent::DOM_VK_END :
|
case nsIDOMKeyEvent::DOM_VK_END :
|
||||||
InvalidateDesiredX();
|
InvalidateDesiredX();
|
||||||
pos.mAmount = eSelectEndLine;
|
pos.mAmount = eSelectEndLine;
|
||||||
tHint = HINTLEFT;//stick to this line
|
|
||||||
PostReason(nsISelectionListener::KEYPRESS_REASON);
|
|
||||||
break;
|
break;
|
||||||
default :return NS_ERROR_FAILURE;
|
default :return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
pos.mPreferLeft = tHint;
|
PostReason(nsISelectionListener::KEYPRESS_REASON);
|
||||||
if (NS_SUCCEEDED(result = frame->PeekOffset(context, &pos)) && pos.mResultContent)
|
if (NS_SUCCEEDED(result = frame->PeekOffset(context, &pos)) && pos.mResultContent)
|
||||||
{
|
{
|
||||||
nsIFrame *theFrame;
|
nsIFrame *theFrame;
|
||||||
@@ -1257,7 +1249,7 @@ nsFrameSelection::MoveCaret(PRUint32 aKeycode,
|
|||||||
if (aKeycode == nsIDOMKeyEvent::DOM_VK_RIGHT ||
|
if (aKeycode == nsIDOMKeyEvent::DOM_VK_RIGHT ||
|
||||||
aKeycode == nsIDOMKeyEvent::DOM_VK_LEFT)
|
aKeycode == nsIDOMKeyEvent::DOM_VK_LEFT)
|
||||||
{
|
{
|
||||||
// For left/right, PeekOffset() sets pos.mResultFrame correctly, but does not set pos.mPreferLeft,
|
// For left/right, PeekOffset() sets pos.mResultFrame correctly, but does not set pos.mAttachForward,
|
||||||
// so determine the hint here based on the result frame and offset:
|
// so determine the hint here based on the result frame and offset:
|
||||||
// If we're at the end of a text frame, set the hint to HINTLEFT to indicate that we
|
// If we're at the end of a text frame, set the hint to HINTLEFT to indicate that we
|
||||||
// want the caret displayed at the end of this frame, not at the beginning of the next one.
|
// want the caret displayed at the end of this frame, not at the beginning of the next one.
|
||||||
@@ -1271,7 +1263,7 @@ nsFrameSelection::MoveCaret(PRUint32 aKeycode,
|
|||||||
} else {
|
} else {
|
||||||
// For up/down and home/end, pos.mResultFrame might not be set correctly, or not at all.
|
// For up/down and home/end, pos.mResultFrame might not be set correctly, or not at all.
|
||||||
// In these cases, get the frame based on the content and hint returned by PeekOffset().
|
// In these cases, get the frame based on the content and hint returned by PeekOffset().
|
||||||
tHint = (HINT)pos.mPreferLeft;
|
tHint = (HINT)pos.mAttachForward;
|
||||||
theFrame = GetFrameForNodeOffset(pos.mResultContent, pos.mContentOffset,
|
theFrame = GetFrameForNodeOffset(pos.mResultContent, pos.mContentOffset,
|
||||||
tHint, ¤tOffset);
|
tHint, ¤tOffset);
|
||||||
if (!theFrame)
|
if (!theFrame)
|
||||||
@@ -2286,8 +2278,8 @@ nsFrameSelection::HandleDrag(nsIFrame *aFrame, nsPoint aPoint)
|
|||||||
amount = eSelectEndLine;
|
amount = eSelectEndLine;
|
||||||
|
|
||||||
nsPeekOffsetStruct pos;
|
nsPeekOffsetStruct pos;
|
||||||
pos.SetData(mShell, 0, amount, direction, offsets.offset, PR_FALSE,
|
pos.SetData(amount, direction, offsets.offset, 0,
|
||||||
PR_TRUE, PR_FALSE, mLimiter != nsnull, PR_TRUE, PR_FALSE);
|
PR_FALSE, mLimiter != nsnull, PR_FALSE, PR_FALSE);
|
||||||
nsIFrame* frame = mShell->GetPrimaryFrameFor(offsets.content);
|
nsIFrame* frame = mShell->GetPrimaryFrameFor(offsets.content);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(result = frame->PeekOffset(mShell->GetPresContext(), &pos)) && pos.mResultContent) {
|
if (NS_SUCCEEDED(result = frame->PeekOffset(mShell->GetPresContext(), &pos)) && pos.mResultContent) {
|
||||||
@@ -2303,8 +2295,8 @@ nsFrameSelection::HandleDrag(nsIFrame *aFrame, nsPoint aPoint)
|
|||||||
nsPeekOffsetStruct pos;
|
nsPeekOffsetStruct pos;
|
||||||
//set data using mLimiter to stop on scroll views. If we have a limiter then we stop peeking
|
//set data using mLimiter to stop on scroll views. If we have a limiter then we stop peeking
|
||||||
//when we hit scrollable views. If no limiter then just let it go ahead
|
//when we hit scrollable views. If no limiter then just let it go ahead
|
||||||
pos.SetData(mShell, 0, eSelectDir, eDirNext, startPos, PR_FALSE,
|
pos.SetData(eSelectDir, eDirNext, startPos, 0,
|
||||||
PR_TRUE, PR_TRUE, mLimiter != nsnull, PR_FALSE);
|
PR_TRUE, mLimiter != nsnull, PR_FALSE, PR_TRUE);
|
||||||
mHint = HINT(beginOfContent);
|
mHint = HINT(beginOfContent);
|
||||||
HINT saveHint = mHint;
|
HINT saveHint = mHint;
|
||||||
if (NS_GET_EMBEDDING_LEVEL(newFrame) & 1)
|
if (NS_GET_EMBEDDING_LEVEL(newFrame) & 1)
|
||||||
|
|||||||
@@ -4979,8 +4979,6 @@ TryNextFrame:
|
|||||||
result = NS_ERROR_FAILURE; break;
|
result = NS_ERROR_FAILURE; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
aPos->mContentOffsetEnd = aPos->mContentOffset;
|
|
||||||
|
|
||||||
if (NS_FAILED(result)){
|
if (NS_FAILED(result)){
|
||||||
aPos->mResultContent = mContent;
|
aPos->mResultContent = mContent;
|
||||||
//aPos->mContentOffset = aPos->mStartOffset;
|
//aPos->mContentOffset = aPos->mStartOffset;
|
||||||
|
|||||||
Reference in New Issue
Block a user