fixing table selection again. also adding parameter to nsIFocusTracker that allows us to get the current caret location. I am also stopping nsTableRowFrame from putting blue border around itself since cells are a high enough granularity. made a change to nsIFrame GetPosition to remove some useless parameters ect. this caused me to change nsDOMEvent.cpp and some other places.

MJ


git-svn-id: svn://10.0.0.236/trunk@34640 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mjudge%netscape.com 1999-06-10 21:08:17 +00:00
parent 4062735a01
commit 21a15def92
18 changed files with 302 additions and 243 deletions

View File

@ -780,7 +780,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
if (NS_FAILED(aRange->GetEndParent(getter_AddRefs(endParent))) || !endParent)
return NS_ERROR_FAILURE;
cEndP = do_QueryInterface(endParent);
aRange->GetStartOffset(&endIndx);
aRange->GetEndOffset(&endIndx);
// short circuit when start node == end node
if (startParent == endParent)

View File

@ -384,10 +384,8 @@ NS_METHOD nsDOMEvent::GetRangeParent(nsIDOMNode** aRangeParent)
PRInt32 offset, endOffset;
if (NS_SUCCEEDED(targetFrame->GetPosition(*mPresContext,
(nsGUIEvent*)mEvent,
targetFrame,
mEvent->point.x,
&parent,
actualOffset,
offset,
endOffset))) {
if (parent && NS_SUCCEEDED(parent->QueryInterface(kIDOMNodeIID, (void**)aRangeParent))) {
@ -416,10 +414,8 @@ NS_METHOD nsDOMEvent::GetRangeOffset(PRInt32* aRangeOffset)
PRInt32 endOffset;
if (NS_SUCCEEDED(targetFrame->GetPosition(*mPresContext,
(nsGUIEvent*)mEvent,
targetFrame,
mEvent->point.x,
&parent,
actualOffset,
*aRangeOffset,
endOffset))) {
*aRangeOffset += actualOffset;

View File

@ -318,7 +318,7 @@ public:
PRUint32 aHFlags) const;
NS_IMETHOD DoCopy();
//nsIViewObserver interface
NS_IMETHOD Paint(nsIView *aView,

View File

@ -20,6 +20,9 @@
#include "nsISupports.h"
#include "nsIFrame.h"
class nsICaret;
// IID for the nsIFocusTracker interface
@ -53,6 +56,12 @@ public:
*/
NS_IMETHOD GetPrimaryFrameFor(nsIContent* aContent,
nsIFrame** aPrimaryFrame) const = 0;
/**
* GetCaret will return the nsICaret Interface from this FocusTracker
* usefull for getting screen coordinates of current selection
*/
NS_IMETHOD GetCaret(nsICaret **aCaret) = 0;
};

View File

@ -45,7 +45,7 @@ struct nsPoint;
struct nsRect;
struct nsStyleStruct;
class nsIDOMRange;
class nsICaret;
struct PRLogModuleInfo;
// IID for the nsIFrame interface
@ -416,13 +416,11 @@ public:
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus) = 0;
NS_IMETHOD GetPosition(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsIFrame * aNewFrame,
nsIContent ** aNewContent,
PRUint32& aAcutalContentOffset,
PRInt32& aOffset,
PRInt32& aOffsetEnd) = 0;
NS_IMETHOD GetPosition(nsIPresContext& aCX,
nscoord aXCoord,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd) = 0;
/**
@ -605,6 +603,7 @@ public:
* nsIFrame and the frame offset. THIS DOES NOT CHANGE SELECTION STATE
* uses frame's begin selection state to start. if no selection on this frame will
* return NS_ERROR_FAILURE
* @param aCaret is the caret interface to get geometry of the current selection
* @param aAmount eWord, eCharacter, eLine
* @param aDirection enum defined in this file to be eForward or eBackward
* @param aStartOffset start offset to start the peek. 0 == beginning -1 = end
@ -612,7 +611,7 @@ public:
* @param aResultOffset offset for result content
* @param aEatingWS boolean to tell us the state of our search for Next/Prev
*/
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount, nsDirection aDirection, PRInt32 aStartOffset,
NS_IMETHOD PeekOffset(nsICaret *aCaret, nsSelectionAmount aAmount, nsDirection aDirection, PRInt32 aStartOffset,
nsIContent **aResultContent, PRInt32 *aResultOffset, PRBool aEatingWS) = 0;
/**

View File

@ -780,7 +780,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
if (NS_FAILED(aRange->GetEndParent(getter_AddRefs(endParent))) || !endParent)
return NS_ERROR_FAILURE;
cEndP = do_QueryInterface(endParent);
aRange->GetStartOffset(&endIndx);
aRange->GetEndOffset(&endIndx);
// short circuit when start node == end node
if (startParent == endParent)

View File

@ -43,7 +43,7 @@
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsICaret.h"
#define STATUS_CHECK_RETURN_MACRO() {if (!mTracker) return NS_ERROR_FAILURE;}
@ -905,7 +905,7 @@ nsRangeList::HandleTextEvent(nsGUIEvent *aGUIEvent)
NS_IMETHODIMP
nsRangeList::HandleKeyEvent(nsGUIEvent *aGuiEvent)
{
if (!aGuiEvent)
if (!aGuiEvent)
return NS_ERROR_NULL_POINTER;
STATUS_CHECK_RETURN_MACRO();
nsresult result = NS_OK;
@ -916,6 +916,10 @@ if (!aGuiEvent)
nsSelectionAmount amount = eSelectCharacter;
if (keyEvent->isControl)
amount = eSelectWord;
nsCOMPtr<nsICaret> caret;
result = mTracker->GetCaret(getter_AddRefs(caret));
if (NS_FAILED(result))
return result;
switch (keyEvent->keyCode){
case nsIDOMUIEvent::VK_LEFT :
//we need to look for the previous PAINTED location to move the cursor to.
@ -935,7 +939,7 @@ if (!aGuiEvent)
nsCOMPtr<nsIContent> content = do_QueryInterface(weakNodeUsed);
if (content){
result = mTracker->GetPrimaryFrameFor(content, &frame);
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(frame->PeekOffset(amount, eDirPrevious, offsetused, getter_AddRefs(content), &offsetused, PR_FALSE)) && content){
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(frame->PeekOffset(caret, amount, eDirPrevious, offsetused, getter_AddRefs(content), &offsetused, PR_FALSE)) && content){
result = TakeFocus(content, offsetused, offsetused, keyEvent->isShift);
}
result = ScrollIntoView();
@ -960,7 +964,7 @@ if (!aGuiEvent)
nsCOMPtr<nsIContent> content = do_QueryInterface(weakNodeUsed);
if (content){
result = mTracker->GetPrimaryFrameFor(content, &frame);
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(frame->PeekOffset(amount, eDirNext, offsetused, getter_AddRefs(content), &offsetused, PR_FALSE)) && content){
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(frame->PeekOffset(caret, amount, eDirNext, offsetused, getter_AddRefs(content), &offsetused, PR_FALSE)) && content){
result = TakeFocus(content, offsetused, offsetused, keyEvent->isShift);
}
result = ScrollIntoView();
@ -969,30 +973,30 @@ if (!aGuiEvent)
break;
case nsIDOMUIEvent::VK_UP :
{
#if 0 //we need to look for the previous PAINTED location to move the cursor to.
amount = eSelectLine;
//we need to look for the previous PAINTED location to move the cursor to.
amount = eSelectLine;
#ifdef DEBUG_NAVIGATION
printf("debug vk left\n");
printf("debug vk left\n");
#endif
if (keyEvent->isShift || (GetDirection() == eDirPrevious)) { //f,a
offsetused = FetchFocusOffset();
weakNodeUsed = FetchFocusNode();
}
else {
offsetused = FetchAnchorOffset();
weakNodeUsed = FetchAnchorNode();
}
if (weakNodeUsed && offsetused >=0){
nsIFrame *frame;
nsCOMPtr<nsIContent> content = do_QueryInterface(weakNodeUsed);
if (content){
result = mTracker->GetPrimaryFrameFor(content, &frame);
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(frame->PeekOffset(amount, eDirPrevious, offsetused, getter_AddRefs(content), &offsetused, PR_FALSE)) && content){
result = TakeFocus(content, offsetused, offsetused, keyEvent->isShift);
}
result = ScrollIntoView();
if (keyEvent->isShift || (GetDirection() == eDirPrevious)) { //f,a
offsetused = FetchFocusOffset();
weakNodeUsed = FetchFocusNode();
}
else {
offsetused = FetchAnchorOffset();
weakNodeUsed = FetchAnchorNode();
}
if (weakNodeUsed && offsetused >=0){
nsIFrame *frame;
nsCOMPtr<nsIContent> content = do_QueryInterface(weakNodeUsed);
if (content){
result = mTracker->GetPrimaryFrameFor(content, &frame);
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(frame->PeekOffset(caret, amount, eDirPrevious, offsetused, getter_AddRefs(content), &offsetused, PR_FALSE)) && content){
result = TakeFocus(content, offsetused, offsetused, keyEvent->isShift);
}
result = ScrollIntoView();
}
}
#endif //0
}
break;
case nsIDOMUIEvent::VK_DOWN :
@ -1070,9 +1074,14 @@ nsRangeList::selectFrames(nsIDOMRange *aRange, PRBool aFlags)
content = do_QueryInterface(FetchStartParent(aRange), &result);
if (NS_FAILED(result))
return result;
result = mTracker->GetPrimaryFrameFor(content, &frame);
if (NS_SUCCEEDED(result) && frame)
frame->SetSelected(aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow
PRBool canContainChildren = PR_FALSE;
result = content->CanContainChildren(canContainChildren);
if (NS_SUCCEEDED(result) && !canContainChildren)
{
result = mTracker->GetPrimaryFrameFor(content, &frame);
if (NS_SUCCEEDED(result) && frame)
frame->SetSelected(aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow
}
//end start content
result = iter->First();
if (NS_SUCCEEDED(result))
@ -1096,9 +1105,14 @@ nsRangeList::selectFrames(nsIDOMRange *aRange, PRBool aFlags)
content = do_QueryInterface(FetchEndParent(aRange), &result);
if (NS_FAILED(result))
return result;
result = mTracker->GetPrimaryFrameFor(content, &frame);
if (NS_SUCCEEDED(result) && frame)
frame->SetSelected(aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow
canContainChildren = PR_FALSE;
result = content->CanContainChildren(canContainChildren);
if (NS_SUCCEEDED(result) && !canContainChildren)
{
result = mTracker->GetPrimaryFrameFor(content, &frame);
if (NS_SUCCEEDED(result) && frame)
frame->SetSelected(aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow
}
}
//end end parent
}
@ -1307,6 +1321,22 @@ nsRangeList::ScrollIntoView()
nsIFrame *frame;
nsCOMPtr<nsIDOMNode> node = dont_QueryInterface(FetchFocusNode());
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
PRBool canContainChildren = PR_FALSE;
result = content->CanContainChildren(canContainChildren);
if (NS_SUCCEEDED(result) && canContainChildren)
{
PRInt32 offset = FetchFocusOffset();
if (GetDirection() == eDirNext)
offset--;
if (offset >0)
{
nsCOMPtr<nsIContent> child;
result = content->ChildAt(offset, *getter_AddRefs(child));
if (NS_FAILED(result) || !child) //out of bounds?
return result;
content = child;//releases the focusnode
}
}
result = mTracker->GetPrimaryFrameFor(content,&frame);
if (NS_FAILED(result))
return result;

View File

@ -384,10 +384,8 @@ NS_METHOD nsDOMEvent::GetRangeParent(nsIDOMNode** aRangeParent)
PRInt32 offset, endOffset;
if (NS_SUCCEEDED(targetFrame->GetPosition(*mPresContext,
(nsGUIEvent*)mEvent,
targetFrame,
mEvent->point.x,
&parent,
actualOffset,
offset,
endOffset))) {
if (parent && NS_SUCCEEDED(parent->QueryInterface(kIDOMNodeIID, (void**)aRangeParent))) {
@ -416,10 +414,8 @@ NS_METHOD nsDOMEvent::GetRangeOffset(PRInt32* aRangeOffset)
PRInt32 endOffset;
if (NS_SUCCEEDED(targetFrame->GetPosition(*mPresContext,
(nsGUIEvent*)mEvent,
targetFrame,
mEvent->point.x,
&parent,
actualOffset,
*aRangeOffset,
endOffset))) {
*aRangeOffset += actualOffset;

View File

@ -884,8 +884,8 @@ nsFrame::HandlePress(nsIPresContext& aPresContext,
PRUint32 contentOffset = 0;
PRInt32 contentOffsetEnd = 0;
nsCOMPtr<nsIContent> newContent;
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent, this, getter_AddRefs(newContent),
contentOffset, startPos, contentOffsetEnd))){
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x, getter_AddRefs(newContent),
startPos, contentOffsetEnd))){
nsCOMPtr<nsIDOMSelection> selection;
if (NS_SUCCEEDED(shell->GetSelection(getter_AddRefs(selection)))){
nsCOMPtr<nsIFrameSelection> frameselection;
@ -893,7 +893,7 @@ nsFrame::HandlePress(nsIPresContext& aPresContext,
if (frameselection) {
if (NS_SUCCEEDED( rv )){
frameselection->SetMouseDownState(PR_TRUE);//not important if it fails here
frameselection->TakeFocus(newContent, startPos + contentOffset, contentOffsetEnd + contentOffset, inputEvent->isShift);
frameselection->TakeFocus(newContent, startPos , contentOffsetEnd , inputEvent->isShift);
}
}
}
@ -927,17 +927,16 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext,
nsresult rv = aPresContext.GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell) {
PRInt32 startPos = 0;
PRUint32 contentOffset = 0;
PRInt32 contentOffsetEnd = 0;
nsCOMPtr<nsIContent> newContent;
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent, this, getter_AddRefs(newContent),
contentOffset, startPos, contentOffsetEnd))){
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x, getter_AddRefs(newContent),
startPos, contentOffsetEnd))){
nsIDOMSelection *selection = nsnull;
if (NS_SUCCEEDED(shell->GetSelection(&selection))){
nsIFrameSelection* frameselection;
if (NS_SUCCEEDED(selection->QueryInterface(kIFrameSelection, (void **)&frameselection))) {
if (NS_SUCCEEDED( rv )){
frameselection->TakeFocus(newContent, startPos + contentOffset, contentOffsetEnd + contentOffset, PR_TRUE); //TRUE IS THE DIFFERENCE
frameselection->TakeFocus(newContent, startPos, contentOffsetEnd , PR_TRUE); //TRUE IS THE DIFFERENCE
}
NS_RELEASE(frameselection);
}
@ -959,13 +958,11 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsIPresContext& aPresContext,
//--------------------------------------------------------------------------
//-- GetPosition
//--------------------------------------------------------------------------
NS_IMETHODIMP nsFrame::GetPosition(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsIFrame * aNewFrame,
nsIContent ** aNewContent,
PRUint32& aAcutalContentOffset,
PRInt32& aOffset,
PRInt32& aOffsetEnd)
NS_IMETHODIMP nsFrame::GetPosition(nsIPresContext& aCX,
nscoord aXCoord,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd)
{
//default getposition will return parent as newcontent
//also aActualContentOffset will be 0
@ -978,12 +975,12 @@ NS_IMETHODIMP nsFrame::GetPosition(nsIPresContext& aPresContext,
if (*aNewContent){
PRInt32 index = 0;
nsresult result = (*aNewContent)->IndexOf(mContent, aOffset);
nsresult result = (*aNewContent)->IndexOf(mContent, aContentOffset);
if (NS_FAILED(result))
{
return result;
}
aOffsetEnd = aOffset +1;
aContentOffsetEnd = aContentOffset +1;
}
return NS_OK;
}
@ -1634,7 +1631,8 @@ nsFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset, PRInt32* outFram
}
NS_IMETHODIMP
nsFrame::PeekOffset(nsSelectionAmount aAmount,
nsFrame::PeekOffset(nsICaret *aCaret,
nsSelectionAmount aAmount,
nsDirection aDirection,
PRInt32 aStartOffset,
nsIContent **aResultContent,
@ -1664,10 +1662,10 @@ nsFrame::PeekOffset(nsSelectionAmount aAmount,
//for speed reasons
nsIFrame *newFrame = (nsIFrame *)isupports;
if (aDirection == eDirNext)
return newFrame->PeekOffset(aAmount, aDirection, 0, aResultContent,
return newFrame->PeekOffset(aCaret, aAmount, aDirection, 0, aResultContent,
aContentOffset, aEatingWS);
else
return newFrame->PeekOffset(aAmount, aDirection, -1, aResultContent,
return newFrame->PeekOffset(aCaret, aAmount, aDirection, -1, aResultContent,
aContentOffset, aEatingWS);
return NS_OK;

View File

@ -83,6 +83,7 @@
#define NS_FRAME_TRACE_REFLOW_OUT(_method, _status)
#endif
//----------------------------------------------------------------------
/**
@ -210,7 +211,8 @@ public:
NS_IMETHOD VerifyTree() const;
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread);
NS_IMETHOD GetSelected(PRBool *aSelected) const;
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount,
NS_IMETHOD PeekOffset(nsICaret *aCaret,
nsSelectionAmount aAmount,
nsDirection aDirection,
PRInt32 aStartOffset,
nsIContent **aResultContent,
@ -256,13 +258,11 @@ public:
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD GetPosition(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsIFrame * aNewFrame,
nsIContent ** aNewContent,
PRUint32& aAcutalContentOffset,
PRInt32& aOffset,
PRInt32& aOffsetEnd);
NS_IMETHOD GetPosition(nsIPresContext& aCX,
nscoord aXCoord,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd);
//--------------------------------------------------
// Additional methods

View File

@ -45,7 +45,7 @@ struct nsPoint;
struct nsRect;
struct nsStyleStruct;
class nsIDOMRange;
class nsICaret;
struct PRLogModuleInfo;
// IID for the nsIFrame interface
@ -416,13 +416,11 @@ public:
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus) = 0;
NS_IMETHOD GetPosition(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsIFrame * aNewFrame,
nsIContent ** aNewContent,
PRUint32& aAcutalContentOffset,
PRInt32& aOffset,
PRInt32& aOffsetEnd) = 0;
NS_IMETHOD GetPosition(nsIPresContext& aCX,
nscoord aXCoord,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd) = 0;
/**
@ -605,6 +603,7 @@ public:
* nsIFrame and the frame offset. THIS DOES NOT CHANGE SELECTION STATE
* uses frame's begin selection state to start. if no selection on this frame will
* return NS_ERROR_FAILURE
* @param aCaret is the caret interface to get geometry of the current selection
* @param aAmount eWord, eCharacter, eLine
* @param aDirection enum defined in this file to be eForward or eBackward
* @param aStartOffset start offset to start the peek. 0 == beginning -1 = end
@ -612,7 +611,7 @@ public:
* @param aResultOffset offset for result content
* @param aEatingWS boolean to tell us the state of our search for Next/Prev
*/
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount, nsDirection aDirection, PRInt32 aStartOffset,
NS_IMETHOD PeekOffset(nsICaret *aCaret, nsSelectionAmount aAmount, nsDirection aDirection, PRInt32 aStartOffset,
nsIContent **aResultContent, PRInt32 *aResultOffset, PRBool aEatingWS) = 0;
/**

View File

@ -223,24 +223,22 @@ public:
NS_IMETHOD GetFrameName(nsString& aResult) const;
NS_IMETHOD GetPosition(nsIPresContext& aCX,
nsGUIEvent* aEvent,
nsIFrame * aNewFrame,
nscoord aXCoord,
nsIContent ** aNewContent,
PRUint32& aActualContentOffset,
PRInt32& aOffset,
PRInt32& aOffsetEnd);
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd);
NS_IMETHOD GetPositionSlowly(nsIPresContext& aCX,
nsIRenderingContext * aRendContext,
nsGUIEvent* aEvent,
nscoord aXCoord,
nsIContent ** aNewContent,
PRUint32& aActualContentOffset,
PRInt32& aOffset);
PRInt32& aOffset);
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread);
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount,
NS_IMETHOD PeekOffset(nsICaret *aCaret,
nsSelectionAmount aAmount,
nsDirection aDirection,
PRInt32 aStartOffset,
nsIContent **aResultContent,
@ -968,17 +966,17 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
}
}
//measure Spaced Textvoid
nsresult
nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
nsIRenderingContext* aRendContext,
nsGUIEvent* aEvent,
nscoord aXCoord,
nsIContent** aNewContent,
PRUint32& aAcutalContentOffset,
PRInt32& aOffset)
{
if (!aRendContext || !aEvent || !aNewContent) {
if (!aRendContext || !aNewContent) {
return NS_ERROR_NULL_POINTER;
}
@ -1051,8 +1049,8 @@ nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
aRendContext->GetWidth(ch, charWidth);
glyphWidth = charWidth + ts.mLetterSpacing;
}
if ((aEvent->point.x - origin.x) >= widthsofar && (aEvent->point.x - origin.x) <= (widthsofar + glyphWidth)){
if ( ((aEvent->point.x - origin.x) - widthsofar) <= (glyphWidth /2)){
if ((aXCoord - origin.x) >= widthsofar && (aXCoord - origin.x) <= (widthsofar + glyphWidth)){
if ( ((aXCoord - origin.x) - widthsofar) <= (glyphWidth /2)){
aOffset = index;
found = PR_TRUE;
break;
@ -1073,10 +1071,10 @@ nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
if (!found){
aOffset = textLength;
}
aAcutalContentOffset = mContentOffset;//offset;//((nsTextFrame *)aNewFrame)->mContentOffset;
aOffset += mContentOffset;//offset;//((nsTextFrame *)aNewFrame)->mContentOffset;
PRInt32 i;
for (i = 0;i <= mContentLength; i ++){
if (ip[i] == aOffset + mContentOffset){ //reverse mapping
if (ip[i] == aOffset){ //reverse mapping
aOffset = i;
break;
}
@ -1698,26 +1696,25 @@ BinarySearchForPosition(nsIRenderingContext* acx,
// display of selection is based on the compressed text.
//---------------------------------------------------------------------------
NS_IMETHODIMP
nsTextFrame::GetPosition(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsIFrame* aNewFrame,
nsIContent **aNewContent,
PRUint32& aActualContentOffset,
PRInt32& aOffset,
PRInt32& aOffsetEnd)
nsTextFrame::GetPosition(nsIPresContext& aCX,
nscoord aXCoord,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd)
{
nsCOMPtr<nsIPresShell> shell;
nsresult rv = aPresContext.GetShell(getter_AddRefs(shell));
nsresult rv = aCX.GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell) {
nsCOMPtr<nsIRenderingContext> acx;
rv = shell->CreateRenderingContext(this, getter_AddRefs(acx));
if (NS_SUCCEEDED(rv)) {
TextStyle ts(&aPresContext, *acx, mStyleContext);
TextStyle ts(&aCX, *acx, mStyleContext);
if (ts.mSmallCaps || ts.mWordSpacing || ts.mLetterSpacing) {
nsresult result = GetPositionSlowly(aPresContext, acx, aEvent, aNewContent,
aActualContentOffset, aOffset);
aOffsetEnd = aOffset;
nsresult result = GetPositionSlowly(aCX, acx, aXCoord, aNewContent,
aContentOffset);
aContentOffsetEnd = aContentOffset;
return result;
}
@ -1734,16 +1731,16 @@ nsTextFrame::GetPosition(nsIPresContext& aPresContext,
// Find the font metrics for this text
nsIStyleContext* styleContext;
aNewFrame->GetStyleContext(&styleContext);
GetStyleContext(&styleContext);
const nsStyleFont *font = (const nsStyleFont*)
styleContext->GetStyleData(eStyleStruct_Font);
NS_RELEASE(styleContext);
nsCOMPtr<nsIFontMetrics> fm;
aPresContext.GetMetricsFor(font->mFont, getter_AddRefs(fm));
aCX.GetMetricsFor(font->mFont, getter_AddRefs(fm));
acx->SetFont(fm);
// Get the document
nsCOMPtr<nsIDocument> doc(getter_AddRefs(GetDocument(&aPresContext)));
nsCOMPtr<nsIDocument> doc(getter_AddRefs(GetDocument(&aCX)));
// Get the renderable form of the text
nsCOMPtr<nsILineBreaker> lb;
@ -1767,14 +1764,14 @@ nsTextFrame::GetPosition(nsIPresContext& aPresContext,
GetOffsetFromView(origin, &view);
PRBool found = BinarySearchForPosition(acx, text, origin.x, 0, 0,
PRInt32(textLength),
PRInt32(aEvent->point.x) , //go to local coordinates
PRInt32(aXCoord) , //go to local coordinates
index, textWidth);
if (found) {
PRInt32 charWidth;
acx->GetWidth(text[index], charWidth);
charWidth /= 2;
if (PRInt32(aEvent->point.x) - origin.x > textWidth+charWidth) {
if (PRInt32(aXCoord) - origin.x > textWidth+charWidth) {
index++;
}
@ -1797,18 +1794,18 @@ nsTextFrame::GetPosition(nsIPresContext& aPresContext,
delete [] paintBuf;
}
aActualContentOffset = mContentOffset;//offset;//((nsTextFrame *)aNewFrame)->mContentOffset;
aOffset = index;
aOffsetEnd = aOffset;
//reusing wordBufMem
aContentOffset = index + mContentOffset;
aContentOffsetEnd = aContentOffset;
/* //reusing wordBufMem
PRInt32 i;
for (i = 0;i <= mContentLength; i ++){
if (ip[i] == aOffset + mContentOffset){ //reverse mapping
aOffset = i;
if (ip[i] == aContentOffset){ //reverse mapping
aContentOffset = i;
break;
}
}
NS_ASSERTION(i<= mContentLength, "offset we got from binary search is messed up");
*/
*aNewContent = mContent;
if (*aNewContent) {
(*aNewContent)->AddRef();
@ -2012,7 +2009,8 @@ nsTextFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset,
NS_IMETHODIMP
nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
nsTextFrame::PeekOffset(nsICaret *aCaret,
nsSelectionAmount aAmount,
nsDirection aDirection,
PRInt32 aStartOffset,
nsIContent **aResultContent,
@ -2035,7 +2033,7 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
NS_ASSERTION(PR_FALSE,"nsTextFrame::PeekOffset no more flow \n");
return NS_ERROR_INVALID_ARG;
}
return nextInFlow->PeekOffset(aAmount,aDirection,aStartOffset,
return nextInFlow->PeekOffset(aCaret, aAmount,aDirection,aStartOffset,
aResultContent,aContentOffset,aEatingWS);
}
@ -2113,11 +2111,11 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
}
if (!found){
if (frameUsed){
result = frameUsed->PeekOffset(eSelectCharacter, aDirection, start, aResultContent,
result = frameUsed->PeekOffset(aCaret, eSelectCharacter, aDirection, start, aResultContent,
aContentOffset, aEatingWS);
}
else {//reached end ask the frame for help
result = nsFrame::PeekOffset(eSelectCharacter, aDirection, start, aResultContent,
result = nsFrame::PeekOffset(aCaret, eSelectCharacter, aDirection, start, aResultContent,
aContentOffset, aEatingWS);
}
}
@ -2194,11 +2192,11 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
}
if (!found || (*aContentOffset > (mContentOffset + mContentLength)) || (*aContentOffset < mContentOffset)){ //gone too far
if (frameUsed){
result = frameUsed->PeekOffset(aAmount, aDirection, start, aResultContent,
result = frameUsed->PeekOffset(aCaret, aAmount, aDirection, start, aResultContent,
aContentOffset, aEatingWS);
}
else {//reached end ask the frame for help
result = nsFrame::PeekOffset(aAmount, aDirection, start, aResultContent,
result = nsFrame::PeekOffset(aCaret, aAmount, aDirection, start, aResultContent,
aContentOffset, aEatingWS);
}
}
@ -2210,20 +2208,33 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
}
break;
case eSelectLine :
#if 0
{
// Cleanup
if (paintBuf != paintBufMem) {
delete [] paintBuf;
#if 0
nsPoint origin;
nsIView* view;
nsPoint coord;
PRBool collapsed;
result = aCaret->GetWindowRelativeCoordinates(coord,collapsed);
if (NS_FAILED(result))
return result;
nsIFrame *frame = GetPrevInFlow();
while(frame){
result = NS_OK;
nsPoint futurecoord;
do {
result = frame->GetOffsetFromView(futurecoord, &view);
}
while (NS_SUCCEEDED(result) && view);
if (coord.y < futurecoord.y)
{
lineup = PR_TRUE;
GetPosition
}
}
if (ip != indicies) {
delete [] ip;
}
return nsFrame::PeekOffset(aAmount, aDirection, aStartOffset,
aResultContent, aContentOffset, aEatingWS)
#endif
}
break;
#endif
default: result = NS_ERROR_FAILURE; break;
}
// Cleanup
@ -2257,14 +2268,18 @@ nsTextFrame::HandleMultiplePress(nsIPresContext& aPresContext,
nsInputEvent *inputEvent = (nsInputEvent *)aEvent;
if (NS_SUCCEEDED(rv) && shell) {
nsCOMPtr<nsIRenderingContext> acx;
nsICaret *caret;
rv = shell->GetCaret(&caret);
if (NS_FAILED(rv))
return rv;
rv = shell->CreateRenderingContext(this, getter_AddRefs(acx));
if (NS_SUCCEEDED(rv)){
PRInt32 startPos = 0;
PRUint32 contentOffset = 0;
PRInt32 contentOffsetEnd = 0;
nsCOMPtr<nsIContent> newContent;
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent, this,
getter_AddRefs(newContent), contentOffset, startPos, contentOffsetEnd))){
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x,
getter_AddRefs(newContent), startPos, contentOffsetEnd))){
//find which word needs to be selected! use peek offset one way then the other
nsCOMPtr<nsIContent> startContent;
nsCOMPtr<nsIDOMNode> startNode;
@ -2273,17 +2288,19 @@ nsTextFrame::HandleMultiplePress(nsIPresContext& aPresContext,
PRInt32 startOffset;
PRInt32 endOffset;
//peeks{}
rv = PeekOffset(eSelectWord,
rv = PeekOffset(caret,
eSelectWord,
eDirPrevious,
contentOffset + startPos,
startPos,
getter_AddRefs(startContent),
&startOffset,
PR_FALSE);
if (NS_FAILED(rv))
return rv;
rv = PeekOffset(eSelectWord,
rv = PeekOffset(caret,
eSelectWord,
eDirNext,
contentOffset + startPos,
startPos,
getter_AddRefs(endContent),
&endOffset,
PR_FALSE);

View File

@ -884,8 +884,8 @@ nsFrame::HandlePress(nsIPresContext& aPresContext,
PRUint32 contentOffset = 0;
PRInt32 contentOffsetEnd = 0;
nsCOMPtr<nsIContent> newContent;
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent, this, getter_AddRefs(newContent),
contentOffset, startPos, contentOffsetEnd))){
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x, getter_AddRefs(newContent),
startPos, contentOffsetEnd))){
nsCOMPtr<nsIDOMSelection> selection;
if (NS_SUCCEEDED(shell->GetSelection(getter_AddRefs(selection)))){
nsCOMPtr<nsIFrameSelection> frameselection;
@ -893,7 +893,7 @@ nsFrame::HandlePress(nsIPresContext& aPresContext,
if (frameselection) {
if (NS_SUCCEEDED( rv )){
frameselection->SetMouseDownState(PR_TRUE);//not important if it fails here
frameselection->TakeFocus(newContent, startPos + contentOffset, contentOffsetEnd + contentOffset, inputEvent->isShift);
frameselection->TakeFocus(newContent, startPos , contentOffsetEnd , inputEvent->isShift);
}
}
}
@ -927,17 +927,16 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext,
nsresult rv = aPresContext.GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell) {
PRInt32 startPos = 0;
PRUint32 contentOffset = 0;
PRInt32 contentOffsetEnd = 0;
nsCOMPtr<nsIContent> newContent;
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent, this, getter_AddRefs(newContent),
contentOffset, startPos, contentOffsetEnd))){
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x, getter_AddRefs(newContent),
startPos, contentOffsetEnd))){
nsIDOMSelection *selection = nsnull;
if (NS_SUCCEEDED(shell->GetSelection(&selection))){
nsIFrameSelection* frameselection;
if (NS_SUCCEEDED(selection->QueryInterface(kIFrameSelection, (void **)&frameselection))) {
if (NS_SUCCEEDED( rv )){
frameselection->TakeFocus(newContent, startPos + contentOffset, contentOffsetEnd + contentOffset, PR_TRUE); //TRUE IS THE DIFFERENCE
frameselection->TakeFocus(newContent, startPos, contentOffsetEnd , PR_TRUE); //TRUE IS THE DIFFERENCE
}
NS_RELEASE(frameselection);
}
@ -959,13 +958,11 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsIPresContext& aPresContext,
//--------------------------------------------------------------------------
//-- GetPosition
//--------------------------------------------------------------------------
NS_IMETHODIMP nsFrame::GetPosition(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsIFrame * aNewFrame,
nsIContent ** aNewContent,
PRUint32& aAcutalContentOffset,
PRInt32& aOffset,
PRInt32& aOffsetEnd)
NS_IMETHODIMP nsFrame::GetPosition(nsIPresContext& aCX,
nscoord aXCoord,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd)
{
//default getposition will return parent as newcontent
//also aActualContentOffset will be 0
@ -978,12 +975,12 @@ NS_IMETHODIMP nsFrame::GetPosition(nsIPresContext& aPresContext,
if (*aNewContent){
PRInt32 index = 0;
nsresult result = (*aNewContent)->IndexOf(mContent, aOffset);
nsresult result = (*aNewContent)->IndexOf(mContent, aContentOffset);
if (NS_FAILED(result))
{
return result;
}
aOffsetEnd = aOffset +1;
aContentOffsetEnd = aContentOffset +1;
}
return NS_OK;
}
@ -1634,7 +1631,8 @@ nsFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset, PRInt32* outFram
}
NS_IMETHODIMP
nsFrame::PeekOffset(nsSelectionAmount aAmount,
nsFrame::PeekOffset(nsICaret *aCaret,
nsSelectionAmount aAmount,
nsDirection aDirection,
PRInt32 aStartOffset,
nsIContent **aResultContent,
@ -1664,10 +1662,10 @@ nsFrame::PeekOffset(nsSelectionAmount aAmount,
//for speed reasons
nsIFrame *newFrame = (nsIFrame *)isupports;
if (aDirection == eDirNext)
return newFrame->PeekOffset(aAmount, aDirection, 0, aResultContent,
return newFrame->PeekOffset(aCaret, aAmount, aDirection, 0, aResultContent,
aContentOffset, aEatingWS);
else
return newFrame->PeekOffset(aAmount, aDirection, -1, aResultContent,
return newFrame->PeekOffset(aCaret, aAmount, aDirection, -1, aResultContent,
aContentOffset, aEatingWS);
return NS_OK;

View File

@ -83,6 +83,7 @@
#define NS_FRAME_TRACE_REFLOW_OUT(_method, _status)
#endif
//----------------------------------------------------------------------
/**
@ -210,7 +211,8 @@ public:
NS_IMETHOD VerifyTree() const;
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread);
NS_IMETHOD GetSelected(PRBool *aSelected) const;
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount,
NS_IMETHOD PeekOffset(nsICaret *aCaret,
nsSelectionAmount aAmount,
nsDirection aDirection,
PRInt32 aStartOffset,
nsIContent **aResultContent,
@ -256,13 +258,11 @@ public:
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD GetPosition(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsIFrame * aNewFrame,
nsIContent ** aNewContent,
PRUint32& aAcutalContentOffset,
PRInt32& aOffset,
PRInt32& aOffsetEnd);
NS_IMETHOD GetPosition(nsIPresContext& aCX,
nscoord aXCoord,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd);
//--------------------------------------------------
// Additional methods

View File

@ -318,7 +318,7 @@ public:
PRUint32 aHFlags) const;
NS_IMETHOD DoCopy();
//nsIViewObserver interface
NS_IMETHOD Paint(nsIView *aView,

View File

@ -223,24 +223,22 @@ public:
NS_IMETHOD GetFrameName(nsString& aResult) const;
NS_IMETHOD GetPosition(nsIPresContext& aCX,
nsGUIEvent* aEvent,
nsIFrame * aNewFrame,
nscoord aXCoord,
nsIContent ** aNewContent,
PRUint32& aActualContentOffset,
PRInt32& aOffset,
PRInt32& aOffsetEnd);
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd);
NS_IMETHOD GetPositionSlowly(nsIPresContext& aCX,
nsIRenderingContext * aRendContext,
nsGUIEvent* aEvent,
nscoord aXCoord,
nsIContent ** aNewContent,
PRUint32& aActualContentOffset,
PRInt32& aOffset);
PRInt32& aOffset);
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread);
NS_IMETHOD PeekOffset(nsSelectionAmount aAmount,
NS_IMETHOD PeekOffset(nsICaret *aCaret,
nsSelectionAmount aAmount,
nsDirection aDirection,
PRInt32 aStartOffset,
nsIContent **aResultContent,
@ -968,17 +966,17 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
}
}
//measure Spaced Textvoid
nsresult
nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
nsIRenderingContext* aRendContext,
nsGUIEvent* aEvent,
nscoord aXCoord,
nsIContent** aNewContent,
PRUint32& aAcutalContentOffset,
PRInt32& aOffset)
{
if (!aRendContext || !aEvent || !aNewContent) {
if (!aRendContext || !aNewContent) {
return NS_ERROR_NULL_POINTER;
}
@ -1051,8 +1049,8 @@ nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
aRendContext->GetWidth(ch, charWidth);
glyphWidth = charWidth + ts.mLetterSpacing;
}
if ((aEvent->point.x - origin.x) >= widthsofar && (aEvent->point.x - origin.x) <= (widthsofar + glyphWidth)){
if ( ((aEvent->point.x - origin.x) - widthsofar) <= (glyphWidth /2)){
if ((aXCoord - origin.x) >= widthsofar && (aXCoord - origin.x) <= (widthsofar + glyphWidth)){
if ( ((aXCoord - origin.x) - widthsofar) <= (glyphWidth /2)){
aOffset = index;
found = PR_TRUE;
break;
@ -1073,10 +1071,10 @@ nsTextFrame::GetPositionSlowly(nsIPresContext& aPresContext,
if (!found){
aOffset = textLength;
}
aAcutalContentOffset = mContentOffset;//offset;//((nsTextFrame *)aNewFrame)->mContentOffset;
aOffset += mContentOffset;//offset;//((nsTextFrame *)aNewFrame)->mContentOffset;
PRInt32 i;
for (i = 0;i <= mContentLength; i ++){
if (ip[i] == aOffset + mContentOffset){ //reverse mapping
if (ip[i] == aOffset){ //reverse mapping
aOffset = i;
break;
}
@ -1698,26 +1696,25 @@ BinarySearchForPosition(nsIRenderingContext* acx,
// display of selection is based on the compressed text.
//---------------------------------------------------------------------------
NS_IMETHODIMP
nsTextFrame::GetPosition(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsIFrame* aNewFrame,
nsIContent **aNewContent,
PRUint32& aActualContentOffset,
PRInt32& aOffset,
PRInt32& aOffsetEnd)
nsTextFrame::GetPosition(nsIPresContext& aCX,
nscoord aXCoord,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd)
{
nsCOMPtr<nsIPresShell> shell;
nsresult rv = aPresContext.GetShell(getter_AddRefs(shell));
nsresult rv = aCX.GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell) {
nsCOMPtr<nsIRenderingContext> acx;
rv = shell->CreateRenderingContext(this, getter_AddRefs(acx));
if (NS_SUCCEEDED(rv)) {
TextStyle ts(&aPresContext, *acx, mStyleContext);
TextStyle ts(&aCX, *acx, mStyleContext);
if (ts.mSmallCaps || ts.mWordSpacing || ts.mLetterSpacing) {
nsresult result = GetPositionSlowly(aPresContext, acx, aEvent, aNewContent,
aActualContentOffset, aOffset);
aOffsetEnd = aOffset;
nsresult result = GetPositionSlowly(aCX, acx, aXCoord, aNewContent,
aContentOffset);
aContentOffsetEnd = aContentOffset;
return result;
}
@ -1734,16 +1731,16 @@ nsTextFrame::GetPosition(nsIPresContext& aPresContext,
// Find the font metrics for this text
nsIStyleContext* styleContext;
aNewFrame->GetStyleContext(&styleContext);
GetStyleContext(&styleContext);
const nsStyleFont *font = (const nsStyleFont*)
styleContext->GetStyleData(eStyleStruct_Font);
NS_RELEASE(styleContext);
nsCOMPtr<nsIFontMetrics> fm;
aPresContext.GetMetricsFor(font->mFont, getter_AddRefs(fm));
aCX.GetMetricsFor(font->mFont, getter_AddRefs(fm));
acx->SetFont(fm);
// Get the document
nsCOMPtr<nsIDocument> doc(getter_AddRefs(GetDocument(&aPresContext)));
nsCOMPtr<nsIDocument> doc(getter_AddRefs(GetDocument(&aCX)));
// Get the renderable form of the text
nsCOMPtr<nsILineBreaker> lb;
@ -1767,14 +1764,14 @@ nsTextFrame::GetPosition(nsIPresContext& aPresContext,
GetOffsetFromView(origin, &view);
PRBool found = BinarySearchForPosition(acx, text, origin.x, 0, 0,
PRInt32(textLength),
PRInt32(aEvent->point.x) , //go to local coordinates
PRInt32(aXCoord) , //go to local coordinates
index, textWidth);
if (found) {
PRInt32 charWidth;
acx->GetWidth(text[index], charWidth);
charWidth /= 2;
if (PRInt32(aEvent->point.x) - origin.x > textWidth+charWidth) {
if (PRInt32(aXCoord) - origin.x > textWidth+charWidth) {
index++;
}
@ -1797,18 +1794,18 @@ nsTextFrame::GetPosition(nsIPresContext& aPresContext,
delete [] paintBuf;
}
aActualContentOffset = mContentOffset;//offset;//((nsTextFrame *)aNewFrame)->mContentOffset;
aOffset = index;
aOffsetEnd = aOffset;
//reusing wordBufMem
aContentOffset = index + mContentOffset;
aContentOffsetEnd = aContentOffset;
/* //reusing wordBufMem
PRInt32 i;
for (i = 0;i <= mContentLength; i ++){
if (ip[i] == aOffset + mContentOffset){ //reverse mapping
aOffset = i;
if (ip[i] == aContentOffset){ //reverse mapping
aContentOffset = i;
break;
}
}
NS_ASSERTION(i<= mContentLength, "offset we got from binary search is messed up");
*/
*aNewContent = mContent;
if (*aNewContent) {
(*aNewContent)->AddRef();
@ -2012,7 +2009,8 @@ nsTextFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset,
NS_IMETHODIMP
nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
nsTextFrame::PeekOffset(nsICaret *aCaret,
nsSelectionAmount aAmount,
nsDirection aDirection,
PRInt32 aStartOffset,
nsIContent **aResultContent,
@ -2035,7 +2033,7 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
NS_ASSERTION(PR_FALSE,"nsTextFrame::PeekOffset no more flow \n");
return NS_ERROR_INVALID_ARG;
}
return nextInFlow->PeekOffset(aAmount,aDirection,aStartOffset,
return nextInFlow->PeekOffset(aCaret, aAmount,aDirection,aStartOffset,
aResultContent,aContentOffset,aEatingWS);
}
@ -2113,11 +2111,11 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
}
if (!found){
if (frameUsed){
result = frameUsed->PeekOffset(eSelectCharacter, aDirection, start, aResultContent,
result = frameUsed->PeekOffset(aCaret, eSelectCharacter, aDirection, start, aResultContent,
aContentOffset, aEatingWS);
}
else {//reached end ask the frame for help
result = nsFrame::PeekOffset(eSelectCharacter, aDirection, start, aResultContent,
result = nsFrame::PeekOffset(aCaret, eSelectCharacter, aDirection, start, aResultContent,
aContentOffset, aEatingWS);
}
}
@ -2194,11 +2192,11 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
}
if (!found || (*aContentOffset > (mContentOffset + mContentLength)) || (*aContentOffset < mContentOffset)){ //gone too far
if (frameUsed){
result = frameUsed->PeekOffset(aAmount, aDirection, start, aResultContent,
result = frameUsed->PeekOffset(aCaret, aAmount, aDirection, start, aResultContent,
aContentOffset, aEatingWS);
}
else {//reached end ask the frame for help
result = nsFrame::PeekOffset(aAmount, aDirection, start, aResultContent,
result = nsFrame::PeekOffset(aCaret, aAmount, aDirection, start, aResultContent,
aContentOffset, aEatingWS);
}
}
@ -2210,20 +2208,33 @@ nsTextFrame::PeekOffset(nsSelectionAmount aAmount,
}
break;
case eSelectLine :
#if 0
{
// Cleanup
if (paintBuf != paintBufMem) {
delete [] paintBuf;
#if 0
nsPoint origin;
nsIView* view;
nsPoint coord;
PRBool collapsed;
result = aCaret->GetWindowRelativeCoordinates(coord,collapsed);
if (NS_FAILED(result))
return result;
nsIFrame *frame = GetPrevInFlow();
while(frame){
result = NS_OK;
nsPoint futurecoord;
do {
result = frame->GetOffsetFromView(futurecoord, &view);
}
while (NS_SUCCEEDED(result) && view);
if (coord.y < futurecoord.y)
{
lineup = PR_TRUE;
GetPosition
}
}
if (ip != indicies) {
delete [] ip;
}
return nsFrame::PeekOffset(aAmount, aDirection, aStartOffset,
aResultContent, aContentOffset, aEatingWS)
#endif
}
break;
#endif
default: result = NS_ERROR_FAILURE; break;
}
// Cleanup
@ -2257,14 +2268,18 @@ nsTextFrame::HandleMultiplePress(nsIPresContext& aPresContext,
nsInputEvent *inputEvent = (nsInputEvent *)aEvent;
if (NS_SUCCEEDED(rv) && shell) {
nsCOMPtr<nsIRenderingContext> acx;
nsICaret *caret;
rv = shell->GetCaret(&caret);
if (NS_FAILED(rv))
return rv;
rv = shell->CreateRenderingContext(this, getter_AddRefs(acx));
if (NS_SUCCEEDED(rv)){
PRInt32 startPos = 0;
PRUint32 contentOffset = 0;
PRInt32 contentOffsetEnd = 0;
nsCOMPtr<nsIContent> newContent;
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent, this,
getter_AddRefs(newContent), contentOffset, startPos, contentOffsetEnd))){
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x,
getter_AddRefs(newContent), startPos, contentOffsetEnd))){
//find which word needs to be selected! use peek offset one way then the other
nsCOMPtr<nsIContent> startContent;
nsCOMPtr<nsIDOMNode> startNode;
@ -2273,17 +2288,19 @@ nsTextFrame::HandleMultiplePress(nsIPresContext& aPresContext,
PRInt32 startOffset;
PRInt32 endOffset;
//peeks{}
rv = PeekOffset(eSelectWord,
rv = PeekOffset(caret,
eSelectWord,
eDirPrevious,
contentOffset + startPos,
startPos,
getter_AddRefs(startContent),
&startOffset,
PR_FALSE);
if (NS_FAILED(rv))
return rv;
rv = PeekOffset(eSelectWord,
rv = PeekOffset(caret,
eSelectWord,
eDirNext,
contentOffset + startPos,
startPos,
getter_AddRefs(endContent),
&endOffset,
PR_FALSE);

View File

@ -358,7 +358,7 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext& aPresContext,
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
return NS_OK;
}

View File

@ -358,7 +358,7 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext& aPresContext,
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
return NS_OK;
}