1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * Steve Clark <buster@netscape.com>
24 * Dan Rosen <dr@netscape.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK *****
40 * This Original Code has been modified by IBM Corporation.
41 * Modifications made by IBM described herein are
42 * Copyright (c) International Business Machines
45 * Modifications to Mozilla code or documentation
46 * identified per MPL Section 3.3
48 * Date Modified by Description of modification
49 * 05/03/2000 IBM Corp. Observer related defines for reflow
52 /* a presentation of a document, part 2 */
54 #ifndef nsIPresShell_h___
55 #define nsIPresShell_h___
57 #include "nsISupports.h"
62 #include "nsCompatibility.h"
63 #include "nsFrameManagerBase.h"
64 #include "mozFlushType.h"
65 #include "nsWeakReference.h"
66 #include <stdio.h> // for FILE definition
70 class nsIContentIterator
;
72 class nsIDocumentObserver
;
77 class nsIDeviceContext
;
78 class nsIRenderingContext
;
79 class nsIPageSequenceFrame
;
85 class nsFrameSelection
;
87 class nsILayoutHistoryState
;
88 class nsIReflowCallback
;
89 class nsISupportsArray
;
92 class nsIStyleFrameConstruction
;
94 class nsCSSFrameConstructor
;
96 template<class E
> class nsCOMArray
;
98 class nsIScrollableFrame
;
102 typedef short SelectionType
;
103 typedef PRUint32 nsFrameState
;
105 // 23439d06-4642-4c4e-b60b-d84ad9bd8897
106 #define NS_IPRESSHELL_IID \
107 { 0x23439d06, 0x4642, 0x4c4e, \
108 { 0xb6, 0x0b, 0xd8, 0x4a, 0xd9, 0xbd, 0x88, 0x97 } }
110 // Constants for ScrollContentIntoView() function
111 #define NS_PRESSHELL_SCROLL_TOP 0
112 #define NS_PRESSHELL_SCROLL_BOTTOM 100
113 #define NS_PRESSHELL_SCROLL_LEFT 0
114 #define NS_PRESSHELL_SCROLL_RIGHT 100
115 #define NS_PRESSHELL_SCROLL_CENTER 50
116 #define NS_PRESSHELL_SCROLL_ANYWHERE -1
117 #define NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE -2
119 // debug VerifyReflow flags
120 #define VERIFY_REFLOW_ON 0x01
121 #define VERIFY_REFLOW_NOISY 0x02
122 #define VERIFY_REFLOW_ALL 0x04
123 #define VERIFY_REFLOW_DUMP_COMMANDS 0x08
124 #define VERIFY_REFLOW_NOISY_RC 0x10
125 #define VERIFY_REFLOW_REALLY_NOISY_RC 0x20
126 #define VERIFY_REFLOW_INCLUDE_SPACE_MANAGER 0x40
127 #define VERIFY_REFLOW_DURING_RESIZE_REFLOW 0x80
130 * Presentation shell interface. Presentation shells are the
131 * controlling point for managing the presentation of a document. The
132 * presentation shell holds a live reference to the document, the
133 * presentation context, the style manager, the style set and the root
136 * When this object is Release'd, it will release the document, the
137 * presentation context, the style manager, the style set and the root
141 // hack to make egcs / gcc 2.95.2 happy
142 class nsIPresShell_base
: public nsISupports
145 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRESSHELL_IID
)
148 NS_DEFINE_STATIC_IID_ACCESSOR(nsIPresShell_base
, NS_IPRESSHELL_IID
)
150 class nsIPresShell
: public nsIPresShell_base
153 NS_IMETHOD
Init(nsIDocument
* aDocument
,
154 nsPresContext
* aPresContext
,
155 nsIViewManager
* aViewManager
,
156 nsStyleSet
* aStyleSet
,
157 nsCompatibility aCompatMode
) = 0;
160 * All callers are responsible for calling |Destroy| after calling
161 * |EndObservingDocument|. It needs to be separate only because form
162 * controls incorrectly store their data in the frames rather than the
163 * content model and printing calls |EndObservingDocument| multiple
164 * times to make form controls behave nicely when printed.
166 NS_IMETHOD
Destroy() = 0;
168 PRBool
IsDestroying() { return mIsDestroying
; }
170 // All frames owned by the shell are allocated from an arena. They are also recycled
171 // using free lists (separate free lists being maintained for each size_t).
172 // Methods for recycling frames.
173 virtual void* AllocateFrame(size_t aSize
) = 0;
174 virtual void FreeFrame(size_t aSize
, void* aFreeChunk
) = 0;
177 * Stack memory allocation:
179 * Callers who wish to allocate memory whose lifetime corresponds to
180 * the lifetime of a stack-allocated object can use this API. The
181 * caller must use a pair of calls to PushStackMemory and
182 * PopStackMemory, such that all stack object lifetimes are either
183 * entirely between the calls or containing both calls.
185 * Then, between the calls, the caller can call AllocateStackMemory to
186 * allocate memory from an arena pool that will be freed by the call
189 * The allocations cannot be for more than 4044 bytes.
191 virtual void PushStackMemory() = 0;
192 virtual void PopStackMemory() = 0;
193 virtual void* AllocateStackMemory(size_t aSize
) = 0;
195 nsIDocument
* GetDocument() { return mDocument
; }
197 nsPresContext
* GetPresContext() { return mPresContext
; }
199 nsIViewManager
* GetViewManager() { return mViewManager
; }
201 #ifdef _IMPL_NS_LAYOUT
202 nsStyleSet
* StyleSet() { return mStyleSet
; }
204 nsCSSFrameConstructor
* FrameConstructor()
206 return mFrameConstructor
;
209 nsFrameManager
* FrameManager() const {
210 return reinterpret_cast<nsFrameManager
*>
211 (&const_cast<nsIPresShell
*>(this)->mFrameManager
);
216 /* Enable/disable author style level. Disabling author style disables the entire
217 * author level of the cascade, including the HTML preshint level.
219 // XXX these could easily be inlined, but there is a circular #include
220 // problem with nsStyleSet.
221 NS_HIDDEN_(void) SetAuthorStyleDisabled(PRBool aDisabled
);
222 NS_HIDDEN_(PRBool
) GetAuthorStyleDisabled();
225 * Called when stylesheets are added/removed/enabled/disabled to rebuild
226 * all style data for a given pres shell without necessarily reconstructing
227 * all of the frames. This will not reconstruct style synchronously; if
228 * you need to do that, call FlushPendingNotifications to flush out style
230 * // XXXbz why do we have this on the interface anyway? The only consumer
231 * is calling AddOverrideStyleSheet/RemoveOverrideStyleSheet, and I think
232 * those should just handle reconstructing style data...
234 virtual NS_HIDDEN_(void) ReconstructStyleDataExternal();
235 NS_HIDDEN_(void) ReconstructStyleDataInternal();
236 #ifdef _IMPL_NS_LAYOUT
237 void ReconstructStyleData() { ReconstructStyleDataInternal(); }
239 void ReconstructStyleData() { ReconstructStyleDataExternal(); }
242 /** Setup all style rules required to implement preferences
243 * - used for background/text/link colors and link underlining
244 * may be extended for any prefs that are implemented via style rules
245 * - aForceReflow argument is used to force a full reframe to make the rules show
246 * (only used when the current page needs to reflect changed pref rules)
248 * - initially created for bugs 31816, 20760, 22963
250 NS_IMETHOD
SetPreferenceStyleRules(PRBool aForceReflow
) = 0;
253 * FrameSelection will return the Frame based selection API.
254 * You cannot go back and forth anymore with QI between nsIDOM sel and
257 already_AddRefed
<nsFrameSelection
> FrameSelection();
260 * ConstFrameSelection returns an object which methods are safe to use for
261 * example in nsIFrame code.
263 const nsFrameSelection
* ConstFrameSelection() { return mSelection
; }
265 // Make shell be a document observer. If called after Destroy() has
266 // been called on the shell, this will be ignored.
267 NS_IMETHOD
BeginObservingDocument() = 0;
269 // Make shell stop being a document observer
270 NS_IMETHOD
EndObservingDocument() = 0;
273 * Determine if InitialReflow() was previously called.
274 * @param aDidInitialReflow PR_TRUE if InitalReflow() was previously called,
275 * PR_FALSE otherwise.
277 NS_IMETHOD
GetDidInitialReflow(PRBool
*aDidInitialReflow
) = 0;
280 * Perform the initial reflow. Constructs the frame for the root content
281 * object and then reflows the frame model into the specified width and
284 * The coordinates for aWidth and aHeight must be in standard nscoords.
286 * Callers of this method must hold a reference to this shell that
287 * is guaranteed to survive through arbitrary script execution.
288 * Calling InitialReflow can execute arbitrary script.
290 NS_IMETHOD
InitialReflow(nscoord aWidth
, nscoord aHeight
) = 0;
293 * Reflow the frame model into a new width and height. The
294 * coordinates for aWidth and aHeight must be in standard nscoord's.
296 NS_IMETHOD
ResizeReflow(nscoord aWidth
, nscoord aHeight
) = 0;
299 * Reflow the frame model with a reflow reason of eReflowReason_StyleChange
301 NS_IMETHOD
StyleChangeReflow() = 0;
304 * This calls through to the frame manager to get the root frame.
305 * Callers inside of gklayout should use FrameManager()->GetRootFrame()
306 * instead, as it's more efficient.
308 virtual NS_HIDDEN_(nsIFrame
*) GetRootFrame() const;
311 * Get root scroll frame from FrameManager()->GetRootFrame().
313 nsIFrame
* GetRootScrollFrame() const;
316 * The same as GetRootScrollFrame, but returns an nsIScrollableFrame
318 nsIScrollableFrame
* GetRootScrollFrameAsScrollable() const;
321 * Returns the page sequence frame associated with the frame hierarchy.
322 * Returns NULL if not a paginated view.
324 NS_IMETHOD
GetPageSequenceFrame(nsIPageSequenceFrame
** aResult
) const = 0;
327 * Gets the primary frame associated with the content object. This is a
328 * helper function that just forwards the request to the frame manager.
330 * The primary frame is the frame that is most closely associated with the
331 * content. A frame is more closely associated with the content that another
332 * frame if the one frame contains directly or indirectly the other frame (e.g.,
333 * when a frame is scrolled there is a scroll frame that contains the frame
334 * being scrolled). The primary frame is always the first-in-flow.
336 * In the case of absolutely positioned elements and floated elements,
337 * the primary frame is the placeholder frame.
339 virtual NS_HIDDEN_(nsIFrame
*) GetPrimaryFrameFor(nsIContent
* aContent
) const = 0;
342 * Gets the real primary frame associated with the content object.
344 * In the case of absolutely positioned elements and floated elements,
345 * the real primary frame is the frame that is out of the flow and not the
348 virtual NS_HIDDEN_(nsIFrame
*) GetRealPrimaryFrameFor(nsIContent
* aContent
) const = 0;
351 * Gets the placeholder frame associated with the specified frame. This is
352 * a helper frame that forwards the request to the frame manager.
354 NS_IMETHOD
GetPlaceholderFrameFor(nsIFrame
* aFrame
,
355 nsIFrame
** aPlaceholderFrame
) const = 0;
358 * Tell the pres shell that a frame needs to be marked dirty and needs
359 * Reflow. It's OK if this is an ancestor of the frame needing reflow as
360 * long as the ancestor chain between them doesn't cross a reflow root. The
361 * bit to add should be either NS_FRAME_IS_DIRTY or
362 * NS_FRAME_HAS_DIRTY_CHILDREN (but not both!).
364 enum IntrinsicDirty
{
365 // XXXldb eResize should be renamed
366 eResize
, // don't mark any intrinsic widths dirty
367 eTreeChange
, // mark intrinsic widths dirty on aFrame and its ancestors
368 eStyleChange
// Do eTreeChange, plus all of aFrame's descendants
370 NS_IMETHOD
FrameNeedsReflow(nsIFrame
*aFrame
,
371 IntrinsicDirty aIntrinsicDirty
,
372 nsFrameState aBitToAdd
) = 0;
374 NS_IMETHOD
CancelAllPendingReflows() = 0;
377 * Recreates the frames for a node
379 NS_IMETHOD
RecreateFramesFor(nsIContent
* aContent
) = 0;
381 void PostRecreateFramesFor(nsIContent
* aContent
);
384 * Determine if it is safe to flush all pending notifications
385 * @param aIsSafeToFlush PR_TRUE if it is safe, PR_FALSE otherwise.
388 NS_IMETHOD
IsSafeToFlush(PRBool
& aIsSafeToFlush
) = 0;
391 * Flush pending notifications of the type specified. This method
392 * will not affect the content model; it'll just affect style and
393 * frames. Callers that actually want up-to-date presentation (other
394 * than the document itself) should probably be calling
395 * nsIDocument::FlushPendingNotifications.
397 * @param aType the type of notifications to flush
399 NS_IMETHOD
FlushPendingNotifications(mozFlushType aType
) = 0;
402 * Callbacks will be called even if reflow itself fails for
405 NS_IMETHOD
PostReflowCallback(nsIReflowCallback
* aCallback
) = 0;
406 NS_IMETHOD
CancelReflowCallback(nsIReflowCallback
* aCallback
) = 0;
408 NS_IMETHOD
ClearFrameRefs(nsIFrame
* aFrame
) = 0;
411 * Given a frame, create a rendering context suitable for use with
414 NS_IMETHOD
CreateRenderingContext(nsIFrame
*aFrame
,
415 nsIRenderingContext
** aContext
) = 0;
418 * Informs the pres shell that the document is now at the anchor with
419 * the given name. If |aScroll| is true, scrolls the view of the
420 * document so that the anchor with the specified name is displayed at
421 * the top of the window. If |aAnchorName| is empty, then this informs
422 * the pres shell that there is no current target, and |aScroll| must
425 NS_IMETHOD
GoToAnchor(const nsAString
& aAnchorName
, PRBool aScroll
) = 0;
428 * Tells the presshell to scroll again to the last anchor scrolled to by
429 * GoToAnchor, if any. This scroll only happens if the scroll
430 * position has not changed since the last GoToAnchor. This is called
431 * by nsDocumentViewer::LoadComplete. This clears the last anchor
432 * scrolled to by GoToAnchor (we don't want to keep it alive if it's
433 * removed from the DOM), so don't call this more than once.
435 NS_IMETHOD
ScrollToAnchor() = 0;
438 * Scrolls the view of the document so that the primary frame of the content
439 * is displayed at the top of the window. Layout is flushed before scrolling.
441 * @param aContent The content object of which primary frame should be
442 * scrolled into view.
443 * @param aVPercent How to align the frame vertically. A value of 0
444 * (NS_PRESSHELL_SCROLL_TOP) means the frame's upper edge is
445 * aligned with the top edge of the visible area. A value of
446 * 100 (NS_PRESSHELL_SCROLL_BOTTOM) means the frame's bottom
447 * edge is aligned with the bottom edge of the visible area.
448 * For values in between, the point "aVPercent" down the frame
449 * is placed at the point "aVPercent" down the visible area. A
450 * value of 50 (NS_PRESSHELL_SCROLL_CENTER) centers the frame
451 * vertically. A value of NS_PRESSHELL_SCROLL_ANYWHERE means move
452 * the frame the minimum amount necessary in order for the entire
453 * frame to be visible vertically (if possible)
454 * @param aHPercent How to align the frame horizontally. A value of 0
455 * (NS_PRESSHELL_SCROLL_LEFT) means the frame's left edge is
456 * aligned with the left edge of the visible area. A value of
457 * 100 (NS_PRESSHELL_SCROLL_RIGHT) means the frame's right
458 * edge is aligned with the right edge of the visible area.
459 * For values in between, the point "aVPercent" across the frame
460 * is placed at the point "aVPercent" across the visible area.
461 * A value of 50 (NS_PRESSHELL_SCROLL_CENTER) centers the frame
462 * horizontally . A value of NS_PRESSHELL_SCROLL_ANYWHERE means move
463 * the frame the minimum amount necessary in order for the entire
464 * frame to be visible horizontally (if possible)
466 NS_IMETHOD
ScrollContentIntoView(nsIContent
* aContent
,
468 PRIntn aHPercent
) const = 0;
471 * Suppress notification of the frame manager that frames are
474 NS_IMETHOD
SetIgnoreFrameDestruction(PRBool aIgnore
) = 0;
477 * Notification sent by a frame informing the pres shell that it is about to
479 * This allows any outstanding references to the frame to be cleaned up
481 NS_IMETHOD
NotifyDestroyingFrame(nsIFrame
* aFrame
) = 0;
484 * Notify the Clipboard that we have something to copy.
486 NS_IMETHOD
DoCopy() = 0;
489 * Get the selection of the focussed element (either the page selection,
490 * or the selection for a text field).
492 NS_IMETHOD
GetSelectionForCopy(nsISelection
** outSelection
) = 0;
497 NS_IMETHOD
GetLinkLocation(nsIDOMNode
* aNode
, nsAString
& aLocation
) = 0;
500 * Get the doc or the selection as text or html.
502 NS_IMETHOD
DoGetContents(const nsACString
& aMimeType
, PRUint32 aFlags
, PRBool aSelectionOnly
, nsAString
& outValue
) = 0;
505 * Get the caret, if it exists. AddRefs it.
507 NS_IMETHOD
GetCaret(nsCaret
**aOutCaret
) = 0;
510 * Invalidate the caret's current position if it's outside of its frame's
511 * boundaries. This function is useful if you're batching selection
512 * notifications and might remove the caret's frame out from under it.
514 NS_IMETHOD_(void) MaybeInvalidateCaretPosition() = 0;
517 * Set the current caret to a new caret. To undo this, call RestoreCaret.
519 virtual void SetCaret(nsCaret
*aNewCaret
) = 0;
522 * Restore the caret to the original caret that this pres shell was created
525 virtual void RestoreCaret() = 0;
528 * Should the images have borders etc. Actual visual effects are determined
529 * by the frames. Visual effects may not effect layout, only display.
530 * Takes effect on next repaint, does not force a repaint itself.
532 * @param aEnabled if PR_TRUE, visual selection effects are enabled
533 * if PR_FALSE visual selection effects are disabled
534 * @return always NS_OK
536 NS_IMETHOD
SetSelectionFlags(PRInt16 aInEnable
) = 0;
539 * Gets the current state of non text selection effects
540 * @param aEnabled [OUT] set to the current state of non text selection,
541 * as set by SetDisplayNonTextSelection
542 * @return if aOutEnabled==null, returns NS_ERROR_INVALID_ARG
545 NS_IMETHOD
GetSelectionFlags(PRInt16
*aOutEnabled
) = 0;
547 virtual nsISelection
* GetCurrentSelection(SelectionType aType
) = 0;
550 * Interface to dispatch events via the presshell
551 * @note The caller must have a strong reference to the PresShell.
553 NS_IMETHOD
HandleEventWithTarget(nsEvent
* aEvent
,
555 nsIContent
* aContent
,
556 nsEventStatus
* aStatus
) = 0;
559 * Dispatch event to content only (NOT full processing)
560 * @note The caller must have a strong reference to the PresShell.
562 NS_IMETHOD
HandleDOMEventWithTarget(nsIContent
* aTargetContent
,
564 nsEventStatus
* aStatus
) = 0;
567 * Gets the current target event frame from the PresShell
569 NS_IMETHOD
GetEventTargetFrame(nsIFrame
** aFrame
) = 0;
572 * Gets the current target event frame from the PresShell
574 NS_IMETHOD
GetEventTargetContent(nsEvent
* aEvent
, nsIContent
** aContent
) = 0;
577 * Get and set the history state for the current document
580 NS_IMETHOD
CaptureHistoryState(nsILayoutHistoryState
** aLayoutHistoryState
, PRBool aLeavingPage
= PR_FALSE
) = 0;
583 * Determine if reflow is currently locked
584 * @param aIsReflowLocked returns PR_TRUE if reflow is locked, PR_FALSE otherwise
586 NS_IMETHOD
IsReflowLocked(PRBool
* aIsLocked
) = 0;
589 * Called to find out if painting is suppressed for this presshell. If it is suppressd,
590 * we don't allow the painting of any layer but the background, and we don't
591 * recur into our children.
593 NS_IMETHOD
IsPaintingSuppressed(PRBool
* aResult
)=0;
596 * Unsuppress painting.
598 NS_IMETHOD
UnsuppressPainting() = 0;
601 * Called to disable nsITheme support in a specific presshell.
603 NS_IMETHOD
DisableThemeSupport() = 0;
606 * Indicates whether theme support is enabled.
608 virtual PRBool
IsThemeSupportEnabled() = 0;
611 * Get the set of agent style sheets for this presentation
613 virtual nsresult
GetAgentStyleSheets(nsCOMArray
<nsIStyleSheet
>& aSheets
) = 0;
616 * Replace the set of agent style sheets
618 virtual nsresult
SetAgentStyleSheets(const nsCOMArray
<nsIStyleSheet
>& aSheets
) = 0;
621 * Add an override style sheet for this presentation
623 virtual nsresult
AddOverrideStyleSheet(nsIStyleSheet
*aSheet
) = 0;
626 * Remove an override style sheet
628 virtual nsresult
RemoveOverrideStyleSheet(nsIStyleSheet
*aSheet
) = 0;
631 * Reconstruct frames for all elements in the document
633 virtual nsresult
ReconstructFrames() = 0;
636 * Given aFrame, the root frame of a stacking context, find its descendant
637 * frame under the point aPt that receives a mouse event at that location,
638 * or nsnull if there is no such frame.
639 * @param aPt the point, relative to the frame origin
641 virtual nsIFrame
* GetFrameForPoint(nsIFrame
* aFrame
, nsPoint aPt
) = 0;
644 * See if reflow verification is enabled. To enable reflow verification add
645 * "verifyreflow:1" to your NSPR_LOG_MODULES environment variable
646 * (any non-zero debug level will work). Or, call SetVerifyReflowEnable
649 static PRBool
GetVerifyReflowEnable();
652 * Set the verify-reflow enable flag.
654 static void SetVerifyReflowEnable(PRBool aEnabled
);
657 * Get the flags associated with the VerifyReflow debug tool
659 static PRInt32
GetVerifyReflowFlags();
661 virtual nsIFrame
* GetAbsoluteContainingBlock(nsIFrame
* aFrame
);
663 #ifdef MOZ_REFLOW_PERF
664 NS_IMETHOD
DumpReflows() = 0;
665 NS_IMETHOD
CountReflows(const char * aName
, nsIFrame
* aFrame
) = 0;
666 NS_IMETHOD
PaintCount(const char * aName
,
667 nsIRenderingContext
* aRenderingContext
,
668 nsPresContext
* aPresContext
,
670 PRUint32 aColor
) = 0;
671 NS_IMETHOD
SetPaintFrameCount(PRBool aOn
) = 0;
676 virtual void ListStyleContexts(nsIFrame
*aRootFrame
, FILE *out
,
677 PRInt32 aIndent
= 0) = 0;
679 virtual void ListStyleSheets(FILE *out
, PRInt32 aIndent
= 0) = 0;
680 virtual void VerifyStyleTree() = 0;
683 static PRBool gIsAccessibilityActive
;
684 static PRBool
IsAccessibilityActive() { return gIsAccessibilityActive
; }
687 * Stop all active elements (plugins and the caret) in this presentation and
688 * in the presentations of subdocuments. Resets painting to a suppressed state.
689 * XXX this should include image animations
691 virtual void Freeze() = 0;
694 * Restarts active elements (plugins) in this presentation and in the
695 * presentations of subdocuments, then do a full invalidate of the content area.
697 virtual void Thaw() = 0;
700 * When this shell is disconnected from its containing docshell, we
701 * lose our container pointer. However, we'd still like to be able to target
702 * user events at the docshell's parent. This pointer allows us to do that.
703 * It should not be used for any other purpose.
705 void SetForwardingContainer(nsWeakPtr aContainer
)
707 mForwardingContainer
= aContainer
;
711 * Render the document into an arbitrary gfxContext
712 * Designed for getting a picture of a document or a piece of a document
713 * Note that callers will generally want to call FlushPendingNotifications
714 * to get an up-to-date view of the document
715 * @param aRect is the region to capture into the offscreen buffer, in the
716 * root frame's coordinate system (if aIgnoreViewportScrolling is false)
717 * or in the root scrolled frame's coordinate system
718 * (if aIgnoreViewportScrolling is true). The coordinates are in appunits.
719 * @param aFlags see below;
720 * set RENDER_IS_UNTRUSTED if the contents may be passed to malicious
721 * agents. E.g. we might choose not to paint the contents of sensitive widgets
722 * such as the file name in a file upload widget, and we might choose not
724 * set RENDER_IGNORE_VIEWPORT_SCROLLING to ignore
725 * clipping/scrolling/scrollbar painting due to scrolling in the viewport
726 * set RENDER_CARET to draw the caret if one would be visible
727 * (by default the caret is never drawn)
728 * @param aBackgroundColor a background color to render onto
729 * @param aRenderedContext the gfxContext to render to. We render so that
730 * one CSS pixel in the source document is rendered to one unit in the current
734 RENDER_IS_UNTRUSTED
= 0x01,
735 RENDER_IGNORE_VIEWPORT_SCROLLING
= 0x02,
738 NS_IMETHOD
RenderDocument(const nsRect
& aRect
, PRUint32 aFlags
,
739 nscolor aBackgroundColor
,
740 gfxContext
* aRenderedContext
) = 0;
743 * Renders a node aNode to a surface and returns it. The aRegion may be used
744 * to clip the rendering. This region is measured in device pixels from the
745 * edge of the presshell area. The aPoint, aScreenRect and aSurface
746 * arguments function in a similar manner as RenderSelection.
748 virtual already_AddRefed
<gfxASurface
> RenderNode(nsIDOMNode
* aNode
,
751 nsRect
* aScreenRect
) = 0;
754 * Renders a selection to a surface and returns it. This method is primarily
755 * intended to create the drag feedback when dragging a selection.
757 * aScreenRect will be filled in with the bounding rectangle of the
758 * selection area on screen.
760 * If the area of the selection is large, the image will be scaled down.
761 * The argument aPoint is used in this case as a reference point when
762 * determining the new screen rectangle after scaling. Typically, this
763 * will be the mouse position, so that the screen rectangle is positioned
764 * such that the mouse is over the same point in the scaled image as in
765 * the original. When scaling does not occur, the mouse point isn't used
766 * as the position can be determined from the displayed frames.
768 virtual already_AddRefed
<gfxASurface
> RenderSelection(nsISelection
* aSelection
,
770 nsRect
* aScreenRect
) = 0;
772 void AddWeakFrame(nsWeakFrame
* aWeakFrame
);
773 void RemoveWeakFrame(nsWeakFrame
* aWeakFrame
);
776 nsIFrame
* GetDrawEventTargetFrame() { return mDrawEventTargetFrame
; }
780 // IMPORTANT: The ownership implicit in the following member variables
781 // has been explicitly checked. If you add any members to this class,
782 // please make the ownership explicit (pinkerton, scc).
784 // these are the same Document and PresContext owned by the DocViewer.
785 // we must share ownership.
786 nsIDocument
* mDocument
; // [STRONG]
787 nsPresContext
* mPresContext
; // [STRONG]
788 nsStyleSet
* mStyleSet
; // [OWNS]
789 nsCSSFrameConstructor
* mFrameConstructor
; // [OWNS]
790 nsIViewManager
* mViewManager
; // [WEAK] docViewer owns it so I don't have to
791 nsFrameSelection
* mSelection
;
792 nsFrameManagerBase mFrameManager
; // [OWNS]
793 nsWeakPtr mForwardingContainer
;
796 nsIFrame
* mDrawEventTargetFrame
;
799 PRPackedBool mStylesHaveChanged
;
800 PRPackedBool mDidInitialReflow
;
801 PRPackedBool mIsDestroying
;
805 * Call this when there have been significant changes in the rendering for
806 * a content subtree, so the matching accessibility subtree can be invalidated
808 void InvalidateAccessibleSubtree(nsIContent
*aContent
);
811 // Set to true when the accessibility service is being used to mirror
812 // the dom/layout trees
813 PRPackedBool mIsAccessibilityActive
;
815 // A list of weak frames. This is a pointer to the last item in the list.
816 nsWeakFrame
* mWeakFrames
;
820 * Create a new empty presentation shell. Upon success, call Init
821 * before attempting to use the shell.
824 NS_NewPresShell(nsIPresShell
** aInstancePtrResult
);
826 #endif /* nsIPresShell_h___ */