Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
nsView.cpp File Reference
#include "nsView.h"
#include "nsIWidget.h"
#include "nsViewManager.h"
#include "nsIButton.h"
#include "nsGUIEvent.h"
#include "nsIDeviceContext.h"
#include "nsIComponentManager.h"
#include "nsIRenderingContext.h"
#include "nsTransform2D.h"
#include "nsIScrollableView.h"
#include "nsVoidArray.h"
#include "nsGfxCIID.h"
#include "nsIRegion.h"
#include "nsIInterfaceRequestor.h"

Go to the source code of this file.

Classes

class  ViewWrapper
 nsISupports-derived helper class that allows to store and get a view More...

Defines

#define VIEW_WRAPPER_IID   { 0x34297a07, 0xa8fd, 0xd811, { 0x87, 0xc6, 0x0, 0x2, 0x44, 0x21, 0x2b, 0xcb } };

Functions

static nsEventStatus PR_CALLBACK HandleEvent (nsGUIEvent *aEvent)
static ViewWrapperGetWrapperFor (nsIWidget *aWidget)
 Given a widget, returns the stored ViewWrapper on it, or NULL if no ViewWrapper is there.
static void UpdateNativeWidgetZIndexes (nsView *aView, PRInt32 aZIndex)
static PRInt32 FindNonAutoZIndex (nsView *aView)
static PRBool ApplyClipRect (const nsView *aView, nsRect *aRect, PRBool aFollowPlaceholders, nsIView *aStopAtView)

Define Documentation

#define VIEW_WRAPPER_IID   { 0x34297a07, 0xa8fd, 0xd811, { 0x87, 0xc6, 0x0, 0x2, 0x44, 0x21, 0x2b, 0xcb } };

Definition at line 64 of file nsView.cpp.


Function Documentation

static PRBool ApplyClipRect ( const nsView aView,
nsRect aRect,
PRBool  aFollowPlaceholders,
nsIView aStopAtView 
) [static]
Parameters:
aStopAtViewclipping from ancestors of this view will not be applied
Returns:
PR_TRUE iff we found a placeholder parent edge on the way up the view tree from aView to aStopAtView

Definition at line 935 of file nsView.cpp.

{
  // this records the offset from the origin of the current aView
  // to the origin of the initial aView
  nsPoint offset(0, 0);
  PRBool lastViewIsFloating = aView->GetFloating();
  PRBool foundPlaceholders = PR_FALSE;
  while (NS_STATIC_CAST(const nsIView*, aView) != aStopAtView) {
    const nsView* parentView = aView->GetParent();
    nsPoint offsetFromParent = aView->GetPosition();

    const nsView* zParent = aView->GetZParent();
    if (zParent) {
      foundPlaceholders = PR_TRUE;
      if (aFollowPlaceholders) {
        // correct offsetFromParent to account for the fact that we're
        // switching parentView to ZParent
        // Note that the common case is that parentView is an ancestor of
        // ZParent.
        const nsView* zParentChain;
        for (zParentChain = zParent;
             zParentChain != parentView && zParentChain;
             zParentChain = zParentChain->GetParent()) {
          offsetFromParent -= zParentChain->GetPosition();
        }
        if (!zParentChain) {
          // uh oh. As we walked up the tree, we missed zParent. This can
          // happen because of odd (but legal) containing block hierarchies.
          // Just compute the required offset from scratch; this is slow,
          // but hopefully rarely executed.
          offsetFromParent = nsViewManager::ComputeViewOffset(aView)
            - nsViewManager::ComputeViewOffset(zParent);
        }
        parentView = zParent;
      }
    }

    if (!parentView) {
      break;
    }

    PRBool parentIsFloating = parentView->GetFloating();
    if (lastViewIsFloating && !parentIsFloating) {
      break;
    }

    // now make offset be the offset from parentView's origin to the initial
    // aView's origin
    offset += offsetFromParent;
    if (parentView->GetClipChildrenToBounds(aFollowPlaceholders)) {
      // Get the parent's clip rect (which is just the dimensions in this
      // case) into the initial aView's coordinates
      nsRect clipRect = parentView->GetDimensions();
      clipRect -= offset;
      PRBool overlap = aRect->IntersectRect(clipRect, *aRect);
      if (!overlap) {
        break;
      }
    }
    // The child-clipping rect is applied to all *content* children.
    // So we apply it if we're in the placeholder-following pass, or
    // if we're in the first pass and we haven't detected any
    // placeholders yet, in which case this geometric ancestor is also
    // a content ancestor.
    const nsRect* r = parentView->GetClipChildrenToRect();
    if (r && (!foundPlaceholders || aFollowPlaceholders)) {
      // Get the parent's clip rect into the initial aView's coordinates
      nsRect clipRect = *r;
      clipRect -= offset;
      PRBool overlap = aRect->IntersectRect(clipRect, *aRect);
      if (!overlap) {
        break;
      }
    }

    aView = parentView;
    lastViewIsFloating = parentIsFloating;
  }

  return foundPlaceholders;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRInt32 FindNonAutoZIndex ( nsView aView) [static]

Definition at line 639 of file nsView.cpp.

{
  while (aView) {
    if (!aView->GetZIndexIsAuto()) {
      return aView->GetZIndex();
    }
    aView = aView->GetParent();
  }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static ViewWrapper* GetWrapperFor ( nsIWidget aWidget) [static]

Given a widget, returns the stored ViewWrapper on it, or NULL if no ViewWrapper is there.

Definition at line 138 of file nsView.cpp.

{
  // The widget's client data points back to the owning view
  if (aWidget) {
    void* clientData;
    aWidget->GetClientData(clientData);
    nsISupports* data = (nsISupports*)clientData;
    
    if (data) {
      ViewWrapper* wrapper;
      CallQueryInterface(data, &wrapper);
      // Give a weak reference to the caller. There will still be at least one
      // reference left, since the wrapper was addrefed when set on the widget.
      if (wrapper)
        wrapper->Release();
      return wrapper;
    }
  }
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsEventStatus PR_CALLBACK HandleEvent ( nsGUIEvent aEvent) [static]
static void UpdateNativeWidgetZIndexes ( nsView aView,
PRInt32  aZIndex 
) [static]

Definition at line 621 of file nsView.cpp.

{
  if (aView->HasWidget()) {
    nsIWidget* widget = aView->GetWidget();
    PRInt32 curZ;
    widget->GetZIndex(&curZ);
    if (curZ != aZIndex) {
      widget->SetZIndex(aZIndex);
    }
  } else {
    for (nsView* v = aView->GetFirstChild(); v; v = v->GetNextSibling()) {
      if (v->GetZIndexIsAuto()) {
        UpdateNativeWidgetZIndexes(v, aZIndex);
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function: