Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends
PresShell Class Reference
Inheritance diagram for PresShell:
Inheritance graph
[legend]
Collaboration diagram for PresShell:
Collaboration graph
[legend]

List of all members.

Public Types

enum  GeneratedContentType { Before, After }
 Returns a content iterator to iterate the generated content nodes. More...

Public Member Functions

 PresShell ()
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS NS_IMETHOD 
Init (nsIDocument *aDocument, nsPresContext *aPresContext, nsIViewManager *aViewManager, nsStyleSet *aStyleSet, nsCompatibility aCompatMode)
 Initialize the presentation shell.
NS_IMETHOD Destroy ()
 All callers are responsible for calling |Destroy| after calling |EndObservingDocument|.
virtual NS_HIDDEN_ (void *) AllocateFrame(size_t aSize)
virtual NS_HIDDEN_ (void) FreeFrame(size_t aSize
NS_IMETHOD PushStackMemory ()
NS_IMETHOD PopStackMemory ()
NS_IMETHOD AllocateStackMemory (size_t aSize, void **aResult)
NS_IMETHOD GetActiveAlternateStyleSheet (nsString &aSheetTitle)
NS_IMETHOD SelectAlternateStyleSheet (const nsString &aSheetTitle)
NS_IMETHOD ListAlternateStyleSheets (nsStringArray &aTitleList)
 Gather titles of all selectable (alternate and preferred) style sheets fills void array with nsString* caller must free strings.
NS_IMETHOD SetPreferenceStyleRules (PRBool aForceReflow)
 Setup all style rules required to implement preferences.
NS_IMETHOD GetSelection (SelectionType aType, nsISelection **aSelection)
NS_IMETHOD SetDisplaySelection (PRInt16 aToggle)
NS_IMETHOD GetDisplaySelection (PRInt16 *aToggle)
NS_IMETHOD ScrollSelectionIntoView (SelectionType aType, SelectionRegion aRegion, PRBool aIsSynchronous)
NS_IMETHOD RepaintSelection (SelectionType aType)
NS_IMETHOD BeginObservingDocument ()
NS_IMETHOD EndObservingDocument ()
NS_IMETHOD GetDidInitialReflow (PRBool *aDidInitialReflow)
 Determine if InitialReflow() was previously called.
NS_IMETHOD InitialReflow (nscoord aWidth, nscoord aHeight)
 Perform the initial reflow.
NS_IMETHOD ResizeReflow (nscoord aWidth, nscoord aHeight)
 Reflow the frame model into a new width and height.
NS_IMETHOD StyleChangeReflow ()
 Reflow the frame model with a reflow reason of eReflowReason_StyleChange.
NS_IMETHOD GetPageSequenceFrame (nsIPageSequenceFrame **aResult) const
 Returns the page sequence frame associated with the frame hierarchy.
NS_IMETHOD GetPrimaryFrameFor (nsIContent *aContent, nsIFrame **aPrimaryFrame) const
 Gets the primary frame associated with the content object.
NS_IMETHOD GetLayoutObjectFor (nsIContent *aContent, nsISupports **aResult) const
 Returns a layout object associated with the primary frame for the content object.
NS_IMETHOD GetPlaceholderFrameFor (nsIFrame *aFrame, nsIFrame **aPlaceholderFrame) const
 Gets the placeholder frame associated with the specified frame.
NS_IMETHOD AppendReflowCommand (nsIFrame *aTargetFrame, nsReflowType aReflowType, nsIAtom *aChildListName)
 Reflow commands.
NS_IMETHOD CancelReflowCommand (nsIFrame *aTargetFrame, nsReflowType *aCmdType)
NS_IMETHOD CancelReflowCommandInternal (nsIFrame *aTargetFrame, nsReflowType *aCmdType, PRBool aProcessDummyLayoutRequest=PR_TRUE)
NS_IMETHOD CancelAllReflowCommands ()
NS_IMETHOD IsSafeToFlush (PRBool &aIsSafeToFlush)
 Determine if it is safe to flush all pending notifications.
NS_IMETHOD FlushPendingNotifications (mozFlushType aType)
 Flush pending notifications of the type specified.
NS_IMETHOD RecreateFramesFor (nsIContent *aContent)
 Recreates the frames for a node.
NS_IMETHOD PostDOMEvent (nsIContent *aContent, nsEvent *aEvent)
 Post a request to handle a DOM event after Reflow has finished.
NS_IMETHOD PostAttributeChange (nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aName, const nsString &aValue, PRBool aNotify, nsAttributeChangeType aType)
 Post a request to set and attribute after reflow has finished.
NS_IMETHOD PostReflowCallback (nsIReflowCallback *aCallback)
 Post a callback that should be handled after reflow has finished.
NS_IMETHOD CancelReflowCallback (nsIReflowCallback *aCallback)
NS_IMETHOD BeginReflowBatching ()
 Reflow batching.
NS_IMETHOD EndReflowBatching (PRBool aFlushPendingReflows)
NS_IMETHOD GetReflowBatchingStatus (PRBool *aBatch)
NS_IMETHOD ClearFrameRefs (nsIFrame *aFrame)
NS_IMETHOD CreateRenderingContext (nsIFrame *aFrame, nsIRenderingContext **aContext)
 Given a frame, create a rendering context suitable for use with the frame.
NS_IMETHOD CantRenderReplacedElement (nsIFrame *aFrame)
 Notification that we were unable to render a replaced element.
NS_IMETHOD GoToAnchor (const nsAString &aAnchorName, PRBool aScroll)
 Informs the pres shell that the document is now at the anchor with the given name.
NS_IMETHOD ScrollFrameIntoView (nsIFrame *aFrame, PRIntn aVPercent, PRIntn aHPercent) const
 Scrolls the view of the document so that the frame is displayed at the top of the window.
NS_IMETHOD SetIgnoreFrameDestruction (PRBool aIgnore)
 Suppress notification of the frame manager that frames are being destroyed.
NS_IMETHOD NotifyDestroyingFrame (nsIFrame *aFrame)
 Notification sent by a frame informing the pres shell that it is about to be destroyed.
NS_IMETHOD DoCopy ()
 Notify the Clipboard that we have something to copy.
NS_IMETHOD GetSelectionForCopy (nsISelection **outSelection)
 Get the selection of the focussed element (either the page selection, or the selection for a text field).
NS_IMETHOD GetLinkLocation (nsIDOMNode *aNode, nsAString &aLocationString)
 Get link location.
NS_IMETHOD DoGetContents (const nsACString &aMimeType, PRUint32 aFlags, PRBool aSelectionOnly, nsAString &outValue)
 Get the doc or the selection as text or html.
NS_IMETHOD CaptureHistoryState (nsILayoutHistoryState **aLayoutHistoryState, PRBool aLeavingPage)
 Get and set the history state for the current document.
NS_IMETHOD GetGeneratedContentIterator (nsIContent *aContent, GeneratedContentType aType, nsIContentIterator **aIterator) const
NS_IMETHOD SetAnonymousContentFor (nsIContent *aContent, nsISupportsArray *aAnonymousElements)
 Store the nsIAnonymousContentCreator-generated anonymous content that's associated with an element.
NS_IMETHOD GetAnonymousContentFor (nsIContent *aContent, nsISupportsArray **aAnonymousElements)
 Retrieve the nsIAnonymousContentCreator-generated anonymous content that's associated with an element.
NS_IMETHOD ReleaseAnonymousContent ()
 Release all nsIAnonymousContentCreator-generated anonymous content associated with the shell.
NS_IMETHOD IsPaintingSuppressed (PRBool *aResult)
 Called to find out if painting is suppressed for this presshell.
NS_IMETHOD UnsuppressPainting ()
 Unsuppress painting.
NS_IMETHOD DisableThemeSupport ()
 Called to disable nsITheme support in a specific presshell.
virtual PRBool IsThemeSupportEnabled ()
 Indicates whether theme support is enabled.
virtual nsresult GetAgentStyleSheets (nsCOMArray< nsIStyleSheet > &aSheets)
 Get the set of agent style sheets for this presentation.
virtual nsresult SetAgentStyleSheets (const nsCOMArray< nsIStyleSheet > &aSheets)
 Replace the set of agent style sheets.
virtual nsresult AddOverrideStyleSheet (nsIStyleSheet *aSheet)
 Add an override style sheet for this presentation.
virtual nsresult RemoveOverrideStyleSheet (nsIStyleSheet *aSheet)
 Remove an override style sheet.
NS_IMETHOD HandleEventWithTarget (nsEvent *aEvent, nsIFrame *aFrame, nsIContent *aContent, PRUint32 aFlags, nsEventStatus *aStatus)
 Interface to dispatch events via the presshell.
NS_IMETHOD GetEventTargetFrame (nsIFrame **aFrame)
 Gets the current target event frame from the PresShell.
NS_IMETHOD GetEventTargetContent (nsEvent *aEvent, nsIContent **aContent)
 Gets the current target event frame from the PresShell.
NS_IMETHOD IsReflowLocked (PRBool *aIsLocked)
 Determine if reflow is currently locked.
virtual nsresult ReconstructFrames (void)
 Reconstruct frames for all elements in the document.
virtual void Freeze ()
 Stop all active elements (plugins and the caret) in this presentation and in the presentations of subdocuments.
virtual void Thaw ()
 Restarts active elements (plugins) in this presentation and in the presentations of subdocuments, then do a full invalidate of the content area.
virtual void HidePopups ()
virtual void BlockFlushing ()
virtual void UnblockFlushing ()
virtual void AddObserver (nsIDocumentObserver *aObserver)
virtual PRBool RemoveObserver (nsIDocumentObserver *aObserver)
NS_IMETHOD Paint (nsIView *aView, nsIRenderingContext &aRenderingContext, const nsRect &aDirtyRect)
NS_IMETHOD HandleEvent (nsIView *aView, nsGUIEvent *aEvent, nsEventStatus *aEventStatus, PRBool aForceHandle, PRBool &aHandled)
NS_IMETHOD HandleDOMEventWithTarget (nsIContent *aTargetContent, nsEvent *aEvent, nsEventStatus *aStatus)
 Dispatch event to content only (NOT full processing)
NS_IMETHOD ResizeReflow (nsIView *aView, nscoord aWidth, nscoord aHeight)
 NS_IMETHOD_ (PRBool) IsVisible()
 Hack to find out if the view observer is itself visible, in lieu of having the view trees linked.
 NS_IMETHOD_ (void) WillPaint()
 Notify the observer that we're about to start painting.
NS_IMETHOD GetCaret (nsICaret **aOutCaret)
 Get the caret, if it exists.
NS_IMETHOD SetCaretEnabled (PRBool aInEnable)
NS_IMETHOD SetCaretReadOnly (PRBool aReadOnly)
NS_IMETHOD GetCaretEnabled (PRBool *aOutEnabled)
NS_IMETHOD SetCaretVisibilityDuringSelection (PRBool aVisibility)
NS_IMETHOD SetSelectionFlags (PRInt16 aInEnable)
 Should the images have borders etc.
NS_IMETHOD GetSelectionFlags (PRInt16 *aOutEnable)
 Gets the current state of non text selection effects.
NS_IMETHOD CharacterMove (PRBool aForward, PRBool aExtend)
NS_IMETHOD WordMove (PRBool aForward, PRBool aExtend)
NS_IMETHOD LineMove (PRBool aForward, PRBool aExtend)
NS_IMETHOD IntraLineMove (PRBool aForward, PRBool aExtend)
NS_IMETHOD PageMove (PRBool aForward, PRBool aExtend)
NS_IMETHOD ScrollPage (PRBool aForward)
NS_IMETHOD ScrollLine (PRBool aForward)
NS_IMETHOD ScrollHorizontal (PRBool aLeft)
NS_IMETHOD CompleteScroll (PRBool aForward)
NS_IMETHOD CompleteMove (PRBool aForward, PRBool aExtend)
NS_IMETHOD SelectAll ()
NS_IMETHOD CheckVisibility (nsIDOMNode *node, PRInt16 startOffset, PRInt16 EndOffset, PRBool *_retval)
virtual void BeginUpdate (nsIDocument *aDocument, nsUpdateType aUpdateType)
 Notify that a content model update is beginning.
virtual void EndUpdate (nsIDocument *aDocument, nsUpdateType aUpdateType)
 Notify that a content model update is finished.
virtual void BeginLoad (nsIDocument *aDocument)
 Notify the observer that a document load is beginning.
virtual void EndLoad (nsIDocument *aDocument)
 Notify the observer that a document load has finished.
virtual void CharacterDataChanged (nsIDocument *aDocument, nsIContent *aContent, PRBool aAppend)
 Notification that the content model has changed.
virtual void ContentStatesChanged (nsIDocument *aDocument, nsIContent *aContent1, nsIContent *aContent2, PRInt32 aStateMask)
 Notification that the state of a content node has changed.
virtual void AttributeChanged (nsIDocument *aDocument, nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, PRInt32 aModType)
 Notification that the content model has changed.
virtual void ContentAppended (nsIDocument *aDocument, nsIContent *aContainer, PRInt32 aNewIndexInContainer)
 Notifcation that the content model has had data appended to the given content object.
virtual void ContentInserted (nsIDocument *aDocument, nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer)
 Notification that content has been inserted.
virtual void ContentRemoved (nsIDocument *aDocument, nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer)
 Content has just been removed.
virtual void StyleSheetAdded (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aDocumentSheet)
 A StyleSheet has just been added to the document.
virtual void StyleSheetRemoved (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aDocumentSheet)
 A StyleSheet has just been removed from the document.
virtual void StyleSheetApplicableStateChanged (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aApplicable)
 A StyleSheet has just changed its applicable state.
virtual void StyleRuleChanged (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, nsIStyleRule *aOldStyleRule, nsIStyleRule *aNewStyleRule)
 A StyleRule has just been modified within a style sheet.
virtual void StyleRuleAdded (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, nsIStyleRule *aStyleRule)
 A StyleRule has just been added to a style sheet.
virtual void StyleRuleRemoved (nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, nsIStyleRule *aStyleRule)
 A StyleRule has just been removed from a style sheet.
void AddWeakFrame (nsWeakFrame *aWeakFrame)
void RemoveWeakFrame (nsWeakFrame *aWeakFrame)
virtual voidAllocateFrame (size_t aSize)=0
virtual void FreeFrame (size_t aSize, void *aFreeChunk)=0
nsIDocumentGetDocument ()
nsPresContextGetPresContext ()
nsIViewManagerGetViewManager ()
 NS_HIDDEN_ (PRBool) GetAuthorStyleDisabled()
virtual NS_HIDDEN_ (nsIFrame *) GetRootFrame() const
 This calls through to the frame manager to get the root frame.
void ReconstructStyleData ()
nsIFrameSelectionFrameSelection ()
 FrameSelection will return the Frame based selection API.
PRBool IsAccessibilityActive ()
void SetForwardingContainer (nsWeakPtr aContainer)
 When this shell is disconnected from its containing docshell, we lose our container pointer.
virtual void BeginReflow (nsIDocument *aDocument, nsIPresShell *aShell)=0
 Notify the observer that the document is being reflowed in the given presentation shell.
virtual void EndReflow (nsIDocument *aDocument, nsIPresShell *aShell)=0
 Notify the observer that the document is done being reflowed in the given presentation shell.
virtual void DocumentWillBeDestroyed (nsIDocument *aDocument)=0
 The document is in the process of being destroyed.
void setDisplaySelection (in short toggle)
 SetDisplaySelection will set the display mode for the selection.
short getDisplaySelection ()
 GetDisplaySelection will get the display mode for the selection.
nsISelection getSelection (in short type)
 GetSelection will return the selection that the presentation shell may implement.
void scrollSelectionIntoView (in short type, in short region, in boolean isSynchronous)
 ScrollSelectionIntoView scrolls a region of the selection, so that it is visible in the scrolled view.
void repaintSelection (in short type)
 RepaintSelection repaints the selection specified by aType.
void setCaretEnabled (in boolean enabled)
 Set the caret as enabled or disabled.
void setCaretReadOnly (in boolean readOnly)
 Set the caret readonly or not.
boolean getCaretEnabled ()
 Gets the current state of the caret.
void setCaretVisibilityDuringSelection (in boolean visibility)
 Show the caret even in selections.
void characterMove (in boolean forward, in boolean extend)
 CharacterMove will move the selection one character forward/backward in the document.
void wordMove (in boolean forward, in boolean extend)
 WordMove will move the selection one word forward/backward in the document.
void lineMove (in boolean forward, in boolean extend)
 LineMove will move the selection one line forward/backward in the document.
void intraLineMove (in boolean forward, in boolean extend)
 IntraLineMove will move the selection to the front of the line or end of the line in the document.
void pageMove (in boolean forward, in boolean extend)
 PageMove will move the selection one page forward/backward in the document.
void completeScroll (in boolean forward)
 CompleteScroll will move page view to the top or bottom of the document.
void completeMove (in boolean forward, in boolean extend)
 CompleteMove will move page view to the top or bottom of the document this will also have the effect of collapsing the selection if the aExtend = PR_FALSE the "point" of selection that is extended is considered the "focus" point.
void scrollPage (in boolean forward)
 ScrollPage will scroll the page without affecting the selection.
void scrollLine (in boolean forward)
 ScrolLine will scroll line up or down dependent on the boolean.
void scrollHorizontal (in boolean left)
 ScrolHorizontal will scroll left or right dependent on the boolean.
void selectAll ()
 SelectAll will select the whole page.
boolean checkVisibility (in nsIDOMNode node, in short startOffset, in short endOffset)
 CheckVisibility will return true if textnode and offsets are actually rendered in the current precontext.
void setSelectionFlags (in short toggle)
short getSelectionFlags ()
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Static Public Member Functions

static PRBool GetVerifyReflowEnable ()
 See if reflow verification is enabled.
static void SetVerifyReflowEnable (PRBool aEnabled)
 Set the verify-reflow enable flag.
static PRInt32 GetVerifyReflowFlags ()
 Get the flags associated with the VerifyReflow debug tool.

Public Attributes

virtual voidaFreeChunk
const short SELECTION_NONE = 0
const short SELECTION_NORMAL = 1
const short SELECTION_SPELLCHECK = 2
const short SELECTION_IME_RAWINPUT = 4
const short SELECTION_IME_SELECTEDRAWTEXT = 8
const short SELECTION_IME_CONVERTEDTEXT = 16
const short SELECTION_IME_SELECTEDCONVERTEDTEXT = 32
const short SELECTION_ACCESSIBILITY = 64
const short NUM_SELECTIONTYPES = 8
const short SELECTION_ANCHOR_REGION = 0
const short SELECTION_FOCUS_REGION = 1
const short NUM_SELECTION_REGIONS = 2
const short SELECTION_OFF = 0
const short SELECTION_HIDDEN = 1
const short SELECTION_ON = 2
const short SELECTION_DISABLED = 3
const short SELECTION_ATTENTION = 4
const short DISPLAY_TEXT = 1
const short DISPLAY_IMAGES = 2
const short DISPLAY_FRAMES = 4
const short DISPLAY_ALL = 7

Protected Member Functions

virtual ~PresShell ()
void HandlePostedDOMEvents ()
void HandlePostedAttributeChanges ()
void HandlePostedReflowCallbacks ()
void UnsuppressAndInvalidate ()
nsresult ReflowCommandAdded (nsHTMLReflowCommand *aRC)
nsresult ReflowCommandRemoved (nsHTMLReflowCommand *aRC)
void DoneRemovingReflowCommands ()
nsresult AddDummyLayoutRequest (void)
nsresult RemoveDummyLayoutRequest ()
 NS_HIDDEN_ (void) DequeuePostedEventFor(nsIFrame *aFrame)
 FindPostedEventFor (nsIFrame *aFrame)
void WillCauseReflow ()
nsresult DidCauseReflow ()
void DidDoReflow ()
nsresult ProcessReflowCommands (PRBool aInterruptible)
nsresult ClearReflowEventStatus ()
void PostReflowEvent ()
PRBool AlreadyInQueue (nsHTMLReflowCommand *aReflowCommand)
PRBool IsDragInProgress () const
nsIScrollableViewGetViewToScroll (nsLayoutUtils::Direction aDirection)
nsresult ClearPreferenceStyleRules (void)
 methods that manage rules that are used to implement the associated preferences
nsresult CreatePreferenceStyleSheet (void)
nsresult SetPrefColorRules (void)
nsresult SetPrefLinkRules (void)
nsresult SetPrefFocusRules (void)
nsresult SetPrefNoScriptRule ()
nsresult SetPrefNoFramesRule (void)
void HideViewIfPopup (nsIView *aView)
 MOZ_TIMER_DECLARE (mReflowWatch) MOZ_TIMER_DECLARE(mFrameCreationWatch) nsAutoVoidArray mObservers

Static Protected Member Functions

static void sPaintSuppressionCallback (nsITimer *aTimer, void *aPresShell)

Protected Attributes

PRBool mCaretEnabled
nsICSSStyleSheetmPrefStyleSheet
nsVoidArray mReflowCommands
PLDHashTable mReflowCommandTable
PRPackedBool mDocumentLoading
PRPackedBool mIsReflowing
PRPackedBool mIsDestroying
PRPackedBool mIsReleasingAnonymousContent
PRPackedBool mIgnoreFrameDestruction
PRPackedBool mHaveShutDown
PRUint32 mChangeNestCount
nsIFramemCurrentEventFrame
nsCOMPtr< nsIContentmCurrentEventContent
nsVoidArray mCurrentEventFrameStack
nsCOMArray< nsIContentmCurrentEventContentStack
nsSupportsHashtable * mAnonymousContentTable
nsCOMPtr< nsICaretmCaret
PRInt16 mSelectionFlags
PRPackedBool mBatchReflows
PRPackedBool mDummyLayoutRequestEventPosted
PresShellViewEventListenermViewEventListener
nsCOMPtr< nsIEventQueueServicemEventQueueService
nsCOMPtr< nsIEventQueuemReflowEventQueue
FrameArena mFrameArena
StackArenamStackArena
nsCOMPtr< nsIDragServicemDragService
PRInt32 mRCCreatedDuringLoad
nsCOMPtr< nsIRequestmDummyLayoutRequest
CantRenderReplacedElementEventmPostedReplaces
nsDOMEventRequestmFirstDOMEventRequest
nsDOMEventRequestmLastDOMEventRequest
nsAttributeChangeRequestmFirstAttributeRequest
nsAttributeChangeRequestmLastAttributeRequest
nsCallbackEventRequestmFirstCallbackEventRequest
nsCallbackEventRequestmLastCallbackEventRequest
PRPackedBool mIsThemeSupportDisabled
PRPackedBool mIsDocumentGone
PRPackedBool mPaintingSuppressed
PRPackedBool mShouldUnsuppressPainting
nsCOMPtr< nsITimermPaintSuppressionTimer
nsWeakFramemWeakFrames
nsIDocumentmDocument
nsPresContextmPresContext
nsStyleSetmStyleSet
nsCSSFrameConstructormFrameConstructor
nsIViewManagermViewManager
nsIFrameSelectionmSelection
nsFrameManagerBase mFrameManager
nsWeakPtr mForwardingContainer
PRPackedBool mStylesHaveChanged
PRPackedBool mIsAccessibilityActive
PRPackedBool mDidInitialReflow

Private Types

typedef void(* nsPluginEnumCallback )(PresShell *, nsIContent *)

Private Member Functions

PRBool InZombieDocument (nsIContent *aContent)
nsresult RetargetEventToParent (nsIView *aView, nsGUIEvent *aEvent, nsEventStatus *aEventStatus, PRBool aForceHandle, PRBool &aHandled, nsIContent *aZombieFocusedContent)
void FreeDynamicStack ()
nsIFrameGetCurrentEventFrame ()
void PushCurrentEventInfo (nsIFrame *aFrame, nsIContent *aContent)
void PopCurrentEventInfo ()
nsresult HandleEventInternal (nsEvent *aEvent, nsIView *aView, PRUint32 aFlags, nsEventStatus *aStatus)
void CreateResizeEventTimer ()
void KillResizeEventTimer ()
void FireResizeEvent ()
void EnumeratePlugins (nsIDOMDocument *aDocument, const nsString &aPluginTag, nsPluginEnumCallback aCallback)

Static Private Member Functions

static void sResizeEventCallback (nsITimer *aTimer, void *aPresShell)

Private Attributes

nsCOMPtr< nsITimermResizeEventTimer

Friends

class nsIPresShell
struct DummyLayoutRequestEvent
struct CantRenderReplacedElementEvent
struct ReflowEvent

Detailed Description

Definition at line 1086 of file nsPresShell.cpp.


Member Typedef Documentation

Definition at line 1562 of file nsPresShell.cpp.


Member Enumeration Documentation

Returns a content iterator to iterate the generated content nodes.

You must specify whether you want to iterate the "before" generated content or the "after" generated content. If there is no generated content of the specified type for the promary frame associated with with the content object then NULL is returned

Enumerator:
Before 
After 

Definition at line 556 of file nsIPresShell.h.


Constructor & Destructor Documentation

Definition at line 1725 of file nsPresShell.cpp.

  : mBidiLevel(BIDI_LEVEL_UNDEFINED)
#endif
{
  mIsAccessibilityActive = PR_FALSE;
  mSelection = nsnull;
#ifdef MOZ_REFLOW_PERF
  mReflowCountMgr = new ReflowCountMgr();
  mReflowCountMgr->SetPresContext(mPresContext);
  mReflowCountMgr->SetPresShell(this);
#endif
#ifdef IBMBIDI
  mBidiLevel = BIDI_LEVEL_UNDEFINED;
#endif
#ifdef PR_LOGGING
  if (! gLog)
    gLog = PR_NewLogModule("PresShell");
#endif
  mSelectionFlags = nsISelectionDisplay::DISPLAY_TEXT | nsISelectionDisplay::DISPLAY_IMAGES;
  mIsThemeSupportDisabled = PR_FALSE;
  mIsReleasingAnonymousContent = PR_FALSE;

  new (this) nsFrameManager();
}
virtual PresShell::~PresShell ( ) [protected, virtual]

Member Function Documentation

Definition at line 7306 of file nsPresShell.cpp.

{ 
  nsresult rv = NS_OK;

  if (gAsyncReflowDuringDocLoad && !mIsReflowing) {
    rv = nsDummyLayoutRequest::Create(getter_AddRefs(mDummyLayoutRequest), this);
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsILoadGroup> loadGroup;
    if (mDocument)
      loadGroup = mDocument->GetDocumentLoadGroup();

    if (loadGroup) {
      rv = mDummyLayoutRequest->SetLoadGroup(loadGroup);
      if (NS_FAILED(rv)) return rv;
      rv = loadGroup->AddRequest(mDummyLayoutRequest, nsnull);
      if (NS_FAILED(rv)) return rv;

      PR_LOG(gLog, PR_LOG_ALWAYS,
             ("presshell=%p, Added dummy layout request %p", this, mDummyLayoutRequest.get()));
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PresShell::AddObserver ( nsIDocumentObserver aObserver) [virtual]

Implements nsIPresShell_MOZILLA_1_8_BRANCH2.

Definition at line 6865 of file nsPresShell.cpp.

{
 if (mObservers.IndexOf(aObserver) == -1) {
    mObservers.AppendElement(aObserver);
  }
}

Add an override style sheet for this presentation.

Implements nsIPresShell.

Definition at line 6707 of file nsPresShell.cpp.

Here is the call graph for this function:

Definition at line 1683 of file nsPresShell.cpp.

{
  if (aWeakFrame->GetFrame()) {
    aWeakFrame->GetFrame()->AddStateBits(NS_FRAME_EXTERNAL_REFERENCE);
  }
  aWeakFrame->SetPreviousWeakFrame(mWeakFrames);
  mWeakFrames = aWeakFrame;
}

Here is the call graph for this function:

virtual void* nsIPresShell::AllocateFrame ( size_t  aSize) [pure virtual, inherited]

Here is the caller graph for this function:

NS_IMETHODIMP PresShell::AllocateStackMemory ( size_t  aSize,
void **  aResult 
) [virtual]

Implements nsIPresShell.

Definition at line 2110 of file nsPresShell.cpp.

PRBool PresShell::AlreadyInQueue ( nsHTMLReflowCommand aReflowCommand) [protected]

Definition at line 3719 of file nsPresShell.cpp.

{
  if (!mReflowCommandTable.ops) {
    // We're already destroyed
    NS_ERROR("We really shouldn't be posting reflow commands here");
  }

  ReflowCommandEntry* e =
    NS_STATIC_CAST(ReflowCommandEntry*,
                   PL_DHashTableOperate(&mReflowCommandTable, aReflowCommand,
                                        PL_DHASH_ADD));

  if (!e) {
    // We lie no matter what we say here
    return PR_FALSE;
  }

  // We're using the stub ClearEntry, which zeros out entries, so a
  // non-null mCommand means we're in the queue already.
  if (e->mCommand) {
#ifdef DEBUG
    if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
      printf("*** PresShell::AlreadyInQueue(): Discarding reflow command: this=%p\n", (void*)this);
      aReflowCommand->List(stdout);
    }
#endif
    return PR_TRUE;
  }

  e->mCommand = aReflowCommand;
  return PR_FALSE;
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::AppendReflowCommand ( nsIFrame aTargetFrame,
nsReflowType  aReflowType,
nsIAtom aChildListName 
) [virtual]

Reflow commands.

Implements nsIPresShell.

Definition at line 3753 of file nsPresShell.cpp.

{
  // If we've not yet done the initial reflow, then don't bother
  // enqueuing a reflow command yet.
  if (! mDidInitialReflow)
    return NS_OK;

  // If we're already destroying, don't bother with this either.
  if (mIsDestroying)
    return NS_OK;

#ifdef DEBUG
  //printf("gShellCounter: %d\n", gShellCounter++);
  if (mInVerifyReflow) {
    return NS_OK;
  }
#endif

  nsHTMLReflowCommand* command = new nsHTMLReflowCommand(aTargetFrame,
                                                         aReflowType,
                                                         aChildListName);
  if (!command) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  
#ifdef DEBUG
  if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
    printf("\nPresShell@%p: adding reflow command\n", (void*)this);
    command->List(stdout);
    if (VERIFY_REFLOW_REALLY_NOISY_RC & gVerifyReflowFlags) {
      printf("Current content model:\n");
      nsIContent *rootContent = mDocument->GetRootContent();
      if (rootContent) {
        rootContent->List(stdout, 0);
      }
    }
  }  
#endif

  // Add the reflow command to the queue
  nsresult rv = NS_OK;
  if (!AlreadyInQueue(command)) {
    if (mReflowCommands.AppendElement(command)) {
      ReflowCommandAdded(command);
    } else {
      // Drop this command.... we're out of memory
      PL_DHashTableOperate(&mReflowCommandTable, command,
                           PL_DHASH_REMOVE);
      delete command;
      rv = NS_ERROR_OUT_OF_MEMORY;
    }
  }
  else {
    // We're not going to process this reflow command.
    delete command;
  }

  // For async reflow during doc load, post a reflow event if we are not batching reflow commands.
  // For sync reflow during doc load, post a reflow event if we are not batching reflow commands
  // and the document is not loading.
  if ((gAsyncReflowDuringDocLoad && !mBatchReflows) ||
      (!gAsyncReflowDuringDocLoad && !mBatchReflows && !mDocumentLoading)) {
    // If we're in the middle of a drag, process it right away (needed for mac,
    // might as well do it on all platforms just to keep the code paths the same).
    if ( !IsDragInProgress() )
      PostReflowEvent();
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PresShell::AttributeChanged ( nsIDocument aDocument,
nsIContent aContent,
PRInt32  aNameSpaceID,
nsIAtom aAttribute,
PRInt32  aModType 
) [virtual]

Notification that the content model has changed.

This method is called automatically by content objects when an attribute's value has changed (therefore there is normally no need to invoke this method directly). The notification is passed to any IDocumentObservers document observers.

Parameters:
aDocumentThe document being observed
aContentthe piece of content whose attribute changed
aAttributethe atom name of the attribute
aModTypeWhether or not the attribute was added, changed, or removed. The constants are defined in nsIDOMMutationEvent.h.

Implements nsIDocumentObserver.

Definition at line 5571 of file nsPresShell.cpp.

{
  NS_PRECONDITION(!mIsDocumentGone, "Unexpected AttributeChanged");
  NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");

  NS_PRESSHELL_NOTIFY_OBSERVERS(AttributeChanged, 
                                (aDocument, aContent, aNameSpaceID,
                                 aAttribute, aModType));

  // XXXwaterson it might be more elegant to wait until after the
  // initial reflow to begin observing the document. That would
  // squelch any other inappropriate notifications as well.
  if (mDidInitialReflow) {
    WillCauseReflow();
    mFrameConstructor->AttributeChanged(aContent, aNameSpaceID,
                                        aAttribute, aModType);
    VERIFY_STYLE_TREE;
    DidCauseReflow();
  }
}

Here is the call graph for this function:

void PresShell::BeginLoad ( nsIDocument aDocument) [virtual]

Notify the observer that a document load is beginning.

Implements nsIDocumentObserver.

Definition at line 3659 of file nsPresShell.cpp.

{  
#ifdef MOZ_PERF_METRICS
  // Reset style resolution stopwatch maintained by style set
  MOZ_TIMER_DEBUGLOG(("Reset: Style Resolution: PresShell::BeginLoad(), this=%p\n", (void*)this));
#endif  
  mDocumentLoading = PR_TRUE;
}

Implements nsIPresShell.

Definition at line 2721 of file nsPresShell.cpp.

{
  if (mDocument && !mIsDestroying) {
    mDocument->AddObserver(this);
    if (mIsDocumentGone) {
      NS_WARNING("Adding a presshell that was disconnected from the document "
                 "as a document observer?  Sounds wrong...");
      mIsDocumentGone = PR_FALSE;
    }
  }
  return NS_OK;
}
virtual void nsIDocumentObserver::BeginReflow ( nsIDocument aDocument,
nsIPresShell aShell 
) [pure virtual, inherited]

Notify the observer that the document is being reflowed in the given presentation shell.

Reflow batching.

Implements nsIPresShell.

Definition at line 5512 of file nsPresShell.cpp.

{  
  mBatchReflows = PR_TRUE;
  return NS_OK;
}
void PresShell::BeginUpdate ( nsIDocument aDocument,
nsUpdateType  aUpdateType 
) [virtual]

Notify that a content model update is beginning.

This call can be nested.

Implements nsIDocumentObserver.

Definition at line 3630 of file nsPresShell.cpp.

{
#ifdef DEBUG
  mUpdateCount++;
#endif
  mFrameConstructor->BeginUpdate();

  if (aUpdateType & UPDATE_STYLE)
    mStyleSet->BeginUpdate();
}

Implements nsIPresShell_MOZILLA_1_8_BRANCH2.

Definition at line 6852 of file nsPresShell.cpp.

Implements nsIPresShell.

Definition at line 3930 of file nsPresShell.cpp.

{
  PRInt32 n = mReflowCommands.Count();
  nsHTMLReflowCommand* rc;
  PRInt32 i;
  for (i = 0; i < n; i++) {
    rc = NS_STATIC_CAST(nsHTMLReflowCommand*, mReflowCommands.ElementAt(i));
    ReflowCommandRemoved(rc);
    delete rc;
  }
  NS_ASSERTION(n == mReflowCommands.Count(),"reflow command list changed during cancel!");
  mReflowCommands.Clear();

  DoneRemovingReflowCommands();

  return NS_OK;
}

Implements nsIPresShell.

Definition at line 5243 of file nsPresShell.cpp.

{
   nsCallbackEventRequest* before = nsnull;
   nsCallbackEventRequest* node = mFirstCallbackEventRequest;
   while(node)
   {
      nsIReflowCallback* callback = node->callback;

      if (callback == aCallback) 
      {
        nsCallbackEventRequest* toFree = node;
        if (node == mFirstCallbackEventRequest) {
          node = node->next;
          mFirstCallbackEventRequest = node;
          NS_ASSERTION(before == nsnull, "impossible");
        } else {
          node = node->next;
          before->next = node;
        }

        if (toFree == mLastCallbackEventRequest) {
          mLastCallbackEventRequest = before;
        }

        FreeFrame(sizeof(nsCallbackEventRequest), toFree);
        NS_RELEASE(callback);
      } else {
        before = node;
        node = node->next;
      }
   }

   return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::CancelReflowCommand ( nsIFrame aTargetFrame,
nsReflowType aCmdType 
) [virtual]

Implements nsIPresShell.

Definition at line 3922 of file nsPresShell.cpp.

{
  return CancelReflowCommandInternal(aTargetFrame, aCmdType);
}
NS_IMETHODIMP PresShell::CancelReflowCommandInternal ( nsIFrame aTargetFrame,
nsReflowType aCmdType,
PRBool  aProcessDummyLayoutRequest = PR_TRUE 
)

Definition at line 3890 of file nsPresShell.cpp.

{
  PRInt32 i, n = mReflowCommands.Count();
  for (i = 0; i < n; i++) {
    nsHTMLReflowCommand* rc = (nsHTMLReflowCommand*) mReflowCommands.ElementAt(i);
    if (rc && rc->GetTarget() == aTargetFrame &&
        (!aCmdType || rc->Type() == *aCmdType)) {
#ifdef DEBUG
      if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
        printf("PresShell: removing rc=%p for frame ", (void*)rc);
        nsFrame::ListTag(stdout, aTargetFrame);
        printf("\n");
      }
#endif
      mReflowCommands.RemoveElementAt(i);
      ReflowCommandRemoved(rc);
      delete rc;
      n--;
      i--;
    }
  }

  if (aProcessDummyLayoutRequest) {
    DoneRemovingReflowCommands();
  }

  return NS_OK;
}

Here is the call graph for this function:

Notification that we were unable to render a replaced element.

Called when the replaced element can not be rendered, and we should instead render the element's contents. The content object associated with aFrame should either be a IMG element, an OBJECT element, or an APPLET element

Implements nsIPresShell.

Definition at line 4229 of file nsPresShell.cpp.

{
  if (*FindPostedEventFor(aFrame))
    return NS_OK;

  // Handle this asynchronously
  nsCOMPtr<nsIEventQueue> eventQueue;
  nsresult rv = mEventQueueService->
    GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
                         getter_AddRefs(eventQueue));

  NS_ENSURE_SUCCESS(rv, rv);
  // Verify that there isn't already a posted event associated with
  // this frame.
  CantRenderReplacedElementEvent* ev;

  // Create a new event
  ev = new CantRenderReplacedElementEvent(this, aFrame);
  if (!ev) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  // Post the event
  rv = eventQueue->PostEvent(ev);
  if (NS_FAILED(rv)) {
    PL_DestroyEvent(ev);
  }
  else {
    // Add the event to our linked list of posted events
    ev->mNext = mPostedReplaces;
    mPostedReplaces = ev;
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP PresShell::CaptureHistoryState ( nsILayoutHistoryState **  aLayoutHistoryState,
PRBool  aLeavingPage 
) [virtual]

Get and set the history state for the current document.

Implements nsIPresShell.

Definition at line 4939 of file nsPresShell.cpp.

{
  nsresult rv = NS_OK;

  NS_PRECONDITION(nsnull != aState, "null state pointer");

  // We actually have to mess with the docshell here, since we want to
  // store the state back in it.
  // XXXbz this isn't really right, since this is being called in the
  // content viewer's Hide() method...  by that point the docshell's
  // state could be wrong.  We should sort out a better ownership
  // model for the layout history state.
  nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
  if (!container)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
  if (!docShell)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsILayoutHistoryState> historyState;
  docShell->GetLayoutHistoryState(getter_AddRefs(historyState));
  if (!historyState) {
    // Create the document state object
    rv = NS_NewLayoutHistoryState(getter_AddRefs(historyState));
  
    if (NS_FAILED(rv)) { 
      *aState = nsnull;
      return rv;
    }    

    docShell->SetLayoutHistoryState(historyState);
  }

  *aState = historyState;
  NS_IF_ADDREF(*aState);
  
  // Capture frame state for the entire frame hierarchy
  nsIFrame* rootFrame = FrameManager()->GetRootFrame();
  if (!rootFrame) return NS_OK;
  // Capture frame state for the root scroll frame
  // Don't capture state when first creating doc element heirarchy
  // As the scroll position is 0 and this will cause us to loose
  // our previously saved place!
  if (aLeavingPage) {
    nsIFrame* scrollFrame = GetRootScrollFrame(rootFrame);
    if (scrollFrame) {
      FrameManager()->CaptureFrameStateFor(scrollFrame, historyState,
                                           nsIStatefulFrame::eDocumentScrollState);
    }
  }

  FrameManager()->CaptureFrameState(rootFrame, historyState);  
 
  return NS_OK;
}

Here is the call graph for this function:

void PresShell::CharacterDataChanged ( nsIDocument aDocument,
nsIContent aContent,
PRBool  aAppend 
) [virtual]

Notification that the content model has changed.

This method is called automatically by content objects when their state is changed (therefore there is normally no need to invoke this method directly). The notification is passed to any IDocumentObservers. The notification is passed on to all of the document observers.

This notification is not sent when a piece of content is added/removed from the document (the other notifications are used for that).

Parameters:
aDocumentThe document being observed
aContentthe piece of content that changed
aAppendWhether the change was an append

Implements nsIDocumentObserver.

Definition at line 5541 of file nsPresShell.cpp.

{
  NS_PRECONDITION(!mIsDocumentGone, "Unexpected CharacterDataChanged");
  NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");

  WillCauseReflow();
  mFrameConstructor->CharacterDataChanged(aContent, aAppend);
  VERIFY_STYLE_TREE;
  DidCauseReflow();
}

Here is the call graph for this function:

void nsISelectionController::characterMove ( in boolean  forward,
in boolean  extend 
) [inherited]

CharacterMove will move the selection one character forward/backward in the document.

this will also have the effect of collapsing the selection if the aExtend = PR_FALSE the "point" of selection that is extended is considered the "focus" point. or the last point adjusted by the selection.

Parameters:
aForwardforward or backward if PR_FALSE
aExtendshould it collapse the selection of extend it?
NS_IMETHODIMP PresShell::CharacterMove ( PRBool  aForward,
PRBool  aExtend 
)

Definition at line 3324 of file nsPresShell.cpp.

{
  return mSelection->CharacterMove(aForward, aExtend);  
}
boolean nsISelectionController::checkVisibility ( in nsIDOMNode  node,
in short  startOffset,
in short  endOffset 
) [inherited]

CheckVisibility will return true if textnode and offsets are actually rendered in the current precontext.

Parameters:
aNodetextNode to test
aStartOffsetoffset in dom to first char of textnode to test
aEndOffsetoffset in dom to last char of textnode to test
aReturnBoolboolean returned TRUE if visible FALSE if not
NS_IMETHODIMP PresShell::CheckVisibility ( nsIDOMNode node,
PRInt16  startOffset,
PRInt16  EndOffset,
PRBool _retval 
)

Definition at line 3493 of file nsPresShell.cpp.

{
  if (!node || startOffset>EndOffset || !_retval || startOffset<0 || EndOffset<0)
    return NS_ERROR_INVALID_ARG;
  *_retval = PR_FALSE; //initialize return parameter
  nsCOMPtr<nsIContent> content(do_QueryInterface(node));
  if (!content)
    return NS_ERROR_FAILURE;
  nsIFrame *frame;
  nsresult result = GetPrimaryFrameFor(content,&frame);
  if (NS_FAILED(result)) //failure is taken as a no.
    return result;
  if (!frame) //no frame to look at so it must not be visible
    return NS_OK;  
  //start process now to go through all frames to find startOffset. then check chars after that to see 
  //if anything until EndOffset is visible.
  PRBool finished = PR_FALSE;
  frame->CheckVisibility(mPresContext,startOffset,EndOffset,PR_TRUE,&finished, _retval);
  return NS_OK;//dont worry about other return val
}

Here is the call graph for this function:

Implements nsIPresShell.

Definition at line 3984 of file nsPresShell.cpp.

{
  mPresContext->EventStateManager()->ClearFrameRefs(aFrame);
  
  if (aFrame == mCurrentEventFrame) {
    mCurrentEventContent = aFrame->GetContent();
    mCurrentEventFrame = nsnull;
  }

  for (int i=0; i<mCurrentEventFrameStack.Count(); i++) {
    if (aFrame == (nsIFrame*)mCurrentEventFrameStack.ElementAt(i)) {
      //One of our stack frames was deleted.  Get its content so that when we
      //pop it we can still get its new frame from its content
      nsIContent *currentEventContent = aFrame->GetContent();
      mCurrentEventContentStack.ReplaceObjectAt(currentEventContent, i);
      mCurrentEventFrameStack.ReplaceElementAt(nsnull, i);
    }
  }

  nsWeakFrame* weakFrame = mWeakFrames;
  while (weakFrame) {
    nsWeakFrame* prev = weakFrame->GetPreviousWeakFrame();
    if (weakFrame->GetFrame() == aFrame) {
      // This removes weakFrame from mWeakFrames.
      weakFrame->Clear(this);
    }
    weakFrame = prev;
  }

  return NS_OK;
}

Here is the call graph for this function:

methods that manage rules that are used to implement the associated preferences

  • initially created for bugs 31816, 20760, 22963

Definition at line 2332 of file nsPresShell.cpp.

{
  nsresult result = NS_OK;
  if (mPrefStyleSheet) {
    NS_ASSERTION(mStyleSet, "null styleset entirely unexpected!");
    if (mStyleSet) {
      // remove the sheet from the styleset: 
      // - note that we have to check for success by comparing the count before and after...
#ifdef NS_DEBUG
      PRInt32 numBefore = mStyleSet->SheetCount(nsStyleSet::eUserSheet);
      NS_ASSERTION(numBefore > 0, "no user stylesheets in styleset, but we have one!");
#endif
      mStyleSet->RemoveStyleSheet(nsStyleSet::eUserSheet, mPrefStyleSheet);

#ifdef DEBUG_attinasi
      NS_ASSERTION((numBefore - 1) == mStyleSet->GetNumberOfUserStyleSheets(),
                   "Pref stylesheet was not removed");
      printf("PrefStyleSheet removed\n");
#endif
      // clear the sheet pointer: it is strictly historical now
      NS_RELEASE(mPrefStyleSheet);
    }
  }
  return result;
}

Definition at line 7171 of file nsPresShell.cpp.

Here is the caller graph for this function:

void nsISelectionController::completeMove ( in boolean  forward,
in boolean  extend 
) [inherited]

CompleteMove will move page view to the top or bottom of the document this will also have the effect of collapsing the selection if the aExtend = PR_FALSE the "point" of selection that is extended is considered the "focus" point.

or the last point adjusted by the selection.

Parameters:
aForwardforward or backward if PR_FALSE
aExtendshould it collapse the selection of extend it?
NS_IMETHODIMP PresShell::CompleteMove ( PRBool  aForward,
PRBool  aExtend 
)

Definition at line 3444 of file nsPresShell.cpp.

{
  nsIScrollableView *scrollableView;
  if (!mViewManager) 
    return NS_ERROR_UNEXPECTED;
  nsresult result = mViewManager->GetRootScrollableView(&scrollableView);
  if (NS_FAILED(result)) 
    return result;
  if (!scrollableView) 
    return NS_ERROR_UNEXPECTED;
  nsIView *scrolledView;
  result = scrollableView->GetScrolledView(scrolledView);
  // get a frame
  nsIFrame *frame = (nsIFrame*)scrolledView->GetClientData();
  if (!frame)
    return NS_ERROR_FAILURE;
  //we need to get to the area frame.
  nsIAtom* frameType;
  do 
  {
    frameType = frame->GetType();
    if (frameType != nsLayoutAtoms::areaFrame)
    {
      frame = frame->GetFirstChild(nsnull);
      if (!frame)
        break;
    }
  }while(frameType != nsLayoutAtoms::areaFrame);
  
  if (!frame)
    return NS_ERROR_FAILURE; //could not find an area frame.

  nsPeekOffsetStruct pos = frame->GetExtremeCaretPosition(!aForward);

  // we 'prefer left' (i.e. prefer the beginning of the next line)
  // iff we're moving to the end of the content
  pos.mPreferLeft = aForward;
  
  mSelection->HandleClick(pos.mResultContent ,pos.mContentOffset ,pos.mContentOffset/*End*/ ,aExtend, PR_FALSE, pos.mPreferLeft);
  return ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL, nsISelectionController::SELECTION_FOCUS_REGION, PR_TRUE);
}

Here is the call graph for this function:

CompleteScroll will move page view to the top or bottom of the document.

Parameters:
aForwardforward or backward if PR_FALSE

Definition at line 3434 of file nsPresShell.cpp.

{
  nsIScrollableView* scrollView = GetViewToScroll(nsLayoutUtils::eVertical);
  if (scrollView) {
    scrollView->ScrollByWhole(!aForward);//TRUE = top, aForward TRUE=bottom
  }
  return NS_OK;
}

Here is the call graph for this function:

void PresShell::ContentAppended ( nsIDocument aDocument,
nsIContent aContainer,
PRInt32  aNewIndexInContainer 
) [virtual]

Notifcation that the content model has had data appended to the given content object.

This method is called automatically by the content container objects when a new content object is appended to the container (therefore there is normally no need to invoke this method directly). The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aContainerthe container that had a new child appended
aNewIndexInContainerthe index in the container of the first new child

Implements nsIDocumentObserver.

Definition at line 5597 of file nsPresShell.cpp.

{
  NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentAppended");
  NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");
  
  NS_PRESSHELL_NOTIFY_OBSERVERS(ContentAppended,
                                (aDocument, aContainer,
                                 aNewIndexInContainer));

  if (!mDidInitialReflow) {
    return;
  }
  
  WillCauseReflow();
  MOZ_TIMER_DEBUGLOG(("Start: Frame Creation: PresShell::ContentAppended(), this=%p\n", this));
  MOZ_TIMER_START(mFrameCreationWatch);

  mFrameConstructor->ContentAppended(aContainer, aNewIndexInContainer);
  VERIFY_STYLE_TREE;

  MOZ_TIMER_DEBUGLOG(("Stop: Frame Creation: PresShell::ContentAppended(), this=%p\n", this));
  MOZ_TIMER_STOP(mFrameCreationWatch);
  DidCauseReflow();
}

Here is the call graph for this function:

void PresShell::ContentInserted ( nsIDocument aDocument,
nsIContent aContainer,
nsIContent aChild,
PRInt32  aIndexInContainer 
) [virtual]

Notification that content has been inserted.

This method is called automatically by the content container objects when a new content object is inserted in the container (therefore there is normally no need to invoke this method directly). The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aContainerthe container that now contains aChild
aChildthe child that was inserted
aIndexInContainerthe index of the child in the container

Implements nsIDocumentObserver.

Definition at line 5625 of file nsPresShell.cpp.

{
  NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentInserted");
  NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");

  NS_PRESSHELL_NOTIFY_OBSERVERS(ContentInserted,
                                (aDocument, aContainer, aChild,
                                 aIndexInContainer));
  
  if (!mDidInitialReflow) {
    return;
  }
  
  WillCauseReflow();
  mFrameConstructor->ContentInserted(aContainer, nsnull, aChild,
                                     aIndexInContainer, nsnull, PR_FALSE);
  VERIFY_STYLE_TREE;
  DidCauseReflow();
}

Here is the call graph for this function:

void PresShell::ContentRemoved ( nsIDocument aDocument,
nsIContent aContainer,
nsIContent aChild,
PRInt32  aIndexInContainer 
) [virtual]

Content has just been removed.

This method is called automatically by content container objects when a content object has just been removed from the container (therefore there is normally no need to invoke this method directly). The notification is passed on to all of the document observers.

Parameters:
aDocumentThe document being observed
aContainerthe container that had a child removed
aChildthe child that was just removed
aIndexInContainerthe index of the child in the container before it was removed

Implements nsIDocumentObserver.

Definition at line 5649 of file nsPresShell.cpp.

{
  NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentRemoved");
  NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");

  NS_PRESSHELL_NOTIFY_OBSERVERS(ContentRemoved,
                                (aDocument, aContainer, aChild, 
                                 aIndexInContainer));

  // XXX fix for bug 304383. Remove when bug 287813 is fixed?
  if (mCaret) {
    nsIFrame* frame = nsnull;
    GetPrimaryFrameFor(aChild, &frame);
    if (frame && (frame->GetStateBits() & NS_FRAME_EXTERNAL_REFERENCE)) {
      mCaret->EraseCaret();
    }
  }

  // Notify the ESM that the content has been removed, so that
  // it can clean up any state related to the content.
  mPresContext->EventStateManager()->ContentRemoved(aChild);

  WillCauseReflow();
  mFrameConstructor->ContentRemoved(aContainer, aChild,
                                    aIndexInContainer, PR_FALSE);

  // If we have no root content node at this point, be sure to reset
  // mDidInitialReflow to PR_FALSE, this will allow InitialReflow()
  // to be called again should a new root node be inserted for this
  // presShell. (Bug 167355)

  if (mDocument && !mDocument->GetRootContent())
    mDidInitialReflow = PR_FALSE;

  VERIFY_STYLE_TREE;
  DidCauseReflow();
}

Here is the call graph for this function:

void PresShell::ContentStatesChanged ( nsIDocument aDocument,
nsIContent aContent1,
nsIContent aContent2,
PRInt32  aStateMask 
) [virtual]

Notification that the state of a content node has changed.

(ie: gained or lost focus, became active or hovered over) This method is called automatically by content objects when their state is changed (therefore there is normally no need to invoke this method directly). The notification is passed to any IDocumentObservers. The notification is passed on to all of the document observers.

This notification is not sent when a piece of content is added/removed from the document or the content itself changed (the other notifications are used for that).

The optional second content node is to allow optimization of the case where state moves from one node to another (as is likely for :focus and :hover)

Either content node may be nsnull, but not both

Parameters:
aDocumentThe document being observed
aContent1the piece of content that changed
aContent2optional second piece of content that changed

Implements nsIDocumentObserver.

Definition at line 5555 of file nsPresShell.cpp.

{
  NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentStatesChanged");
  NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");

  WillCauseReflow();
  mFrameConstructor->ContentStatesChanged(aContent1, aContent2, aStateMask);
  VERIFY_STYLE_TREE;
  DidCauseReflow();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2358 of file nsPresShell.cpp.

{
  NS_ASSERTION(!mPrefStyleSheet, "prefStyleSheet already exists");
  nsresult result = CallCreateInstance(kCSSStyleSheetCID, &mPrefStyleSheet);
  if (NS_SUCCEEDED(result)) {
    NS_ASSERTION(mPrefStyleSheet, "null but no error");
    nsCOMPtr<nsIURI> uri;
    result = NS_NewURI(getter_AddRefs(uri), "about:PreferenceStyleSheet", nsnull);
    if (NS_SUCCEEDED(result)) {
      NS_ASSERTION(uri, "null but no error");
      nsCOMPtr<nsICSSStyleSheet_MOZILLA_1_8_BRANCH> sheet =
        do_QueryInterface(mPrefStyleSheet);
      result = sheet->SetURIs18(uri, uri, uri);
      if (NS_SUCCEEDED(result)) {
        mPrefStyleSheet->SetComplete();
        nsCOMPtr<nsIDOMCSSStyleSheet> sheet(do_QueryInterface(mPrefStyleSheet));
        if (sheet) {
          PRUint32 index;
          result = sheet->InsertRule(NS_LITERAL_STRING("@namespace url(http://www.w3.org/1999/xhtml);"),
                                     0, &index);
          NS_ENSURE_SUCCESS(result, result);
        }
        mStyleSet->AppendStyleSheet(nsStyleSet::eUserSheet, mPrefStyleSheet);
      }
    }
  } else {
    result = NS_ERROR_OUT_OF_MEMORY;
  }

#ifdef DEBUG_attinasi
  printf("CreatePrefStyleSheet completed: error=%ld\n",(long)result);
#endif

  return result;
}

Here is the call graph for this function:

Given a frame, create a rendering context suitable for use with the frame.

Implements nsIPresShell.

Definition at line 4017 of file nsPresShell.cpp.

{
  NS_PRECONDITION(nsnull != aResult, "null ptr");
  if (nsnull == aResult) {
    return NS_ERROR_NULL_POINTER;
  }

  nsresult  rv;

  nsIView *view = aFrame->GetClosestView();

  nsIWidget* widget = view ? view->GetNearestWidget(nsnull) : nsnull;

  nsIRenderingContext* result = nsnull;
  nsIDeviceContext *deviceContext = mPresContext->DeviceContext();
  if (widget) {
    rv = deviceContext->CreateRenderingContext(widget, result);
  }
  else {
    rv = deviceContext->CreateRenderingContext(result);
  }
  *aResult = result;

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3180 of file nsPresShell.cpp.

Here is the call graph for this function:

All callers are responsible for calling |Destroy| after calling |EndObservingDocument|.

It needs to be separate only because form controls incorrectly store their data in the frames rather than the content model and printing calls |EndObservingDocument| multiple times to make form controls behave nicely when printed.

Implements nsIPresShell.

Definition at line 1952 of file nsPresShell.cpp.

{
#ifdef MOZ_REFLOW_PERF
  DumpReflows();
  if (mReflowCountMgr) {
    delete mReflowCountMgr;
    mReflowCountMgr = nsnull;
  }
#endif

  if (mHaveShutDown)
    return NS_OK;

  {
    nsCOMPtr<nsIObserverService> os =
      do_GetService("@mozilla.org/observer-service;1");
    if (os) {
      os->RemoveObserver(this, NS_LINK_VISITED_EVENT_TOPIC);
#ifdef MOZ_XUL
      os->RemoveObserver(this, "chrome-flush-skin-caches");
#endif
    }
  }

  // If our paint suppression timer is still active, kill it.
  if (mPaintSuppressionTimer) {
    mPaintSuppressionTimer->Cancel();
    mPaintSuppressionTimer = nsnull;
  }

  if (mCaret) {
    mCaret->Terminate();
    mCaret = nsnull;
  }
  
  // release our pref style sheet, if we have one still
  ClearPreferenceStyleRules();

  // free our table of anonymous content
  ReleaseAnonymousContent();

  mIsDestroying = PR_TRUE;

  // We can't release all the event content in
  // mCurrentEventContentStack here since there might be code on the
  // stack that will release the event content too. Double release
  // bad!

  // The frames will be torn down, so remove them from the current
  // event frame stack (since they'd be dangling references if we'd
  // leave them in) and null out the mCurrentEventFrame pointer as
  // well.

  mCurrentEventFrame = nsnull;

  PRInt32 i, count = mCurrentEventFrameStack.Count();
  for (i = 0; i < count; i++) {
    mCurrentEventFrameStack.ReplaceElementAt(nsnull, i);
  }

  if (mViewManager) {
    // Clear the view manager's weak pointer back to |this| in case it
    // was leaked.
    mViewManager->SetViewObserver(nsnull);
    mViewManager = nsnull;
  }

  mStyleSet->BeginShutdown(mPresContext);

  // This shell must be removed from the document before the frame
  // hierarchy is torn down to avoid finding deleted frames through
  // this presshell while the frames are being torn down
  if (mDocument) {
    mDocument->DeleteShell(this);
  }

  // Revoke pending events.  We need to do this and cancel reflow commands
  // before we destroy the frame manager, since apparently frame destruction
  // sometimes spins the event queue when plug-ins are involved(!).
  mPostedReplaces = nsnull;
  mReflowEventQueue = nsnull;
  nsCOMPtr<nsIEventQueue> eventQueue;
  mEventQueueService->GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
                                           getter_AddRefs(eventQueue));
  eventQueue->RevokeEvents(this);

  CancelAllReflowCommands();

  // Destroy the frame manager. This will destroy the frame hierarchy
  mFrameConstructor->WillDestroyFrameTree();
  FrameManager()->Destroy();

  NS_WARN_IF_FALSE(!mWeakFrames, "Weak frames alive after destroying FrameManager");
  while (mWeakFrames) {
    mWeakFrames->Clear(this);
  }

  // Let the style set do its cleanup.
  mStyleSet->Shutdown(mPresContext);

  if (mPresContext) {
    // Clear out the prescontext's property table -- since our frame tree is
    // now dead, we shouldn't be looking up any more properties in that table.
    // We want to do this before we call SetShell() on the prescontext, so
    // property destructors can usefully call GetPresShell() on the
    // prescontext.
    mPresContext->PropertyTable()->DeleteAllProperties();

    // We hold a reference to the pres context, and it holds a weak link back
    // to us. To avoid the pres context having a dangling reference, set its 
    // pres shell to NULL
    mPresContext->SetShell(nsnull);

    // Clear the link handler (weak reference) as well
    mPresContext->SetLinkHandler(nsnull);
  }

  if (mViewEventListener) {
    mViewEventListener->SetPresShell((nsIPresShell*)nsnull);
    NS_RELEASE(mViewEventListener);
  }

  RemoveDummyLayoutRequest();
  
  KillResizeEventTimer();

  // Now that mReflowCommandTable won't be accessed anymore, finish it
  if (mReflowCommandTable.ops) {
    PL_DHashTableFinish(&mReflowCommandTable);
  }
  
  mHaveShutDown = PR_TRUE;

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 6987 of file nsPresShell.cpp.

{
  NS_ASSERTION(mChangeNestCount != 0, "Unexpected call to DidCauseReflow()");
  if (--mChangeNestCount == 0) {
    // We may have had more reflow commands appended to the queue during
    // our reflow.  Make sure these get processed at some point.
    if (!gAsyncReflowDuringDocLoad && mDocumentLoading) {
      FlushPendingNotifications(Flush_Layout);
    } else {
      PostReflowEvent();
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PresShell::DidDoReflow ( ) [protected]

Definition at line 7004 of file nsPresShell.cpp.

{
  HandlePostedDOMEvents();
  HandlePostedAttributeChanges();
  HandlePostedReflowCallbacks();
  // Null-check mViewManager in case this happens during Destroy.  See
  // bugs 244435 and 238546.
  if (!mPaintingSuppressed && mViewManager)
    mViewManager->SynthesizeMouseMove(PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Called to disable nsITheme support in a specific presshell.

Implements nsIPresShell.

Definition at line 5207 of file nsPresShell.cpp.

{
  // Doesn't have to be dynamic.  Just set the bool.
  mIsThemeSupportDisabled = PR_TRUE;
  return NS_OK;
}

Notify the Clipboard that we have something to copy.

Implements nsIPresShell.

Definition at line 4905 of file nsPresShell.cpp.

{
  if (!mDocument) return NS_ERROR_FAILURE;

  nsCOMPtr<nsISelection> sel;
  nsresult rv = GetSelectionForCopy(getter_AddRefs(sel));
  if (NS_FAILED(rv)) 
    return rv;
  if (!sel) 
    return NS_ERROR_FAILURE;

  // Now we have the selection.  Make sure it's nonzero:
  PRBool isCollapsed;
  sel->GetIsCollapsed(&isCollapsed);
  if (isCollapsed)
    return NS_OK;

  // call the copy code
  rv = nsCopySupport::HTMLCopy(sel, mDocument, nsIClipboard::kGlobalClipboard);
  if (NS_FAILED(rv))
    return rv;

  // Now that we have copied, update the Paste menu item
  nsCOMPtr<nsIDOMWindowInternal> domWindow =
    do_QueryInterface(mDocument->GetScriptGlobalObject());
  if (domWindow)
  {
    domWindow->UpdateCommands(NS_LITERAL_STRING("clipboard"));
  }
  
  return NS_OK;
}

Here is the call graph for this function:

virtual void nsIDocumentObserver::DocumentWillBeDestroyed ( nsIDocument aDocument) [pure virtual, inherited]

The document is in the process of being destroyed.

This method is called automatically during document destruction.

Parameters:
aDocumentThe document being observed

Implemented in nsFragmentObserver, nsDOMStyleSheetList, nsContentList, nsBindingManager, nsXULContentBuilder, nsXULTreeBuilder, nsXULTemplateBuilder, nsTreeContentView, and nsXMLPrettyPrinter.

NS_IMETHODIMP PresShell::DoGetContents ( const nsACString &  aMimeType,
PRUint32  aFlags,
PRBool  aSelectionOnly,
nsAString &  outValue 
) [virtual]

Get the doc or the selection as text or html.

Implements nsIPresShell.

Definition at line 4877 of file nsPresShell.cpp.

{
  aOutValue.Truncate();
  
  if (!mDocument) return NS_ERROR_FAILURE;

  nsresult rv;
  nsCOMPtr<nsISelection> sel;

  // Now we have the selection.  Make sure it's nonzero:
  if (aSelectionOnly)
  {
    rv = GetSelectionForCopy(getter_AddRefs(sel));
    if (NS_FAILED(rv)) return rv;
    if (!sel) return NS_ERROR_FAILURE;
  
    PRBool isCollapsed;
    sel->GetIsCollapsed(&isCollapsed);
    if (isCollapsed)
      return NS_OK;
  }
  
  // call the copy code
  return nsCopySupport::GetContents(aMimeType, aFlags, sel,
                                    mDocument, aOutValue);
}

Here is the call graph for this function:

Definition at line 7273 of file nsPresShell.cpp.

{
  if (mRCCreatedDuringLoad == 0 && mDummyLayoutRequest && !mIsReflowing &&
      !mIsDestroying && !mDummyLayoutRequestEventPosted) {
    // Post an event to remove mDummyLayoutRequest from the loadgroup
    nsCOMPtr<nsIEventQueue> eventQueue;
    mEventQueueService->
      GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
                           getter_AddRefs(eventQueue));
    if (!eventQueue) {
      NS_WARNING("onload won't fire, due to failure to get event queue.");
      return;
    }

    DummyLayoutRequestEvent* evt = new DummyLayoutRequestEvent(this);
    if (!evt) {
      NS_WARNING("onload won't fire, due to failure to create event.");
      return;
    }

    nsresult rv = eventQueue->PostEvent(evt);
    if (NS_FAILED(rv)) {
      NS_WARNING("onload won't fire, due to failure to post dummy layout "
                 "request event");
      PL_DestroyEvent(evt);
      return;
    }

    mDummyLayoutRequestEventPosted = PR_TRUE;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PresShell::EndLoad ( nsIDocument aDocument) [virtual]

Notify the observer that a document load has finished.

Note that the associated reflow of the document will be done before EndLoad is invoked, not after.

Implements nsIDocumentObserver.

Definition at line 3669 of file nsPresShell.cpp.

{

  // Restore frame state for the root scroll frame
  nsIFrame* rootFrame = FrameManager()->GetRootFrame();
  nsCOMPtr<nsILayoutHistoryState> historyState =
    aDocument->GetLayoutHistoryState();
  // Make sure we don't reenter reflow via the sync paint that happens while
  // we're scrolling to our restored position.  Entering reflow for the
  // scrollable frame will cause it to reenter ScrollToRestoredPosition(), and
  // it'll get all confused.
  ++mChangeNestCount;

  if (rootFrame && historyState) {
    nsIFrame* scrollFrame = GetRootScrollFrame(rootFrame);
    if (scrollFrame) {
      nsIScrollableFrame* scrollableFrame;
      CallQueryInterface(scrollFrame, &scrollableFrame);
      if (scrollableFrame) {
        FrameManager()->RestoreFrameStateFor(scrollFrame, historyState,
                                             nsIStatefulFrame::eDocumentScrollState);
        scrollableFrame->ScrollToRestoredPosition();
      }
    }
  }

  --mChangeNestCount;
  
#ifdef MOZ_PERF_METRICS
  // Dump reflow, style resolution and frame construction times here.
  MOZ_TIMER_DEBUGLOG(("Stop: Reflow: PresShell::EndLoad(), this=%p\n", this));
  MOZ_TIMER_STOP(mReflowWatch);
  MOZ_TIMER_LOG(("Reflow time (this=%p): ", this));
  MOZ_TIMER_PRINT(mReflowWatch);  

  MOZ_TIMER_DEBUGLOG(("Stop: Frame Creation: PresShell::EndLoad(), this=%p\n", this));
  MOZ_TIMER_STOP(mFrameCreationWatch);
  MOZ_TIMER_LOG(("Frame construction plus style resolution time (this=%p): ", this));
  MOZ_TIMER_PRINT(mFrameCreationWatch);

  // Print style resolution stopwatch maintained by style set
  MOZ_TIMER_DEBUGLOG(("Stop: Style Resolution: PresShell::EndLoad(), this=%p\n", this));
#endif  
  mDocumentLoading = PR_FALSE;
}

Here is the call graph for this function:

Implements nsIPresShell.

Definition at line 2736 of file nsPresShell.cpp.

{
  // XXXbz do we need to tell the frame constructor that the document
  // is gone, perhaps?  Except for printing it's NOT gone, sometimes.
  mIsDocumentGone = PR_TRUE;
  if (mDocument) {
    mDocument->RemoveObserver(this);
  }
  if (mSelection){
    nsCOMPtr<nsISelection> domselection;
    nsresult result;
    result = mSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domselection));
    if (NS_FAILED(result))
      return result;
    if (!domselection)
      return NS_ERROR_UNEXPECTED;
    mSelection->ShutDown();
  }

  return NS_OK;
}

Here is the call graph for this function:

virtual void nsIDocumentObserver::EndReflow ( nsIDocument aDocument,
nsIPresShell aShell 
) [pure virtual, inherited]

Notify the observer that the document is done being reflowed in the given presentation shell.

NS_IMETHODIMP PresShell::EndReflowBatching ( PRBool  aFlushPendingReflows) [virtual]

Implements nsIPresShell.

Definition at line 5519 of file nsPresShell.cpp.

{  
  nsresult rv = NS_OK;
  mBatchReflows = PR_FALSE;
  if (aFlushPendingReflows) {
    rv = FlushPendingNotifications(Flush_OnlyReflow);
  }
  else {
    PostReflowEvent();
  }
  return rv;
}

Here is the call graph for this function:

void PresShell::EndUpdate ( nsIDocument aDocument,
nsUpdateType  aUpdateType 
) [virtual]

Notify that a content model update is finished.

This call can be nested.

Implements nsIDocumentObserver.

Definition at line 3642 of file nsPresShell.cpp.

{
#ifdef DEBUG
  NS_PRECONDITION(0 != mUpdateCount, "too many EndUpdate's");
  --mUpdateCount;
#endif

  if (aUpdateType & UPDATE_STYLE) {
    mStyleSet->EndUpdate();
    if (mStylesHaveChanged)
      ReconstructStyleData();
  }

  mFrameConstructor->EndUpdate();
}
void PresShell::EnumeratePlugins ( nsIDOMDocument aDocument,
const nsString aPluginTag,
nsPluginEnumCallback  aCallback 
) [private]

Definition at line 7473 of file nsPresShell.cpp.

{
  nsCOMPtr<nsIDOMNodeList> nodes;
  aDocument->GetElementsByTagName(aPluginTag, getter_AddRefs(nodes));
  if (!nodes)
    return;

  PRUint32 length;
  nodes->GetLength(&length);

  for (PRUint32 i = 0; i < length; ++i) {
    nsCOMPtr<nsIDOMNode> node;
    nodes->Item(i, getter_AddRefs(node));

    nsCOMPtr<nsIContent> content = do_QueryInterface(node);
    if (content)
      aCallback(this, content);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4214 of file nsPresShell.cpp.

{
  CantRenderReplacedElementEvent** event = &mPostedReplaces;

  while (*event) {
    if ((*event)->mFrame == aFrame) {
      return event;
    }
    event = &(*event)->mNext;
  }

  return event;
}

Here is the caller graph for this function:

Definition at line 3213 of file nsPresShell.cpp.

{
  if (mIsDocumentGone)
    return;

  //Send resize event from here.
  nsEvent event(PR_TRUE, NS_RESIZE_EVENT);
  nsEventStatus status = nsEventStatus_eIgnore;

  nsCOMPtr<nsIScriptGlobalObject> globalObj = mDocument->GetScriptGlobalObject();
  if (globalObj) {
    globalObj->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
  }
}

Flush pending notifications of the type specified.

This method will not affect the content model; it'll just affect style and frames. Callers that actually want up-to-date presentation (other than the document itself) should probably be calling nsIDocument::FlushPendingNotifications.

Parameters:
aTypethe type of notifications to flush

Implements nsIPresShell.

Definition at line 5441 of file nsPresShell.cpp.

{
  NS_ASSERTION(aType & (Flush_StyleReresolves | Flush_OnlyReflow |
                        Flush_OnlyPaint),
               "Why did we get called?");
  
  PRBool isSafeToFlush;
  IsSafeToFlush(isSafeToFlush);

  NS_ASSERTION(!isSafeToFlush || mViewManager, "Must have view manager");
  // Make sure the view manager stays alive while batching view updates.
  nsCOMPtr<nsIViewManager> viewManager = mViewManager;
  if (isSafeToFlush && viewManager) {

    // Style reresolves not in conjunction with reflows can't cause
    // painting or geometry changes, so don't bother with view update
    // batching if we only have style reresolve
    viewManager->BeginUpdateViewBatch();

    if (aType & Flush_StyleReresolves) {
      // Processing pending restyles can kill us, and some callers only
      // hold weak refs when calling FlushPendingNotifications().  :(
      nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
      mFrameConstructor->ProcessPendingRestyles();
      if (mIsDestroying) {
        // We no longer have a view manager and all that.
        // XXX FIXME: Except we're in the middle of a view update batch...  We
        // need to address that somehow.  See bug 369165.
        return NS_OK;
      }

      mDocument->BindingManager()->ProcessAttachedQueue();
      if (mIsDestroying) {
        // We no longer have a view manager and all that.
        // XXX FIXME: Except we're in the middle of a view update batch...  We
        // need to address that somehow.  See bug 369165.
        return NS_OK;
      }
    }

    if (aType & Flush_OnlyReflow) {
      mFrameConstructor->RecalcQuotesAndCounters();
      ProcessReflowCommands(PR_FALSE);
    }

    PRUint32 updateFlags = NS_VMREFRESH_NO_SYNC;
    if (aType & Flush_OnlyPaint) {
      // Flushing paints, so perform the invalidates and drawing
      // immediately
      updateFlags = NS_VMREFRESH_IMMEDIATE;
    }
    else if (!(aType & Flush_OnlyReflow)) {
      // Not flushing reflows, so do deferred invalidates.  This will keep us
      // from possibly flushing out reflows due to invalidates being processed
      // at the end of this view batch.
      updateFlags = NS_VMREFRESH_DEFERRED;
    }
    viewManager->EndUpdateViewBatch(updateFlags);
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

FrameSelection will return the Frame based selection API.

You cannot go back and forth anymore with QI between nsIDOM sel and nsIFrame sel.

Definition at line 251 of file nsIPresShell.h.

{ return mSelection; }

Here is the caller graph for this function:

Definition at line 2122 of file nsPresShell.cpp.

{
  if (mStackArena) {
    delete mStackArena;
    mStackArena = nsnull;
  }
}
virtual void nsIPresShell::FreeFrame ( size_t  aSize,
void aFreeChunk 
) [pure virtual, inherited]

Here is the caller graph for this function:

void PresShell::Freeze ( ) [virtual]

Stop all active elements (plugins and the caret) in this presentation and in the presentations of subdocuments.

Resets painting to a suppressed state. XXX this should include image animations

Implements nsIPresShell.

Definition at line 6775 of file nsPresShell.cpp.

Here is the call graph for this function:

Implements nsIPresShell.

Definition at line 2144 of file nsPresShell.cpp.

{ // first non-html sheet in style set that has title
  if (mStyleSet) {
    PRInt32 count = mStyleSet->SheetCount(nsStyleSet::eDocSheet);
    PRInt32 index;
    NS_NAMED_LITERAL_STRING(textHtml, "text/html");
    for (index = 0; index < count; index++) {
      nsIStyleSheet* sheet = mStyleSet->StyleSheetAt(nsStyleSet::eDocSheet,
                                                     index);
      if (nsnull != sheet) {
        nsAutoString type;
        sheet->GetType(type);
        if (PR_FALSE == type.Equals(textHtml)) {
          nsAutoString title;
          sheet->GetTitle(title);
          if (!title.IsEmpty()) {
            aSheetTitle = title;
            index = count;  // stop looking
          }
        }
      }
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Get the set of agent style sheets for this presentation.

Implements nsIPresShell.

Definition at line 6686 of file nsPresShell.cpp.

{
  aSheets.Clear();
  PRInt32 sheetCount = mStyleSet->SheetCount(nsStyleSet::eAgentSheet);

  for (PRInt32 i = 0; i < sheetCount; ++i) {
    nsIStyleSheet *sheet = mStyleSet->StyleSheetAt(nsStyleSet::eAgentSheet, i);
    if (!aSheets.AppendObject(sheet))
      return NS_ERROR_OUT_OF_MEMORY;
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::GetAnonymousContentFor ( nsIContent aContent,
nsISupportsArray **  aAnonymousElements 
) [virtual]

Retrieve the nsIAnonymousContentCreator-generated anonymous content that's associated with an element.

Parameters:
aContentthe element for which to retrieve the associated anonymous content
aAnonymousElementsan array of nsIContent objects, or null to indicate that there are no anonymous elements associated with aContent

Implements nsIPresShell.

Definition at line 5096 of file nsPresShell.cpp.

{
  if (! mAnonymousContentTable) {
    *aAnonymousElements = nsnull;
    return NS_OK;
  }

  nsISupportsKey key(aContent);
  *aAnonymousElements =
    NS_REINTERPRET_CAST(nsISupportsArray*, mAnonymousContentTable->Get(&key)); // addrefs

  return NS_OK;
}
NS_IMETHODIMP PresShell::GetCaret ( nsICaret **  aOutCaret) [virtual]

Get the caret, if it exists.

AddRefs it.

Implements nsIPresShell.

Definition at line 3257 of file nsPresShell.cpp.

{
  NS_ENSURE_ARG_POINTER(outCaret);
  
  *outCaret = mCaret;
  NS_IF_ADDREF(*outCaret);
  return NS_OK;
}

Gets the current state of the caret.

Parameters:
aEnabled[OUT] set to the current caret state, as set by SetCaretEnabled
Returns:
if aOutEnabled==null, returns NS_ERROR_INVALID_ARG else NS_OK

Definition at line 3293 of file nsPresShell.cpp.

{
  NS_ENSURE_ARG_POINTER(aOutEnabled);
  *aOutEnabled = mCaretEnabled;
  return NS_OK;
}

Definition at line 6006 of file nsPresShell.cpp.

{
  if (!mCurrentEventFrame && mCurrentEventContent) {
    // Make sure the content still has a document reference. If not,
    // then we assume it is no longer in the content tree and the
    // frame shouldn't get an event, nor should we even assume its
    // safe to try and find the frame.
    if (mCurrentEventContent->GetDocument()) {
      GetPrimaryFrameFor(mCurrentEventContent, &mCurrentEventFrame);
    }
  }

  return mCurrentEventFrame;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP PresShell::GetDidInitialReflow ( PRBool aDidInitialReflow) [virtual]

Determine if InitialReflow() was previously called.

Parameters:
aDidInitialReflowPR_TRUE if InitalReflow() was previously called, PR_FALSE otherwise.

Implements nsIPresShell.

Definition at line 2850 of file nsPresShell.cpp.

{
  if (!aDidInitialReflow)
    return NS_ERROR_FAILURE;

  *aDidInitialReflow = mDidInitialReflow;

  return NS_OK;
}

GetDisplaySelection will get the display mode for the selection.

OFF,ON,DISABLED

Definition at line 2688 of file nsPresShell.cpp.

{
  return mSelection->GetDisplaySelection(aToggle);
}
nsIDocument* nsIPresShell::GetDocument ( ) [inline, inherited]

Definition at line 175 of file nsIPresShell.h.

{ return mDocument; }

Here is the caller graph for this function:

NS_IMETHODIMP PresShell::GetEventTargetContent ( nsEvent aEvent,
nsIContent **  aContent 
) [virtual]

Gets the current target event frame from the PresShell.

Implements nsIPresShell.

Definition at line 6029 of file nsPresShell.cpp.

{
  if (mCurrentEventContent) {
    *aContent = mCurrentEventContent;
    NS_IF_ADDREF(*aContent);
  } else {
    nsIFrame* currentEventFrame = GetCurrentEventFrame();
    if (currentEventFrame) {
      currentEventFrame->GetContentForEvent(mPresContext, aEvent, aContent);
    } else {
      *aContent = nsnull;
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Gets the current target event frame from the PresShell.

Implements nsIPresShell.

Definition at line 6022 of file nsPresShell.cpp.

{
  *aFrame = GetCurrentEventFrame();
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::GetGeneratedContentIterator ( nsIContent aContent,
GeneratedContentType  aType,
nsIContentIterator **  aIterator 
) const [virtual]

Implements nsIPresShell.

Definition at line 4997 of file nsPresShell.cpp.

{
  nsIFrame* primaryFrame;
  nsresult  rv = NS_OK;

  // Initialize OUT parameter
  *aIterator = nsnull;

  // Get the primary frame associated with the content object
  GetPrimaryFrameFor(aContent, &primaryFrame);
  if (primaryFrame) {
    // See whether it's a request for the before or after generated content
    if (Before == aType) {
      nsIFrame* beforeFrame = nsLayoutUtils::GetBeforeFrame(primaryFrame);
      if (beforeFrame) {
        // Create an iterator
        rv = NS_NewFrameContentIterator(mPresContext, beforeFrame, aIterator);
      }
      
    } else {
      // Avoid finding the :after frame unless we need to (it's
      // expensive). Instead probe for the existence of the pseudo-element
      nsStyleContext *styleContext;
      
      styleContext = primaryFrame->GetStyleContext();
      if (nsLayoutUtils::HasPseudoStyle(aContent, styleContext,
                                        nsCSSPseudoElements::after,
                                        mPresContext)) {
        nsIFrame* afterFrame = nsLayoutUtils::GetAfterFrame(primaryFrame);
        if (afterFrame)
        {
          NS_ASSERTION(afterFrame->IsGeneratedContentFrame(),
                       "can't find generated content frame");
          // Create an iterator
          rv = NS_NewFrameContentIterator(mPresContext, afterFrame, aIterator);
        }
      }
    }
  }

  return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::GetLayoutObjectFor ( nsIContent aContent,
nsISupports **  aResult 
) const [virtual]

Returns a layout object associated with the primary frame for the content object.

Parameters:
aContentthe content object for which we seek a layout object
aResultthe resulting layout object as an nsISupports, if found. Refcounted.

Implements nsIPresShell.

Definition at line 5812 of file nsPresShell.cpp.

{
  nsresult result = NS_ERROR_NULL_POINTER;
  if ((nsnull!=aResult) && (nsnull!=aContent))
  {
    *aResult = nsnull;
    nsIFrame *primaryFrame=nsnull;
    result = GetPrimaryFrameFor(aContent, &primaryFrame);
    if ((NS_SUCCEEDED(result)) && (nsnull!=primaryFrame))
    {
      result = primaryFrame->QueryInterface(NS_GET_IID(nsISupports),
                                            (void**)aResult);
    }
  }
  return result;
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::GetLinkLocation ( nsIDOMNode aNode,
nsAString &  aLocation 
) [virtual]

Get link location.

Implements nsIPresShell.

Definition at line 4745 of file nsPresShell.cpp.

{
#ifdef DEBUG_dr
  printf("dr :: PresShell::GetLinkLocation\n");
#endif

  NS_ENSURE_ARG_POINTER(aNode);
  nsresult rv;
  nsAutoString anchorText;
  static char strippedChars[] = {'\t','\r','\n'};

  // are we an anchor?
  nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(do_QueryInterface(aNode));
  nsCOMPtr<nsIDOMHTMLAreaElement> area;
  nsCOMPtr<nsIDOMHTMLLinkElement> link;
  nsAutoString xlinkType;
  if (anchor) {
    rv = anchor->GetHref(anchorText);
    NS_ENSURE_SUCCESS(rv, rv);
  } else {
    // area?
    area = do_QueryInterface(aNode);
    if (area) {
      rv = area->GetHref(anchorText);
      NS_ENSURE_SUCCESS(rv, rv);
    } else {
      // link?
      link = do_QueryInterface(aNode);
      if (link) {
        rv = link->GetHref(anchorText);
        NS_ENSURE_SUCCESS(rv, rv);
      } else {
        // Xlink?
        nsCOMPtr<nsIDOMElement> element(do_QueryInterface(aNode));
        if (element) {
          NS_NAMED_LITERAL_STRING(xlinkNS,"http://www.w3.org/1999/xlink");
          element->GetAttributeNS(xlinkNS,NS_LITERAL_STRING("type"),xlinkType);
          if (xlinkType.EqualsLiteral("simple")) {
            element->GetAttributeNS(xlinkNS,NS_LITERAL_STRING("href"),anchorText);
            if (!anchorText.IsEmpty()) {
              // Resolve the full URI using baseURI property

              nsAutoString base;
              nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(aNode,&rv));
              NS_ENSURE_SUCCESS(rv, rv);
              node->GetBaseURI(base);

              nsCOMPtr<nsIIOService>
                ios(do_GetService("@mozilla.org/network/io-service;1", &rv));
              NS_ENSURE_SUCCESS(rv, rv);

              nsCOMPtr<nsIURI> baseURI;
              rv = ios->NewURI(NS_ConvertUCS2toUTF8(base),nsnull,nsnull,getter_AddRefs(baseURI));
              NS_ENSURE_SUCCESS(rv, rv);

              nsCAutoString spec;
              rv = baseURI->Resolve(NS_ConvertUCS2toUTF8(anchorText),spec);
              NS_ENSURE_SUCCESS(rv, rv);

              CopyUTF8toUTF16(spec, anchorText);
            }
          }
        }
      }
    }
  }

  if (anchor || area || link || xlinkType.EqualsLiteral("simple")) {
    //Remove all the '\t', '\r' and '\n' from 'anchorText'
    anchorText.StripChars(strippedChars);

    aLocationString = anchorText;

    return NS_OK;
  }

  // if no link, fail.
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Returns the page sequence frame associated with the frame hierarchy.

Returns NULL if not a paginated view.

Implements nsIPresShell.

Definition at line 3614 of file nsPresShell.cpp.

{
  NS_PRECONDITION(nsnull != aResult, "null ptr");
  if (nsnull == aResult) {
    return NS_ERROR_NULL_POINTER;
  }

  *aResult = nsnull;
  nsIFrame* frame = mFrameConstructor->GetPageSequenceFrame();
  if (frame) {
    CallQueryInterface(frame, aResult);
  }
  return *aResult ? NS_OK : NS_ERROR_FAILURE;
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::GetPlaceholderFrameFor ( nsIFrame aFrame,
nsIFrame **  aPlaceholderFrame 
) const [virtual]

Gets the placeholder frame associated with the specified frame.

This is a helper frame that forwards the request to the frame manager.

Implements nsIPresShell.

Definition at line 5831 of file nsPresShell.cpp.

{
  *aResult = FrameManager()->GetPlaceholderFrameFor(aFrame);
  return NS_OK;
}
nsPresContext* nsIPresShell::GetPresContext ( ) [inline, inherited]

Definition at line 177 of file nsIPresShell.h.

{ return mPresContext; }
NS_IMETHODIMP PresShell::GetPrimaryFrameFor ( nsIContent aContent,
nsIFrame **  aPrimaryFrame 
) const [virtual]

Gets the primary frame associated with the content object.

This is a helper function that just forwards the request to the frame manager.

The primary frame is the frame that is most closely associated with the content. A frame is more closely associated with the content that another frame if the one frame contains directly or indirectly the other frame (e.g., when a frame is scrolled there is a scroll frame that contains the frame being scrolled). The primary frame is always the first-in-flow.

In the case of absolutely positioned elements and floated elements, the primary frame is the frame that is out of the flow and not the placeholder frame.

Implements nsIPresShell.

Definition at line 5804 of file nsPresShell.cpp.

{
  *aResult = FrameManager()->GetPrimaryFrameFor(aContent);
  return NS_OK;
}

Here is the caller graph for this function:

Implements nsIPresShell.

Definition at line 5534 of file nsPresShell.cpp.

{
  *aIsBatching = mBatchReflows;
  return NS_OK;
}

Here is the caller graph for this function:

GetSelection will return the selection that the presentation shell may implement.

Parameters:
aTypewill hold the type of selection //SelectionType
_returnwill hold the return value

Definition at line 2694 of file nsPresShell.cpp.

{
  if (!aSelection || !mSelection)
    return NS_ERROR_NULL_POINTER;
  return mSelection->GetSelection(aType, aSelection);
}

Here is the caller graph for this function:

NS_IMETHODIMP PresShell::GetSelectionFlags ( PRInt16 aOutEnabled) [virtual]

Gets the current state of non text selection effects.

Parameters:
aEnabled[OUT] set to the current state of non text selection, as set by SetDisplayNonTextSelection
Returns:
if aOutEnabled==null, returns NS_ERROR_INVALID_ARG else NS_OK

Implements nsIPresShell.

Definition at line 3313 of file nsPresShell.cpp.

{
  if (!aOutEnable)
    return NS_ERROR_INVALID_ARG;
  *aOutEnable = mSelectionFlags;
  return NS_OK;
}

Get the selection of the focussed element (either the page selection, or the selection for a text field).

Implements nsIPresShell.

Definition at line 4826 of file nsPresShell.cpp.

{
  nsresult rv = NS_OK;

  *outSelection = nsnull;

  if (!mDocument) return NS_ERROR_FAILURE;

  nsCOMPtr<nsIContent> content;
  nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(mDocument->GetScriptGlobalObject());
  if (ourWindow) {
    nsIFocusController *focusController = ourWindow->GetRootFocusController();
    if (focusController) {
      nsCOMPtr<nsIDOMElement> focusedElement;
      focusController->GetFocusedElement(getter_AddRefs(focusedElement));
      content = do_QueryInterface(focusedElement);
    }
  }

  nsCOMPtr<nsISelection> sel;
  if (content)
  {
    //check to see if we need to get selection from frame
    //optimization that MAY need to be expanded as more things implement their own "selection"
    nsCOMPtr<nsIDOMNSHTMLInputElement>    htmlInputElement(do_QueryInterface(content));
    nsCOMPtr<nsIDOMNSHTMLTextAreaElement> htmlTextAreaElement(do_QueryInterface(content));
    if (htmlInputElement || htmlTextAreaElement)
    {
      nsIFrame *htmlInputFrame;
      rv = GetPrimaryFrameFor(content, &htmlInputFrame);
      if (NS_FAILED(rv))  return rv;
      if (!htmlInputFrame) return NS_ERROR_FAILURE;

      nsCOMPtr<nsISelectionController> selCon;
      rv = htmlInputFrame->GetSelectionController(mPresContext,getter_AddRefs(selCon));
      if (NS_FAILED(rv)) return rv;
      if (!selCon) return NS_ERROR_FAILURE;

      rv = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel));
    }
  }
  if (!sel) //get selection from this PresShell
    rv = GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel));
   
  *outSelection = sel;
  NS_IF_ADDREF(*outSelection);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

See if reflow verification is enabled.

To enable reflow verification add "verifyreflow:1" to your NSPR_LOG_MODULES environment variable (any non-zero debug level will work). Or, call SetVerifyReflowEnable with PR_TRUE.

Definition at line 1599 of file nsPresShell.cpp.

{
#ifdef NS_DEBUG
  static PRBool firstTime = PR_TRUE;
  if (firstTime) {
    firstTime = PR_FALSE;
    char* flags = PR_GetEnv("GECKO_VERIFY_REFLOW_FLAGS");
    if (flags) {
      PRBool error = PR_FALSE;

      for (;;) {
        char* comma = PL_strchr(flags, ',');
        if (comma)
          *comma = '\0';

        PRBool found = PR_FALSE;
        const VerifyReflowFlags* flag = gFlags;
        const VerifyReflowFlags* limit = gFlags + NUM_VERIFY_REFLOW_FLAGS;
        while (flag < limit) {
          if (PL_strcasecmp(flag->name, flags) == 0) {
            gVerifyReflowFlags |= flag->bit;
            found = PR_TRUE;
            break;
          }
          ++flag;
        }

        if (! found)
          error = PR_TRUE;

        if (! comma)
          break;

        *comma = ',';
        flags = comma + 1;
      }

      if (error)
        ShowVerifyReflowFlags();
    }

    if (VERIFY_REFLOW_ON & gVerifyReflowFlags) {
      gVerifyReflowEnabled = PR_TRUE;
    }
    printf("Note: verifyreflow is %sabled",
           gVerifyReflowEnabled ? "en" : "dis");
    if (VERIFY_REFLOW_NOISY & gVerifyReflowFlags) {
      printf(" (noisy)");
    }
    if (VERIFY_REFLOW_ALL & gVerifyReflowFlags) {
      printf(" (all)");
    }
    if (VERIFY_REFLOW_DUMP_COMMANDS & gVerifyReflowFlags) {
      printf(" (show reflow commands)");
    }
    if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
      printf(" (noisy reflow commands)");
      if (VERIFY_REFLOW_REALLY_NOISY_RC & gVerifyReflowFlags) {
        printf(" (REALLY noisy reflow commands)");
      }
    }
    printf("\n");
  }
#endif
  return gVerifyReflowEnabled;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Get the flags associated with the VerifyReflow debug tool.

Definition at line 1673 of file nsPresShell.cpp.

{
#ifdef NS_DEBUG
  return gVerifyReflowFlags;
#else
  return 0;
#endif
}

Here is the caller graph for this function:

nsIViewManager* nsIPresShell::GetViewManager ( ) [inline, inherited]

Definition at line 179 of file nsIPresShell.h.

{ return mViewManager; }

Here is the caller graph for this function:

Definition at line 3848 of file nsPresShell.cpp.

{
  nsCOMPtr<nsIEventStateManager> esm = mPresContext->EventStateManager();
  nsIScrollableView* scrollView = nsnull;
  nsCOMPtr<nsIContent> focusedContent;
  esm->GetFocusedContent(getter_AddRefs(focusedContent));
  if (!focusedContent && mSelection) {
    nsCOMPtr<nsISelection> domSelection;
    mSelection->GetSelection(nsISelectionController::SELECTION_NORMAL,
                             getter_AddRefs(domSelection));
    if (domSelection) {
      nsCOMPtr<nsIDOMNode> focusedNode;
      domSelection->GetFocusNode(getter_AddRefs(focusedNode));
      focusedContent = do_QueryInterface(focusedNode);
    }
  }
  if (focusedContent) {
    nsIFrame* startFrame = nsnull;
    GetPrimaryFrameFor(focusedContent, &startFrame);
    if (startFrame) {
      nsCOMPtr<nsIScrollableViewProvider> svp = do_QueryInterface(startFrame);
      // If this very frame provides a scroll view, start there instead of frame's
      // closest view, because the scroll view may be inside a child frame.
      // For example, this happens in the case of overflow:scroll.
      // In that case we still use GetNearestScrollingView() because
      // we need a scrolling view that matches aDirection.
      nsIScrollableView* sv;
      nsIView* startView = svp && (sv = svp->GetScrollableView()) ? sv->View() : startFrame->GetClosestView();
      NS_ASSERTION(startView, "No view to start searching for scrollable view from");
      scrollView = nsLayoutUtils::GetNearestScrollingView(startView, aDirection);
    }
  }
  if (!scrollView) {
    nsIViewManager* viewManager = GetViewManager();
    if (viewManager) {
      viewManager->GetRootScrollableView(&scrollView);
    }
  }
  return scrollView;
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::GoToAnchor ( const nsAString &  aAnchorName,
PRBool  aScroll 
) [virtual]

Informs the pres shell that the document is now at the anchor with the given name.

If |aScroll| is true, scrolls the view of the document so that the anchor with the specified name is displayed at the top of the window. If |aAnchorName| is empty, then this informs the pres shell that there is no current target, and |aScroll| must be false.

Implements nsIPresShell.

Definition at line 4266 of file nsPresShell.cpp.

{
  if (!mDocument) {
    return NS_ERROR_FAILURE;
  }
  
  // Hold a reference to the ESM in case event dispatch tears us down.
  nsCOMPtr<nsIEventStateManager> esm = mPresContext->EventStateManager();

  if (aAnchorName.IsEmpty()) {
    NS_ASSERTION(!aScroll, "can't scroll to empty anchor name");
    esm->SetContentState(nsnull, NS_EVENT_STATE_URLTARGET);
    return NS_OK;
  }

  nsCOMPtr<nsIDOMDocument> doc = do_QueryInterface(mDocument);
  nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
  nsresult rv = NS_OK;
  nsCOMPtr<nsIContent> content;

  // Search for an element with a matching "id" attribute
  if (doc) {    
    nsCOMPtr<nsIDOMElement> element;
    rv = doc->GetElementById(aAnchorName, getter_AddRefs(element));
    if (NS_SUCCEEDED(rv) && element) {
      // Get the nsIContent interface, because that's what we need to
      // get the primary frame
      content = do_QueryInterface(element);
    }
  }

  // Search for an anchor element with a matching "name" attribute
  if (!content && htmlDoc) {
    nsCOMPtr<nsIDOMNodeList> list;
    // Find a matching list of named nodes
    rv = htmlDoc->GetElementsByName(aAnchorName, getter_AddRefs(list));
    if (NS_SUCCEEDED(rv) && list) {
      PRUint32 i;
      // Loop through the named nodes looking for the first anchor
      for (i = 0; PR_TRUE; i++) {
        nsCOMPtr<nsIDOMNode> node;
        rv = list->Item(i, getter_AddRefs(node));
        if (!node) {  // End of list
          break;
        }
        // Ensure it's an anchor element
        content = do_QueryInterface(node);
        if (content) {
          if (content->Tag() == nsHTMLAtoms::a &&
              content->IsContentOfType(nsIContent::eHTML)) {
            break;
          }
          content = nsnull;
        }
      }
    }
  }

  // Search for anchor in the HTML namespace with a matching name
  if (!content && !htmlDoc)
  {
    nsCOMPtr<nsIDOMNodeList> list;
    NS_NAMED_LITERAL_STRING(nameSpace, "http://www.w3.org/1999/xhtml");
    // Get the list of anchor elements
    rv = doc->GetElementsByTagNameNS(nameSpace, NS_LITERAL_STRING("a"), getter_AddRefs(list));
    if (NS_SUCCEEDED(rv) && list) {
      PRUint32 i;
      // Loop through the named nodes looking for the first anchor
      for (i = 0; PR_TRUE; i++) {
        nsCOMPtr<nsIDOMNode> node;
        rv = list->Item(i, getter_AddRefs(node));
        if (!node) { // End of list
          break;
        }
        // Compare the name attribute
        nsCOMPtr<nsIDOMElement> element = do_QueryInterface(node);
        nsAutoString value;
        if (element && NS_SUCCEEDED(element->GetAttribute(NS_LITERAL_STRING("name"), value))) {
          if (value.Equals(aAnchorName)) {
            content = do_QueryInterface(element);
            break;
          }
        }
      }
    }
  }

  nsCOMPtr<nsIDOMRange> jumpToRange;
  nsCOMPtr<nsIXPointerResult> xpointerResult;
  if (!content) {
    nsCOMPtr<nsIDOMXMLDocument> xmldoc = do_QueryInterface(mDocument);
    if (xmldoc) {
      // Try XPointer
      xmldoc->EvaluateXPointer(aAnchorName, getter_AddRefs(xpointerResult));
      if (xpointerResult) {
        xpointerResult->Item(0, getter_AddRefs(jumpToRange));
        if (!jumpToRange) {
          // We know it was an XPointer, so there is no point in
          // trying any other pointer types, let's just return
          // an error.
          return NS_ERROR_FAILURE;
        }
      }

      // Finally try FIXptr
      if (!jumpToRange) {
        xmldoc->EvaluateFIXptr(aAnchorName,getter_AddRefs(jumpToRange));
      }

      if (jumpToRange) {
        nsCOMPtr<nsIDOMNode> node;
        jumpToRange->GetStartContainer(getter_AddRefs(node));
        if (node) {
          PRUint16 nodeType;
          node->GetNodeType(&nodeType);
          PRInt32 offset = -1;
          jumpToRange->GetStartOffset(&offset);
          switch (nodeType) {
            case nsIDOMNode::ATTRIBUTE_NODE:
            {
              // XXX Assuming jumping to the ownerElement is the sanest action.
              nsCOMPtr<nsIAttribute> attr = do_QueryInterface(node);
              content = attr->GetContent();
              break;
            }
            case nsIDOMNode::DOCUMENT_NODE:
            {
              if (offset >= 0) {
                nsCOMPtr<nsIDocument> document = do_QueryInterface(node);
                content = document->GetChildAt(offset);
              }
              break;
            }
            case nsIDOMNode::DOCUMENT_FRAGMENT_NODE:
            case nsIDOMNode::ELEMENT_NODE:
            case nsIDOMNode::ENTITY_REFERENCE_NODE:
            {
              if (offset >= 0) {
                nsCOMPtr<nsIContent> parent = do_QueryInterface(node);
                content = parent->GetChildAt(offset);
              }
              break;
            }
            case nsIDOMNode::CDATA_SECTION_NODE:
            case nsIDOMNode::COMMENT_NODE:
            case nsIDOMNode::TEXT_NODE:
            case nsIDOMNode::PROCESSING_INSTRUCTION_NODE:
            {
              // XXX This should scroll to a specific position in the text.
              content = do_QueryInterface(node);
              break;
            }
          }
        }
      }
    }
  }

  esm->SetContentState(content, NS_EVENT_STATE_URLTARGET);

  if (content) {
    // Flush notifications so we scroll to the right place
    if (aScroll) {
      mDocument->FlushPendingNotifications(Flush_Layout);   
      // Get the primary frame
      nsIFrame* frame = nsnull;
      GetPrimaryFrameFor(content, &frame);
      NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
      rv = ScrollFrameIntoView(frame, NS_PRESSHELL_SCROLL_TOP,
                               NS_PRESSHELL_SCROLL_ANYWHERE);
      NS_ENSURE_SUCCESS(rv, rv);
    }

    // Should we select the target? This action is controlled by a
    // preference: the default is to not select.
    PRBool selectAnchor = nsContentUtils::GetBoolPref("layout.selectanchor");

    // Even if select anchor pref is false, we must still move the
    // caret there. That way tabbing will start from the new
    // location
    if (!jumpToRange) {
      jumpToRange = do_CreateInstance(kRangeCID);
      if (jumpToRange) {
        while (content && content->GetChildCount() > 0) {
          content = content->GetChildAt(0);
        }
        nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
        NS_ASSERTION(node, "No nsIDOMNode for descendent of anchor");
        jumpToRange->SelectNodeContents(node);
      }
    }
    if (jumpToRange) {
      // Select the anchor
      nsCOMPtr<nsISelection> sel;
      if (NS_SUCCEEDED(
          GetSelection(nsISelectionController::SELECTION_NORMAL,
                        getter_AddRefs(sel))) &&
          sel) {
        sel->RemoveAllRanges();
        sel->AddRange(jumpToRange);
        if (!selectAnchor) {
          // Use a caret (collapsed selection) at the start of the anchor
          sel->CollapseToStart();
        }
      }  

      if (selectAnchor && xpointerResult) {
        // Select the rest (if any) of the ranges in XPointerResult
        PRUint32 count, i;
        xpointerResult->GetLength(&count);
        for (i = 1; i < count; i++) { // jumpToRange is i = 0
          nsCOMPtr<nsIDOMRange> range;
          xpointerResult->Item(i, getter_AddRefs(range));
          sel->AddRange(range);
        }
      }
      // Selection is at anchor.
      // Now focus the document itself if focus is on an element within it.
      nsPIDOMWindow *win = mDocument->GetWindow();

      if (win) {
        nsCOMPtr<nsIFocusController> focusController = win->GetRootFocusController();
        if (focusController) {
          nsCOMPtr<nsIDOMWindowInternal> focusedWin;
          focusController->GetFocusedWindow(getter_AddRefs(focusedWin));
          if (SameCOMIdentity(win, focusedWin)) {
            esm->ChangeFocusWith(nsnull, nsIEventStateManager::eEventFocusedByApplication);
          }
        }
      }
    }
  } else {
    rv = NS_ERROR_FAILURE; //changed to NS_OK in quirks mode if ScrollTo is called
    
    // Scroll to the top/left if the anchor can not be
    // found and it is labelled top (quirks mode only). @see bug 80784
    if ((NS_LossyConvertUCS2toASCII(aAnchorName).LowerCaseEqualsLiteral("top")) &&
        (mPresContext->CompatibilityMode() == eCompatibility_NavQuirks)) {
      rv = NS_OK;
      // Check |aScroll| after setting |rv| so we set |rv| to the same
      // thing whether or not |aScroll| is true.
      if (aScroll && mViewManager) {
        // Get the viewport scroller
        nsIScrollableView* scrollingView;
        mViewManager->GetRootScrollableView(&scrollingView);
        if (scrollingView) {
          // Scroll to the top of the page
          scrollingView->ScrollTo(0, 0, NS_VMREFRESH_IMMEDIATE);
        }
      }
    }
  }

  return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::HandleDOMEventWithTarget ( nsIContent aTargetContent,
nsEvent aEvent,
nsEventStatus aStatus 
) [virtual]

Dispatch event to content only (NOT full processing)

Note:
The caller must have a strong reference to the PresShell.

Implements nsIPresShell.

Definition at line 6624 of file nsPresShell.cpp.

{
  PushCurrentEventInfo(nsnull, aTargetContent);

  // Bug 41013: Check if the event should be dispatched to content.
  // It's possible that we are in the middle of destroying the window
  // and the js context is out of date. This check detects the case
  // that caused a crash in bug 41013, but there may be a better way
  // to handle this situation!
  nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
  if (container) {

    // Dispatch event to content
    aTargetContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
                                   NS_EVENT_FLAG_INIT, aStatus);
  }

  PopCurrentEventInfo();
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::HandleEvent ( nsIView aView,
nsGUIEvent aEvent,
nsEventStatus aEventStatus,
PRBool  aForceHandle,
PRBool aHandled 
) [virtual]

Implements nsIViewObserver.

Definition at line 6157 of file nsPresShell.cpp.

{
  NS_ASSERTION(aView, "null view");
  aHandled = PR_TRUE;

  if (mIsDestroying || mIsReflowing || mChangeNestCount) {
    return NS_OK;
  }

#ifdef ACCESSIBILITY
  if (aEvent->eventStructType == NS_ACCESSIBLE_EVENT) {
    return HandleEventInternal(aEvent, aView,
                               NS_EVENT_FLAG_INIT, aEventStatus);
  }
#endif

  // Check for a theme change up front, since the frame type is irrelevant
  if (aEvent->message == NS_THEMECHANGED && mPresContext) {
    mPresContext->ThemeChanged();
    return NS_OK;
  }

  // Check for a system color change up front, since the frame type is
  // irrelevant
  if ((aEvent->message == NS_SYSCOLORCHANGED) && mPresContext) {
    nsIViewManager* vm = GetViewManager();
    if (vm) {
      // Only dispatch system color change when the message originates from
      // from the root views widget. This is necessary to prevent us from 
      // dispatching the SysColorChanged notification for each child window 
      // which may be redundant.
      nsIView *view;
      vm->GetRootView(view);
      if (view == aView) {
        aHandled = PR_TRUE;
        *aEventStatus = nsEventStatus_eConsumeDoDefault;
        mPresContext->SysColorChanged();
        return NS_OK;
      }
    }
    return NS_OK;
  }

  nsIFrame* frame = NS_STATIC_CAST(nsIFrame*, aView->GetClientData());

  // if this event has no frame, we need to retarget it at a parent
  // view that has a frame.
  if (!frame &&
      ((NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent)))) {
    nsIView* targetView = aView;
    while (targetView && !targetView->GetClientData()) {
      targetView = targetView->GetParent();
    }
    
    if (targetView) {
      aEvent->point += aView->GetOffsetTo(targetView);
      aView = targetView;
      frame = NS_STATIC_CAST(nsIFrame*, aView->GetClientData());
    }
  }

  nsresult rv = NS_OK;
  
  if (frame) {
    PushCurrentEventInfo(nsnull, nsnull);

    // key and IME events go to the focused frame
    nsCOMPtr<nsIEventStateManager> manager;
    if ((NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent) ||
         aEvent->message == NS_CONTEXTMENU_KEY)) {

      nsIEventStateManager *esm = mPresContext->EventStateManager();

      esm->GetFocusedFrame(&mCurrentEventFrame);
      if (mCurrentEventFrame) {
        esm->GetFocusedContent(getter_AddRefs(mCurrentEventContent));
      }
      else {
#if defined(MOZ_X11) || defined(XP_WIN)
#if defined(MOZ_X11)
        if (NS_IS_IME_EVENT(aEvent)) {
          // bug 52416 (MOZ_X11)
          // Lookup region (candidate window) of UNIX IME grabs
          // input focus from Mozilla but wants to send IME event
          // to redraw pre-edit (composed) string
          // If Mozilla does not have input focus and event is IME,
          // sends IME event to pre-focused element
#else
        if (NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent)) {
          // bug 292263 (XP_WIN)
          // If software keyboard has focus, it may send the key messages and
          // the IME messages to pre-focused window. Therefore, if Mozilla
          // doesn't have focus and event is key event or IME event, we should
          // send the events to pre-focused element.
#endif /* defined(MOZ_X11) */
          nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(mDocument->GetScriptGlobalObject());
          if (ourWindow) {
            nsIFocusController *focusController =
              ourWindow->GetRootFocusController();
            if (focusController) {
              PRBool active = PR_FALSE;
              // check input focus is in Mozilla
              focusController->GetActive(&active);
              if (!active) {
                // if not, search for pre-focused element
                nsCOMPtr<nsIDOMElement> focusedElement;
                focusController->GetFocusedElement(getter_AddRefs(focusedElement));
                if (focusedElement) {
                  // get mCurrentEventContent from focusedElement
                  mCurrentEventContent = do_QueryInterface(focusedElement);
                }
              }
            }
          }
        }
#endif /* defined(MOZ_X11) || defined(XP_WIN) */
        if (!mCurrentEventContent) {
          mCurrentEventContent = mDocument->GetRootContent();
        }
        mCurrentEventFrame = nsnull; // XXXldb Isn't it already?
      }
      if (mCurrentEventContent && InZombieDocument(mCurrentEventContent)) {
        return RetargetEventToParent(aView, aEvent, aEventStatus, aForceHandle,
                                     aHandled, mCurrentEventContent);
      }
    }
    else if (!InClipRect(frame, aEvent->point)) {
      // we only check for the clip rect on this frame ... all frames with clip
      // have views so any viewless children of this frame cannot have clip. 
      // Furthermore if the event is not in the clip for this frame, then none
      // of the children can get it either.
      if (aForceHandle) {
        mCurrentEventFrame = frame;
      }
      else {
        mCurrentEventFrame = nsnull;
      }
      aHandled = PR_FALSE;
      rv = NS_OK;
    } else {
      // aEvent->point is relative to aView's upper left corner. We need
      // a point that is in the same coordinate system as frame's rect
      // so that the frame->mRect.Contains(aPoint) calls in 
      // GetFrameForPoint() work. The assumption here is that frame->GetView()
      // will return aView, and frame's parent view is aView's parent.

      nsPoint eventPoint = frame->GetPosition();
      eventPoint += aEvent->point;

      nsPoint originOffset;
      nsIView *view = nsnull;
      frame->GetOriginToViewOffset(originOffset, &view);

      NS_ASSERTION(view == aView, "view != aView");
      if (view == aView)
        eventPoint -= originOffset;

      rv = frame->GetFrameForPoint(eventPoint,
                                   NS_FRAME_PAINT_LAYER_FOREGROUND,
                                   &mCurrentEventFrame);
      if (NS_FAILED(rv)) {
        rv = frame->GetFrameForPoint(eventPoint,
                                     NS_FRAME_PAINT_LAYER_FLOATS,
                                     &mCurrentEventFrame);
        if (NS_FAILED(rv)) {
          rv = frame->GetFrameForPoint(eventPoint,
                                       NS_FRAME_PAINT_LAYER_BACKGROUND,
                                       &mCurrentEventFrame);
          if (NS_FAILED (rv)) {
            if (aForceHandle) {
              mCurrentEventFrame = frame;
            }
            else {
              mCurrentEventFrame = nsnull;
            }
            aHandled = PR_FALSE;
            rv = NS_OK;
          }
        }
      }

      if (mCurrentEventFrame) {
        nsCOMPtr<nsIContent> targetElement;
        mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent,
                                               getter_AddRefs(targetElement));

        // If there is no content for this frame, target it anyway.  Some
        // frames can be targeted but do not have content, particularly
        // windows with scrolling off.
        if (targetElement) {
          // Bug 103055, bug 185889: mouse events apply to *elements*, not all
          // nodes.  Thus we get the nearest element parent here.
          // XXX we leave the frame the same even if we find an element
          // parent, so that the text frame will receive the event (selection
          // and friends are the ones who care about that anyway)
          //
          // We use weak pointers because during this tight loop, the node
          // will *not* go away.  And this happens on every mousemove.
          while (targetElement &&
                 !targetElement->IsContentOfType(nsIContent::eELEMENT)) {
            targetElement = targetElement->GetParent();
          }

          // If we found an element, target it.  Otherwise, target *nothing*.
          if (!targetElement) {
            mCurrentEventContent = nsnull;
            mCurrentEventFrame = nsnull;
          } else if (targetElement != mCurrentEventContent) {
            mCurrentEventContent = targetElement;
          }
        }
      }

    }
    if (GetCurrentEventFrame()) {
      rv = HandleEventInternal(aEvent, aView,
                               NS_EVENT_FLAG_INIT, aEventStatus);
    }

#ifdef NS_DEBUG
    if ((nsIFrameDebug::GetShowEventTargetFrameBorder()) &&
        (GetCurrentEventFrame())) {
      nsIView *oldView = mCurrentTargetView;
      nsPoint offset(0,0);
      nsRect oldTargetRect(mCurrentTargetRect);
      mCurrentTargetRect = mCurrentEventFrame->GetRect();
      mCurrentTargetView = mCurrentEventFrame->GetView();
      if (!mCurrentTargetView ) {
        mCurrentEventFrame->GetOffsetFromView(offset, &mCurrentTargetView);
      }
      if (mCurrentTargetView) {
        mCurrentTargetRect.x = offset.x;
        mCurrentTargetRect.y = offset.y;
        // use aView or mCurrentTargetView??
        if ((mCurrentTargetRect != oldTargetRect) ||
            (mCurrentTargetView != oldView)) {

          nsIViewManager* vm = GetViewManager();
          if (vm) {
            vm->UpdateView(mCurrentTargetView,mCurrentTargetRect,0);
            if (oldView)
              vm->UpdateView(oldView,oldTargetRect,0);
          }
        }
      }
    }
#endif
    PopCurrentEventInfo();
  }
  else {
    // Focus events need to be dispatched even if no frame was found, since
    // we don't want the focus controller to be out of sync.

    if (!NS_EVENT_NEEDS_FRAME(aEvent)) {
      mCurrentEventFrame = nsnull;
      return HandleEventInternal(aEvent, aView,
                                 NS_EVENT_FLAG_INIT, aEventStatus);
    }
    else if (NS_IS_KEY_EVENT(aEvent)) {
      // Keypress events in new blank tabs should not be completely thrown away.
      // Retarget them -- the parent chrome shell might make use of them.
      return RetargetEventToParent(aView, aEvent, aEventStatus, aForceHandle,
                                   aHandled, mCurrentEventContent);
    }

    aHandled = PR_FALSE;
  }

  return rv;
}

Here is the call graph for this function:

nsresult PresShell::HandleEventInternal ( nsEvent aEvent,
nsIView aView,
PRUint32  aFlags,
nsEventStatus aStatus 
) [private]

Definition at line 6451 of file nsPresShell.cpp.

{
#ifdef ACCESSIBILITY
  if (aEvent->eventStructType == NS_ACCESSIBLE_EVENT)
  {
    NS_STATIC_CAST(nsAccessibleEvent*, aEvent)->accessible = nsnull;
    nsCOMPtr<nsIAccessibilityService> accService = 
      do_GetService("@mozilla.org/accessibilityService;1");
    if (accService) {
      nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
      if (!container) {
        // This presshell is not active. This often happens when a
        // preshell is being held onto for fastback.
        return NS_OK;
      }
      nsIAccessible* acc;
      nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(mDocument));
      NS_ASSERTION(domNode, "No dom node for doc");
      accService->GetAccessibleInShell(domNode, this, &acc);
      // Addref this - it's not a COM Ptr
      // We'll make sure the right number of Addref's occur before
      // handing this back to the accessibility client
      NS_STATIC_CAST(nsAccessibleEvent*, aEvent)->accessible = acc;
      mIsAccessibilityActive = PR_TRUE;
      return NS_OK;
    }
  }
#endif

  nsCOMPtr<nsIEventStateManager> manager = mPresContext->EventStateManager();
  nsresult rv = NS_OK;

  // Grab the offset of aView from our root view.  We can use this to adjust
  // coordinates as needed.  Note that we can't just adjust them later, because
  // event dispatch can destroy aView.  Also note that at times aView is null
  // here.  When that happens, there isn't much we can do about getting
  // coordinates right....
  nsPoint offsetOfaView(0,0);
  if (aView) {
    nsIView* rootView;
    mViewManager->GetRootView(rootView);
    offsetOfaView = aView->GetOffsetTo(rootView);
  }

  if (!NS_EVENT_NEEDS_FRAME(aEvent) || GetCurrentEventFrame()) {
    PRBool isHandlingUserInput = PR_FALSE;

    if (aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED) {
      switch (aEvent->message) {
      case NS_GOTFOCUS:
      case NS_LOSTFOCUS:
      case NS_ACTIVATE:
      case NS_DEACTIVATE:
        // Treat focus/blur events as user input if they happen while
        // executing trusted script, or no script at all. If they
        // happen during execution of non-trusted script, then they
        // should not be considerd user input.
        if (!nsContentUtils::IsCallerChrome()) {
          break;
        }
      case NS_MOUSE_LEFT_BUTTON_DOWN:
      case NS_MOUSE_MIDDLE_BUTTON_DOWN:
      case NS_MOUSE_RIGHT_BUTTON_DOWN:
      case NS_MOUSE_LEFT_BUTTON_UP:
      case NS_MOUSE_RIGHT_BUTTON_UP:
      case NS_MOUSE_MIDDLE_BUTTON_UP:
      case NS_KEY_PRESS:
      case NS_KEY_DOWN:
      case NS_KEY_UP:
        isHandlingUserInput = PR_TRUE;
      }
    }

    nsAutoHandlingUserInputStatePusher userInpStatePusher(isHandlingUserInput);

    nsAutoPopupStatePusher popupStatePusher(nsDOMEvent::GetEventPopupControlState(aEvent));

    nsWeakView weakView(aView);
    // 1. Give event to event manager for pre event state changes and
    //    generation of synthetic events.
    rv = manager->PreHandleEvent(mPresContext, aEvent, mCurrentEventFrame,
                                 aStatus, aView);

    // 2. Give event to the DOM for third party and JS use.
    if ((GetCurrentEventFrame()) && NS_SUCCEEDED(rv)) {
      // We want synthesized mouse moves to cause mouseover and mouseout
      // DOM events (PreHandleEvent above), but not mousemove DOM events.
      if (!IsSynthesizedMouseMove(aEvent)) {
        if (mCurrentEventContent) {
          rv = mCurrentEventContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
                                                    aFlags, aStatus);
        }
        else {
          nsCOMPtr<nsIContent> targetContent;
          rv = mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent,
                                                      getter_AddRefs(targetContent));
          if (NS_SUCCEEDED(rv) && targetContent) {
            rv = targetContent->HandleDOMEvent(mPresContext, aEvent, nsnull, 
                                               aFlags, aStatus);
          }
        }

        // Stopping propagation in the default group does not affect
        // propagation in the system event group.
        // (see also section 1.2.2.6 of the DOM3 Events Working Draft)

        aEvent->flags &= ~NS_EVENT_FLAG_STOP_DISPATCH;

        // 3. Give event to the Frames for browser default processing.
        if (GetCurrentEventFrame() && NS_SUCCEEDED (rv) &&
            aEvent->eventStructType != NS_EVENT) {
          // If aView is non-null, adjust coordinates of aEvent to be in the
          // coordinate system of mCurrentEventFrame's closest view.  Don't use
          // aView here, since it may be dead by now.
          nsPoint offset(0,0);
          if (aView) {
            NS_ASSERTION(mViewManager,
                         "How did GetCurrentEventFrame() succeed?");
            nsIView* rootView;
            mViewManager->GetRootView(rootView);
            nsIView* frameView;
            nsPoint pt;
            mCurrentEventFrame->GetOffsetFromView(pt, &frameView);
            offset = frameView->GetOffsetTo(rootView) - offsetOfaView;
          }
  
          // Transform aEvent->point from aView's coordinate system to
          // that of mCurrentEventFrame's closest view
          aEvent->point -= offset;
  
          rv = mCurrentEventFrame->HandleEvent(mPresContext, (nsGUIEvent*)aEvent,
                                               aStatus);
          // Now transform back
          aEvent->point += offset;
        }

        // Continue with second dispatch to system event handlers.

        // Need to null check mCurrentEventContent and mCurrentEventFrame
        // since the previous dispatch could have nuked them.
        if (mCurrentEventContent) {
          rv = mCurrentEventContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
                                                    aFlags | NS_EVENT_FLAG_SYSTEM_EVENT,
                                                    aStatus);
        }
        else if (mCurrentEventFrame) {
          nsCOMPtr<nsIContent> targetContent;
          rv = mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent,
                                                      getter_AddRefs(targetContent));
          if (NS_SUCCEEDED(rv) && targetContent) {
            rv = targetContent->HandleDOMEvent(mPresContext, aEvent, nsnull, 
                                               aFlags | NS_EVENT_FLAG_SYSTEM_EVENT,
                                               aStatus);
          }
        }
      }

      // 4. Give event to event manager for post event state changes and
      //    generation of synthetic events.
      if (NS_SUCCEEDED (rv) &&
          (GetCurrentEventFrame() || !NS_EVENT_NEEDS_FRAME(aEvent))) {
        rv = manager->PostHandleEvent(mPresContext, aEvent, mCurrentEventFrame,
                                      aStatus, weakView.GetView());
      }
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP PresShell::HandleEventWithTarget ( nsEvent aEvent,
nsIFrame aFrame,
nsIContent aContent,
PRUint32  aFlags,
nsEventStatus aStatus 
) [virtual]

Interface to dispatch events via the presshell.

Note:
The caller must have a strong reference to the PresShell.

Implements nsIPresShell.

Definition at line 6433 of file nsPresShell.cpp.

{
  nsresult ret;

  PushCurrentEventInfo(aFrame, aContent);
  ret = HandleEventInternal(aEvent, nsnull, aFlags, aStatus);
  PopCurrentEventInfo();
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 5393 of file nsPresShell.cpp.

{
   while(mFirstAttributeRequest)
   {
      /* pull the node from the request list. Be prepared for reentrant access to the list
         from within SetAttribute/UnsetAttribute and its callees! */
      nsAttributeChangeRequest* node = mFirstAttributeRequest;

      mFirstAttributeRequest = node->next;
      if (nsnull == mFirstAttributeRequest) {
        mLastAttributeRequest = nsnull;
      }

      if (node->type == eChangeType_Set)
         node->content->SetAttr(node->nameSpaceID, node->name, node->value, node->notify);   
      else
         node->content->UnsetAttr(node->nameSpaceID, node->name, node->notify);   

      NS_RELEASE(node->content);
      node->nsAttributeChangeRequest::~nsAttributeChangeRequest();
      FreeFrame(sizeof(nsAttributeChangeRequest), node);
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5370 of file nsPresShell.cpp.

{
   while(mFirstDOMEventRequest)
   {
      /* pull the node from the event request list. Be prepared for reentrant access to the list
         from within HandleDOMEvent and its callees! */
      nsDOMEventRequest* node = mFirstDOMEventRequest;
      nsEventStatus status = nsEventStatus_eIgnore;

      mFirstDOMEventRequest = node->next;
      if (nsnull == mFirstDOMEventRequest) {
        mLastDOMEventRequest = nsnull;
      }

      node->content->HandleDOMEvent(mPresContext, node->event, nsnull, NS_EVENT_FLAG_INIT, &status);
      NS_RELEASE(node->content);
      delete node->event;
      node->nsDOMEventRequest::~nsDOMEventRequest(); // doesn't do anything, but just in case
      FreeFrame(sizeof(nsDOMEventRequest), node);
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5348 of file nsPresShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void PresShell::HidePopups ( ) [virtual]

Implements nsIPresShell_MOZILLA_1_8_BRANCH.

Definition at line 6840 of file nsPresShell.cpp.

{
  nsIViewManager *vm = GetViewManager();
  if (vm) {
    nsIView *rootView = nsnull;
    vm->GetRootView(rootView);
    if (rootView)
      HideViewIfPopup(rootView);
  }
}

Here is the call graph for this function:

void PresShell::HideViewIfPopup ( nsIView aView) [protected]

Definition at line 7496 of file nsPresShell.cpp.

{
  nsIFrame* frame = NS_STATIC_CAST(nsIFrame*, aView->GetClientData());
  if (frame) {
    nsIMenuParent* parent;
    CallQueryInterface(frame, &parent);
    if (parent) {
      parent->HideChain();
      // really make sure the view is hidden
      mViewManager->SetViewVisibility(aView, nsViewVisibility_kHide);
    }
  }

  nsIView* child = aView->GetFirstChild();
  while (child) {
    HideViewIfPopup(child);
    child = child->GetNextSibling();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP PresShell::Init ( nsIDocument aDocument,
nsPresContext aPresContext,
nsIViewManager aViewManager,
nsStyleSet aStyleSet,
nsCompatibility  aCompatMode 
) [virtual]

Initialize the presentation shell.

Create view manager and style manager.

Implements nsIPresShell.

Definition at line 1791 of file nsPresShell.cpp.

{
  NS_PRECONDITION(nsnull != aDocument, "null ptr");
  NS_PRECONDITION(nsnull != aPresContext, "null ptr");
  NS_PRECONDITION(nsnull != aViewManager, "null ptr");

  if ((nsnull == aDocument) || (nsnull == aPresContext) ||
      (nsnull == aViewManager)) {
    return NS_ERROR_NULL_POINTER;
  }
  if (mDocument) {
    return NS_ERROR_ALREADY_INITIALIZED;
  }

  mDocument = aDocument;
  NS_ADDREF(mDocument);
  mViewManager = aViewManager;

  // Create our frame constructor.
  mFrameConstructor = new nsCSSFrameConstructor(mDocument, this);
  NS_ENSURE_TRUE(mFrameConstructor, NS_ERROR_OUT_OF_MEMORY);

  // The document viewer owns both view manager and pres shell.
  mViewManager->SetViewObserver(this);

  // Bind the context to the presentation shell.
  mPresContext = aPresContext;
  NS_ADDREF(mPresContext);
  aPresContext->SetShell(this);

  // Create our reflow command hashtable
  static PLDHashTableOps reflowCommandOps =
    {
      PL_DHashAllocTable,
      PL_DHashFreeTable,
      ReflowCommandHashGetKey,
      ReflowCommandHashHashKey,
      ReflowCommandHashMatchEntry,
      PL_DHashMoveEntryStub,
      PL_DHashClearEntryStub,
      PL_DHashFinalizeStub
    };

  if (!PL_DHashTableInit(&mReflowCommandTable, &reflowCommandOps,
                         nsnull, sizeof(ReflowCommandEntry), 16)) {
    mReflowCommandTable.ops = nsnull;
    return NS_ERROR_OUT_OF_MEMORY;
  }
  
  // Now we can initialize the style set.
  nsresult result = aStyleSet->Init(aPresContext);
  NS_ENSURE_SUCCESS(result, result);

  // From this point on, any time we return an error we need to make
  // sure to null out mStyleSet first, since an error return from this
  // method will cause the caller to delete the style set, so we don't
  // want to delete it in our destructor.
  mStyleSet = aStyleSet;

  // Set the compatibility mode after attaching the pres context and
  // style set, but before creating any frames.
  mPresContext->SetCompatibilityMode(aCompatMode);

  // setup the preference style rules (no forced reflow), and do it
  // before creating any frames.
  SetPreferenceStyleRules(PR_FALSE);

  result = CallCreateInstance(kFrameSelectionCID, &mSelection);
  if (NS_FAILED(result)) {
    mStyleSet = nsnull;
    return result;
  }

  // Create and initialize the frame manager
  result = FrameManager()->Init(this, mStyleSet);
  if (NS_FAILED(result)) {
    NS_WARNING("Frame manager initialization failed");
    mStyleSet = nsnull;
    return result;
  }

  result = mSelection->Init(this, nsnull);
  if (NS_FAILED(result)) {
    mStyleSet = nsnull;
    return result;
  }
  // Important: this has to happen after the selection has been set up
#ifdef SHOW_CARET
  // make the caret
  nsresult  err = NS_NewCaret(getter_AddRefs(mCaret));
  if (NS_SUCCEEDED(err))
  {
    mCaret->Init(this);
  }

  //SetCaretEnabled(PR_TRUE);       // make it show in browser windows
#endif  
  //set up selection to be displayed in document
  SetDisplaySelection(nsISelectionController::SELECTION_DISABLED);
  
  mEventQueueService = do_GetService(kEventQueueServiceCID, &result);

  if (!mEventQueueService) {
    NS_WARNING("couldn't get event queue service");
    mStyleSet = nsnull;
    return NS_ERROR_FAILURE;
  }

  if (gMaxRCProcessingTime == -1) {
    gMaxRCProcessingTime =
      nsContentUtils::GetIntPref("layout.reflow.timeslice",
                                 NS_MAX_REFLOW_TIME);

    gAsyncReflowDuringDocLoad =
      nsContentUtils::GetBoolPref("layout.reflow.async.duringDocLoad",
                                  PR_TRUE);
  }

  {
    nsCOMPtr<nsIObserverService> os =
      do_GetService("@mozilla.org/observer-service;1", &result);
    if (os) {
      os->AddObserver(this, NS_LINK_VISITED_EVENT_TOPIC, PR_FALSE);
#ifdef MOZ_XUL
      os->AddObserver(this, "chrome-flush-skin-caches", PR_FALSE);
#endif
    }
  }

  // cache the drag service so we can check it during reflows
  mDragService = do_GetService("@mozilla.org/widget/dragservice;1");

#ifdef IBMBIDI
  mBidiKeyboard = do_GetService("@mozilla.org/widget/bidikeyboard;1");
#endif

#ifdef MOZ_REFLOW_PERF
    if (mReflowCountMgr) {
      PRBool paintFrameCounts =
        nsContentUtils::GetBoolPref("layout.reflow.showframecounts");

      PRBool dumpFrameCounts =
        nsContentUtils::GetBoolPref("layout.reflow.dumpframecounts");

      PRBool dumpFrameByFrameCounts =
        nsContentUtils::GetBoolPref("layout.reflow.dumpframebyframecounts");

      mReflowCountMgr->SetDumpFrameCounts(dumpFrameCounts);
      mReflowCountMgr->SetDumpFrameByFrameCounts(dumpFrameByFrameCounts);
      mReflowCountMgr->SetPaintFrameCounts(paintFrameCounts);
    }
#endif

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::InitialReflow ( nscoord  aWidth,
nscoord  aHeight 
) [virtual]

Perform the initial reflow.

Constructs the frame for the root content object and then reflows the frame model into the specified width and height.

The coordinates for aWidth and aHeight must be in standard nscoord's.

Implements nsIPresShell.

Definition at line 2861 of file nsPresShell.cpp.

{
  mDidInitialReflow = PR_TRUE;

#ifdef NS_DEBUG
  if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
    if (mDocument) {
      nsIURI *uri = mDocument->GetDocumentURI();
      if (uri) {
        nsCAutoString url;
        uri->GetSpec(url);
        printf("*** PresShell::InitialReflow (this=%p, url='%s')\n", (void*)this, url.get());
      }
    }
  }
#endif

  if (mCaret)
    mCaret->EraseCaret();

  NS_ASSERTION(mViewManager, "Should have view manager");
  // Painting should be suppressed for the initial reflow, so this won't
  // really do anything right now, but it will be useful when we
  // start batching widget changes
  mViewManager->BeginUpdateViewBatch();

  WillCauseReflow();

  if (mPresContext) {
    nsRect r(0, 0, aWidth, aHeight);
    mPresContext->SetVisibleArea(r);
  }

  nsIContent *root = mDocument ? mDocument->GetRootContent() : nsnull;

  // Get the root frame from the frame manager
  nsIFrame* rootFrame = FrameManager()->GetRootFrame();
  
  if (root) {
    MOZ_TIMER_DEBUGLOG(("Reset and start: Frame Creation: PresShell::InitialReflow(), this=%p\n",
                        (void*)this));
    MOZ_TIMER_RESET(mFrameCreationWatch);
    MOZ_TIMER_START(mFrameCreationWatch);

    if (!rootFrame) {
      // Have style sheet processor construct a frame for the
      // precursors to the root content object's frame
      mFrameConstructor->ConstructRootFrame(root, &rootFrame);
      FrameManager()->SetRootFrame(rootFrame);
    }

    // Have the style sheet processor construct frame for the root
    // content object down
    mFrameConstructor->ContentInserted(nsnull, nsnull, root, 0,
                                       nsnull, PR_FALSE);
    VERIFY_STYLE_TREE;
    MOZ_TIMER_DEBUGLOG(("Stop: Frame Creation: PresShell::InitialReflow(), this=%p\n",
                        (void*)this));
    MOZ_TIMER_STOP(mFrameCreationWatch);

    NS_ENSURE_STATE(!mHaveShutDown);

    // Run the XBL binding constructors for any new frames we've constructed
    // Hold a strong ref to ourselves while we do that
    nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
    mDocument->BindingManager()->ProcessAttachedQueue();

    // Constructors may have killed us too
    NS_ENSURE_STATE(!mHaveShutDown);

    // Now flush out pending restyles before we actually reflow, in
    // case XBL constructors changed styles somewhere.
    mFrameConstructor->ProcessPendingRestyles();

    // And that might have run _more_ XBL constructors
    NS_ENSURE_STATE(!mHaveShutDown);

    // Now reget the root frame, since all that script might have affected it
    // somehow.  Currently that can't happen, as long as mHaveShutDown is
    // false, but let's not rely on that.
    rootFrame = FrameManager()->GetRootFrame();
  }

  if (rootFrame) {
    MOZ_TIMER_DEBUGLOG(("Reset and start: Reflow: PresShell::InitialReflow(), this=%p\n",
                        (void*)this));
    MOZ_TIMER_RESET(mReflowWatch);
    MOZ_TIMER_START(mReflowWatch);
    // Kick off a top-down reflow
    NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
                 ("enter nsPresShell::InitialReflow: %d,%d", aWidth, aHeight));
#ifdef NS_DEBUG
    if (nsIFrameDebug::GetVerifyTreeEnable()) {
      nsIFrameDebug*  frameDebug;

      if (NS_SUCCEEDED(rootFrame->QueryInterface(NS_GET_IID(nsIFrameDebug),
                                                (void**)&frameDebug))) {
        frameDebug->VerifyTree();
      }
    }
#endif
#ifdef DEBUG_kipp
    nsPresShell_ReflowStackPointerTop = (char*) &aWidth;
#endif
    nsRect                bounds = mPresContext->GetVisibleArea();
    nsSize                maxSize(bounds.width, bounds.height);
    nsHTMLReflowMetrics   desiredSize(nsnull);
    nsReflowStatus        status;
    nsIRenderingContext*  rcx = nsnull;

    nsresult rv=CreateRenderingContext(rootFrame, &rcx);
    if (NS_FAILED(rv)) return rv;

    mIsReflowing = PR_TRUE;

    nsHTMLReflowState reflowState(mPresContext, rootFrame,
                                  eReflowReason_Initial, rcx, maxSize);
    rootFrame->WillReflow(mPresContext);
    nsContainerFrame::PositionFrameView(rootFrame);
    rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
    rootFrame->SetSize(nsSize(desiredSize.width, desiredSize.height));
    mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));

    nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, rootFrame->GetView(),
                                               nsnull);
    rootFrame->DidReflow(mPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
      
#ifdef NS_DEBUG
    if (nsIFrameDebug::GetVerifyTreeEnable()) {
      nsIFrameDebug*  frameDebug;

      if (NS_SUCCEEDED(rootFrame->QueryInterface(NS_GET_IID(nsIFrameDebug),
                                                 (void**)&frameDebug))) {
        frameDebug->VerifyTree();
      }
    }
#endif
    VERIFY_STYLE_TREE;
    NS_IF_RELEASE(rcx);
    NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("exit nsPresShell::InitialReflow"));
    MOZ_TIMER_DEBUGLOG(("Stop: Reflow: PresShell::InitialReflow(), this=%p\n", (void*)this));
    MOZ_TIMER_STOP(mReflowWatch);

    mIsReflowing = PR_FALSE;
  }

  DidCauseReflow();
  DidDoReflow();

  mViewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);

  if (mViewManager && mCaret && !mViewEventListener) {
    nsIScrollableView* scrollingView = nsnull;
    mViewManager->GetRootScrollableView(&scrollingView);

    if (scrollingView) {
      mViewEventListener = new PresShellViewEventListener;

      if (!mViewEventListener)
        return NS_ERROR_OUT_OF_MEMORY;

      NS_ADDREF(mViewEventListener);
      mViewEventListener->SetPresShell(this);
      scrollingView->AddScrollPositionListener((nsIScrollPositionListener *)mViewEventListener);
      mViewManager->AddCompositeListener((nsICompositeListener *)mViewEventListener);
    }
  }

  // For printing, we just immediately unsuppress.
  if (!mPresContext->IsPaginated()) {
    // Kick off a one-shot timer based off our pref value.  When this timer
    // fires, if painting is still locked down, then we will go ahead and
    // trigger a full invalidate and allow painting to proceed normally.
    mPaintingSuppressed = PR_TRUE;
    mPaintSuppressionTimer = do_CreateInstance("@mozilla.org/timer;1");
    if (!mPaintSuppressionTimer)
      // Uh-oh.  We must be out of memory.  No point in keeping painting locked down.
      mPaintingSuppressed = PR_FALSE;
    else {
      // Initialize the timer.

      // Default to PAINTLOCK_EVENT_DELAY if we can't get the pref value.
      PRInt32 delay =
        nsContentUtils::GetIntPref("nglayout.initialpaint.delay",
                                   PAINTLOCK_EVENT_DELAY);

      nsCOMPtr<nsITimerInternal> ti = do_QueryInterface(mPaintSuppressionTimer);
      ti->SetIdle(PR_FALSE);

      mPaintSuppressionTimer->InitWithFuncCallback(sPaintSuppressionCallback,
                                                   this, delay, 
                                                   nsITimer::TYPE_ONE_SHOT);
    }
  }

  return NS_OK; //XXX this needs to be real. MMP
}

Here is the call graph for this function:

void nsISelectionController::intraLineMove ( in boolean  forward,
in boolean  extend 
) [inherited]

IntraLineMove will move the selection to the front of the line or end of the line in the document.

this will also have the effect of collapsing the selection if the aExtend = PR_FALSE the "point" of selection that is extended is considered the "focus" point. or the last point adjusted by the selection.

Parameters:
aForwardforward or backward if PR_FALSE
aExtendshould it collapse the selection of extend it?
NS_IMETHODIMP PresShell::IntraLineMove ( PRBool  aForward,
PRBool  aExtend 
)

Definition at line 3347 of file nsPresShell.cpp.

{
  return mSelection->IntraLineMove(aForward, aExtend);  
}
PRBool PresShell::InZombieDocument ( nsIContent aContent) [private]

Definition at line 6070 of file nsPresShell.cpp.

{
  // If a content node points to a null document, or the document is not
  // attached to a window, then it is possibly in a zombie document,
  // about to be replaced by a newly loading document.
  // Such documents cannot handle DOM events.
  // It might actually be in a node not attached to any document,
  // in which case there is not parent presshell to retarget it to.
  nsIDocument *doc = aContent->GetDocument();
  return !doc || !doc->GetScriptGlobalObject();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 698 of file nsIPresShell.h.

Here is the caller graph for this function:

PRBool PresShell::IsDragInProgress ( ) const [protected]

Definition at line 3833 of file nsPresShell.cpp.

{
  PRBool dragInProgress = PR_FALSE;
  if ( mDragService ) {
    nsCOMPtr<nsIDragSession> session;
    mDragService->GetCurrentSession ( getter_AddRefs(session) );
    if ( session )
      dragInProgress = PR_TRUE;
  }
  
  return dragInProgress;

} // IsDragInProgress

Here is the call graph for this function:

Called to find out if painting is suppressed for this presshell.

If it is suppressd, we don't allow the painting of any layer but the background, and we don't recur into our children.

Implements nsIPresShell.

Definition at line 5145 of file nsPresShell.cpp.

NS_IMETHODIMP PresShell::IsReflowLocked ( PRBool aIsLocked) [virtual]

Determine if reflow is currently locked.

Parameters:
aIsReflowLockedreturns PR_TRUE if reflow is locked, PR_FALSE otherwise

Implements nsIPresShell.

Definition at line 5505 of file nsPresShell.cpp.

{
  *aIsReflowLocked = mIsReflowing;
  return NS_OK;
}
NS_IMETHODIMP PresShell::IsSafeToFlush ( PRBool aIsSafeToFlush) [virtual]

Determine if it is safe to flush all pending notifications.

Parameters:
aIsSafeToFlushPR_TRUE if it is safe, PR_FALSE otherwise.

Implements nsIPresShell.

Definition at line 5418 of file nsPresShell.cpp.

{
  aIsSafeToFlush = PR_TRUE;

  if (mIsReflowing || mChangeNestCount) {
    // Not safe if we are reflowing or in the middle of frame construction
    aIsSafeToFlush = PR_FALSE;
  } else {
    // Not safe if we are painting
    nsIViewManager* viewManager = GetViewManager();
    if (viewManager) {
      PRBool isPainting = PR_FALSE;
      viewManager->IsPainting(isPainting);
      if (isPainting) {
        aIsSafeToFlush = PR_FALSE;
      }
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Indicates whether theme support is enabled.

Implements nsIPresShell.

Definition at line 5215 of file nsPresShell.cpp.

Definition at line 3195 of file nsPresShell.cpp.

void nsISelectionController::lineMove ( in boolean  forward,
in boolean  extend 
) [inherited]

LineMove will move the selection one line forward/backward in the document.

this will also have the effect of collapsing the selection if the aExtend = PR_FALSE the "point" of selection that is extended is considered the "focus" point. or the last point adjusted by the selection.

Parameters:
aForwardforward or backward if PR_FALSE
aExtendshould it collapse the selection of extend it?
NS_IMETHODIMP PresShell::LineMove ( PRBool  aForward,
PRBool  aExtend 
)

Definition at line 3336 of file nsPresShell.cpp.

{
  nsresult result = mSelection->LineMove(aForward, aExtend);  
// if we cant go down/up any more we must then move caret completely to 
// end/beginning respectively.
  if (NS_FAILED(result)) 
    result = CompleteMove(aForward,aExtend);
  return result;
}
NS_IMETHODIMP PresShell::ListAlternateStyleSheets ( nsStringArray &  aTitleList) [virtual]

Gather titles of all selectable (alternate and preferred) style sheets fills void array with nsString* caller must free strings.

Implements nsIPresShell.

Definition at line 2207 of file nsPresShell.cpp.

{
  // XXX should this be returning incomplete sheets?  Probably.
  if (mDocument) {
    PRInt32 count = mDocument->GetNumberOfStyleSheets();
    PRInt32 index;
    NS_NAMED_LITERAL_STRING(textHtml,"text/html");
    for (index = 0; index < count; index++) {
      nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(index);
      if (sheet) {
        nsAutoString type;
        sheet->GetType(type);
        if (PR_FALSE == type.Equals(textHtml)) {
          nsAutoString  title;
          sheet->GetTitle(title);
          if (!title.IsEmpty()) {
            if (-1 == aTitleList.IndexOf(title)) {
              aTitleList.AppendString(title);
            }
          }
        }
      }
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

PresShell::MOZ_TIMER_DECLARE ( mReflowWatch  ) [protected]

Notification sent by a frame informing the pres shell that it is about to be destroyed.

This allows any outstanding references to the frame to be cleaned up

Implements nsIPresShell.

Definition at line 3236 of file nsPresShell.cpp.

{
  if (!mIgnoreFrameDestruction) {
    mFrameConstructor->NotifyDestroyingFrame(aFrame);

    // Cancel any pending reflow commands targeted at this frame
    CancelReflowCommandInternal(aFrame, nsnull);

    DequeuePostedEventFor(aFrame);
    
    // Notify the frame manager
    FrameManager()->NotifyDestroyingFrame(aFrame);

    // Remove frame properties
    mPresContext->PropertyTable()->DeleteAllPropertiesFor(aFrame);
  }

  return NS_OK;
}

Here is the call graph for this function:

nsIPresShell::NS_HIDDEN_ ( PRBool  ) [inherited]
virtual nsIPresShell::NS_HIDDEN_ ( nsIFrame ) const [virtual, inherited]

This calls through to the frame manager to get the root frame.

Callers inside of gklayout should use FrameManager()->GetRootFrame() instead, as it's more efficient.

virtual PresShell::NS_HIDDEN_ ( void ) [virtual]
virtual PresShell::NS_HIDDEN_ ( void  ) [virtual]

Reimplemented from nsIPresShell.

PresShell::NS_HIDDEN_ ( void  ) [protected]

Reimplemented from nsIPresShell.

PresShell::NS_IMETHOD_ ( PRBool  ) [virtual]

Hack to find out if the view observer is itself visible, in lieu of having the view trees linked.

Implements nsIViewObserver.

PresShell::NS_IMETHOD_ ( void  ) [virtual]

Notify the observer that we're about to start painting.

This gives the observer a chance to make some last-minute invalidates and geometry changes if it wants to.

Implements nsIViewObserver.

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
void nsISelectionController::pageMove ( in boolean  forward,
in boolean  extend 
) [inherited]

PageMove will move the selection one page forward/backward in the document.

this will also have the effect of collapsing the selection if the aExtend = PR_FALSE the "point" of selection that is extended is considered the "focus" point. or the last point adjusted by the selection.

Parameters:
aForwardforward or backward if PR_FALSE
aExtendshould it collapse the selection of extend it?
NS_IMETHODIMP PresShell::PageMove ( PRBool  aForward,
PRBool  aExtend 
)

Definition at line 3355 of file nsPresShell.cpp.

{
  nsresult result;
  nsIViewManager* viewManager = GetViewManager();
  nsIScrollableView *scrollableView;
  if (!viewManager) 
    return NS_ERROR_UNEXPECTED;
  result = viewManager->GetRootScrollableView(&scrollableView);
  if (NS_FAILED(result)) 
    return result;
  if (!scrollableView) 
    return NS_ERROR_UNEXPECTED;
  nsIView *scrolledView;
  result = scrollableView->GetScrolledView(scrolledView);
  mSelection->CommonPageMove(aForward, aExtend, scrollableView, mSelection);
  // do ScrollSelectionIntoView()
  return ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL, nsISelectionController::SELECTION_FOCUS_REGION, PR_TRUE);
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::Paint ( nsIView aView,
nsIRenderingContext aRenderingContext,
const nsRect aDirtyRect 
) [virtual]

Implements nsIViewObserver.

Definition at line 5952 of file nsPresShell.cpp.

{
  nsIFrame* frame;
  nsresult  rv = NS_OK;

  if (mIsDestroying) {
    NS_ASSERTION(PR_FALSE, "A paint message was dispatched to a destroyed PresShell");
    return NS_OK;
  }

  NS_ASSERTION(!(nsnull == aView), "null view");

  frame = NS_STATIC_CAST(nsIFrame*, aView->GetClientData());
     
  if (nsnull != frame)
  {
    if (mCaret)
      mCaret->EraseCaret();

    // If the frame is absolutely positioned, then the 'clip' property
    // applies
    PRBool  setClipRect = SetClipRect(aRenderingContext, frame);

    rv = frame->Paint(mPresContext, aRenderingContext, aDirtyRect,
                      NS_FRAME_PAINT_LAYER_BACKGROUND);
    rv = frame->Paint(mPresContext, aRenderingContext, aDirtyRect,
                      NS_FRAME_PAINT_LAYER_FLOATS);
    rv = frame->Paint(mPresContext, aRenderingContext, aDirtyRect,
                      NS_FRAME_PAINT_LAYER_FOREGROUND);
                      
    if (setClipRect)
      aRenderingContext.PopState();

#ifdef NS_DEBUG
    // Draw a border around the frame
    if (nsIFrameDebug::GetShowFrameBorders()) {
      nsRect r = frame->GetRect();
      aRenderingContext.SetColor(NS_RGB(0,0,255));
      aRenderingContext.DrawRect(0, 0, r.width, r.height);
    }
    // Draw a border around the current event target
    if ((nsIFrameDebug::GetShowEventTargetFrameBorder()) && (aView == mCurrentTargetView)) {
      aRenderingContext.SetColor(NS_RGB(128,0,128));
      aRenderingContext.DrawRect(mCurrentTargetRect.x, mCurrentTargetRect.y, mCurrentTargetRect.width, mCurrentTargetRect.height);
    }
#endif
  }

  return rv;
}

Here is the call graph for this function:

Definition at line 6057 of file nsPresShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIPresShell.

Definition at line 2102 of file nsPresShell.cpp.

NS_IMETHODIMP PresShell::PostAttributeChange ( nsIContent aContent,
PRInt32  aNameSpaceID,
nsIAtom aName,
const nsString aValue,
PRBool  aNotify,
nsAttributeChangeType  aType 
) [virtual]

Post a request to set and attribute after reflow has finished.

Implements nsIPresShell.

Definition at line 5312 of file nsPresShell.cpp.

{
 // ok we have a list of events to handle. Queue them up and handle them
 // after we finish reflow.
  nsAttributeChangeRequest* request = nsnull;

  void* result = AllocateFrame(sizeof(nsAttributeChangeRequest));
  request = new (result) nsAttributeChangeRequest();

  request->content = aContent;
  NS_ADDREF(aContent);

  request->nameSpaceID = aNameSpaceID;
  request->name = aName;
  request->value = aValue;
  request->notify = aNotify;
  request->type = aType;
  request->next = nsnull;

  if (mLastAttributeRequest) {
    mLastAttributeRequest = mLastAttributeRequest->next = request;
  } else {
    mFirstAttributeRequest = request;
    mLastAttributeRequest = request;
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP PresShell::PostDOMEvent ( nsIContent aContent,
nsEvent aEvent 
) [virtual]

Post a request to handle a DOM event after Reflow has finished.

The event must have been created with the "new" operator.

Implements nsIPresShell.

Definition at line 5283 of file nsPresShell.cpp.

{
 // ok we have a list of events to handle. Queue them up and handle them
 // after we finish reflow.
  nsDOMEventRequest* request = nsnull;
  void* result = AllocateFrame(sizeof(nsDOMEventRequest));
  request = (nsDOMEventRequest*)result;

  request->content = aContent;
  NS_ADDREF(aContent);

  request->event = aEvent;
  request->next = nsnull;

  if (mLastDOMEventRequest) {
    mLastDOMEventRequest = mLastDOMEventRequest->next = request;
  } else {
    mFirstDOMEventRequest = request;
    mLastDOMEventRequest = request;
  }
 
  return NS_OK;
}

Here is the call graph for this function:

Post a callback that should be handled after reflow has finished.

Implements nsIPresShell.

Definition at line 5222 of file nsPresShell.cpp.

Here is the call graph for this function:

Definition at line 6962 of file nsPresShell.cpp.

{
  nsCOMPtr<nsIEventQueue> eventQueue;
  mEventQueueService->GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
                                           getter_AddRefs(eventQueue));

  if (eventQueue != mReflowEventQueue && !mIsDestroying &&
      !mIsReflowing && mReflowCommands.Count() > 0) {
    ReflowEvent* ev = new ReflowEvent(NS_STATIC_CAST(nsIPresShell*, this));
    if (NS_FAILED(eventQueue->PostEvent(ev))) {
      NS_ERROR("failed to post reflow event");
      PL_DestroyEvent(ev);
    }
    else {
      mReflowEventQueue = eventQueue;
#ifdef DEBUG
      if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
        printf("\n*** PresShell::PostReflowEvent(), this=%p, event=%p\n", (void*)this, (void*)ev);
      }
#endif    
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult PresShell::ProcessReflowCommands ( PRBool  aInterruptible) [protected]

Definition at line 7016 of file nsPresShell.cpp.

{
  MOZ_TIMER_DEBUGLOG(("Start: Reflow: PresShell::ProcessReflowCommands(), this=%p\n", this));
  MOZ_TIMER_START(mReflowWatch);  

  if (0 != mReflowCommands.Count()) {
    nsHTMLReflowMetrics   desiredSize(nsnull);
    nsCOMPtr<nsIRenderingContext> rcx;
    nsIFrame*             rootFrame = FrameManager()->GetRootFrame();
    nsSize          maxSize = rootFrame->GetSize();

    nsresult rv=CreateRenderingContext(rootFrame, getter_AddRefs(rcx));
    if (NS_FAILED(rv)) return rv;

#ifdef DEBUG
    if (GetVerifyReflowEnable()) {
      if (VERIFY_REFLOW_ALL & gVerifyReflowFlags) {
        printf("ProcessReflowCommands: begin incremental reflow\n");
      }
    }
    if (VERIFY_REFLOW_DUMP_COMMANDS & gVerifyReflowFlags) {   
      PRInt32 i, n = mReflowCommands.Count();
      printf("\nPresShell::ProcessReflowCommands: this=%p, count=%d\n", (void*)this, n);
      for (i = 0; i < n; i++) {
        nsHTMLReflowCommand* rc = (nsHTMLReflowCommand*)
          mReflowCommands.ElementAt(i);
        rc->List(stdout);
      }
    }
#endif

    // If reflow is interruptible, then make a note of our deadline.
    const PRIntervalTime deadline = aInterruptible
        ? PR_IntervalNow() + PR_MicrosecondsToInterval(gMaxRCProcessingTime)
        : (PRIntervalTime)0;

    // force flushing of any pending notifications
    mDocument->BeginUpdate(UPDATE_ALL);
    mDocument->EndUpdate(UPDATE_ALL);

    // That might have executed (via XBL binding constructors).  So we
    // may no longer have reflow commands.  In fact, we may have
    // gotten destroyed.
    if (!mIsDestroying && mReflowCommands.Count() != 0) {
      mIsReflowing = PR_TRUE;

      do {
        // Coalesce the reflow commands into a tree.
        IncrementalReflow reflow;
        for (PRInt32 i = mReflowCommands.Count() - 1; i >= 0; --i) {
          nsHTMLReflowCommand *command =
            NS_STATIC_CAST(nsHTMLReflowCommand *, mReflowCommands[i]);

          IncrementalReflow::AddCommandResult res =
            reflow.AddCommand(mPresContext, command);
          if (res == IncrementalReflow::eEnqueued ||
              res == IncrementalReflow::eCancel) {
            // Remove the command from the queue.
            mReflowCommands.RemoveElementAt(i);
            ReflowCommandRemoved(command);
            if (res == IncrementalReflow::eCancel)
              delete command;
          }
          else {
            // The reflow command couldn't be added to the tree; leave
            // it in the queue, and we'll handle it next time.
#ifdef DEBUG
            printf("WARNING: Couldn't add reflow command, so splitting.\n");
#endif
          }
        }

#ifdef DEBUG
        if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
          printf("Incremental reflow tree:\n");
          reflow.Dump(mPresContext);
        }
#endif

        // Dispatch an incremental reflow.
        reflow.Dispatch(mPresContext, desiredSize, maxSize, *rcx);

        // Keep going until we're out of reflow commands, or we've run
        // past our deadline.
      } while (mReflowCommands.Count() &&
               (!aInterruptible || PR_IntervalNow() < deadline));

      // XXXwaterson for interruptible reflow, examine the tree and
      // re-enqueue any unflowed reflow targets.

      mIsReflowing = PR_FALSE;
    }
    
    // If any new reflow commands were enqueued during the reflow,
    // schedule another reflow event to process them.
    if (mReflowCommands.Count())
      PostReflowEvent();
    
#ifdef DEBUG
    if (VERIFY_REFLOW_DUMP_COMMANDS & gVerifyReflowFlags) {
      printf("\nPresShell::ProcessReflowCommands() finished: this=%p\n", (void*)this);
    }

    if (nsIFrameDebug::GetVerifyTreeEnable()) {
      nsIFrameDebug*  frameDebug;

      if (NS_SUCCEEDED(rootFrame->QueryInterface(NS_GET_IID(nsIFrameDebug),
                                                 (void**)&frameDebug))) {
        frameDebug->VerifyTree();
      }
    }
    if (GetVerifyReflowEnable()) {
      // First synchronously render what we have so far so that we can
      // see it.
      nsIView* rootView;
      mViewManager->GetRootView(rootView);
      mViewManager->UpdateView(rootView, NS_VMREFRESH_IMMEDIATE);

      mInVerifyReflow = PR_TRUE;
      PRBool ok = VerifyIncrementalReflow();
      mInVerifyReflow = PR_FALSE;
      if (VERIFY_REFLOW_ALL & gVerifyReflowFlags) {
        printf("ProcessReflowCommands: finished (%s)\n",
               ok ? "ok" : "failed");
      }

      if (0 != mReflowCommands.Count()) {
        printf("XXX yikes! reflow commands queued during verify-reflow\n");
      }
    }
#endif

    // If there are no more reflow commands in the queue, we'll want
    // to remove the ``dummy request''.
    DoneRemovingReflowCommands();

    DidDoReflow();
  }
  
  MOZ_TIMER_DEBUGLOG(("Stop: Reflow: PresShell::ProcessReflowCommands(), this=%p\n", this));
  MOZ_TIMER_STOP(mReflowWatch);  

  if (mShouldUnsuppressPainting && mReflowCommands.Count() == 0) {
    // We only unlock if we're out of reflows.  It's pointless
    // to unlock if reflows are still pending, since reflows
    // are just going to thrash the frames around some more.  By
    // waiting we avoid an overeager "jitter" effect.
    mShouldUnsuppressPainting = PR_FALSE;
    UnsuppressAndInvalidate();
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PresShell::PushCurrentEventInfo ( nsIFrame aFrame,
nsIContent aContent 
) [private]

Definition at line 6046 of file nsPresShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIPresShell.

Definition at line 2090 of file nsPresShell.cpp.

{
  if (!mStackArena) {
    mStackArena = new StackArena();
    if (!mStackArena)
      return NS_ERROR_OUT_OF_MEMORY;
  }

  return mStackArena->Push();
}

Reconstruct frames for all elements in the document.

Implements nsIPresShell.

Definition at line 5691 of file nsPresShell.cpp.

Here is the call graph for this function:

void nsIPresShell::ReconstructStyleData ( ) [inline, inherited]

Definition at line 227 of file nsIPresShell.h.

{ ReconstructStyleDataExternal(); }

Recreates the frames for a node.

Implements nsIPresShell.

Definition at line 3963 of file nsPresShell.cpp.

{
  NS_ENSURE_TRUE(mPresContext, NS_ERROR_FAILURE);

  // Don't call RecreateFramesForContent since that is not exported and we want
  // to keep the number of entrypoints down.

  nsStyleChangeList changeList;
  changeList.AppendChange(nsnull, aContent, nsChangeHint_ReconstructFrame);

  NS_ASSERTION(mViewManager, "Should have view manager");
  mViewManager->BeginUpdateViewBatch();
  nsresult rv = mFrameConstructor->ProcessRestyledFrames(changeList);
  mViewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
#ifdef ACCESSIBILITY
  InvalidateAccessibleSubtree(aContent);
#endif
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7178 of file nsPresShell.cpp.

{

  if (gAsyncReflowDuringDocLoad) {
    NS_PRECONDITION(mRCCreatedDuringLoad >= 0, "PresShell's reflow command queue is in a bad state.");
    if (mDocumentLoading) {
      aRC->AddFlagBits(NS_RC_CREATED_DURING_DOCUMENT_LOAD);
      mRCCreatedDuringLoad++;

#ifdef PR_LOGGING
      if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {
        nsIFrame* target;
        aRC->GetTarget(target);

        nsIAtom* type = target->GetType();
        NS_ASSERTION(type, "frame didn't override GetType()");

        nsAutoString typeStr(NS_LITERAL_STRING("unknown"));
        if (type)
          type->ToString(typeStr);

        PR_LOG(gLog, PR_LOG_DEBUG,
               ("presshell=%p, ReflowCommandAdded(%p) target=%p[%s] mRCCreatedDuringLoad=%d\n",
                this, aRC, target, NS_ConvertUCS2toUTF8(typeStr).get(), mRCCreatedDuringLoad));
      }
#endif

      if (!mDummyLayoutRequest) {
        AddDummyLayoutRequest();
      }
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 7214 of file nsPresShell.cpp.

{
  NS_PRECONDITION(mReflowCommandTable.ops, "How did that happen?");
  
  PL_DHashTableOperate(&mReflowCommandTable, aRC, PL_DHASH_REMOVE);
  
  if (gAsyncReflowDuringDocLoad) {
    NS_PRECONDITION(mRCCreatedDuringLoad >= 0, "PresShell's reflow command queue is in a bad state.");  
    if (aRC->GetFlagBits() & NS_RC_CREATED_DURING_DOCUMENT_LOAD) {
      mRCCreatedDuringLoad--;

      PR_LOG(gLog, PR_LOG_DEBUG,
             ("presshell=%p, ReflowCommandRemoved(%p) mRCCreatedDuringLoad=%d\n",
              this, aRC, mRCCreatedDuringLoad));
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Release all nsIAnonymousContentCreator-generated anonymous content associated with the shell.

Implements nsIPresShell.

Definition at line 5133 of file nsPresShell.cpp.

Here is the call graph for this function:

Definition at line 7332 of file nsPresShell.cpp.

{
  nsresult rv = NS_OK;

  if (gAsyncReflowDuringDocLoad) {
    nsCOMPtr<nsILoadGroup> loadGroup;
    if (mDocument)
      loadGroup = mDocument->GetDocumentLoadGroup();

    if (loadGroup && mDummyLayoutRequest) {
      rv = loadGroup->RemoveRequest(mDummyLayoutRequest, nsnull, NS_OK);
      NS_ENSURE_SUCCESS(rv, rv);

      PR_LOG(gLog, PR_LOG_ALWAYS,
             ("presshell=%p, Removed dummy layout request %p", this,
              mDummyLayoutRequest.get()));

      mDummyLayoutRequest = nsnull;
    }
  }
  return rv;
}

Here is the call graph for this function:

Implements nsIPresShell_MOZILLA_1_8_BRANCH2.

Definition at line 6874 of file nsPresShell.cpp.

{
  PRInt32 index = mObservers.IndexOf(aObserver);
  if (index == -1) {
    return PR_FALSE;
  }

#ifdef DEBUG
  PRBool removed =
#endif
    mObservers.RemoveElementAt(index);
  NS_ASSERTION(removed, "How could we fail to remove by index?");

  return PR_TRUE;
}

Remove an override style sheet.

Implements nsIPresShell.

Definition at line 6713 of file nsPresShell.cpp.

Here is the call graph for this function:

Definition at line 1693 of file nsPresShell.cpp.

{
  if (mWeakFrames == aWeakFrame) {
    mWeakFrames = aWeakFrame->GetPreviousWeakFrame();
    return;
  }
  nsWeakFrame* nextWeak = mWeakFrames;
  while (nextWeak && nextWeak->GetPreviousWeakFrame() != aWeakFrame) {
    nextWeak = nextWeak->GetPreviousWeakFrame();
  }
  if (nextWeak) {
    nextWeak->SetPreviousWeakFrame(aWeakFrame->GetPreviousWeakFrame());
  }
}

Here is the caller graph for this function:

void nsISelectionController::repaintSelection ( in short  type) [inherited]

RepaintSelection repaints the selection specified by aType.

Parameters:
aTypespecifies the selection to repaint.

Definition at line 2711 of file nsPresShell.cpp.

NS_IMETHODIMP PresShell::ResizeReflow ( nscoord  aWidth,
nscoord  aHeight 
) [virtual]

Reflow the frame model into a new width and height.

The coordinates for aWidth and aHeight must be in standard nscoord's.

Implements nsIPresShell.

Definition at line 3068 of file nsPresShell.cpp.

{
  PRBool firstReflow = PR_FALSE;

  NS_ASSERTION(mViewManager, "Must have view manager");
  mViewManager->BeginUpdateViewBatch();

  WillCauseReflow();

  if (mCaret)
    mCaret->EraseCaret();

  // If we don't have a root frame yet, that means we haven't had our initial
  // reflow... If that's the case, and aWidth or aHeight is unconstrained,
  // ignore them altogether.
  nsIFrame* rootFrame = FrameManager()->GetRootFrame();

  if (!rootFrame &&
      (aWidth == NS_UNCONSTRAINEDSIZE || aHeight == NS_UNCONSTRAINEDSIZE)) {
    return NS_ERROR_NOT_AVAILABLE;
  }
  
  if (mPresContext) {
    nsRect r(0, 0, aWidth, aHeight);
    mPresContext->SetVisibleArea(r);
  }

  if (rootFrame) {
    // Kick off a top-down reflow
    NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
                 ("enter nsPresShell::ResizeReflow: %d,%d", aWidth, aHeight));
#ifdef NS_DEBUG
    if (nsIFrameDebug::GetVerifyTreeEnable()) {
      nsIFrameDebug*  frameDebug;

      if (NS_SUCCEEDED(rootFrame->QueryInterface(NS_GET_IID(nsIFrameDebug),
                                                 (void**)&frameDebug))) {
        frameDebug->VerifyTree();
      }
    }
#endif
#ifdef DEBUG_kipp
    nsPresShell_ReflowStackPointerTop = (char*) &aWidth;
#endif
    nsRect                bounds = mPresContext->GetVisibleArea();
    nsSize                maxSize(bounds.width, bounds.height);
    nsHTMLReflowMetrics   desiredSize(nsnull);
    nsReflowStatus        status;
    nsIRenderingContext*  rcx = nsnull;

    nsresult rv=CreateRenderingContext(rootFrame, &rcx);
    if (NS_FAILED(rv)) return rv;

    nsHTMLReflowState reflowState(mPresContext, rootFrame,
                                  eReflowReason_Resize, rcx, maxSize);

    rootFrame->WillReflow(mPresContext);
    nsContainerFrame::PositionFrameView(rootFrame);
    rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
    rootFrame->SetSize(nsSize(desiredSize.width, desiredSize.height));
    mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));

    nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, rootFrame->GetView(),
                                               nsnull);
    rootFrame->DidReflow(mPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
#ifdef NS_DEBUG
    if (nsIFrameDebug::GetVerifyTreeEnable()) {
      nsIFrameDebug*  frameDebug;

      if (NS_SUCCEEDED(rootFrame->QueryInterface(NS_GET_IID(nsIFrameDebug),
                                                 (void**)&frameDebug))) {
        frameDebug->VerifyTree();
      }
    }
#endif
    VERIFY_STYLE_TREE;
    NS_IF_RELEASE(rcx);
    NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("exit nsPresShell::ResizeReflow"));

    // XXX if debugging then we should assert that the cache is empty
  } else {
    firstReflow = PR_TRUE;
#ifdef NOISY
    printf("PresShell::ResizeReflow: null root frame\n");
#endif
  }
  DidCauseReflow();
  // if the proper flag is set, VerifyReflow now
#ifdef NS_DEBUG
  if (GetVerifyReflowEnable() && (VERIFY_REFLOW_DURING_RESIZE_REFLOW & gVerifyReflowFlags))
  {
    mInVerifyReflow = PR_TRUE;
    /*PRBool ok = */VerifyIncrementalReflow();
    mInVerifyReflow = PR_FALSE;
  }
#endif
  
  DidDoReflow();

  mViewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);

  if (!firstReflow) {
    //Set resize event timer
    CreateResizeEventTimer();
  }
  
  return NS_OK; //XXX this needs to be real. MMP
}