Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Static Public Member Functions
nsLayoutUtils Class Reference

nsLayoutUtils is a namespace class used for various helper functions that are useful in multiple places in layout. More...

#include <nsLayoutUtils.h>

List of all members.

Public Types

enum  Direction { eHorizontal, eVertical, eEither }
 GetNearestScrollingView locates the first ancestor of aView (or aView itself) that is scrollable. More...

Static Public Member Functions

static nsIFrameGetBeforeFrame (nsIFrame *aFrame)
 GetBeforeFrame returns the :before frame of the given frame, if one exists.
static nsIFrameGetAfterFrame (nsIFrame *aFrame)
 GetAfterFrame returns the :after frame of the given frame, if one exists.
static nsIFrameGetPageFrame (nsIFrame *aFrame)
 Given a frame, search up the frame tree until we find an ancestor "Page" frame, if any.
static PRBool IsGeneratedContentFor (nsIContent *aContent, nsIFrame *aFrame, nsIAtom *aPseudoElement)
 IsGeneratedContentFor returns PR_TRUE if aFrame is generated content of type aPseudoElement for aContent.
static PRInt32 CompareTreePosition (nsIContent *aContent1, nsIContent *aContent2, nsIContent *aCommonAncestor=nsnull)
 CompareTreePosition determines whether aContent1 comes before or after aContent2 in a preorder traversal of the content tree.
static PRInt32 DoCompareTreePosition (nsIContent *aContent1, nsIContent *aContent2, PRInt32 aIf1Ancestor, PRInt32 aIf2Ancestor, nsIContent *aCommonAncestor=nsnull)
static nsIFrameGetLastSibling (nsIFrame *aFrame)
 GetLastSibling simply finds the last sibling of aFrame, or returns nsnull if aFrame is null.
static nsIViewFindSiblingViewFor (nsIView *aParentView, nsIFrame *aFrame)
 FindSiblingViewFor locates the child of aParentView that aFrame's view should be inserted 'above' (i.e., before in sibling view order).
static PRBool IsProperAncestorFrame (nsIFrame *aAncestorFrame, nsIFrame *aFrame, nsIFrame *aCommonAncestor=nsnull)
 IsProperAncestorFrame checks whether aAncestorFrame is an ancestor of aFrame and not equal to aFrame.
static nsIFrameGetFrameFor (nsIView *aView)
 GetFrameFor returns the root frame for a view.
static nsIScrollableFrameGetScrollableFrameFor (nsIScrollableView *aScrollableView)
 GetScrollableFrameFor returns the scrollable frame for a scrollable view.
static nsIScrollableFrameGetScrollableFrameFor (nsIFrame *aScrolledFrame)
 GetScrollableFrameFor returns the scrollable frame for a scrolled frame.
static
nsPresContext::ScrollbarStyles 
ScrollbarStylesOfView (nsIScrollableView *aScrollableView)
static nsIScrollableViewGetNearestScrollingView (nsIView *aView, Direction aDirection)
static PRBool HasPseudoStyle (nsIContent *aContent, nsStyleContext *aStyleContext, nsIAtom *aPseudoElement, nsPresContext *aPresContext)
 HasPseudoStyle returns PR_TRUE if aContent (whose primary style context is aStyleContext) has the aPseudoElement pseudo-style attached to it; returns PR_FALSE otherwise.
static nsIFrameGetFloatFromPlaceholder (nsIFrame *aPossiblePlaceholder)
 If this frame is a placeholder for a float, then return the float, otherwise return nsnull.
static PRUint8 CombineBreakType (PRUint8 aOrigBreakType, PRUint8 aNewBreakType)
static PRBool IsInitialContainingBlock (nsIFrame *aFrame)
static nsPoint GetDOMEventCoordinatesRelativeTo (nsIDOMEvent *aDOMEvent, nsIFrame *aFrame)
 Get the coordinates of a given DOM mouse event, relative to a given frame.
static nsPoint GetEventCoordinatesForNearestView (nsEvent *aEvent, nsIFrame *aFrame, nsIView **aView=nsnull)
 Get the coordinates of a given native mouse event, relative to the nearest view for a given frame.
static nsPoint TranslateWidgetToView (nsPresContext *aPresContext, nsIWidget *aWidget, nsIntPoint aPt, nsIView *aView)
 Translate from widget coordinates to the view's coordinates.

Detailed Description

nsLayoutUtils is a namespace class used for various helper functions that are useful in multiple places in layout.

The goal is not to define multiple copies of the same static helper.

Definition at line 60 of file nsLayoutUtils.h.


Member Enumeration Documentation

GetNearestScrollingView locates the first ancestor of aView (or aView itself) that is scrollable.

It does not count an 'overflow' style of 'hidden' as scrollable, even though a scrolling view is present. Thus, the direction of the scroll is needed as an argument.

Parameters:
aViewthe view we're looking at
aDirectionWhether it's for horizontal or vertical scrolling.
Returns:
the nearest scrollable view or nsnull if not found
Enumerator:
eHorizontal 
eVertical 
eEither 

Definition at line 202 of file nsLayoutUtils.h.


Member Function Documentation

PRUint8 nsLayoutUtils::CombineBreakType ( PRUint8  aOrigBreakType,
PRUint8  aNewBreakType 
) [static]

Definition at line 462 of file nsLayoutUtils.cpp.

{
  PRUint8 breakType = aOrigBreakType;
  switch(breakType) {
  case NS_STYLE_CLEAR_LEFT:
    if ((NS_STYLE_CLEAR_RIGHT          == aNewBreakType) ||
        (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aNewBreakType)) {
      breakType = NS_STYLE_CLEAR_LEFT_AND_RIGHT;
    }
    break;
  case NS_STYLE_CLEAR_RIGHT:
    if ((NS_STYLE_CLEAR_LEFT           == aNewBreakType) ||
        (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aNewBreakType)) {
      breakType = NS_STYLE_CLEAR_LEFT_AND_RIGHT;
    }
    break;
  case NS_STYLE_CLEAR_NONE:
    if ((NS_STYLE_CLEAR_LEFT           == aNewBreakType) ||
        (NS_STYLE_CLEAR_RIGHT          == aNewBreakType) ||
        (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aNewBreakType)) {
      breakType = aNewBreakType;
    }
  }
  return breakType;
}

Here is the caller graph for this function:

static PRInt32 nsLayoutUtils::CompareTreePosition ( nsIContent aContent1,
nsIContent aContent2,
nsIContent aCommonAncestor = nsnull 
) [inline, static]

CompareTreePosition determines whether aContent1 comes before or after aContent2 in a preorder traversal of the content tree.

Parameters:
aCommonAncestoreither null, or a common ancestor of aContent1 and aContent2. Actually this is only a hint; if it's not an ancestor of aContent1 or aContent2, this function will still work, but it will be slower than normal.
Returns:
< 0 if aContent1 is before aContent2 > 0 if aContent1 is after aContent2, 0 otherwise (meaning they're the same, or they're in different documents)

Definition at line 123 of file nsLayoutUtils.h.

  {
    return DoCompareTreePosition(aContent1, aContent2, -1, 1, aCommonAncestor);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsLayoutUtils::DoCompareTreePosition ( nsIContent aContent1,
nsIContent aContent2,
PRInt32  aIf1Ancestor,
PRInt32  aIf2Ancestor,
nsIContent aCommonAncestor = nsnull 
) [static]

Definition at line 234 of file nsLayoutUtils.cpp.

{
  NS_PRECONDITION(aContent1, "aContent1 must not be null");
  NS_PRECONDITION(aContent2, "aContent2 must not be null");

  nsAutoVoidArray content1Ancestors;
  nsIContent* c1;
  for (c1 = aContent1; c1 && c1 != aCommonAncestor; c1 = c1->GetParent()) {
    content1Ancestors.AppendElement(c1);
  }
  if (!c1 && aCommonAncestor) {
    // So, it turns out aCommonAncestor was not an ancestor of c1. Oops.
    // Never mind. We can continue as if aCommonAncestor was null.
    aCommonAncestor = nsnull;
  }

  nsAutoVoidArray content2Ancestors;
  nsIContent* c2;
  for (c2 = aContent2; c2 && c2 != aCommonAncestor; c2 = c2->GetParent()) {
    content2Ancestors.AppendElement(c2);
  }
  if (!c2 && aCommonAncestor) {
    // So, it turns out aCommonAncestor was not an ancestor of c2.
    // We need to retry with no common ancestor hint.
    return DoCompareTreePosition(aContent1, aContent2,
                                 aIf1Ancestor, aIf2Ancestor, nsnull);
  }
  
  int last1 = content1Ancestors.Count() - 1;
  int last2 = content2Ancestors.Count() - 1;
  nsIContent* content1Ancestor = nsnull;
  nsIContent* content2Ancestor = nsnull;
  while (last1 >= 0 && last2 >= 0
         && ((content1Ancestor = NS_STATIC_CAST(nsIContent*, content1Ancestors.ElementAt(last1)))
             == (content2Ancestor = NS_STATIC_CAST(nsIContent*, content2Ancestors.ElementAt(last2))))) {
    last1--;
    last2--;
  }

  if (last1 < 0) {
    if (last2 < 0) {
      NS_ASSERTION(aContent1 == aContent2, "internal error?");
      return 0;
    } else {
      // aContent1 is an ancestor of aContent2
      return aIf1Ancestor;
    }
  } else {
    if (last2 < 0) {
      // aContent2 is an ancestor of aContent1
      return aIf2Ancestor;
    } else {
      // content1Ancestor != content2Ancestor, so they must be siblings with the same parent
      nsIContent* parent = content1Ancestor->GetParent();
      NS_ASSERTION(parent, "no common ancestor at all???");
      if (!parent) { // different documents??
        return 0;
      }

      PRInt32 index1 = parent->IndexOf(content1Ancestor);
      PRInt32 index2 = parent->IndexOf(content2Ancestor);
      if (index1 < 0 || index2 < 0) {
        // one of them must be anonymous; we can't determine the order
        return 0;
      }

      return index1 - index2;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIView * nsLayoutUtils::FindSiblingViewFor ( nsIView aParentView,
nsIFrame aFrame 
) [static]

FindSiblingViewFor locates the child of aParentView that aFrame's view should be inserted 'above' (i.e., before in sibling view order).

This is the first child view of aParentView whose corresponding content is before aFrame's content (view siblings are in reverse content order).

Definition at line 324 of file nsLayoutUtils.cpp.

                                                                        {
  nsIFrame* parentViewFrame = NS_STATIC_CAST(nsIFrame*, aParentView->GetClientData());
  nsIContent* parentViewContent = parentViewFrame ? parentViewFrame->GetContent() : nsnull;
  for (nsIView* insertBefore = aParentView->GetFirstChild(); insertBefore;
       insertBefore = insertBefore->GetNextSibling()) {
    nsIFrame* f = NS_STATIC_CAST(nsIFrame*, insertBefore->GetClientData());
    if (!f) {
      // this view could be some anonymous view attached to a meaningful parent
      for (nsIView* searchView = insertBefore->GetParent(); searchView;
           searchView = searchView->GetParent()) {
        f = NS_STATIC_CAST(nsIFrame*, searchView->GetClientData());
        if (f) {
          break;
        }
      }
      NS_ASSERTION(f, "Can't find a frame anywhere!");
    }
    if (!f || !aFrame->GetContent() || !f->GetContent() ||
        CompareTreePosition(aFrame->GetContent(), f->GetContent(), parentViewContent) > 0) {
      // aFrame's content is after f's content (or we just don't know),
      // so put our view before f's view
      return insertBefore;
    }
  }
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GetAfterFrame returns the :after frame of the given frame, if one exists.

This will walk the in-flow chain to the last-in-flow if needed. This function is typically O(N) in the number of child frames, following in-flows, etc.

Parameters:
aFramethe frame whose :after is wanted
Returns:
the :after frame or nsnull if there isn't one

Definition at line 149 of file nsLayoutUtils.cpp.

{
  NS_PRECONDITION(aFrame, "NULL frame pointer");

  nsIFrame* lastFrame = GetLastChildFrame(aFrame, aFrame->GetContent());

  if (lastFrame && IsGeneratedContentFor(nsnull, lastFrame,
                                         nsCSSPseudoElements::after)) {
    return lastFrame;
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GetBeforeFrame returns the :before frame of the given frame, if one exists.

This is typically O(1). The frame passed in must be the first-in-flow.

Parameters:
aFramethe frame whose :before is wanted
Returns:
the :before frame or nsnull if there isn't one

Definition at line 132 of file nsLayoutUtils.cpp.

{
  NS_PRECONDITION(aFrame, "NULL frame pointer");
  NS_ASSERTION(!aFrame->GetPrevInFlow(), "aFrame must be first-in-flow");
  
  nsIFrame* firstFrame = GetFirstChildFrame(aFrame, aFrame->GetContent());

  if (firstFrame && IsGeneratedContentFor(nsnull, firstFrame,
                                          nsCSSPseudoElements::before)) {
    return firstFrame;
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Get the coordinates of a given DOM mouse event, relative to a given frame.

Works only for DOM events generated by nsGUIEvents.

Parameters:
aDOMEventthe event
aFramethe frame to make coordinates relative to
Returns:
the point, or (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if for some reason the coordinates for the mouse are not known (e.g., the event is not a GUI event).

Definition at line 428 of file nsLayoutUtils.cpp.

{
  nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aDOMEvent));
  NS_ASSERTION(privateEvent, "bad implementation");
  if (!privateEvent)
    return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
  nsEvent* event;
  nsresult rv = privateEvent->GetInternalNSEvent(&event);
  if (NS_FAILED(rv))
    return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
  if (!event || event->eventStructType != NS_MOUSE_EVENT)
    return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
  
  nsGUIEvent* GUIEvent = NS_STATIC_CAST(nsGUIEvent*, event);
  if (!GUIEvent->widget)
    return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
  nsIView* view = nsIView::GetViewFor(GUIEvent->widget);
  if (!view)
    return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);

  nsPoint widgetToView;
  view->GetNearestWidget(&widgetToView);
  nsPoint viewToFrame;
  nsIView* frameView = aFrame->GetClosestView(&viewToFrame);

  float p2t = aFrame->GetPresContext()->PixelsToTwips();
  nsPoint mousePt(NSIntPixelsToTwips(GUIEvent->refPoint.x, p2t),
                  NSIntPixelsToTwips(GUIEvent->refPoint.y, p2t));
  return mousePt + widgetToView + (-frameView->GetOffsetTo(view)) +  viewToFrame;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsPoint nsLayoutUtils::GetEventCoordinatesForNearestView ( nsEvent aEvent,
nsIFrame aFrame,
nsIView **  aView = nsnull 
) [static]

Get the coordinates of a given native mouse event, relative to the nearest view for a given frame.

The "nearest view" is the view returned by nsFrame::GetOffsetFromView. XXX this is extremely BOGUS because "nearest view" is a mess; every use of this method is really a bug!

Parameters:
aEventthe event
aFramethe frame to make coordinates relative to
aViewview to which returned coordinates are relative
Returns:
the point, or (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if for some reason the coordinates for the mouse are not known (e.g., the event is not a GUI event).

Definition at line 497 of file nsLayoutUtils.cpp.

{
  if (!aEvent || (aEvent->eventStructType != NS_MOUSE_EVENT && 
                  aEvent->eventStructType != NS_MOUSE_SCROLL_EVENT))
    return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);

  nsGUIEvent* GUIEvent = NS_STATIC_CAST(nsGUIEvent*, aEvent);
  if (!GUIEvent->widget)
    return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);

  nsPoint viewToFrame;
  nsIView* frameView;
  aFrame->GetOffsetFromView(viewToFrame, &frameView);
  if (aView)
    *aView = frameView;

  return TranslateWidgetToView(aFrame->GetPresContext(), GUIEvent->widget,
                               GUIEvent->refPoint, frameView);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIFrame * nsLayoutUtils::GetFloatFromPlaceholder ( nsIFrame aPossiblePlaceholder) [static]

If this frame is a placeholder for a float, then return the float, otherwise return nsnull.

Definition at line 176 of file nsLayoutUtils.cpp.

                                                       {
  if (nsLayoutAtoms::placeholderFrame != aFrame->GetType()) {
    return nsnull;
  }

  nsIFrame *outOfFlowFrame =
    nsPlaceholderFrame::GetRealFrameForPlaceholder(aFrame);
  if (outOfFlowFrame->GetStyleDisplay()->IsFloating()) {
    return outOfFlowFrame;
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsIFrame* nsLayoutUtils::GetFrameFor ( nsIView aView) [inline, static]

GetFrameFor returns the root frame for a view.

Parameters:
aViewis the view to return the root frame for
Returns:
the root frame for the view

Definition at line 172 of file nsLayoutUtils.h.

  { return NS_STATIC_CAST(nsIFrame*, aView->GetClientData()); }

Here is the call graph for this function:

Here is the caller graph for this function:

GetLastSibling simply finds the last sibling of aFrame, or returns nsnull if aFrame is null.

Definition at line 310 of file nsLayoutUtils.cpp.

                                                        {
  if (!aFrame) {
    return nsnull;
  }

  nsIFrame* next;
  while ((next = aFrame->GetNextSibling()) != nsnull) {
    aFrame = next;
  }
  return aFrame;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 389 of file nsLayoutUtils.cpp.

{
  // If aDirection is eEither, find first view with a scrolllable frame.
  // Otherwise, find the first view that has a scrollable frame whose
  // ScrollbarStyles is not NS_STYLE_OVERFLOW_HIDDEN in aDirection
  // and where there is something currently not visible
  // that can be scrolled to in aDirection.
  NS_ASSERTION(aView, "GetNearestScrollingView expects a non-null view");
  nsIScrollableView* scrollableView = nsnull;
  for (; aView; aView = aView->GetParent()) {
    scrollableView = aView->ToScrollableView();
    if (scrollableView) {
      nsPresContext::ScrollbarStyles ss =
        nsLayoutUtils::ScrollbarStylesOfView(scrollableView);
      nsIScrollableFrame *scrollableFrame = GetScrollableFrameFor(scrollableView);
      NS_ASSERTION(scrollableFrame, "Must have scrollable frame for view!");
      nsMargin margin = scrollableFrame->GetActualScrollbarSizes();
      // Get size of total scrollable area
      nscoord totalWidth, totalHeight;
      scrollableView->GetContainerSize(&totalWidth, &totalHeight);
      // Get size of currently visible area
      nsSize visibleSize = aView->GetBounds().Size();
      // aDirection can be eHorizontal, eVertical, or eEither
      // If scrolling in a specific direction, require visible scrollbars or
      // something to scroll to in that direction.
      if (aDirection != eHorizontal &&
          ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN &&
          (aDirection == eEither || totalHeight > visibleSize.height || margin.right))
        break;
      if (aDirection != eVertical &&
          ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN &&
          (aDirection == eEither || totalWidth > visibleSize.width || margin.bottom))
        break;
    }
  }
  return scrollableView;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIFrame * nsLayoutUtils::GetPageFrame ( nsIFrame aFrame) [static]

Given a frame, search up the frame tree until we find an ancestor "Page" frame, if any.

Parameters:
theframe to start at
Returns:
a frame of type nsLayoutAtoms::pageFrame or nsnull if no such ancestor exists

Definition at line 165 of file nsLayoutUtils.cpp.

{
  for (nsIFrame* frame = aFrame; frame; frame = frame->GetParent()) {
    if (frame->GetType() == nsLayoutAtoms::pageFrame) {
      return frame;
    }
  }
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GetScrollableFrameFor returns the scrollable frame for a scrollable view.

Parameters:
aScrollableViewis the scrollable view to return the scrollable frame for.
Returns:
the scrollable frame for the scrollable view

Definition at line 366 of file nsLayoutUtils.cpp.

{
  nsIFrame *frame = GetFrameFor(aScrollableView->View()->GetParent());
  if (frame) {
    nsIScrollableFrame *sf;
    CallQueryInterface(frame, &sf);
    return sf;
  }
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GetScrollableFrameFor returns the scrollable frame for a scrolled frame.

Definition at line 353 of file nsLayoutUtils.cpp.

{
  nsIFrame *frame = aScrolledFrame->GetParent();
  if (!frame) {
    return nsnull;
  }
  nsIScrollableFrame *sf;
  CallQueryInterface(frame, &sf);
  return sf;
}

Here is the call graph for this function:

static PRBool nsLayoutUtils::HasPseudoStyle ( nsIContent aContent,
nsStyleContext aStyleContext,
nsIAtom aPseudoElement,
nsPresContext aPresContext 
) [inline, static]

HasPseudoStyle returns PR_TRUE if aContent (whose primary style context is aStyleContext) has the aPseudoElement pseudo-style attached to it; returns PR_FALSE otherwise.

Parameters:
aContentthe content node we're looking at
aStyleContextaContent's style context
aPseudoElementthe name of the pseudo style we care about
aPresContextthe presentation context
Returns:
whether aContent has aPseudoElement style attached to it

Definition at line 217 of file nsLayoutUtils.h.

  {
    NS_PRECONDITION(aPresContext, "Must have a prescontext");
    NS_PRECONDITION(aPseudoElement, "Must have a pseudo name");

    nsRefPtr<nsStyleContext> pseudoContext;
    if (aContent) {
      pseudoContext = aPresContext->StyleSet()->
        ProbePseudoStyleFor(aContent, aPseudoElement, aStyleContext);
    }
    return pseudoContext != nsnull;
  }

Here is the caller graph for this function:

PRBool nsLayoutUtils::IsGeneratedContentFor ( nsIContent aContent,
nsIFrame aFrame,
nsIAtom aPseudoElement 
) [static]

IsGeneratedContentFor returns PR_TRUE if aFrame is generated content of type aPseudoElement for aContent.

Parameters:
aContentthe content node we're looking at. If this is null, then we just assume that aFrame has the right content pointer.
aFramethe frame we're looking at
aPseudoElementthe pseudo type we're interested in
Returns:
whether aFrame is the generated aPseudoElement frame for aContent

Definition at line 192 of file nsLayoutUtils.cpp.

{
  NS_PRECONDITION(aFrame, "Must have a frame");
  NS_PRECONDITION(aPseudoElement, "Must have a pseudo name");

  if (!aFrame->IsGeneratedContentFrame()) {
    return PR_FALSE;
  }
  
  if (aContent && aFrame->GetContent() != aContent) {
    return PR_FALSE;
  }

  return aFrame->GetStyleContext()->GetPseudoType() == aPseudoElement;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Returns:
PR_TRUE if aFrame is the CSS initial containing block for its pres-shell

Definition at line 490 of file nsLayoutUtils.cpp.

{
  return aFrame ==
    aFrame->GetPresContext()->PresShell()->FrameConstructor()->GetInitialContainingBlock();
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsLayoutUtils::IsProperAncestorFrame ( nsIFrame aAncestorFrame,
nsIFrame aFrame,
nsIFrame aCommonAncestor = nsnull 
) [static]

IsProperAncestorFrame checks whether aAncestorFrame is an ancestor of aFrame and not equal to aFrame.

Parameters:
aCommonAncestornsnull, or a common ancestor of aFrame and aAncestorFrame. If non-null, this can bound the search and speed up the function

Definition at line 212 of file nsLayoutUtils.cpp.

{
  if (aFrame == aCommonAncestor) {
    return PR_FALSE;
  }
  
  nsIFrame* parentFrame = aFrame->GetParent();

  while (parentFrame != aCommonAncestor) {
    if (parentFrame == aAncestorFrame) {
      return PR_TRUE;
    }

    parentFrame = parentFrame->GetParent();
  }

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 379 of file nsLayoutUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsPoint nsLayoutUtils::TranslateWidgetToView ( nsPresContext aPresContext,
nsIWidget aWidget,
nsIntPoint  aPt,
nsIView aView 
) [static]

Translate from widget coordinates to the view's coordinates.

Parameters:
aPresContextthe PresContext for the view
aWidgetthe widget
aPtthe point relative to the widget
aViewview to which returned coordinates are relative
Returns:
the point in the view's coordinates

Definition at line 520 of file nsLayoutUtils.cpp.

{
  nsIView* baseView = nsIView::GetViewFor(aWidget);
  if (!baseView)
    return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
  nsPoint viewToWidget;
  nsIWidget* wid = baseView->GetNearestWidget(&viewToWidget);
  NS_ASSERTION(aWidget == wid, "Clashing widgets");
  float pixelsToTwips = aPresContext->PixelsToTwips();
  nsPoint refPointTwips(NSIntPixelsToTwips(aPt.x, pixelsToTwips),
                        NSIntPixelsToTwips(aPt.y, pixelsToTwips));
  return refPointTwips - viewToWidget - aView->GetOffsetTo(baseView);
}

Here is the call graph for this function:

Here is the caller graph for this function:


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