зеркало из https://github.com/mozilla/gecko-dev.git
r= kin. fix for another parameter. fixing m13 bug with multiple selection.
This commit is contained in:
Родитель
c89ee29031
Коммит
dcbf3266bd
|
@ -179,9 +179,10 @@ public:
|
|||
* @param aContentOffset is the starting content boundary
|
||||
* @param aContentLength is the length of the content piece asking
|
||||
* @param aReturnDetails linkedlist of return values for the selection.
|
||||
* @param aSlowCheck will check using slow method with no shortcuts
|
||||
*/
|
||||
NS_IMETHOD LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength,
|
||||
SelectionDetails **aReturnDetails) = 0;
|
||||
SelectionDetails **aReturnDetails, PRBool aSlowCheck) = 0;
|
||||
|
||||
/** SetMouseDownState(PRBool);
|
||||
* sets the mouse state to aState for resons of drag state.
|
||||
|
|
|
@ -179,9 +179,10 @@ public:
|
|||
* @param aContentOffset is the starting content boundary
|
||||
* @param aContentLength is the length of the content piece asking
|
||||
* @param aReturnDetails linkedlist of return values for the selection.
|
||||
* @param aSlowCheck will check using slow method with no shortcuts
|
||||
*/
|
||||
NS_IMETHOD LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength,
|
||||
SelectionDetails **aReturnDetails) = 0;
|
||||
SelectionDetails **aReturnDetails, PRBool aSlowCheck) = 0;
|
||||
|
||||
/** SetMouseDownState(PRBool);
|
||||
* sets the mouse state to aState for resons of drag state.
|
||||
|
|
|
@ -157,13 +157,14 @@ public:
|
|||
|
||||
nsDirection GetDirection(){return mDirection;}
|
||||
void SetDirection(nsDirection aDir){mDirection = aDir;}
|
||||
NS_IMETHOD CopyRangeToAnchorFocus(nsIDOMRange *aRange);
|
||||
// NS_IMETHOD GetPrimaryFrameForRangeEndpoint(nsIDOMNode *aNode, PRInt32 aOffset, PRBool aIsEndNode, nsIFrame **aResultFrame);
|
||||
NS_IMETHOD GetPrimaryFrameForAnchorNode(nsIFrame **aResultFrame);
|
||||
NS_IMETHOD GetPrimaryFrameForFocusNode(nsIFrame **aResultFrame);
|
||||
NS_IMETHOD SetOriginalAnchorPoint(nsIDOMNode *aNode, PRInt32 aOffset);
|
||||
NS_IMETHOD GetOriginalAnchorPoint(nsIDOMNode **aNode, PRInt32 *aOffset);
|
||||
NS_IMETHOD LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength,
|
||||
SelectionDetails **aReturnDetails, SelectionType aType);
|
||||
SelectionDetails **aReturnDetails, SelectionType aType, PRBool aSlowCheck);
|
||||
NS_IMETHOD Repaint(nsIPresContext* aPresContext);
|
||||
|
||||
nsresult StartAutoScrollTimer(nsIPresContext *aPresContext, nsIFrame *aFrame, nsPoint& aPoint, PRUint32 aDelay);
|
||||
|
@ -219,7 +220,7 @@ public:
|
|||
NS_IMETHOD StopAutoScrollTimer();
|
||||
NS_IMETHOD EnableFrameNotification(PRBool aEnable){mNotifyFrames = aEnable; return NS_OK;}
|
||||
NS_IMETHOD LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength,
|
||||
SelectionDetails **aReturnDetails);
|
||||
SelectionDetails **aReturnDetails, PRBool aSlowCheck);
|
||||
NS_IMETHOD SetMouseDownState(PRBool aState);
|
||||
NS_IMETHOD GetMouseDownState(PRBool *aState);
|
||||
NS_IMETHOD GetSelection(SelectionType aType, nsIDOMSelection **aDomSelection);
|
||||
|
@ -1216,11 +1217,34 @@ nsRangeList::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA
|
|||
default :return NS_ERROR_FAILURE;
|
||||
}
|
||||
pos.mPreferLeft = mHint;
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(frame->PeekOffset(context, &pos)) && pos.mResultContent)
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(result = frame->PeekOffset(context, &pos)) && pos.mResultContent)
|
||||
{
|
||||
mHint = (HINT)pos.mPreferLeft;
|
||||
result = TakeFocus(pos.mResultContent, pos.mContentOffset, pos.mContentOffset, aContinue, PR_FALSE);
|
||||
}
|
||||
else if (NS_FAILED(result))
|
||||
{
|
||||
if (nsIDOMKeyEvent::DOM_VK_UP == aKeycode)
|
||||
{
|
||||
pos.mPreferLeft = HINTRIGHT;
|
||||
pos.mAmount = eSelectBeginLine;
|
||||
InvalidateDesiredX();
|
||||
}
|
||||
else if(nsIDOMKeyEvent::DOM_VK_DOWN == aKeycode)
|
||||
{
|
||||
pos.mPreferLeft = HINTLEFT;
|
||||
pos.mAmount = eSelectEndLine;
|
||||
InvalidateDesiredX();
|
||||
}
|
||||
if (nsIDOMKeyEvent::DOM_VK_UP == aKeycode || nsIDOMKeyEvent::DOM_VK_DOWN == aKeycode )
|
||||
{
|
||||
if (NS_SUCCEEDED(result = frame->PeekOffset(context, &pos)) && pos.mResultContent)
|
||||
{
|
||||
mHint = (HINT)pos.mPreferLeft;
|
||||
result = TakeFocus(pos.mResultContent, pos.mContentOffset, pos.mContentOffset, aContinue, PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NS_SUCCEEDED(result))
|
||||
result = mDomSelections[SELECTION_NORMAL]->ScrollIntoView();
|
||||
|
||||
|
@ -1453,7 +1477,7 @@ nsRangeList::TakeFocus(nsIContent *aNewFocus, PRUint32 aContentOffset,
|
|||
|
||||
NS_METHOD
|
||||
nsRangeList::LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength,
|
||||
SelectionDetails **aReturnDetails)
|
||||
SelectionDetails **aReturnDetails, PRBool aSlowCheck)
|
||||
{
|
||||
if (!aContent || !aReturnDetails)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
@ -1464,7 +1488,7 @@ nsRangeList::LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt
|
|||
PRInt8 j;
|
||||
for (j = (PRInt8) SELECTION_NORMAL; j < (PRInt8)NUM_SELECTIONTYPES; j++){
|
||||
if (mDomSelections[j])
|
||||
mDomSelections[j]->LookUpSelection(aContent, aContentOffset, aContentLength, aReturnDetails, (SelectionType)j);
|
||||
mDomSelections[j]->LookUpSelection(aContent, aContentOffset, aContentLength, aReturnDetails, (SelectionType)j, aSlowCheck);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2316,7 +2340,7 @@ nsDOMSelection::selectFrames(nsIPresContext* aPresContext, nsIDOMRange *aRange,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsDOMSelection::LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength,
|
||||
SelectionDetails **aReturnDetails, SelectionType aType)
|
||||
SelectionDetails **aReturnDetails, SelectionType aType, PRBool aSlowCheck)
|
||||
{
|
||||
PRInt32 cnt;
|
||||
nsresult rv = GetRangeCount(&cnt);
|
||||
|
@ -2402,7 +2426,7 @@ nsDOMSelection::LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PR
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (cnt > 1){
|
||||
if (cnt > 1 || aSlowCheck){
|
||||
//we only have to look at start offset because anything else would have been in the range
|
||||
PRInt32 resultnum = ComparePoints(startNode, startOffset
|
||||
,passedInNode, aContentOffset);
|
||||
|
@ -2413,6 +2437,7 @@ nsDOMSelection::LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PR
|
|||
if (resultnum <0)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!details){
|
||||
details = new SelectionDetails;
|
||||
newDetails = details;
|
||||
|
@ -2427,7 +2452,7 @@ nsDOMSelection::LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PR
|
|||
newDetails->mStart = 0;
|
||||
newDetails->mEnd = aContentLength;
|
||||
newDetails->mType = aType;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
@ -3061,6 +3086,7 @@ nsDOMSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir, PR
|
|||
getter_AddRefs(subRange));
|
||||
if (NS_FAILED(res) || !subRange)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
result = subRange->SetStart(startNode,startOffset);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
@ -3282,6 +3308,31 @@ nsDOMSelection::GetOriginalAnchorPoint(nsIDOMNode **aNode, PRInt32 *aOffset)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
utility function
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsDOMSelection::CopyRangeToAnchorFocus(nsIDOMRange *aRange)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> startNode;
|
||||
nsCOMPtr<nsIDOMNode> endNode;
|
||||
PRInt32 startOffset;
|
||||
PRInt32 endOffset;
|
||||
aRange->GetStartParent(getter_AddRefs(startNode));
|
||||
aRange->GetEndParent(getter_AddRefs(endNode));
|
||||
aRange->GetStartOffset(&startOffset);
|
||||
aRange->GetEndOffset(&endOffset);
|
||||
if (NS_FAILED(mAnchorFocusRange->SetStart(startNode,startOffset)))
|
||||
{
|
||||
if (NS_FAILED(mAnchorFocusRange->SetEnd(endNode,endOffset)))
|
||||
return NS_ERROR_FAILURE;//???
|
||||
if (NS_FAILED(mAnchorFocusRange->SetStart(startNode,startOffset)))
|
||||
return NS_ERROR_FAILURE;//???
|
||||
}
|
||||
else if (NS_FAILED(mAnchorFocusRange->SetEnd(endNode,endOffset)))
|
||||
return NS_ERROR_FAILURE;//???
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
Notes which might come in handy for extend:
|
||||
|
@ -3333,6 +3384,7 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
|||
return res;
|
||||
nsCOMPtr<nsIDOMRange> range;
|
||||
res = mAnchorFocusRange->Clone(getter_AddRefs(range));
|
||||
//range = mAnchorFocusRange;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> startNode;
|
||||
nsCOMPtr<nsIDOMNode> endNode;
|
||||
|
@ -3399,6 +3451,9 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
|||
else{
|
||||
selectFrames(presContext, difRange , PR_TRUE);
|
||||
}
|
||||
res = CopyRangeToAnchorFocus(range);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
}
|
||||
else if (result1 == 0 && result3 > 0){//2, a1
|
||||
//select from 2 to 1a
|
||||
|
@ -3418,6 +3473,9 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
|||
else
|
||||
#endif
|
||||
selectFrames(presContext, range, PR_TRUE);
|
||||
res = CopyRangeToAnchorFocus(range);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
}
|
||||
else if (result3 <= 0 && result2 >= 0) {//a,2,1 or a2,1 or a,21 or a21
|
||||
//deselect from 2 to 1
|
||||
|
@ -3444,6 +3502,9 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
|||
}
|
||||
else
|
||||
{
|
||||
res = CopyRangeToAnchorFocus(range);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
selectFrames(presContext, difRange, 0);//deselect now if fixup succeeded
|
||||
difRange->SetEnd(FetchEndParent(range),FetchEndOffset(range));
|
||||
selectFrames(presContext, difRange, PR_TRUE);//must reselect last node maybe more if fixup did something
|
||||
|
@ -3475,11 +3536,20 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
|||
if (FetchFocusNode() != FetchAnchorNode() || FetchFocusOffset() != FetchAnchorOffset() ){//if collapsed diff dont do anything
|
||||
res = difRange->SetStart(FetchFocusNode(), FetchFocusOffset());
|
||||
res |= difRange->SetEnd(FetchAnchorNode(), FetchAnchorOffset());
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
res = CopyRangeToAnchorFocus(range);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
//deselect from 1 to a
|
||||
selectFrames(presContext, difRange , PR_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = CopyRangeToAnchorFocus(range);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
}
|
||||
//select from a to 2
|
||||
selectFrames(presContext, range , PR_TRUE);
|
||||
}
|
||||
|
@ -3509,6 +3579,9 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
|||
}
|
||||
else
|
||||
{
|
||||
res = CopyRangeToAnchorFocus(range);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
selectFrames(presContext, difRange , PR_FALSE);
|
||||
difRange->SetStart(FetchStartParent(range),FetchStartOffset(range));
|
||||
selectFrames(presContext, difRange, PR_TRUE);//must reselect last node
|
||||
|
@ -3538,8 +3611,17 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
|||
if (FetchFocusNode() != FetchAnchorNode() || FetchFocusOffset() != FetchAnchorOffset() ){//if collapsed diff dont do anything
|
||||
res = difRange->SetStart(FetchAnchorNode(), FetchAnchorOffset());
|
||||
res |= difRange->SetEnd(FetchFocusNode(), FetchFocusOffset());
|
||||
res = CopyRangeToAnchorFocus(range);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
selectFrames(presContext, difRange, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = CopyRangeToAnchorFocus(range);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
}
|
||||
//select from 2 to a
|
||||
selectFrames(presContext, range , PR_TRUE);
|
||||
}
|
||||
|
@ -3570,6 +3652,10 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
|||
else {
|
||||
selectFrames(presContext, difRange, PR_TRUE);
|
||||
}
|
||||
res = CopyRangeToAnchorFocus(range);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
DEBUG_OUT_RANGE(range);
|
||||
|
@ -3580,21 +3666,6 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
|||
printf(" direction = 0 RIGHT TO LEFT\n");
|
||||
#endif
|
||||
SetDirection(dir);
|
||||
/*hack*/
|
||||
range->GetStartParent(getter_AddRefs(startNode));
|
||||
range->GetEndParent(getter_AddRefs(endNode));
|
||||
range->GetStartOffset(&startOffset);
|
||||
range->GetEndOffset(&endOffset);
|
||||
if (NS_FAILED(mAnchorFocusRange->SetStart(startNode,startOffset)))
|
||||
{
|
||||
if (NS_FAILED(mAnchorFocusRange->SetEnd(endNode,endOffset)))
|
||||
return NS_ERROR_FAILURE;//???
|
||||
if (NS_FAILED(mAnchorFocusRange->SetStart(startNode,startOffset)))
|
||||
return NS_ERROR_FAILURE;//???
|
||||
}
|
||||
else if (NS_FAILED(mAnchorFocusRange->SetEnd(endNode,endOffset)))
|
||||
return NS_ERROR_FAILURE;//???
|
||||
/*end hack*/
|
||||
#ifdef DEBUG_SELECTION
|
||||
if (aParentNode)
|
||||
{
|
||||
|
|
|
@ -56,7 +56,8 @@ public:
|
|||
NS_IMETHOD SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread);
|
||||
|
||||
NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout);
|
||||
|
||||
//override of nsFrame method
|
||||
NS_IMETHOD GetChildFrameContainingOffset(PRInt32 inContentOffset, PRBool inHint, PRInt32* outFrameContentOffset, nsIFrame **outChildFrame);
|
||||
protected:
|
||||
virtual PRIntn GetSkipSides() const;
|
||||
|
||||
|
@ -184,6 +185,21 @@ nsFirstLetterFrame::FindTextRuns(nsLineLayout& aLineLayout)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFirstLetterFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset, PRBool inHint, PRInt32* outFrameContentOffset, nsIFrame **outChildFrame)
|
||||
{
|
||||
nsIFrame *kid;
|
||||
nsresult result = FirstChild(nsnull, &kid);
|
||||
if (NS_SUCCEEDED(result) && kid)
|
||||
{
|
||||
return kid->GetChildFrameContainingOffset(inContentOffset, inHint, outFrameContentOffset, outChildFrame);
|
||||
}
|
||||
else
|
||||
return nsFrame::GetChildFrameContainingOffset(inContentOffset, inHint, outFrameContentOffset, outChildFrame);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFirstLetterFrame::Reflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aMetrics,
|
||||
|
|
|
@ -703,7 +703,7 @@ nsFrame::Paint(nsIPresContext* aPresContext,
|
|||
result = shell->GetFrameSelection(getter_AddRefs(frameSelection));
|
||||
if (NS_SUCCEEDED(result) && frameSelection){
|
||||
result = frameSelection->LookUpSelection(newContent, offset,
|
||||
1, &details);// last param notused
|
||||
1, &details, PR_FALSE);
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
@ -2243,7 +2243,7 @@ nsFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
|||
}
|
||||
//this block is now one child down from blockframe
|
||||
if (NS_FAILED(result) || !it || !blockFrame || !thisBlock)
|
||||
return result;
|
||||
return ((result) ? result : NS_ERROR_FAILURE);
|
||||
result = it->FindLineContaining(thisBlock, &thisLine);
|
||||
if (NS_FAILED(result) || thisLine <0)
|
||||
return result;
|
||||
|
|
|
@ -1276,7 +1276,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
|
|||
rv = GetContent(getter_AddRefs(content));
|
||||
if (NS_SUCCEEDED(rv) && content){
|
||||
rv = frameSelection->LookUpSelection(content, mContentOffset,
|
||||
mContentLength , &details);// last param notused
|
||||
mContentLength , &details, PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1718,7 +1718,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
|
|||
rv = GetContent(getter_AddRefs(content));
|
||||
if (NS_SUCCEEDED(rv)){
|
||||
rv = frameSelection->LookUpSelection(content, mContentOffset,
|
||||
mContentLength , &details);// last param notused
|
||||
mContentLength , &details, PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1820,7 +1820,7 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
|
|||
rv = GetContent(getter_AddRefs(content));
|
||||
if (NS_SUCCEEDED(rv)){
|
||||
rv = frameSelection->LookUpSelection(content, mContentOffset,
|
||||
mContentLength , &details);// last param notused
|
||||
mContentLength , &details, PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2093,10 +2093,10 @@ nsTextFrame::SetSelected(nsIPresContext* aPresContext,
|
|||
nsFrameState frameState;
|
||||
GetFrameState(&frameState);
|
||||
PRBool isSelected = ((frameState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT);
|
||||
if (!aSelected && !isSelected) //already set thanks
|
||||
/*if (!aSelected && !isSelected) //already set thanks
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
}*/
|
||||
|
||||
PRBool found = PR_FALSE;
|
||||
PRBool wholeContentFound = PR_FALSE;//if the entire content we look at is selected.
|
||||
|
@ -2154,7 +2154,28 @@ nsTextFrame::SetSelected(nsIPresContext* aPresContext,
|
|||
if ( aSelected )
|
||||
frameState |= NS_FRAME_SELECTED_CONTENT;
|
||||
else
|
||||
frameState &= ~NS_FRAME_SELECTED_CONTENT;
|
||||
{//we need to see if any other selection available.
|
||||
SelectionDetails *details = nsnull;
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsCOMPtr<nsIFrameSelection> frameSelection;
|
||||
|
||||
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv) && shell){
|
||||
rv = shell->GetFrameSelection(getter_AddRefs(frameSelection));
|
||||
if (NS_SUCCEEDED(rv) && frameSelection){
|
||||
nsCOMPtr<nsIContent> content;
|
||||
rv = GetContent(getter_AddRefs(content));
|
||||
if (NS_SUCCEEDED(rv) && content){
|
||||
rv = frameSelection->LookUpSelection(content, mContentOffset,
|
||||
mContentLength , &details, PR_TRUE);
|
||||
// PR_TRUE last param used here! we need to see if we are still selected. so no shortcut
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!details)
|
||||
frameState &= ~NS_FRAME_SELECTED_CONTENT;
|
||||
}
|
||||
SetFrameState(frameState);
|
||||
if (found){ //if range contains this frame...
|
||||
nsRect frameRect;
|
||||
|
|
|
@ -56,7 +56,8 @@ public:
|
|||
NS_IMETHOD SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread);
|
||||
|
||||
NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout);
|
||||
|
||||
//override of nsFrame method
|
||||
NS_IMETHOD GetChildFrameContainingOffset(PRInt32 inContentOffset, PRBool inHint, PRInt32* outFrameContentOffset, nsIFrame **outChildFrame);
|
||||
protected:
|
||||
virtual PRIntn GetSkipSides() const;
|
||||
|
||||
|
@ -184,6 +185,21 @@ nsFirstLetterFrame::FindTextRuns(nsLineLayout& aLineLayout)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFirstLetterFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset, PRBool inHint, PRInt32* outFrameContentOffset, nsIFrame **outChildFrame)
|
||||
{
|
||||
nsIFrame *kid;
|
||||
nsresult result = FirstChild(nsnull, &kid);
|
||||
if (NS_SUCCEEDED(result) && kid)
|
||||
{
|
||||
return kid->GetChildFrameContainingOffset(inContentOffset, inHint, outFrameContentOffset, outChildFrame);
|
||||
}
|
||||
else
|
||||
return nsFrame::GetChildFrameContainingOffset(inContentOffset, inHint, outFrameContentOffset, outChildFrame);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFirstLetterFrame::Reflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aMetrics,
|
||||
|
|
|
@ -703,7 +703,7 @@ nsFrame::Paint(nsIPresContext* aPresContext,
|
|||
result = shell->GetFrameSelection(getter_AddRefs(frameSelection));
|
||||
if (NS_SUCCEEDED(result) && frameSelection){
|
||||
result = frameSelection->LookUpSelection(newContent, offset,
|
||||
1, &details);// last param notused
|
||||
1, &details, PR_FALSE);
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
@ -2243,7 +2243,7 @@ nsFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
|||
}
|
||||
//this block is now one child down from blockframe
|
||||
if (NS_FAILED(result) || !it || !blockFrame || !thisBlock)
|
||||
return result;
|
||||
return ((result) ? result : NS_ERROR_FAILURE);
|
||||
result = it->FindLineContaining(thisBlock, &thisLine);
|
||||
if (NS_FAILED(result) || thisLine <0)
|
||||
return result;
|
||||
|
|
|
@ -1276,7 +1276,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
|
|||
rv = GetContent(getter_AddRefs(content));
|
||||
if (NS_SUCCEEDED(rv) && content){
|
||||
rv = frameSelection->LookUpSelection(content, mContentOffset,
|
||||
mContentLength , &details);// last param notused
|
||||
mContentLength , &details, PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1718,7 +1718,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
|
|||
rv = GetContent(getter_AddRefs(content));
|
||||
if (NS_SUCCEEDED(rv)){
|
||||
rv = frameSelection->LookUpSelection(content, mContentOffset,
|
||||
mContentLength , &details);// last param notused
|
||||
mContentLength , &details, PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1820,7 +1820,7 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
|
|||
rv = GetContent(getter_AddRefs(content));
|
||||
if (NS_SUCCEEDED(rv)){
|
||||
rv = frameSelection->LookUpSelection(content, mContentOffset,
|
||||
mContentLength , &details);// last param notused
|
||||
mContentLength , &details, PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2093,10 +2093,10 @@ nsTextFrame::SetSelected(nsIPresContext* aPresContext,
|
|||
nsFrameState frameState;
|
||||
GetFrameState(&frameState);
|
||||
PRBool isSelected = ((frameState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT);
|
||||
if (!aSelected && !isSelected) //already set thanks
|
||||
/*if (!aSelected && !isSelected) //already set thanks
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
}*/
|
||||
|
||||
PRBool found = PR_FALSE;
|
||||
PRBool wholeContentFound = PR_FALSE;//if the entire content we look at is selected.
|
||||
|
@ -2154,7 +2154,28 @@ nsTextFrame::SetSelected(nsIPresContext* aPresContext,
|
|||
if ( aSelected )
|
||||
frameState |= NS_FRAME_SELECTED_CONTENT;
|
||||
else
|
||||
frameState &= ~NS_FRAME_SELECTED_CONTENT;
|
||||
{//we need to see if any other selection available.
|
||||
SelectionDetails *details = nsnull;
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsCOMPtr<nsIFrameSelection> frameSelection;
|
||||
|
||||
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv) && shell){
|
||||
rv = shell->GetFrameSelection(getter_AddRefs(frameSelection));
|
||||
if (NS_SUCCEEDED(rv) && frameSelection){
|
||||
nsCOMPtr<nsIContent> content;
|
||||
rv = GetContent(getter_AddRefs(content));
|
||||
if (NS_SUCCEEDED(rv) && content){
|
||||
rv = frameSelection->LookUpSelection(content, mContentOffset,
|
||||
mContentLength , &details, PR_TRUE);
|
||||
// PR_TRUE last param used here! we need to see if we are still selected. so no shortcut
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!details)
|
||||
frameState &= ~NS_FRAME_SELECTED_CONTENT;
|
||||
}
|
||||
SetFrameState(frameState);
|
||||
if (found){ //if range contains this frame...
|
||||
nsRect frameRect;
|
||||
|
|
Загрузка…
Ссылка в новой задаче