Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsPresShell.cpp File Reference
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDOMXULDocument.h"
#include "nsStubDocumentObserver.h"
#include "nsStyleSet.h"
#include "nsICSSStyleSheet.h"
#include "nsIDOMCSSStyleSheet.h"
#include "nsINameSpaceManager.h"
#include "nsIServiceManager.h"
#include "nsFrame.h"
#include "nsHTMLReflowCommand.h"
#include "nsIViewManager.h"
#include "nsCRT.h"
#include "prlog.h"
#include "prmem.h"
#include "prprf.h"
#include "prinrval.h"
#include "nsVoidArray.h"
#include "nsCOMArray.h"
#include "nsHashtable.h"
#include "nsIViewObserver.h"
#include "nsContainerFrame.h"
#include "nsIDeviceContext.h"
#include "nsEventStateManager.h"
#include "nsDOMEvent.h"
#include "nsGUIEvent.h"
#include "nsHTMLParts.h"
#include "nsContentUtils.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsReflowPath.h"
#include "nsLayoutCID.h"
#include "nsLayoutAtoms.h"
#include "nsIDOMRange.h"
#include "nsIDOMDocument.h"
#include "nsIDOMNode.h"
#include "nsIDOM3Node.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMElement.h"
#include "nsHTMLAtoms.h"
#include "nsCSSPseudoElements.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsWeakReference.h"
#include "nsIPageSequenceFrame.h"
#include "nsICaret.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIXPointer.h"
#include "nsIDOMXMLDocument.h"
#include "nsIScrollableView.h"
#include "nsIParser.h"
#include "nsParserCIID.h"
#include "nsIFrameSelection.h"
#include "nsIDOMNSHTMLInputElement.h"
#include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsViewsCID.h"
#include "nsFrameManager.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsILayoutHistoryState.h"
#include "nsIScrollPositionListener.h"
#include "nsICompositeListener.h"
#include "nsILineIterator.h"
#include "nsTimer.h"
#include "nsWeakPtr.h"
#include "plarena.h"
#include "pldhash.h"
#include "nsIObserverService.h"
#include "nsIObserver.h"
#include "nsIDocShell.h"
#include "nsIBaseWindow.h"
#include "nsLayoutErrors.h"
#include "nsLayoutUtils.h"
#include "nsCSSRendering.h"
#include "nsSpaceManager.h"
#include "prenv.h"
#include "nsIAttribute.h"
#include "nsIGlobalHistory2.h"
#include "nsIReflowCallback.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDOMWindowInternal.h"
#include "nsPIDOMWindow.h"
#include "nsIFocusController.h"
#include "nsIPluginInstance.h"
#include "nsIObjectFrame.h"
#include "nsIPluginHost.h"
#include "nsWidgetsCID.h"
#include "nsIClipboard.h"
#include "nsIClipboardHelper.h"
#include "nsIDocShellTreeItem.h"
#include "nsIURI.h"
#include "nsIEventQueue.h"
#include "nsIEventQueueService.h"
#include "nsIScrollableFrame.h"
#include "prtime.h"
#include "prlong.h"
#include "nsIDragService.h"
#include "nsCopySupport.h"
#include "nsIDOMHTMLAnchorElement.h"
#include "nsIDOMHTMLAreaElement.h"
#include "nsIDOMHTMLLinkElement.h"
#include "nsITimer.h"
#include "nsITimerInternal.h"
#include "nsStyleChangeList.h"
#include "nsCSSFrameConstructor.h"
#include "nsIBindingManager.h"
#include "nsIMenuParent.h"
#include "nsPlaceholderFrame.h"
#include "nsDummyLayoutRequest.h"
#include "nsIContentViewer.h"
#include "nsContentCID.h"

Go to the source code of this file.

Classes

struct  StackBlock
 A block of memory that the stack will chop up and hand out. More...
struct  StackMark
class  StackArena
class  FrameArena
class  PresShellViewEventListener
struct  nsDOMEventRequest
struct  nsAttributeChangeRequest
struct  nsCallbackEventRequest
class  IncrementalReflow
 Used to build and maintain the incremental reflow tree, and dispatch incremental reflows to individual reflow roots. More...
struct  ReflowCommandEntry
class  PresShell
struct  CantRenderReplacedElementEvent
struct  ReflowEvent
struct  DummyLayoutRequestEvent

Defines

#define PL_ARENA_CONST_ALIGN_MASK   3
#define SHOW_CARET
#define NS_MAX_REFLOW_TIME   1000000
#define MARK_INCREMENT   50
#define BLOCK_INCREMENT   4044 /* a bit under 4096, for malloc overhead */
#define PAINTLOCK_EVENT_DELAY   250
#define NS_PRESSHELL_NOTIFY_OBSERVERS(func_, params_)
#define VERIFY_STYLE_TREE
#define RESIZE_EVENT_DELAY   200

Functions

static NS_DEFINE_CID (kCSSStyleSheetCID, NS_CSS_STYLESHEET_CID)
static NS_DEFINE_IID (kRangeCID, NS_RANGE_CID)
static void ColorToString (nscolor aColor, nsAutoString &aString)
static NS_DEFINE_CID (kFrameSelectionCID, NS_FRAMESELECTION_CID)
static NS_DEFINE_CID (kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID)
 ReflowCommandHashGetKey (PLDHashTable *table, PLDHashEntryHdr *entry)
 ReflowCommandHashHashKey (PLDHashTable *table, const void *key)
 ReflowCommandHashMatchEntry (PLDHashTable *table, const PLDHashEntryHdr *entry, const void *key)
nsresult NS_NewPresShell (nsIPresShell **aInstancePtrResult)
 Create a new empty presentation shell.
 NS_IMPL_ISUPPORTS9 (PresShell, nsIPresShell, nsIPresShell_MOZILLA_1_8_BRANCH, nsIPresShell_MOZILLA_1_8_BRANCH2, nsIDocumentObserver, nsIViewObserver, nsISelectionController, nsISelectionDisplay, nsIObserver, nsISupportsWeakReference) PresShell
static void CheckForFocus (nsPIDOMWindow *aOurWindow, nsIFocusController *aFocusController, nsIDocument *aDocument)
static nsIFrameGetRootScrollFrame (nsIFrame *aRootFrame)
static void UpdateViewProperties (nsPresContext *aPresContext, nsIViewManager *aVM, nsIView *aView)
 HandleCantRenderReplacedElementEvent (PLEvent *aEvent)
 DestroyCantRenderReplacedElementEvent (PLEvent *aEvent)
static void ScrollViewToShowRect (nsIScrollableView *aScrollingView, nsRect &aRect, PRIntn aVPercent, PRIntn aHPercent)
 This function takes a scrolling view, a rect, and a scroll position and attempts to scroll that rect to that position in that view.
static PRBool PR_CALLBACK ClearDocumentEnumerator (nsHashKey *aKey, void *aData, void *aClosure)
static PRBool ComputeClipRect (nsIFrame *aFrame, nsRect &aResult)
static PRBool SetClipRect (nsIRenderingContext &aRenderingContext, nsIFrame *aFrame)
static PRBool InClipRect (nsIFrame *aFrame, nsPoint &aEventPoint)
PRBool IsSynthesizedMouseMove (nsEvent *aEvent)
static void StopPluginInstance (PresShell *aShell, nsIContent *aContent)
 FreezeSubDocument (nsIDocument *aDocument, void *aData)
static void StartPluginInstance (PresShell *aShell, nsIContent *aContent)
 ThawSubDocument (nsIDocument *aDocument, void *aData)
static void PR_CALLBACK HandlePLEvent (ReflowEvent *aEvent)
static void PR_CALLBACK DestroyPLEvent (ReflowEvent *aEvent)
 HandleDummyLayoutRequestPLEvent (PLEvent *aEvent)
 DestroyDummyLayoutRequestPLEvent (PLEvent *aEvent)

Variables

static PRInt32 gMaxRCProcessingTime = -1
static PRBool gAsyncReflowDuringDocLoad = PR_FALSE
static const size_t gMaxRecycledSize = 400
static PRBool gVerifyReflowEnabled
static PRUint32 sInsertPrefSheetRulesAt = 1

Class Documentation

struct StackMark

Definition at line 439 of file nsPresShell.cpp.

Collaboration diagram for StackMark:
Class Members
StackBlock * mBlock
size_t mPos
struct nsDOMEventRequest

Definition at line 764 of file nsPresShell.cpp.

Collaboration diagram for nsDOMEventRequest:
Class Members
nsIContent * content
nsEvent * event
nsDOMEventRequest * next
struct nsAttributeChangeRequest

Definition at line 771 of file nsPresShell.cpp.

Collaboration diagram for nsAttributeChangeRequest:
Class Members
nsIContent * content
nsIAtom * name
PRInt32 nameSpaceID
nsAttributeChangeRequest * next
PRBool notify
nsAttributeChangeType type
nsAutoString value
struct nsCallbackEventRequest

Definition at line 782 of file nsPresShell.cpp.

Collaboration diagram for nsCallbackEventRequest:
Class Members
nsIReflowCallback * callback
nsCallbackEventRequest * next

Define Documentation

#define BLOCK_INCREMENT   4044 /* a bit under 4096, for malloc overhead */

Definition at line 416 of file nsPresShell.cpp.

Definition at line 415 of file nsPresShell.cpp.

#define NS_MAX_REFLOW_TIME   1000000

Definition at line 405 of file nsPresShell.cpp.

#define NS_PRESSHELL_NOTIFY_OBSERVERS (   func_,
  params_ 
)
Value:
do {                                                                        \
    for (PRInt32 i_ = 0; i_ < mObservers.Count(); ++i_) {                     \
      nsIDocumentObserver* obs_ = NS_STATIC_CAST(nsIDocumentObserver*,        \
                                                 mObservers[i_]);             \
      obs_ -> func_ params_ ;                                                 \
    }                                                                         \
  } while (0)

Definition at line 1569 of file nsPresShell.cpp.

Definition at line 1517 of file nsPresShell.cpp.

Definition at line 55 of file nsPresShell.cpp.

Definition at line 3177 of file nsPresShell.cpp.

Definition at line 397 of file nsPresShell.cpp.

Definition at line 1593 of file nsPresShell.cpp.


Function Documentation

static void CheckForFocus ( nsPIDOMWindow aOurWindow,
nsIFocusController aFocusController,
nsIDocument aDocument 
) [static]

Definition at line 2762 of file nsPresShell.cpp.

{
  NS_ASSERTION(aOurWindow->IsOuterWindow(),
               "Uh, our window has to be an outer window!");

  // Now that we have a root frame, we can set focus on the presshell.
  // We do this only if our DOM window is currently focused or is an
  // an ancestor of a previously focused window.

  if (!aFocusController)
    return;

  nsCOMPtr<nsIDOMWindowInternal> ourWin = do_QueryInterface(aOurWindow);

  nsCOMPtr<nsIDOMWindowInternal> focusedWindow;
  aFocusController->GetFocusedWindow(getter_AddRefs(focusedWindow));
  if (!focusedWindow) {
    // This should never really happen, but if it does, assume
    // we can focus ourself to keep the window from being keydead.
    focusedWindow = ourWin;
  }

  // Walk up the document chain, starting with focusedWindow's document.
  // We stop walking when we find a document that has a null DOMWindow
  // (meaning that the DOMWindow has a new document now) or find ourWin
  // as the document's window.  We also stop if we hit aDocument, since
  // that means there is a child document which loaded before us that's
  // already been given focus.

  nsCOMPtr<nsIDOMDocument> focusedDOMDoc;
  focusedWindow->GetDocument(getter_AddRefs(focusedDOMDoc));

  nsCOMPtr<nsIDocument> curDoc = do_QueryInterface(focusedDOMDoc);
  if (!curDoc) {
    // This can happen if the previously focused DOM window has been
    // unhooked from its document during document teardown.  We don't
    // really have any other information to help us determine where
    // focusedWindow fits into the DOM window hierarchy.  For now, we'll
    // go ahead and allow this window to take focus, so that something
    // ends up focused.

    curDoc = aDocument;
  }

  while (curDoc) {
    nsPIDOMWindow *curWin = curDoc->GetWindow();

    if (!curWin || curWin == ourWin)
      break;

    curDoc = curDoc->GetParentDocument();
    if (curDoc == aDocument)
      return;
  }

  if (!curDoc) {
    // We reached the top of the document chain, and did not encounter ourWin
    // or a windowless document. So, focus should be unaffected by this
    // document load.
    return;
  }

  PRBool active;
  aFocusController->GetActive(&active);
  if (active)
    ourWin->Focus();

  // We need to ensure that the focus controller is updated, since it may be
  // suppressed when this function is called.
  aFocusController->SetFocusedWindow(ourWin);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool PR_CALLBACK ClearDocumentEnumerator ( nsHashKey *  aKey,
void aData,
void aClosure 
) [static]

Definition at line 5112 of file nsPresShell.cpp.

{
  nsISupportsArray* anonymousElements =
    NS_STATIC_CAST(nsISupportsArray*, aData);

  PRUint32 count;
  anonymousElements->Count(&count);
  while (PRInt32(--count) >= 0) {
    nsCOMPtr<nsIContent> content = do_QueryElementAt(anonymousElements, count);
    NS_ASSERTION(content != nsnull, "not an nsIContent");
    if (! content)
      continue;

    content->UnbindFromTree();
  }

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ColorToString ( nscolor  aColor,
nsAutoString aString 
) [static]

Definition at line 8740 of file nsPresShell.cpp.

{
  char buf[8];

  PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
              NS_GET_R(aColor), NS_GET_G(aColor), NS_GET_B(aColor));
  CopyASCIItoUTF16(buf, aString);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool ComputeClipRect ( nsIFrame aFrame,
nsRect aResult 
) [static]

Definition at line 5885 of file nsPresShell.cpp.

                                                                 {
  const nsStyleDisplay* display = aFrame->GetStyleDisplay();
  
  // 'clip' only applies to absolutely positioned elements, and is
  // relative to the element's border edge. 'clip' applies to the entire
  // element: border, padding, and content areas, and even scrollbars if
  // there are any.
  if (display->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT)) {
    nsSize  size = aFrame->GetSize();

    // Start with the 'auto' values and then factor in user specified values
    nsRect  clipRect(0, 0, size.width, size.height);

    if (display->mClipFlags & NS_STYLE_CLIP_RECT) {
      if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) {
        clipRect.y = display->mClip.y;
      }
      if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) {
        clipRect.x = display->mClip.x;
      }
      if (0 == (NS_STYLE_CLIP_RIGHT_AUTO & display->mClipFlags)) {
        clipRect.width = display->mClip.width;
      }
      if (0 == (NS_STYLE_CLIP_BOTTOM_AUTO & display->mClipFlags)) {
        clipRect.height = display->mClip.height;
      }
    }

    aResult = clipRect;

    return PR_TRUE;
  }

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4081 of file nsPresShell.cpp.

Here is the caller graph for this function:

Definition at line 7255 of file nsPresShell.cpp.

Here is the caller graph for this function:

static void PR_CALLBACK DestroyPLEvent ( ReflowEvent aEvent) [static]

Definition at line 6941 of file nsPresShell.cpp.

{
  delete aEvent;
}
FreezeSubDocument ( nsIDocument aDocument,
void aData 
)

Definition at line 6765 of file nsPresShell.cpp.

{
  nsIPresShell *shell = aDocument->GetShellAt(0);
  if (shell)
    shell->Freeze();

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsIFrame* GetRootScrollFrame ( nsIFrame aRootFrame) [static]

Definition at line 2837 of file nsPresShell.cpp.

                                         {
  // Ensure root frame is a viewport frame
  if (aRootFrame && nsLayoutAtoms::viewportFrame == aRootFrame->GetType()) {
    nsIFrame* theFrame = aRootFrame->GetFirstChild(nsnull);
    if (theFrame && nsLayoutAtoms::scrollFrame == theFrame->GetType()) {
      return theFrame;
    }
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4072 of file nsPresShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7246 of file nsPresShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void PR_CALLBACK HandlePLEvent ( ReflowEvent aEvent) [static]

Definition at line 6936 of file nsPresShell.cpp.

{
  aEvent->HandleEvent();
}

Here is the call graph for this function:

static PRBool InClipRect ( nsIFrame aFrame,
nsPoint aEventPoint 
) [static]

Definition at line 5940 of file nsPresShell.cpp.

{
  nsRect clipRect;

  if (ComputeClipRect(aFrame, clipRect)) {
    return clipRect.Contains(aEventPoint);
  } else {
    return PR_TRUE;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool IsSynthesizedMouseMove ( nsEvent aEvent) [inline]

Definition at line 6444 of file nsPresShell.cpp.

{
  return aEvent->eventStructType == NS_MOUSE_EVENT &&
         NS_STATIC_CAST(nsMouseEvent*, aEvent)->reason != nsMouseEvent::eReal;
}

Here is the caller graph for this function:

static NS_DEFINE_CID ( kCSSStyleSheetCID  ,
NS_CSS_STYLESHEET_CID   
) [static]
static NS_DEFINE_CID ( kFrameSelectionCID  ,
NS_FRAMESELECTION_CID   
) [static]
static NS_DEFINE_IID ( kRangeCID  ,
NS_RANGE_CID   
) [static]

Definition at line 1751 of file nsPresShell.cpp.

{
  if (!mHaveShutDown) {
    NS_NOTREACHED("Someone did not call nsIPresShell::destroy");
    Destroy();
  }

  NS_ASSERTION(mCurrentEventContentStack.Count() == 0,
               "Huh, event content left on the stack in pres shell dtor!");
  NS_ASSERTION(mFirstDOMEventRequest == nsnull &&
               mLastDOMEventRequest == nsnull &&
               mFirstAttributeRequest == nsnull &&
               mLastAttributeRequest == nsnull &&
               mFirstCallbackEventRequest == nsnull &&
               mLastCallbackEventRequest == nsnull,
               "post-reflow queues not empty.  This means we're leaking");
 
  delete mStyleSet;
  delete mFrameConstructor;

  mCurrentEventContent = nsnull;

  // if we allocated any stack memory free it.
  FreeDynamicStack();

  NS_IF_RELEASE(mPresContext);
  NS_IF_RELEASE(mDocument);
  NS_IF_RELEASE(mSelection);
}
nsresult NS_NewPresShell ( nsIPresShell **  aInstancePtrResult)

Create a new empty presentation shell.

Upon success, call Init before attempting to use the shell.

Definition at line 1711 of file nsPresShell.cpp.

{
  NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
  if (nsnull == aInstancePtrResult) {
    return NS_ERROR_NULL_POINTER;
  }
  PresShell* it = new PresShell();
  if (nsnull == it) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  return it->QueryInterface(NS_GET_IID(nsIPresShell),
                            (void **) aInstancePtrResult);
}

Here is the caller graph for this function:

Definition at line 1043 of file nsPresShell.cpp.

Here is the caller graph for this function:

ReflowCommandHashHashKey ( PLDHashTable table,
const void key 
)

Definition at line 1051 of file nsPresShell.cpp.

{
  const nsHTMLReflowCommand* command =
    NS_STATIC_CAST(const nsHTMLReflowCommand*, key);
  
  // The target is going to be reasonably unique, if we shift out the
  // always-zero low-order bits, the type comes from an enum and we just don't
  // have that many types, and the child list name is either null or has the
  // same high-order bits as all the other child list names.
  return
    (NS_PTR_TO_INT32(command->GetTarget()) >> 2) ^
    (command->Type() << 17) ^
    (NS_PTR_TO_INT32(command->GetChildListName()) << 20);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1067 of file nsPresShell.cpp.

{
   const ReflowCommandEntry *e =
     NS_STATIC_CAST(const ReflowCommandEntry *, entry);
   const nsHTMLReflowCommand *command = e->mCommand;
   const nsHTMLReflowCommand *command2 =
     NS_STATIC_CAST(const nsHTMLReflowCommand *, key);

   return
     command->GetTarget() == command2->GetTarget() &&
     command->Type() == command2->Type() &&
     command->GetChildListName() == command2->GetChildListName();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ScrollViewToShowRect ( nsIScrollableView aScrollingView,
nsRect aRect,
PRIntn  aVPercent,
PRIntn  aHPercent 
) [static]

This function takes a scrolling view, a rect, and a scroll position and attempts to scroll that rect to that position in that view.

The rect should be in the coordinate system of the scrolled view.

Definition at line 4527 of file nsPresShell.cpp.

{
  // Determine the visible rect in the scrolling view's coordinate space.
  // The size of the visible area is the clip view size
  nsRect visibleRect = aScrollingView->View()->GetBounds(); // get width and height
  aScrollingView->GetScrollPosition(visibleRect.x, visibleRect.y);

  // The actual scroll offsets
  nscoord scrollOffsetX = visibleRect.x;
  nscoord scrollOffsetY = visibleRect.y;

  nscoord lineHeight;
  aScrollingView->GetLineHeight(&lineHeight);
  
  // See how the rect should be positioned vertically
  if (NS_PRESSHELL_SCROLL_ANYWHERE == aVPercent) {
    // The caller doesn't care where the frame is positioned vertically,
    // so long as it's fully visible
    if (aRect.y < visibleRect.y) {
      // Scroll up so the frame's top edge is visible
      scrollOffsetY = aRect.y;
    } else if (aRect.YMost() > visibleRect.YMost()) {
      // Scroll down so the frame's bottom edge is visible. Make sure the
      // frame's top edge is still visible
      scrollOffsetY += aRect.YMost() - visibleRect.YMost();
      if (scrollOffsetY > aRect.y) {
        scrollOffsetY = aRect.y;
      }
    }
  } else if (NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE == aVPercent) {
    // Scroll only if no part of the frame is visible in this view
    if (aRect.YMost() - lineHeight < visibleRect.y) {
      // Scroll up so the frame's top edge is visible
      scrollOffsetY = aRect.y;
    }  else if (aRect.y + lineHeight > visibleRect.YMost()) {
      // Scroll down so the frame's bottom edge is visible. Make sure the
      // frame's top edge is still visible
      scrollOffsetY += aRect.YMost() - visibleRect.YMost();
      if (scrollOffsetY > aRect.y) {
        scrollOffsetY = aRect.y;
      }
    }
  } else {
    // Align the frame edge according to the specified percentage
    nscoord frameAlignY =
      NSToCoordRound(aRect.y + aRect.height * (aVPercent / 100.0f));
    scrollOffsetY =
      NSToCoordRound(frameAlignY - visibleRect.height * (aVPercent / 100.0f));
  }

  // See how the frame should be positioned horizontally
  if (NS_PRESSHELL_SCROLL_ANYWHERE == aHPercent) {
    // The caller doesn't care where the frame is positioned horizontally,
    // so long as it's fully visible
    if (aRect.x < visibleRect.x) {
      // Scroll left so the frame's left edge is visible
      scrollOffsetX = aRect.x;
    } else if (aRect.XMost() > visibleRect.XMost()) {
      // Scroll right so the frame's right edge is visible. Make sure the
      // frame's left edge is still visible
      scrollOffsetX += aRect.XMost() - visibleRect.XMost();
      if (scrollOffsetX > aRect.x) {
        scrollOffsetX = aRect.x;
      }
    }
  } else if (NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE == aHPercent) {
    // Scroll only if no part of the frame is visible in this view
    // XXXbz using the line height here is odd, but there are no
    // natural dimensions to use here, really....
    if (aRect.XMost() - lineHeight < visibleRect.x) {
      // Scroll left so the frame's left edge is visible
      scrollOffsetX = aRect.x;
    }  else if (aRect.x + lineHeight > visibleRect.XMost()) {
      // Scroll right so the frame's right edge is visible. Make sure the
      // frame's left edge is still visible
      scrollOffsetX += aRect.XMost() - visibleRect.XMost();
      if (scrollOffsetX > aRect.x) {
        scrollOffsetX = aRect.x;
      }
    }
  } else {
    // Align the frame edge according to the specified percentage
    nscoord frameAlignX =
      NSToCoordRound(aRect.x + (aRect.width) * (aHPercent / 100.0f));
    scrollOffsetX =
      NSToCoordRound(frameAlignX - visibleRect.width * (aHPercent / 100.0f));
  }

  aScrollingView->ScrollTo(scrollOffsetX, scrollOffsetY,
                           NS_VMREFRESH_IMMEDIATE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool SetClipRect ( nsIRenderingContext aRenderingContext,
nsIFrame aFrame 
) [static]

Definition at line 5925 of file nsPresShell.cpp.

{
  nsRect clipRect;

  if (ComputeClipRect(aFrame, clipRect)) {
    // Set updated clip-rect into the rendering context
    aRenderingContext.PushState();
    aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
    return PR_TRUE;
  }

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void StartPluginInstance ( PresShell aShell,
nsIContent aContent 
) [static]

Definition at line 6794 of file nsPresShell.cpp.

{
  // For now we just reconstruct the frame, but only if the element
  // had a plugin instance before we stopped it.  Other types of
  // embedded content (eg SVG) become unhappy if we do a frame
  // reconstruct here.
  nsIFrame *frame = nsnull;
  aShell->GetPrimaryFrameFor(aContent, &frame);
  if (frame) {
    nsIObjectFrame *objFrame = nsnull;
    CallQueryInterface(frame, &objFrame);
    if (objFrame && frame->GetProperty(nsLayoutAtoms::objectFrame)) {
      // Note: no need to remove the property here, since we're about
      // to blow away the frame
      aShell->RecreateFramesFor(aContent);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void StopPluginInstance ( PresShell aShell,
nsIContent aContent 
) [static]

Definition at line 6719 of file nsPresShell.cpp.

{
  nsIFrame *frame = aShell->FrameManager()->GetPrimaryFrameFor(aContent);

  nsIObjectFrame *objectFrame = nsnull;
  if (frame)
    CallQueryInterface(frame, &objectFrame);
  if (!objectFrame)
    return;

  nsCOMPtr<nsIPluginInstance> instance;
  objectFrame->GetPluginInstance(*getter_AddRefs(instance));
  if (!instance)
    return;

  // Note on the frame that it used to have a plugin instance, since
  // we're about to make said instance go away
  frame->SetProperty(nsLayoutAtoms::objectFrame, NS_INT32_TO_PTR(1));

  // Check whether the plugin wants SetWindow to be called before or after
  // Stop/Destroy.  This is similar to nsObjectFrame::Destroy(), but we
  // don't want to destroy the frame just yet.

  PRBool callSetWindowLast = PR_FALSE;
  instance->GetValue(nsPluginInstanceVariable_CallSetWindowAfterDestroyBool,
                     (void *) &callSetWindowLast);
  if (callSetWindowLast) {
    instance->Stop();
    instance->Destroy();
    instance->SetWindow(nsnull);
  } else {
    instance->Stop();
    instance->SetWindow(nsnull);
    instance->Destroy();
  }

  // XXXbz have to use the plugin manager contract because the plugin host
  // registers for two different contracts with two difference CIDs!  We want
  // the plugin manager CID, since that's the one nsObjectFrame gets.
  nsCOMPtr<nsIPluginHost> pluginHost =
    do_GetService("@mozilla.org/plugin/manager;1");
  if (pluginHost)
    pluginHost->StopPluginInstance(instance);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ThawSubDocument ( nsIDocument aDocument,
void aData 
)

Definition at line 6814 of file nsPresShell.cpp.

{
  nsIPresShell *shell = aDocument->GetShellAt(0);
  if (shell)
    shell->Thaw();

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void UpdateViewProperties ( nsPresContext aPresContext,
nsIViewManager aVM,
nsIView aView 
) [static]

Definition at line 3517 of file nsPresShell.cpp.

                                                 {
  nsIViewManager* thisVM = aView->GetViewManager();
  if (thisVM != aVM) {
    return;
  }

  nsIFrame* frame = NS_STATIC_CAST(nsIFrame*, aView->GetClientData());
  if (frame) {
    nsContainerFrame::SyncFrameViewProperties(aPresContext, frame, nsnull, aView);
  }

  for (nsIView* child = aView->GetFirstChild(); child;
       child = child->GetNextSibling()) {
    UpdateViewProperties(aPresContext, aVM, child);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 410 of file nsPresShell.cpp.

Definition at line 406 of file nsPresShell.cpp.

const size_t gMaxRecycledSize = 400 [static]

Definition at line 413 of file nsPresShell.cpp.

Definition at line 1596 of file nsPresShell.cpp.

Definition at line 2397 of file nsPresShell.cpp.