Logo Search packages:      
Sourcecode: firefox-3.5 version File versions  Download package

NS_IMETHODIMP nsEditor::ScrollSelectionIntoView ( PRBool  aScrollToAnchor  )  [protected, inherited]

helper method for scrolling the selection into view after an edit operation. aScrollToAnchor should be PR_TRUE if you want to scroll to the point where the selection was started. If PR_FALSE, it attempts to scroll the end of the selection into view.

Editor methods *should* call this method instead of the versions in the various selection interfaces, since this version makes sure that the editor's sync/async settings for reflowing, painting, and scrolling match.

Definition at line 2515 of file nsEditor.cpp.

  nsCOMPtr<nsISelectionController> selCon;
  if (NS_SUCCEEDED(GetSelectionController(getter_AddRefs(selCon))) && selCon)
    PRInt16 region = nsISelectionController::SELECTION_FOCUS_REGION;

    if (aScrollToAnchor)
      region = nsISelectionController::SELECTION_ANCHOR_REGION;

    PRBool syncScroll = PR_TRUE;
    PRUint32 flags = 0;

    if (NS_SUCCEEDED(GetFlags(&flags)))
      // If the editor is relying on asynchronous reflows, we have
      // to use asynchronous requests to scroll, so that the scrolling happens
      // after reflow requests are processed.
      // XXXbz why not just always do async scroll?
      syncScroll = !(flags & nsIPlaintextEditor::eEditorUseAsyncUpdatesMask);

    // After ScrollSelectionIntoView(), the pending notifications might be
    // flushed and PresShell/PresContext/Frames may be dead. See bug 418470.
                                    region, syncScroll);

  return NS_OK;

Generated by  Doxygen 1.6.0   Back to index