mFrameSelection->InvalidateDesiredX();
nsTypedSelection::SelectionLanguageChange(PRBool aLangRTL){  nsresult result;  nsCOMPtr<nsIDOMNode>  focusNode;  nsCOMPtr<nsIContent> focusContent;  PRInt32 focusOffset;  nsIFrame *focusFrame = 0;  focusOffset = FetchFocusOffset();  focusNode = FetchFocusNode();  result = GetPrimaryFrameForFocusNode(&focusFrame, nsnull);  if (NS_FAILED(result) || !focusFrame)    return result?result:NS_ERROR_FAILURE;  PRInt32 frameStart, frameEnd;  focusFrame->GetOffsets(frameStart, frameEnd);  nsCOMPtr<nsPresContext> context;  PRUint8 levelBefore, levelAfter;  result = GetPresContext(getter_AddRefs(context));  if (NS_FAILED(result) || !context)    return result?result:NS_ERROR_FAILURE;  PRUint8 level = NS_GET_EMBEDDING_LEVEL(focusFrame);  if ((focusOffset != frameStart) && (focusOffset != frameEnd))    // the cursor is not at a frame boundary, so the level of both the characters (logically) before and after the cursor    //  is equal to the frame level    levelBefore = levelAfter = level;  else {    // the cursor is at a frame boundary, so use GetPrevNextBidiLevels to find the level of the characters    //  before and after the cursor    nsIFrame* frameBefore = nsnull;    nsIFrame* frameAfter = nsnull;    focusContent = do_QueryInterface(focusNode);    /*    nsIFrameSelection::HINT hint;    if ((focusOffset == frameStart && level)        // beginning of an RTL frame        || (focusOffset == frameEnd && !level)) {   // end of an LTR frame      hint = nsIFrameSelection::HINTRIGHT;    }    else {                                          // end of an RTL frame or beginning of an LTR frame      hint = nsIFrameSelection::HINTLEFT;    }    mFrameSelection->SetHint(hint);    */    mFrameSelection->GetPrevNextBidiLevels(context, focusContent, focusOffset, &frameBefore, &frameAfter, &levelBefore, &levelAfter);  }  nsIPresShell* shell = context->GetPresShell();  if (!shell)    return NS_ERROR_FAILURE;  if ((levelBefore & 1) == (levelAfter & 1)) {    // if cursor is between two characters with the same orientation, changing the keyboard language    //  must toggle the cursor level between the level of the character with the lowest level    //  (if the new language corresponds to the orientation of that character) and this level plus 1    //  (if the new language corresponds to the opposite orientation)    if ((level != levelBefore) && (level != levelAfter))      level = PR_MIN(levelBefore, levelAfter);    if ((level & 1) == aLangRTL)      shell->SetCaretBidiLevel(level);    else      shell->SetCaretBidiLevel(level + 1);  }  else {    // if cursor is between characters with opposite orientations, changing the keyboard language must change    //  the cursor level to that of the adjacent character with the orientation corresponding to the new language.    if ((levelBefore & 1) == aLangRTL)      shell->SetCaretBidiLevel(levelBefore);    else      shell->SetCaretBidiLevel(levelAfter);  }  return NS_OK;}