long level; nsPeekOffsetStruct pos; pos.SetData(mTracker, 0, eSelectDir, eDirNext , startPos, PR_FALSE,PR_TRUE, PR_TRUE); mHint = HINT(beginOfContent); HINT saveHint = mHint; newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&level); if (level & 1) mHint = (mHint==HINTLEFT) ? HINTRIGHT : HINTLEFT; pos.mResultContent = newContent; pos.mContentOffset = contentOffsetEnd; result = VisualSelectFrames(aPresContext, newFrame, pos); if (NS_FAILED(result)) result = HandleClick(newContent, startPos, contentOffsetEnd , PR_FALSE, PR_FALSE, beginOfContent); mHint = saveHint; #else result = HandleClick(newContent, startPos, contentOffsetEnd , PR_TRUE, PR_FALSE, beginOfContent);
PRBool bidiEnabled = PR_FALSE; aPresContext->BidiEnabled(bidiEnabled); if (bidiEnabled) { long level; nsPeekOffsetStruct pos; pos.SetData(mTracker, 0, eSelectDir, eDirNext, startPos, PR_FALSE, PR_TRUE, PR_TRUE); mHint = HINT(beginOfContent); HINT saveHint = mHint; newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&level); if (level & 1) mHint = (mHint==HINTLEFT) ? HINTRIGHT : HINTLEFT; pos.mResultContent = newContent; pos.mContentOffset = contentOffsetEnd; result = VisualSelectFrames(aPresContext, newFrame, pos); if (NS_FAILED(result)) result = HandleClick(newContent, startPos, contentOffsetEnd, PR_FALSE, PR_FALSE, beginOfContent); mHint = saveHint; } else
nsSelection::HandleDrag(nsIPresContext *aPresContext, nsIFrame *aFrame, nsPoint& aPoint){  if (!aPresContext || !aFrame)    return NS_ERROR_NULL_POINTER;  nsresult result;  nsIFrame *newFrame = 0;  nsPoint   newPoint;  result = ConstrainFrameAndPointToAnchorSubtree(aPresContext, aFrame, aPoint, &newFrame, newPoint);  if (NS_FAILED(result))    return result;  if (!newFrame)    return NS_ERROR_FAILURE;  nsCOMPtr<nsIPresShell> presShell;  result = aPresContext->GetShell(getter_AddRefs(presShell));  if (NS_FAILED(result))    return result;  PRInt32 startPos = 0;  PRInt32 contentOffsetEnd = 0;  PRBool  beginOfContent;  nsCOMPtr<nsIContent> newContent;  result = newFrame->GetContentAndOffsetsFromPoint(aPresContext, newPoint,                                                   getter_AddRefs(newContent),                                                    startPos, contentOffsetEnd, beginOfContent);  // do we have CSS that changes selection behaviour?  {    PRBool    changeSelection;    nsCOMPtr<nsIContent>  selectContent;    PRInt32   newStart, newEnd;    if (NS_SUCCEEDED(AdjustOffsetsFromStyle(newFrame, &changeSelection, getter_AddRefs(selectContent), &newStart, &newEnd))      && changeSelection)    {      newContent = selectContent;      startPos = newStart;      contentOffsetEnd = newEnd;    }  }  if (NS_SUCCEEDED(result))  {#ifdef IBMBIDI    long level;    nsPeekOffsetStruct pos;    pos.SetData(mTracker, 0, eSelectDir, eDirNext /*????*/, startPos, PR_FALSE,PR_TRUE, PR_TRUE);    mHint = HINT(beginOfContent);    HINT saveHint = mHint;    newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&level);    if (level & 1)      mHint = (mHint==HINTLEFT) ? HINTRIGHT : HINTLEFT;    pos.mResultContent = newContent;    pos.mContentOffset = contentOffsetEnd;    result = VisualSelectFrames(aPresContext, newFrame, pos);    if (NS_FAILED(result))      result = HandleClick(newContent, startPos, contentOffsetEnd , PR_FALSE, PR_FALSE, beginOfContent);    mHint = saveHint;#else    result = HandleClick(newContent, startPos, contentOffsetEnd , PR_TRUE, PR_FALSE, beginOfContent);#endif // IBMBIDI  }  return result;}