Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
nsTypeAheadController Class Reference

#include <nsTypeAheadFind.h>

Inheritance diagram for nsTypeAheadController:
Inheritance graph
[legend]
Collaboration diagram for nsTypeAheadController:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsTypeAheadController (nsIFocusController *aFocusController)
virtual ~nsTypeAheadController ()
boolean isCommandEnabled (in string command)
boolean supportsCommand (in string command)
void doCommand (in string command)
void onEvent (in string eventName)

Private Member Functions

nsresult EnsureContentWindow (nsIDOMWindowInternal *aFocusedWin, nsIDOMWindow **aStartContentWin)

Private Attributes

nsCOMPtr< nsIFocusControllermFocusController

Detailed Description

Definition at line 262 of file nsTypeAheadFind.h.


Constructor & Destructor Documentation

Definition at line 2840 of file nsTypeAheadFind.cpp.

                                                                                :
  mFocusController(aFocusController)
{
}

Definition at line 2845 of file nsTypeAheadFind.cpp.

{
}

Member Function Documentation

void nsIController::doCommand ( in string  command) [inherited]
nsresult nsTypeAheadController::EnsureContentWindow ( nsIDOMWindowInternal aFocusedWin,
nsIDOMWindow **  aStartContentWin 
) [private]

Definition at line 2946 of file nsTypeAheadFind.cpp.

{
  NS_ENSURE_ARG_POINTER(aFocusedWin);
  NS_ENSURE_ARG_POINTER(aStartContentWin);

  *aStartContentWin = nsnull;
  nsCOMPtr<nsIInterfaceRequestor> ifreq(do_QueryInterface(aFocusedWin));
  NS_ENSURE_TRUE(ifreq, NS_OK);

  nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(ifreq));
  nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(webNav));
  NS_ENSURE_TRUE(treeItem, NS_OK);
  PRInt32 treeItemType;
  treeItem->GetItemType(&treeItemType);

  nsCOMPtr<nsIDOMWindow> startContentWin;
  if (treeItemType == nsIDocShellTreeItem::typeContent) {
    startContentWin = do_QueryInterface(aFocusedWin);
  }
  else {
    // Use enumerator tet first content docshell
    nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webNav));
    NS_ENSURE_TRUE(docShell, NS_OK);

    nsCOMPtr<nsISimpleEnumerator> docShellEnumerator;
    docShell->GetDocShellEnumerator(nsIDocShellTreeItem::typeContent,
                                    nsIDocShell::ENUMERATE_FORWARDS,
                                    getter_AddRefs(docShellEnumerator));
  
    PRBool hasMoreDocShells;
    if (NS_SUCCEEDED(docShellEnumerator->HasMoreElements(&hasMoreDocShells))
        && hasMoreDocShells) {

      // There is a content docshell child, let's use it (focus it and return it)
      nsCOMPtr<nsISupports> container;
      docShellEnumerator->GetNext(getter_AddRefs(container));
      nsCOMPtr<nsIInterfaceRequestor> ifreq(do_QueryInterface(container));

      if (ifreq) {
        startContentWin = do_GetInterface(ifreq);
        NS_ENSURE_TRUE(startContentWin, NS_ERROR_FAILURE);

        // Set new focus in root content of new window
        // This only happens if we weren't already in content
        // Using nsIContent to focus makes sure the 
        // previous window's focused content gets blurred properly
        nsCOMPtr<nsIDOMDocument> domDoc;
        startContentWin->GetDocument(getter_AddRefs(domDoc));
        nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
        NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);

        nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
        nsCOMPtr<nsPresContext> presContext;
        docShell->GetPresContext(getter_AddRefs(presContext));
        NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);

        nsIContent *rootContent = doc->GetRootContent();
        NS_ENSURE_TRUE(rootContent, NS_ERROR_FAILURE);
        rootContent->SetFocus(presContext);
      }
    }
  }

  *aStartContentWin = startContentWin;
  NS_IF_ADDREF(*aStartContentWin);
  return NS_OK;
}

Here is the call graph for this function:

void nsIController::onEvent ( in string  eventName) [inherited]
boolean nsIController::supportsCommand ( in string  command) [inherited]

Member Data Documentation

Definition at line 271 of file nsTypeAheadFind.h.


The documentation for this class was generated from the following files: