Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions
inLayoutUtils Class Reference

#include <inLayoutUtils.h>

List of all members.

Static Public Member Functions

static nsIDOMWindowInternalGetWindowFor (nsIDOMNode *aNode)
static nsIDOMWindowInternalGetWindowFor (nsIDOMDocument *aDoc)
static nsIPresShellGetPresShellFor (nsISupports *aThing)
static nsIFrameGetFrameFor (nsIDOMElement *aElement, nsIPresShell *aShell)
static already_AddRefed
< nsIRenderingContext
GetRenderingContextFor (nsIPresShell *aShell)
static nsIEventStateManagerGetEventStateManagerFor (nsIDOMElement *aElement)
static nsIBindingManagerGetBindingManagerFor (nsIDOMNode *aNode)
static nsIDOMDocumentGetSubDocumentFor (nsIDOMNode *aNode)
static nsIDOMNodeGetContainerFor (nsIDOMDocument *aDoc)
static nsPoint GetClientOrigin (nsIFrame *aFrame)
 This function returns the offset of a frame with respect to the root view of the aPresContext's viewmanager (for use by inFlasher::DrawElementOutline and the like)
static nsRectGetScreenOrigin (nsIDOMElement *aElement)

Detailed Description

Definition at line 51 of file inLayoutUtils.h.


Member Function Documentation

Definition at line 222 of file inLayoutUtils.cpp.

{
  nsCOMPtr<nsIDOMDocument> domdoc;
  aNode->GetOwnerDocument(getter_AddRefs(domdoc));
  if (domdoc) {
    nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
    return doc->BindingManager();
  }
  
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

This function returns the offset of a frame with respect to the root view of the aPresContext's viewmanager (for use by inFlasher::DrawElementOutline and the like)

Parameters:
aFramethe frame whose offset we want
aPresContextthe presentation context
Returns:
the offset

Definition at line 133 of file inLayoutUtils.cpp.

{
  nsPoint result(0,0);
  nsIView* view;
  aFrame->GetOffsetFromView(result, &view);
  nsIView* rootView = nsnull;
  if (view) {
      nsIViewManager* viewManager = view->GetViewManager();
      NS_ASSERTION(viewManager, "View must have a viewmanager");
      viewManager->GetRootView(rootView);
  }
  while (view) {
    result += view->GetPosition();
    if (view == rootView) {
      break;
    }
    view = view->GetParent();
  }
  return result;
}

Here is the call graph for this function:

Definition at line 251 of file inLayoutUtils.cpp.

{
  nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDoc);
  if (!doc) return nsnull;

  nsPIDOMWindow *pwin = doc->GetWindow();
  if (!pwin) return nsnull;

  return pwin->GetFrameElementInternal();
}

Here is the call graph for this function:

Definition at line 113 of file inLayoutUtils.cpp.

{
  NS_PRECONDITION(aElement, "Passing in a null element is bad");

  nsCOMPtr<nsIDOMDocument> domDoc;
  aElement->GetOwnerDocument(getter_AddRefs(domDoc));
  nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);

  if (!doc) {
    NS_WARNING("Could not get an nsIDocument!");
    return nsnull;
  }

  nsIPresShell *shell = doc->GetShellAt(0);
  NS_ASSERTION(shell, "No pres shell");

  return shell->GetPresContext()->EventStateManager();
}

Here is the call graph for this function:

nsIFrame * inLayoutUtils::GetFrameFor ( nsIDOMElement aElement,
nsIPresShell aShell 
) [static]

Definition at line 95 of file inLayoutUtils.cpp.

{
  nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
  nsIFrame* frame = nsnull;
  aShell->GetPrimaryFrameFor(content, &frame);

  return frame;
}

Here is the call graph for this function:

nsIPresShell * inLayoutUtils::GetPresShellFor ( nsISupports *  aThing) [static]

Definition at line 83 of file inLayoutUtils.cpp.

{
  nsCOMPtr<nsIScriptGlobalObject> so = do_QueryInterface(aThing);

  nsCOMPtr<nsIPresShell> presShell;
  so->GetDocShell()->GetPresShell(getter_AddRefs(presShell));

  return presShell;
}

Here is the call graph for this function:

Definition at line 105 of file inLayoutUtils.cpp.

{
  nsCOMPtr<nsIWidget> widget;
  aShell->GetViewManager()->GetWidget(getter_AddRefs(widget));
  return widget->GetRenderingContext(); // AddRefs
}

Here is the call graph for this function:

Definition at line 155 of file inLayoutUtils.cpp.

{
  nsRect* rect = new nsRect(0,0,0,0);
 
  nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
  nsCOMPtr<nsIDocument> doc = content->GetDocument();

  if (doc) {
    // Get Presentation shell 0
    nsIPresShell *presShell = doc->GetShellAt(0);

    if (presShell) {
      // Flush all pending notifications so that our frames are uptodate
      doc->FlushPendingNotifications(Flush_Layout);

      nsPresContext *presContext = presShell->GetPresContext();
      
      if (presContext) {
        nsIFrame* frame = nsnull;
        presShell->GetPrimaryFrameFor(content, &frame);
        
        PRInt32 offsetX = 0;
        PRInt32 offsetY = 0;
        nsIWidget* widget = nsnull;
        
        while (frame) {
          // Look for a widget so we can get screen coordinates
          nsIView* view = frame->GetViewExternal();
          if (view) {
            widget = view->GetWidget();
            if (widget)
              break;
          }
          
          // No widget yet, so count up the coordinates of the frame 
          nsPoint origin = frame->GetPosition();
          offsetX += origin.x;
          offsetY += origin.y;
      
          frame = frame->GetParent();
        }
        
        if (widget) {
          // Get the widget's screen coordinates
          nsRect oldBox(0,0,0,0);
          widget->WidgetToScreen(oldBox, *rect);

          // Get the scale from that Presentation Context
          float p2t;
          p2t = presContext->PixelsToTwips();

          // Convert screen rect to twips
          rect->x = NSIntPixelsToTwips(rect->x, p2t);
          rect->y = NSIntPixelsToTwips(rect->y, p2t);

          //  Add the offset we've counted
          rect->x += offsetX;
          rect->y += offsetY;
        }
      }
    }
  }
  
  return *rect;
}

Here is the call graph for this function:

Definition at line 235 of file inLayoutUtils.cpp.

{
  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
  if (content) {
    nsCOMPtr<nsIDocument> doc = content->GetDocument();
    if (doc) {
      nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(doc->GetSubDocumentFor(content)));

      return domdoc;
    }
  }
  
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 61 of file inLayoutUtils.cpp.

{
  nsCOMPtr<nsIDOMDocument> doc1;
  aNode->GetOwnerDocument(getter_AddRefs(doc1));
  return GetWindowFor(doc1.get());
}

Here is the call graph for this function:

Definition at line 69 of file inLayoutUtils.cpp.

{
  nsCOMPtr<nsIDOMDocumentView> doc = do_QueryInterface(aDoc);
  if (!doc) return nsnull;
  
  nsCOMPtr<nsIDOMAbstractView> view;
  doc->GetDefaultView(getter_AddRefs(view));
  if (!view) return nsnull;
  
  nsCOMPtr<nsIDOMWindowInternal> window = do_QueryInterface(view);
  return window;
}

Here is the call graph for this function:


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