зеркало из https://github.com/mozilla/gecko-dev.git
adding back in keyboard navigation. removing const from peekoffset to stop the const creep. changing peekoffset to do the right thing for content based peeking...
This commit is contained in:
Родитель
3c2da32000
Коммит
c0ad47dc75
|
@ -1592,10 +1592,14 @@ nsFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset, PRInt32* outFram
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsFrame::PeekOffset(nsSelectionAmount aAmount, nsDirection aDirection, PRInt32 aStartOffset,
|
nsFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
nsIContent **aResultContent, PRInt32 *aResultOffset, PRBool aEatingWS) const
|
nsDirection aDirection,
|
||||||
|
PRInt32 aStartOffset,
|
||||||
|
nsIContent **aResultContent,
|
||||||
|
PRInt32 *aContentOffset,
|
||||||
|
PRBool aEatingWS)
|
||||||
{
|
{
|
||||||
/* //this will use the nsFrameTraversal as the default peek method.
|
//this will use the nsFrameTraversal as the default peek method.
|
||||||
//this should change to use geometry and also look to ALL the child lists
|
//this should change to use geometry and also look to ALL the child lists
|
||||||
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
|
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
|
||||||
nsresult result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),LEAF,this);
|
nsresult result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),LEAF,this);
|
||||||
|
@ -1617,9 +1621,13 @@ nsFrame::PeekOffset(nsSelectionAmount aAmount, nsDirection aDirection, PRInt32
|
||||||
//we must CAST here to an nsIFrame. nsIFrame doesnt really follow the rules
|
//we must CAST here to an nsIFrame. nsIFrame doesnt really follow the rules
|
||||||
//for speed reasons
|
//for speed reasons
|
||||||
nsIFrame *newFrame = (nsIFrame *)isupports;
|
nsIFrame *newFrame = (nsIFrame *)isupports;
|
||||||
return newFrame->PeekOffset(aAmount, aDirection, aStartOffset, aResultFrame,
|
if (aDirection == eDirNext)
|
||||||
aFrameOffset, aContentOffset, aEatingWS);
|
return newFrame->PeekOffset(aAmount, aDirection, 0, aResultContent,
|
||||||
*/
|
aContentOffset, aEatingWS);
|
||||||
|
else
|
||||||
|
return newFrame->PeekOffset(aAmount, aDirection, -1, aResultContent,
|
||||||
|
aContentOffset, aEatingWS);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,8 +210,12 @@ public:
|
||||||
NS_IMETHOD VerifyTree() const;
|
NS_IMETHOD VerifyTree() const;
|
||||||
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, PRBool aSpread);
|
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, PRBool aSpread);
|
||||||
NS_IMETHOD GetSelected(PRBool *aSelected) const;
|
NS_IMETHOD GetSelected(PRBool *aSelected) const;
|
||||||
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount, nsDirection aDirection, PRInt32 aStartOffset,
|
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount,
|
||||||
nsIContent **aResultContent, PRInt32 *aResultOffset, PRBool aEatingWS) const;
|
nsDirection aDirection,
|
||||||
|
PRInt32 aStartOffset,
|
||||||
|
nsIContent **aResultContent,
|
||||||
|
PRInt32 *aContentOffset,
|
||||||
|
PRBool aEatingWS) ;
|
||||||
|
|
||||||
NS_IMETHOD GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const;
|
NS_IMETHOD GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const;
|
||||||
|
|
||||||
|
|
|
@ -239,9 +239,12 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, PRBool aSpread);
|
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, PRBool aSpread);
|
||||||
|
|
||||||
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount, nsDirection aDirection, PRInt32 aStartOffset,
|
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount,
|
||||||
nsIFrame **aResultFrame, PRInt32 *aFrameOffset, PRInt32 *aContentOffset,
|
nsDirection aDirection,
|
||||||
PRBool aEatingWS)const;
|
PRInt32 aStartOffset,
|
||||||
|
nsIContent **aResultContent,
|
||||||
|
PRInt32 *aContentOffset,
|
||||||
|
PRBool aEatingWS);
|
||||||
|
|
||||||
NS_IMETHOD GetOffsets(PRInt32 &start, PRInt32 &end)const;
|
NS_IMETHOD GetOffsets(PRInt32 &start, PRInt32 &end)const;
|
||||||
|
|
||||||
|
@ -1945,7 +1948,8 @@ nsTextFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset,
|
||||||
if (contentOffset > mContentLength)
|
if (contentOffset > mContentLength)
|
||||||
{
|
{
|
||||||
//this is not the frame we are looking for.
|
//this is not the frame we are looking for.
|
||||||
nsIFrame *nextInFlow = GetNextInFlow();
|
nsIFrame *nextInFlow;
|
||||||
|
nextInFlow = GetNextInFlow();
|
||||||
if (nextInFlow)
|
if (nextInFlow)
|
||||||
return nextInFlow->GetChildFrameContainingOffset(inContentOffset, outFrameContentOffset, outChildFrame);
|
return nextInFlow->GetChildFrameContainingOffset(inContentOffset, outFrameContentOffset, outChildFrame);
|
||||||
else
|
else
|
||||||
|
@ -1962,17 +1966,32 @@ NS_IMETHODIMP
|
||||||
nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
nsDirection aDirection,
|
nsDirection aDirection,
|
||||||
PRInt32 aStartOffset,
|
PRInt32 aStartOffset,
|
||||||
nsIFrame **aResultFrame,
|
nsIContent **aResultContent,
|
||||||
PRInt32 *aFrameOffset,
|
|
||||||
PRInt32 *aContentOffset,
|
PRInt32 *aContentOffset,
|
||||||
PRBool aEatingWS) const
|
PRBool aEatingWS)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
//default, no matter what grab next/ previous sibling.
|
//default, no matter what grab next/ previous sibling.
|
||||||
if (!aResultFrame || !aFrameOffset || !aContentOffset)
|
if (!aResultContent || !aContentOffset)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
if (aStartOffset < 0)
|
if (aStartOffset < 0)
|
||||||
aStartOffset = mContentLength;
|
aStartOffset = mContentLength + mContentOffset;
|
||||||
|
if (aStartOffset < mContentOffset){
|
||||||
|
aStartOffset = mContentOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aStartOffset > (mContentOffset + mContentLength)){
|
||||||
|
nsIFrame *nextInFlow;
|
||||||
|
nextInFlow = GetNextInFlow();
|
||||||
|
if (!nextInFlow){
|
||||||
|
NS_ASSERTION(PR_FALSE,"nsTextFrame::PeekOffset no more flow \n");
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
return nextInFlow->PeekOffset(aAmount,aDirection,aStartOffset,
|
||||||
|
aResultContent,aContentOffset,aEatingWS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PRUnichar wordBufMem[WORD_BUF_SIZE];
|
PRUnichar wordBufMem[WORD_BUF_SIZE];
|
||||||
PRUnichar paintBufMem[TEXT_BUF_SIZE];
|
PRUnichar paintBufMem[TEXT_BUF_SIZE];
|
||||||
PRInt32 indicies[TEXT_BUF_SIZE];
|
PRInt32 indicies[TEXT_BUF_SIZE];
|
||||||
|
@ -1999,11 +2018,10 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
|
|
||||||
switch (aAmount){
|
switch (aAmount){
|
||||||
case eSelectNoAmount : {
|
case eSelectNoAmount : {
|
||||||
*aResultFrame = this;
|
*aResultContent = mContent;
|
||||||
if (aStartOffset > mContentLength)
|
if (*aResultContent)
|
||||||
aStartOffset = mContentLength; //not ok normaly, but eNone means dont leave this frame
|
(*aResultContent)->AddRef();
|
||||||
*aFrameOffset = aStartOffset;
|
*aContentOffset = aStartOffset;
|
||||||
*aContentOffset = mContentOffset;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case eSelectCharacter : {
|
case eSelectCharacter : {
|
||||||
|
@ -2016,49 +2034,51 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
PRBool found = PR_TRUE;
|
PRBool found = PR_TRUE;
|
||||||
if (aDirection == eDirPrevious){
|
if (aDirection == eDirPrevious){
|
||||||
PRInt32 i;
|
PRInt32 i;
|
||||||
for (i = aStartOffset -1; i >=0; i--){
|
for (i = aStartOffset -1 - mContentOffset; i >=0; i--){
|
||||||
if (ip[i] < ip[aStartOffset]){
|
if (ip[i] < ip[aStartOffset - mContentOffset]){
|
||||||
*aFrameOffset = i;
|
*aContentOffset = i + mContentOffset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i <0){
|
if (i <0){
|
||||||
found = PR_FALSE;
|
found = PR_FALSE;
|
||||||
frameUsed = GetPrevInFlow();
|
frameUsed = GetPrevInFlow();
|
||||||
start = -1;
|
start = mContentOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aDirection == eDirNext){
|
else if (aDirection == eDirNext){
|
||||||
PRInt32 i;
|
PRInt32 i;
|
||||||
for (i = aStartOffset +1; i <= mContentLength; i++){
|
for (i = aStartOffset +1 - mContentOffset; i <= mContentLength; i++){
|
||||||
if (ip[i] > ip[aStartOffset]){
|
if (ip[i] > ip[aStartOffset - mContentOffset]){
|
||||||
*aFrameOffset = i;
|
*aContentOffset = i + mContentOffset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aStartOffset == 0 && (mFlags & TEXT_SKIP_LEADING_WS))
|
/* if (aStartOffset == 0 && (mFlags & TEXT_SKIP_LEADING_WS))
|
||||||
i--; //back up because we just skipped over some white space. why skip over the char also?
|
i--; //back up because we just skipped over some white space. why skip over the char also?
|
||||||
|
*/
|
||||||
if (i > mContentLength){
|
if (i > mContentLength){
|
||||||
found = PR_FALSE;
|
found = PR_FALSE;
|
||||||
frameUsed = GetNextInFlow();
|
frameUsed = GetNextInFlow();
|
||||||
start = 0;
|
start = mContentOffset + mContentLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found){
|
if (!found){
|
||||||
if (frameUsed){
|
if (frameUsed){
|
||||||
result = frameUsed->PeekOffset(eSelectCharacter, aDirection, start, aResultFrame,
|
result = frameUsed->PeekOffset(eSelectCharacter, aDirection, start, aResultContent,
|
||||||
aFrameOffset, aContentOffset, aEatingWS);
|
aContentOffset, aEatingWS);
|
||||||
}
|
}
|
||||||
else {//reached end ask the frame for help
|
else {//reached end ask the frame for help
|
||||||
result = nsFrame::PeekOffset(eSelectCharacter, aDirection, start, aResultFrame,
|
result = nsFrame::PeekOffset(eSelectCharacter, aDirection, start, aResultContent,
|
||||||
aFrameOffset, aContentOffset, aEatingWS);
|
aContentOffset, aEatingWS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
*aResultFrame = this;
|
*aResultContent = mContent;
|
||||||
*aContentOffset = mContentOffset;
|
if (*aResultContent)
|
||||||
|
(*aResultContent)->AddRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case eSelectWord : {
|
case eSelectWord : {
|
||||||
nsIFrame *frameUsed = nsnull;
|
nsIFrame *frameUsed = nsnull;
|
||||||
|
@ -2069,19 +2089,19 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
PRInt32 wordLen, contentLen;
|
PRInt32 wordLen, contentLen;
|
||||||
if (aDirection == eDirPrevious){
|
if (aDirection == eDirPrevious){
|
||||||
keepSearching = PR_TRUE;
|
keepSearching = PR_TRUE;
|
||||||
tx.Init(this, mContentOffset + aStartOffset);
|
tx.Init(this, aStartOffset);
|
||||||
if (tx.GetPrevWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
|
if (tx.GetPrevWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
|
||||||
if ((aEatingWS && !isWhitespace) || !aEatingWS){
|
if ((aEatingWS && !isWhitespace) || !aEatingWS){
|
||||||
*aFrameOffset = aStartOffset - contentLen;
|
*aContentOffset = aStartOffset - contentLen;
|
||||||
//check for whitespace next.
|
//check for whitespace next.
|
||||||
if (*aFrameOffset > 0)
|
if (*aContentOffset > mContentOffset)
|
||||||
keepSearching = PR_FALSE;//reached the beginning of a word
|
keepSearching = PR_FALSE;//reached the beginning of a word
|
||||||
aEatingWS = !isWhitespace;//nowhite space, just eat chars.
|
aEatingWS = !isWhitespace;//nowhite space, just eat chars.
|
||||||
while (isWhitespace && tx.GetPrevWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
|
while (isWhitespace && tx.GetPrevWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
|
||||||
*aFrameOffset -= contentLen;
|
*aContentOffset -= contentLen;
|
||||||
aEatingWS = PR_FALSE;
|
aEatingWS = PR_FALSE;
|
||||||
}
|
}
|
||||||
keepSearching = *aFrameOffset <= 0;
|
keepSearching = *aContentOffset <= mContentOffset;
|
||||||
if (!isWhitespace){
|
if (!isWhitespace){
|
||||||
if (!keepSearching)
|
if (!keepSearching)
|
||||||
found = PR_TRUE;
|
found = PR_TRUE;
|
||||||
|
@ -2090,7 +2110,7 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*aFrameOffset = mContentLength;
|
*aContentOffset = mContentLength + mContentOffset;
|
||||||
found = PR_TRUE;
|
found = PR_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2098,20 +2118,21 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
start = -1; //start at end
|
start = -1; //start at end
|
||||||
}
|
}
|
||||||
else if (aDirection == eDirNext){
|
else if (aDirection == eDirNext){
|
||||||
tx.Init(this, mContentOffset + aStartOffset );
|
tx.Init(this, aStartOffset );
|
||||||
if (tx.GetNextWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
|
if (tx.GetNextWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
|
||||||
if ((aEatingWS && isWhitespace) || !aEatingWS){
|
if ((aEatingWS && isWhitespace) || !aEatingWS){
|
||||||
*aFrameOffset = aStartOffset + contentLen;
|
*aContentOffset = aStartOffset + contentLen;
|
||||||
//check for whitespace next.
|
//check for whitespace next.
|
||||||
keepSearching = PR_TRUE;
|
keepSearching = PR_TRUE;
|
||||||
isWhitespace = PR_TRUE;
|
isWhitespace = PR_TRUE;
|
||||||
while (tx.GetNextWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE) && isWhitespace){
|
while (tx.GetNextWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE) && isWhitespace){
|
||||||
*aFrameOffset += contentLen;
|
*aContentOffset += contentLen;
|
||||||
keepSearching = PR_FALSE;
|
keepSearching = PR_FALSE;
|
||||||
|
isWhitespace = PR_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aEatingWS)
|
else if (aEatingWS)
|
||||||
*aFrameOffset = mContentOffset;
|
*aContentOffset = mContentOffset;
|
||||||
|
|
||||||
if (!isWhitespace){
|
if (!isWhitespace){
|
||||||
found = PR_TRUE;
|
found = PR_TRUE;
|
||||||
|
@ -2123,21 +2144,22 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
frameUsed = GetNextInFlow();
|
frameUsed = GetNextInFlow();
|
||||||
start = 0;
|
start = 0;
|
||||||
}
|
}
|
||||||
if (!found || (*aFrameOffset > mContentLength) || (*aFrameOffset < 0)){ //gone too far
|
if (!found || (*aContentOffset > (mContentOffset + mContentLength)) || (*aContentOffset < mContentOffset)){ //gone too far
|
||||||
if (frameUsed){
|
if (frameUsed){
|
||||||
result = frameUsed->PeekOffset(aAmount, aDirection, start, aResultFrame,
|
result = frameUsed->PeekOffset(aAmount, aDirection, start, aResultContent,
|
||||||
aFrameOffset, aContentOffset, aEatingWS);
|
aContentOffset, aEatingWS);
|
||||||
}
|
}
|
||||||
else {//reached end ask the frame for help
|
else {//reached end ask the frame for help
|
||||||
result = nsFrame::PeekOffset(aAmount, aDirection, start, aResultFrame,
|
result = nsFrame::PeekOffset(aAmount, aDirection, start, aResultContent,
|
||||||
aFrameOffset, aContentOffset, aEatingWS);
|
aContentOffset, aEatingWS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*aContentOffset = mContentOffset;
|
*aResultContent = mContent;
|
||||||
*aResultFrame = this;
|
if (*aResultContent)
|
||||||
|
(*aResultContent)->AddRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case eSelectLine :
|
case eSelectLine :
|
||||||
default: result = NS_ERROR_FAILURE; break;
|
default: result = NS_ERROR_FAILURE; break;
|
||||||
|
@ -2150,19 +2172,13 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
delete [] ip;
|
delete [] ip;
|
||||||
}
|
}
|
||||||
if (NS_FAILED(result)){
|
if (NS_FAILED(result)){
|
||||||
*aResultFrame = this;
|
*aResultContent = mContent;
|
||||||
*aContentOffset = mContentOffset;
|
if (*aResultContent)
|
||||||
if (eDirNext == aDirection ){
|
(*aResultContent)->AddRef();
|
||||||
*aFrameOffset = mContentLength;
|
*aContentOffset = aStartOffset;
|
||||||
}
|
|
||||||
else if (eDirPrevious == aDirection){
|
|
||||||
*aFrameOffset = 0;
|
|
||||||
}
|
|
||||||
result = NS_OK;
|
result = NS_OK;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
*/
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -1592,10 +1592,14 @@ nsFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset, PRInt32* outFram
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsFrame::PeekOffset(nsSelectionAmount aAmount, nsDirection aDirection, PRInt32 aStartOffset,
|
nsFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
nsIContent **aResultContent, PRInt32 *aResultOffset, PRBool aEatingWS) const
|
nsDirection aDirection,
|
||||||
|
PRInt32 aStartOffset,
|
||||||
|
nsIContent **aResultContent,
|
||||||
|
PRInt32 *aContentOffset,
|
||||||
|
PRBool aEatingWS)
|
||||||
{
|
{
|
||||||
/* //this will use the nsFrameTraversal as the default peek method.
|
//this will use the nsFrameTraversal as the default peek method.
|
||||||
//this should change to use geometry and also look to ALL the child lists
|
//this should change to use geometry and also look to ALL the child lists
|
||||||
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
|
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
|
||||||
nsresult result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),LEAF,this);
|
nsresult result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),LEAF,this);
|
||||||
|
@ -1617,9 +1621,13 @@ nsFrame::PeekOffset(nsSelectionAmount aAmount, nsDirection aDirection, PRInt32
|
||||||
//we must CAST here to an nsIFrame. nsIFrame doesnt really follow the rules
|
//we must CAST here to an nsIFrame. nsIFrame doesnt really follow the rules
|
||||||
//for speed reasons
|
//for speed reasons
|
||||||
nsIFrame *newFrame = (nsIFrame *)isupports;
|
nsIFrame *newFrame = (nsIFrame *)isupports;
|
||||||
return newFrame->PeekOffset(aAmount, aDirection, aStartOffset, aResultFrame,
|
if (aDirection == eDirNext)
|
||||||
aFrameOffset, aContentOffset, aEatingWS);
|
return newFrame->PeekOffset(aAmount, aDirection, 0, aResultContent,
|
||||||
*/
|
aContentOffset, aEatingWS);
|
||||||
|
else
|
||||||
|
return newFrame->PeekOffset(aAmount, aDirection, -1, aResultContent,
|
||||||
|
aContentOffset, aEatingWS);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,8 +210,12 @@ public:
|
||||||
NS_IMETHOD VerifyTree() const;
|
NS_IMETHOD VerifyTree() const;
|
||||||
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, PRBool aSpread);
|
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, PRBool aSpread);
|
||||||
NS_IMETHOD GetSelected(PRBool *aSelected) const;
|
NS_IMETHOD GetSelected(PRBool *aSelected) const;
|
||||||
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount, nsDirection aDirection, PRInt32 aStartOffset,
|
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount,
|
||||||
nsIContent **aResultContent, PRInt32 *aResultOffset, PRBool aEatingWS) const;
|
nsDirection aDirection,
|
||||||
|
PRInt32 aStartOffset,
|
||||||
|
nsIContent **aResultContent,
|
||||||
|
PRInt32 *aContentOffset,
|
||||||
|
PRBool aEatingWS) ;
|
||||||
|
|
||||||
NS_IMETHOD GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const;
|
NS_IMETHOD GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const;
|
||||||
|
|
||||||
|
|
|
@ -239,9 +239,12 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, PRBool aSpread);
|
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, PRBool aSpread);
|
||||||
|
|
||||||
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount, nsDirection aDirection, PRInt32 aStartOffset,
|
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount,
|
||||||
nsIFrame **aResultFrame, PRInt32 *aFrameOffset, PRInt32 *aContentOffset,
|
nsDirection aDirection,
|
||||||
PRBool aEatingWS)const;
|
PRInt32 aStartOffset,
|
||||||
|
nsIContent **aResultContent,
|
||||||
|
PRInt32 *aContentOffset,
|
||||||
|
PRBool aEatingWS);
|
||||||
|
|
||||||
NS_IMETHOD GetOffsets(PRInt32 &start, PRInt32 &end)const;
|
NS_IMETHOD GetOffsets(PRInt32 &start, PRInt32 &end)const;
|
||||||
|
|
||||||
|
@ -1945,7 +1948,8 @@ nsTextFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset,
|
||||||
if (contentOffset > mContentLength)
|
if (contentOffset > mContentLength)
|
||||||
{
|
{
|
||||||
//this is not the frame we are looking for.
|
//this is not the frame we are looking for.
|
||||||
nsIFrame *nextInFlow = GetNextInFlow();
|
nsIFrame *nextInFlow;
|
||||||
|
nextInFlow = GetNextInFlow();
|
||||||
if (nextInFlow)
|
if (nextInFlow)
|
||||||
return nextInFlow->GetChildFrameContainingOffset(inContentOffset, outFrameContentOffset, outChildFrame);
|
return nextInFlow->GetChildFrameContainingOffset(inContentOffset, outFrameContentOffset, outChildFrame);
|
||||||
else
|
else
|
||||||
|
@ -1962,17 +1966,32 @@ NS_IMETHODIMP
|
||||||
nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
nsDirection aDirection,
|
nsDirection aDirection,
|
||||||
PRInt32 aStartOffset,
|
PRInt32 aStartOffset,
|
||||||
nsIFrame **aResultFrame,
|
nsIContent **aResultContent,
|
||||||
PRInt32 *aFrameOffset,
|
|
||||||
PRInt32 *aContentOffset,
|
PRInt32 *aContentOffset,
|
||||||
PRBool aEatingWS) const
|
PRBool aEatingWS)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
//default, no matter what grab next/ previous sibling.
|
//default, no matter what grab next/ previous sibling.
|
||||||
if (!aResultFrame || !aFrameOffset || !aContentOffset)
|
if (!aResultContent || !aContentOffset)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
if (aStartOffset < 0)
|
if (aStartOffset < 0)
|
||||||
aStartOffset = mContentLength;
|
aStartOffset = mContentLength + mContentOffset;
|
||||||
|
if (aStartOffset < mContentOffset){
|
||||||
|
aStartOffset = mContentOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aStartOffset > (mContentOffset + mContentLength)){
|
||||||
|
nsIFrame *nextInFlow;
|
||||||
|
nextInFlow = GetNextInFlow();
|
||||||
|
if (!nextInFlow){
|
||||||
|
NS_ASSERTION(PR_FALSE,"nsTextFrame::PeekOffset no more flow \n");
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
return nextInFlow->PeekOffset(aAmount,aDirection,aStartOffset,
|
||||||
|
aResultContent,aContentOffset,aEatingWS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PRUnichar wordBufMem[WORD_BUF_SIZE];
|
PRUnichar wordBufMem[WORD_BUF_SIZE];
|
||||||
PRUnichar paintBufMem[TEXT_BUF_SIZE];
|
PRUnichar paintBufMem[TEXT_BUF_SIZE];
|
||||||
PRInt32 indicies[TEXT_BUF_SIZE];
|
PRInt32 indicies[TEXT_BUF_SIZE];
|
||||||
|
@ -1999,11 +2018,10 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
|
|
||||||
switch (aAmount){
|
switch (aAmount){
|
||||||
case eSelectNoAmount : {
|
case eSelectNoAmount : {
|
||||||
*aResultFrame = this;
|
*aResultContent = mContent;
|
||||||
if (aStartOffset > mContentLength)
|
if (*aResultContent)
|
||||||
aStartOffset = mContentLength; //not ok normaly, but eNone means dont leave this frame
|
(*aResultContent)->AddRef();
|
||||||
*aFrameOffset = aStartOffset;
|
*aContentOffset = aStartOffset;
|
||||||
*aContentOffset = mContentOffset;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case eSelectCharacter : {
|
case eSelectCharacter : {
|
||||||
|
@ -2016,49 +2034,51 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
PRBool found = PR_TRUE;
|
PRBool found = PR_TRUE;
|
||||||
if (aDirection == eDirPrevious){
|
if (aDirection == eDirPrevious){
|
||||||
PRInt32 i;
|
PRInt32 i;
|
||||||
for (i = aStartOffset -1; i >=0; i--){
|
for (i = aStartOffset -1 - mContentOffset; i >=0; i--){
|
||||||
if (ip[i] < ip[aStartOffset]){
|
if (ip[i] < ip[aStartOffset - mContentOffset]){
|
||||||
*aFrameOffset = i;
|
*aContentOffset = i + mContentOffset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i <0){
|
if (i <0){
|
||||||
found = PR_FALSE;
|
found = PR_FALSE;
|
||||||
frameUsed = GetPrevInFlow();
|
frameUsed = GetPrevInFlow();
|
||||||
start = -1;
|
start = mContentOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aDirection == eDirNext){
|
else if (aDirection == eDirNext){
|
||||||
PRInt32 i;
|
PRInt32 i;
|
||||||
for (i = aStartOffset +1; i <= mContentLength; i++){
|
for (i = aStartOffset +1 - mContentOffset; i <= mContentLength; i++){
|
||||||
if (ip[i] > ip[aStartOffset]){
|
if (ip[i] > ip[aStartOffset - mContentOffset]){
|
||||||
*aFrameOffset = i;
|
*aContentOffset = i + mContentOffset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aStartOffset == 0 && (mFlags & TEXT_SKIP_LEADING_WS))
|
/* if (aStartOffset == 0 && (mFlags & TEXT_SKIP_LEADING_WS))
|
||||||
i--; //back up because we just skipped over some white space. why skip over the char also?
|
i--; //back up because we just skipped over some white space. why skip over the char also?
|
||||||
|
*/
|
||||||
if (i > mContentLength){
|
if (i > mContentLength){
|
||||||
found = PR_FALSE;
|
found = PR_FALSE;
|
||||||
frameUsed = GetNextInFlow();
|
frameUsed = GetNextInFlow();
|
||||||
start = 0;
|
start = mContentOffset + mContentLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found){
|
if (!found){
|
||||||
if (frameUsed){
|
if (frameUsed){
|
||||||
result = frameUsed->PeekOffset(eSelectCharacter, aDirection, start, aResultFrame,
|
result = frameUsed->PeekOffset(eSelectCharacter, aDirection, start, aResultContent,
|
||||||
aFrameOffset, aContentOffset, aEatingWS);
|
aContentOffset, aEatingWS);
|
||||||
}
|
}
|
||||||
else {//reached end ask the frame for help
|
else {//reached end ask the frame for help
|
||||||
result = nsFrame::PeekOffset(eSelectCharacter, aDirection, start, aResultFrame,
|
result = nsFrame::PeekOffset(eSelectCharacter, aDirection, start, aResultContent,
|
||||||
aFrameOffset, aContentOffset, aEatingWS);
|
aContentOffset, aEatingWS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
*aResultFrame = this;
|
*aResultContent = mContent;
|
||||||
*aContentOffset = mContentOffset;
|
if (*aResultContent)
|
||||||
|
(*aResultContent)->AddRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case eSelectWord : {
|
case eSelectWord : {
|
||||||
nsIFrame *frameUsed = nsnull;
|
nsIFrame *frameUsed = nsnull;
|
||||||
|
@ -2069,19 +2089,19 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
PRInt32 wordLen, contentLen;
|
PRInt32 wordLen, contentLen;
|
||||||
if (aDirection == eDirPrevious){
|
if (aDirection == eDirPrevious){
|
||||||
keepSearching = PR_TRUE;
|
keepSearching = PR_TRUE;
|
||||||
tx.Init(this, mContentOffset + aStartOffset);
|
tx.Init(this, aStartOffset);
|
||||||
if (tx.GetPrevWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
|
if (tx.GetPrevWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
|
||||||
if ((aEatingWS && !isWhitespace) || !aEatingWS){
|
if ((aEatingWS && !isWhitespace) || !aEatingWS){
|
||||||
*aFrameOffset = aStartOffset - contentLen;
|
*aContentOffset = aStartOffset - contentLen;
|
||||||
//check for whitespace next.
|
//check for whitespace next.
|
||||||
if (*aFrameOffset > 0)
|
if (*aContentOffset > mContentOffset)
|
||||||
keepSearching = PR_FALSE;//reached the beginning of a word
|
keepSearching = PR_FALSE;//reached the beginning of a word
|
||||||
aEatingWS = !isWhitespace;//nowhite space, just eat chars.
|
aEatingWS = !isWhitespace;//nowhite space, just eat chars.
|
||||||
while (isWhitespace && tx.GetPrevWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
|
while (isWhitespace && tx.GetPrevWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
|
||||||
*aFrameOffset -= contentLen;
|
*aContentOffset -= contentLen;
|
||||||
aEatingWS = PR_FALSE;
|
aEatingWS = PR_FALSE;
|
||||||
}
|
}
|
||||||
keepSearching = *aFrameOffset <= 0;
|
keepSearching = *aContentOffset <= mContentOffset;
|
||||||
if (!isWhitespace){
|
if (!isWhitespace){
|
||||||
if (!keepSearching)
|
if (!keepSearching)
|
||||||
found = PR_TRUE;
|
found = PR_TRUE;
|
||||||
|
@ -2090,7 +2110,7 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*aFrameOffset = mContentLength;
|
*aContentOffset = mContentLength + mContentOffset;
|
||||||
found = PR_TRUE;
|
found = PR_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2098,20 +2118,21 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
start = -1; //start at end
|
start = -1; //start at end
|
||||||
}
|
}
|
||||||
else if (aDirection == eDirNext){
|
else if (aDirection == eDirNext){
|
||||||
tx.Init(this, mContentOffset + aStartOffset );
|
tx.Init(this, aStartOffset );
|
||||||
if (tx.GetNextWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
|
if (tx.GetNextWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE)){
|
||||||
if ((aEatingWS && isWhitespace) || !aEatingWS){
|
if ((aEatingWS && isWhitespace) || !aEatingWS){
|
||||||
*aFrameOffset = aStartOffset + contentLen;
|
*aContentOffset = aStartOffset + contentLen;
|
||||||
//check for whitespace next.
|
//check for whitespace next.
|
||||||
keepSearching = PR_TRUE;
|
keepSearching = PR_TRUE;
|
||||||
isWhitespace = PR_TRUE;
|
isWhitespace = PR_TRUE;
|
||||||
while (tx.GetNextWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE) && isWhitespace){
|
while (tx.GetNextWord(PR_FALSE, wordLen, contentLen, isWhitespace, PR_FALSE) && isWhitespace){
|
||||||
*aFrameOffset += contentLen;
|
*aContentOffset += contentLen;
|
||||||
keepSearching = PR_FALSE;
|
keepSearching = PR_FALSE;
|
||||||
|
isWhitespace = PR_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aEatingWS)
|
else if (aEatingWS)
|
||||||
*aFrameOffset = mContentOffset;
|
*aContentOffset = mContentOffset;
|
||||||
|
|
||||||
if (!isWhitespace){
|
if (!isWhitespace){
|
||||||
found = PR_TRUE;
|
found = PR_TRUE;
|
||||||
|
@ -2123,21 +2144,22 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
frameUsed = GetNextInFlow();
|
frameUsed = GetNextInFlow();
|
||||||
start = 0;
|
start = 0;
|
||||||
}
|
}
|
||||||
if (!found || (*aFrameOffset > mContentLength) || (*aFrameOffset < 0)){ //gone too far
|
if (!found || (*aContentOffset > (mContentOffset + mContentLength)) || (*aContentOffset < mContentOffset)){ //gone too far
|
||||||
if (frameUsed){
|
if (frameUsed){
|
||||||
result = frameUsed->PeekOffset(aAmount, aDirection, start, aResultFrame,
|
result = frameUsed->PeekOffset(aAmount, aDirection, start, aResultContent,
|
||||||
aFrameOffset, aContentOffset, aEatingWS);
|
aContentOffset, aEatingWS);
|
||||||
}
|
}
|
||||||
else {//reached end ask the frame for help
|
else {//reached end ask the frame for help
|
||||||
result = nsFrame::PeekOffset(aAmount, aDirection, start, aResultFrame,
|
result = nsFrame::PeekOffset(aAmount, aDirection, start, aResultContent,
|
||||||
aFrameOffset, aContentOffset, aEatingWS);
|
aContentOffset, aEatingWS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*aContentOffset = mContentOffset;
|
*aResultContent = mContent;
|
||||||
*aResultFrame = this;
|
if (*aResultContent)
|
||||||
|
(*aResultContent)->AddRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case eSelectLine :
|
case eSelectLine :
|
||||||
default: result = NS_ERROR_FAILURE; break;
|
default: result = NS_ERROR_FAILURE; break;
|
||||||
|
@ -2150,19 +2172,13 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
|
||||||
delete [] ip;
|
delete [] ip;
|
||||||
}
|
}
|
||||||
if (NS_FAILED(result)){
|
if (NS_FAILED(result)){
|
||||||
*aResultFrame = this;
|
*aResultContent = mContent;
|
||||||
*aContentOffset = mContentOffset;
|
if (*aResultContent)
|
||||||
if (eDirNext == aDirection ){
|
(*aResultContent)->AddRef();
|
||||||
*aFrameOffset = mContentLength;
|
*aContentOffset = aStartOffset;
|
||||||
}
|
|
||||||
else if (eDirPrevious == aDirection){
|
|
||||||
*aFrameOffset = 0;
|
|
||||||
}
|
|
||||||
result = NS_OK;
|
result = NS_OK;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
*/
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
Загрузка…
Ссылка в новой задаче