1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 * This Original Code has been modified by IBM Corporation.
7 * Modifications made by IBM described herein are
8 * Copyright (c) International Business Machines
11 * Modifications to Mozilla code or documentation
12 * identified per MPL Section 3.3
14 * Date Modified by Description of modification
15 * 05/03/2000 IBM Corp. Observer related defines for reflow
18 /* a presentation of a document, part 2 */
20 #ifndef nsIPresShell_h___
21 #define nsIPresShell_h___
23 #include "mozilla/EventForwards.h"
24 #include "mozilla/MemoryReporting.h"
25 #include "mozilla/WeakPtr.h"
27 #include "nsTHashtable.h"
28 #include "nsHashKeys.h"
29 #include "nsISupports.h"
30 #include "nsQueryFrame.h"
33 #include "nsCompatibility.h"
34 #include "nsFrameManagerBase.h"
35 #include "mozFlushType.h"
36 #include "nsWeakReference.h"
37 #include <stdio.h> // for FILE definition
38 #include "nsChangeHint.h"
39 #include "nsRefPtrHashtable.h"
40 #include "nsClassHashtable.h"
41 #include "nsPresArena.h"
42 #include "nsIImageLoadingContent.h"
44 #include "nsFrameState.h"
54 class nsRenderingContext
;
55 class nsIPageSequenceFrame
;
61 class SelectionCarets
;
62 } // namespace mozilla
63 class nsFrameSelection
;
65 class nsILayoutHistoryState
;
66 class nsIReflowCallback
;
70 class nsCSSFrameConstructor
;
72 template<class E
> class nsCOMArray
;
74 class nsIScrollableFrame
;
78 class nsDisplayListBuilder
;
85 class nsRefreshDriver
;
86 class nsARefreshObserver
;
87 class nsAPostRefreshObserver
;
89 class nsAccessibilityService
;
94 } // namespace mozilla
97 struct nsArenaMemoryStats
;
99 typedef short SelectionType
;
113 } // namespace layers
118 } // namespace mozilla
120 // Flags to pass to SetCapturingContent
122 // when assigning capture, ignore whether capture is allowed or not
123 #define CAPTURE_IGNOREALLOWED 1
124 // true if events should be targeted at the capturing content or its children
125 #define CAPTURE_RETARGETTOELEMENT 2
126 // true if the current capture wants drags to be prevented
127 #define CAPTURE_PREVENTDRAG 4
128 // true when the mouse is pointer locked, and events are sent to locked element
129 #define CAPTURE_POINTERLOCK 8
131 typedef struct CapturingContentInfo
{
132 // capture should only be allowed during a mousedown event
135 bool mRetargetToElement
;
137 nsIContent
* mContent
;
138 } CapturingContentInfo
;
140 #define NS_IPRESSHELL_IID \
141 { 0x42e9a352, 0x76f3, 0x4ba3, \
142 { 0x94, 0x0b, 0x78, 0x9e, 0x58, 0x38, 0x73, 0x4f } }
144 // debug VerifyReflow flags
145 #define VERIFY_REFLOW_ON 0x01
146 #define VERIFY_REFLOW_NOISY 0x02
147 #define VERIFY_REFLOW_ALL 0x04
148 #define VERIFY_REFLOW_DUMP_COMMANDS 0x08
149 #define VERIFY_REFLOW_NOISY_RC 0x10
150 #define VERIFY_REFLOW_REALLY_NOISY_RC 0x20
151 #define VERIFY_REFLOW_DURING_RESIZE_REFLOW 0x40
153 #undef NOISY_INTERRUPTIBLE_REFLOW
155 enum nsRectVisibility
{
156 nsRectVisibility_kVisible
,
157 nsRectVisibility_kAboveViewport
,
158 nsRectVisibility_kBelowViewport
,
159 nsRectVisibility_kLeftOfViewport
,
160 nsRectVisibility_kRightOfViewport
164 * Presentation shell interface. Presentation shells are the
165 * controlling point for managing the presentation of a document. The
166 * presentation shell holds a live reference to the document, the
167 * presentation context, the style manager, the style set and the root
170 * When this object is Release'd, it will release the document, the
171 * presentation context, the style manager, the style set and the root
175 class nsIPresShell
: public nsISupports
178 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRESSHELL_IID
)
181 typedef mozilla::layers::LayerManager LayerManager
;
182 typedef mozilla::gfx::SourceSurface SourceSurface
;
185 STATE_IGNORING_VIEWPORT_SCROLLING
= 0x1,
186 STATE_DRAWWINDOW_NOT_FLUSHING
= 0x2
188 typedef uint8_t RenderFlags
; // for storing the above flags
192 * All callers are responsible for calling |Destroy| after calling
193 * |EndObservingDocument|. It needs to be separate only because form
194 * controls incorrectly store their data in the frames rather than the
195 * content model and printing calls |EndObservingDocument| multiple
196 * times to make form controls behave nicely when printed.
198 virtual void Destroy() = 0;
200 bool IsDestroying() { return mIsDestroying
; }
203 * Make a one-way transition into a "zombie" state. In this state,
204 * no reflow is done, no painting is done, and no refresh driver
205 * ticks are processed. This is a dangerous state: it can leave
206 * areas of the composition target unpainted if callers aren't
207 * careful. (Don't let your zombie presshell out of the shed.)
209 * This is used in cases where a presshell is created for reasons
210 * other than reflow/painting.
212 virtual void MakeZombie() = 0;
215 * All frames owned by the shell are allocated from an arena. They
216 * are also recycled using free lists. Separate free lists are
217 * maintained for each frame type (aID), which must always correspond
218 * to the same aSize value. AllocateFrame returns zero-filled memory.
219 * AllocateFrame is infallible and will abort on out-of-memory.
221 void* AllocateFrame(nsQueryFrame::FrameIID aID
, size_t aSize
)
224 mPresArenaAllocCount
++;
226 void* result
= mFrameArena
.AllocateByFrameID(aID
, aSize
);
227 memset(result
, 0, aSize
);
231 void FreeFrame(nsQueryFrame::FrameIID aID
, void* aPtr
)
234 mPresArenaAllocCount
--;
237 mFrameArena
.FreeByFrameID(aID
, aPtr
);
241 * This is for allocating other types of objects (not frames). Separate free
242 * lists are maintained for each type (aID), which must always correspond to
243 * the same aSize value. AllocateByObjectID returns zero-filled memory.
244 * AllocateByObjectID is infallible and will abort on out-of-memory.
246 void* AllocateByObjectID(nsPresArena::ObjectID aID
, size_t aSize
)
249 mPresArenaAllocCount
++;
251 void* result
= mFrameArena
.AllocateByObjectID(aID
, aSize
);
252 memset(result
, 0, aSize
);
256 void FreeByObjectID(nsPresArena::ObjectID aID
, void* aPtr
)
259 mPresArenaAllocCount
--;
262 mFrameArena
.FreeByObjectID(aID
, aPtr
);
266 * Other objects closely related to the frame tree that are allocated
267 * from a separate set of per-size free lists. Note that different types
268 * of objects that has the same size are allocated from the same list.
269 * AllocateMisc does *not* clear the memory that it returns.
270 * AllocateMisc is infallible and will abort on out-of-memory.
272 * @deprecated use AllocateByObjectID/FreeByObjectID instead
274 void* AllocateMisc(size_t aSize
)
277 mPresArenaAllocCount
++;
279 return mFrameArena
.AllocateBySize(aSize
);
282 void FreeMisc(size_t aSize
, void* aPtr
)
285 mPresArenaAllocCount
--;
288 mFrameArena
.FreeBySize(aSize
, aPtr
);
291 nsIDocument
* GetDocument() const { return mDocument
; }
293 nsPresContext
* GetPresContext() const { return mPresContext
; }
295 nsViewManager
* GetViewManager() const { return mViewManager
; }
299 * Return the document accessible for this pres shell if there is one.
301 mozilla::a11y::DocAccessible
* GetDocAccessible() const
303 return mDocAccessible
;
307 * Set the document accessible for this pres shell.
309 void SetDocAccessible(mozilla::a11y::DocAccessible
* aDocAccessible
)
311 mDocAccessible
= aDocAccessible
;
315 #ifdef MOZILLA_INTERNAL_API
316 nsStyleSet
* StyleSet() const { return mStyleSet
; }
318 nsCSSFrameConstructor
* FrameConstructor() const { return mFrameConstructor
; }
320 nsFrameManager
* FrameManager() const {
321 // reinterpret_cast is valid since nsFrameManager does not add
322 // any members over nsFrameManagerBase.
323 return reinterpret_cast<nsFrameManager
*>
324 (const_cast<nsIPresShell
*>(this)->mFrameManager
);
329 /* Enable/disable author style level. Disabling author style disables the entire
330 * author level of the cascade, including the HTML preshint level.
332 // XXX these could easily be inlined, but there is a circular #include
333 // problem with nsStyleSet.
334 void SetAuthorStyleDisabled(bool aDisabled
);
335 bool GetAuthorStyleDisabled() const;
338 * Called when stylesheets are added/removed/enabled/disabled to rebuild
339 * all style data for a given pres shell without necessarily reconstructing
340 * all of the frames. This will not reconstruct style synchronously; if
341 * you need to do that, call FlushPendingNotifications to flush out style
343 * // XXXbz why do we have this on the interface anyway? The only consumer
344 * is calling AddOverrideStyleSheet/RemoveOverrideStyleSheet, and I think
345 * those should just handle reconstructing style data...
347 virtual void ReconstructStyleDataExternal();
348 void ReconstructStyleDataInternal();
349 #ifdef MOZILLA_INTERNAL_API
350 void ReconstructStyleData() { ReconstructStyleDataInternal(); }
352 void ReconstructStyleData() { ReconstructStyleDataExternal(); }
355 /** Setup all style rules required to implement preferences
356 * - used for background/text/link colors and link underlining
357 * may be extended for any prefs that are implemented via style rules
358 * - aForceReflow argument is used to force a full reframe to make the rules show
359 * (only used when the current page needs to reflect changed pref rules)
361 * - initially created for bugs 31816, 20760, 22963
363 virtual nsresult
SetPreferenceStyleRules(bool aForceReflow
) = 0;
366 * FrameSelection will return the Frame based selection API.
367 * You cannot go back and forth anymore with QI between nsIDOM sel and
370 already_AddRefed
<nsFrameSelection
> FrameSelection();
373 * ConstFrameSelection returns an object which methods are safe to use for
374 * example in nsIFrame code.
376 const nsFrameSelection
* ConstFrameSelection() const { return mSelection
; }
378 // Make shell be a document observer. If called after Destroy() has
379 // been called on the shell, this will be ignored.
380 virtual void BeginObservingDocument() = 0;
382 // Make shell stop being a document observer
383 virtual void EndObservingDocument() = 0;
386 * Return whether Initialize() was previously called.
388 bool DidInitialize() const { return mDidInitialize
; }
391 * Perform initialization. Constructs the frame for the root content
392 * object and then enqueues a reflow of the frame model into the
393 * specified width and height.
395 * The coordinates for aWidth and aHeight must be in standard nscoords.
397 * Callers of this method must hold a reference to this shell that
398 * is guaranteed to survive through arbitrary script execution.
399 * Calling Initialize can execute arbitrary script.
401 virtual nsresult
Initialize(nscoord aWidth
, nscoord aHeight
) = 0;
404 * Reflow the frame model into a new width and height. The
405 * coordinates for aWidth and aHeight must be in standard nscoord's.
407 virtual nsresult
ResizeReflow(nscoord aWidth
, nscoord aHeight
) = 0;
409 * Reflow, and also change presshell state so as to only permit
410 * reflowing off calls to ResizeReflowOverride() in the future.
411 * ResizeReflow() calls are ignored after ResizeReflowOverride().
413 virtual nsresult
ResizeReflowOverride(nscoord aWidth
, nscoord aHeight
) = 0;
416 * Returns true if ResizeReflowOverride has been called.
418 virtual bool GetIsViewportOverridden() = 0;
421 * Return true if the presshell expects layout flush.
423 virtual bool IsLayoutFlushObserver() = 0;
426 * Called when document load completes.
428 virtual void LoadComplete() = 0;
431 * This calls through to the frame manager to get the root frame.
433 virtual nsIFrame
* GetRootFrameExternal() const;
434 nsIFrame
* GetRootFrame() const {
435 #ifdef MOZILLA_INTERNAL_API
436 return mFrameManager
->GetRootFrame();
438 return GetRootFrameExternal();
443 * Get root scroll frame from FrameManager()->GetRootFrame().
445 nsIFrame
* GetRootScrollFrame() const;
448 * The same as GetRootScrollFrame, but returns an nsIScrollableFrame
450 nsIScrollableFrame
* GetRootScrollFrameAsScrollable() const;
453 * The same as GetRootScrollFrame, but returns an nsIScrollableFrame.
454 * Can be called by code not linked into gklayout.
456 virtual nsIScrollableFrame
* GetRootScrollFrameAsScrollableExternal() const;
459 * Gets nearest scrollable frame from current focused content or DOM
460 * selection if there is no focused content. The frame is scrollable with
461 * overflow:scroll or overflow:auto in some direction when aDirection is
462 * eEither. Otherwise, this returns a nearest frame that is scrollable in
463 * the specified direction.
465 enum ScrollDirection
{ eHorizontal
, eVertical
, eEither
};
466 nsIScrollableFrame
* GetFrameToScrollAsScrollable(ScrollDirection aDirection
);
469 * Returns the page sequence frame associated with the frame hierarchy.
470 * Returns nullptr if not a paginated view.
472 virtual nsIPageSequenceFrame
* GetPageSequenceFrame() const = 0;
475 * Returns the canvas frame associated with the frame hierarchy.
476 * Returns nullptr if is XUL document.
478 virtual nsCanvasFrame
* GetCanvasFrame() const = 0;
481 * Gets the real primary frame associated with the content object.
483 * In the case of absolutely positioned elements and floated elements,
484 * the real primary frame is the frame that is out of the flow and not the
487 virtual nsIFrame
* GetRealPrimaryFrameFor(nsIContent
* aContent
) const = 0;
490 * Gets the placeholder frame associated with the specified frame. This is
491 * a helper frame that forwards the request to the frame manager.
493 virtual nsIFrame
* GetPlaceholderFrameFor(nsIFrame
* aFrame
) const = 0;
496 * Tell the pres shell that a frame needs to be marked dirty and needs
497 * Reflow. It's OK if this is an ancestor of the frame needing reflow as
498 * long as the ancestor chain between them doesn't cross a reflow root.
500 * The bit to add should be NS_FRAME_IS_DIRTY, NS_FRAME_HAS_DIRTY_CHILDREN
501 * or nsFrameState(0); passing 0 means that dirty bits won't be set on the
502 * frame or its ancestors/descendants, but that intrinsic widths will still
503 * be marked dirty. Passing aIntrinsicDirty = eResize and aBitToAdd = 0
504 * would result in no work being done, so don't do that.
506 enum IntrinsicDirty
{
507 // XXXldb eResize should be renamed
508 eResize
, // don't mark any intrinsic widths dirty
509 eTreeChange
, // mark intrinsic widths dirty on aFrame and its ancestors
510 eStyleChange
// Do eTreeChange, plus all of aFrame's descendants
512 virtual void FrameNeedsReflow(nsIFrame
*aFrame
,
513 IntrinsicDirty aIntrinsicDirty
,
514 nsFrameState aBitToAdd
) = 0;
517 * Calls FrameNeedsReflow on all fixed position children of the root frame.
519 virtual void MarkFixedFramesForReflow(IntrinsicDirty aIntrinsicDirty
);
522 * Tell the presshell that the given frame's reflow was interrupted. This
523 * will mark as having dirty children a path from the given frame (inclusive)
524 * to the nearest ancestor with a dirty subtree, or to the reflow root
525 * currently being reflowed if no such ancestor exists (inclusive). This is
526 * to be done immediately after reflow of the current reflow root completes.
527 * This method must only be called during reflow, and the frame it's being
528 * called on must be in the process of being reflowed when it's called. This
529 * method doesn't mark any intrinsic widths dirty and doesn't add any bits
530 * other than NS_FRAME_HAS_DIRTY_CHILDREN.
532 virtual void FrameNeedsToContinueReflow(nsIFrame
*aFrame
) = 0;
534 virtual void CancelAllPendingReflows() = 0;
536 virtual void NotifyCounterStylesAreDirty() = 0;
539 * Recreates the frames for a node
541 virtual nsresult
RecreateFramesFor(nsIContent
* aContent
) = 0;
543 void PostRecreateFramesFor(mozilla::dom::Element
* aElement
);
544 void RestyleForAnimation(mozilla::dom::Element
* aElement
,
545 nsRestyleHint aHint
);
547 // ShadowRoot has APIs that can change styles so we only
548 // want to restyle elements in the ShadowRoot and not the whole
550 virtual void RecordShadowStyleChange(mozilla::dom::ShadowRoot
* aShadowRoot
) = 0;
553 * Determine if it is safe to flush all pending notifications
554 * @param aIsSafeToFlush true if it is safe, false otherwise.
557 virtual bool IsSafeToFlush() const = 0;
560 * Flush pending notifications of the type specified. This method
561 * will not affect the content model; it'll just affect style and
562 * frames. Callers that actually want up-to-date presentation (other
563 * than the document itself) should probably be calling
564 * nsIDocument::FlushPendingNotifications.
566 * @param aType the type of notifications to flush
568 virtual void FlushPendingNotifications(mozFlushType aType
) = 0;
569 virtual void FlushPendingNotifications(mozilla::ChangesToFlush aType
) = 0;
572 * Callbacks will be called even if reflow itself fails for
575 virtual nsresult
PostReflowCallback(nsIReflowCallback
* aCallback
) = 0;
576 virtual void CancelReflowCallback(nsIReflowCallback
* aCallback
) = 0;
578 virtual void ClearFrameRefs(nsIFrame
* aFrame
) = 0;
581 * Get a reference rendering context. This is a context that should not
582 * be rendered to, but is suitable for measuring text and performing
583 * other non-rendering operations. Guaranteed to return non-null.
585 virtual already_AddRefed
<nsRenderingContext
> CreateReferenceRenderingContext() = 0;
588 * Informs the pres shell that the document is now at the anchor with
589 * the given name. If |aScroll| is true, scrolls the view of the
590 * document so that the anchor with the specified name is displayed at
591 * the top of the window. If |aAnchorName| is empty, then this informs
592 * the pres shell that there is no current target, and |aScroll| must
595 virtual nsresult
GoToAnchor(const nsAString
& aAnchorName
, bool aScroll
) = 0;
598 * Tells the presshell to scroll again to the last anchor scrolled to by
599 * GoToAnchor, if any. This scroll only happens if the scroll
600 * position has not changed since the last GoToAnchor. This is called
601 * by nsDocumentViewer::LoadComplete. This clears the last anchor
602 * scrolled to by GoToAnchor (we don't want to keep it alive if it's
603 * removed from the DOM), so don't call this more than once.
605 virtual nsresult
ScrollToAnchor() = 0;
618 SCROLL_IF_NOT_VISIBLE
,
619 SCROLL_IF_NOT_FULLY_VISIBLE
621 typedef struct ScrollAxis
{
622 int16_t mWhereToScroll
;
623 WhenToScroll mWhenToScroll
: 8;
624 bool mOnlyIfPerceivedScrollableDirection
: 1;
626 * @param aWhere: Either a percentage or a special value.
627 * nsIPresShell defines:
628 * * (Default) SCROLL_MINIMUM = -1: The visible area is
629 * scrolled to show the entire frame. If the frame is too
630 * large, the top and left edges are given precedence.
631 * * SCROLL_TOP = 0: The frame's upper edge is aligned with the
632 * top edge of the visible area.
633 * * SCROLL_BOTTOM = 100: The frame's bottom edge is aligned
634 * with the bottom edge of the visible area.
635 * * SCROLL_LEFT = 0: The frame's left edge is aligned with the
636 * left edge of the visible area.
637 * * SCROLL_RIGHT = 100: The frame's right edge is aligned with
638 * the right edge of the visible area.
639 * * SCROLL_CENTER = 50: The frame is centered along the axis
640 * the ScrollAxis is used for.
642 * Other values are treated as a percentage, and the point
643 * "percent" down the frame is placed at the point "percent"
644 * down the visible area.
646 * * (Default) SCROLL_IF_NOT_FULLY_VISIBLE: Move the frame only
647 * if it is not fully visible (including if it's not visible
648 * at all). Note that in this case if the frame is too large to
649 * fit in view, it will only be scrolled if more of it can fit
650 * than is already in view.
651 * * SCROLL_IF_NOT_VISIBLE: Move the frame only if none of it
653 * * SCROLL_ALWAYS: Move the frame regardless of its current
655 * @param aOnlyIfPerceivedScrollableDirection:
656 * If the direction is not a perceived scrollable direction (i.e.
657 * no scrollbar showing and less than one device pixel of
658 * scrollable distance), don't scroll. Defaults to false.
660 explicit ScrollAxis(int16_t aWhere
= SCROLL_MINIMUM
,
661 WhenToScroll aWhen
= SCROLL_IF_NOT_FULLY_VISIBLE
,
662 bool aOnlyIfPerceivedScrollableDirection
= false) :
663 mWhereToScroll(aWhere
), mWhenToScroll(aWhen
),
664 mOnlyIfPerceivedScrollableDirection(aOnlyIfPerceivedScrollableDirection
)
668 * Scrolls the view of the document so that the primary frame of the content
669 * is displayed in the window. Layout is flushed before scrolling.
671 * @param aContent The content object of which primary frame should be
672 * scrolled into view.
673 * @param aVertical How to align the frame vertically and when to do so.
674 * This is a ScrollAxis of Where and When.
675 * @param aHorizontal How to align the frame horizontally and when to do so.
676 * This is a ScrollAxis of Where and When.
677 * @param aFlags If SCROLL_FIRST_ANCESTOR_ONLY is set, only the nearest
678 * scrollable ancestor is scrolled, otherwise all
679 * scrollable ancestors may be scrolled if necessary.
680 * If SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a
681 * direction even if overflow:hidden is specified in that
682 * direction; otherwise we will not scroll in that direction
683 * when overflow:hidden is set for that direction.
684 * If SCROLL_NO_PARENT_FRAMES is set then we only scroll
685 * nodes in this document, not in any parent documents which
686 * contain this document in a iframe or the like.
687 * If SCROLL_SMOOTH is set and CSSOM-VIEW scroll-behavior
688 * is enabled, we will scroll smoothly using
689 * nsIScrollableFrame::ScrollMode::SMOOTH_MSD; otherwise,
690 * nsIScrollableFrame::ScrollMode::INSTANT will be used.
692 virtual nsresult
ScrollContentIntoView(nsIContent
* aContent
,
693 ScrollAxis aVertical
,
694 ScrollAxis aHorizontal
,
695 uint32_t aFlags
) = 0;
698 SCROLL_FIRST_ANCESTOR_ONLY
= 0x01,
699 SCROLL_OVERFLOW_HIDDEN
= 0x02,
700 SCROLL_NO_PARENT_FRAMES
= 0x04,
704 * Scrolls the view of the document so that the given area of a frame
705 * is visible, if possible. Layout is not flushed before scrolling.
707 * @param aRect relative to aFrame
708 * @param aVertical see ScrollContentIntoView and ScrollAxis
709 * @param aHorizontal see ScrollContentIntoView and ScrollAxis
710 * @param aFlags if SCROLL_FIRST_ANCESTOR_ONLY is set, only the
711 * nearest scrollable ancestor is scrolled, otherwise all
712 * scrollable ancestors may be scrolled if necessary
713 * if SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a direction
714 * even if overflow:hidden is specified in that direction; otherwise
715 * we will not scroll in that direction when overflow:hidden is
716 * set for that direction
717 * If SCROLL_NO_PARENT_FRAMES is set then we only scroll
718 * nodes in this document, not in any parent documents which
719 * contain this document in a iframe or the like.
720 * @return true if any scrolling happened, false if no scrolling happened
722 virtual bool ScrollFrameRectIntoView(nsIFrame
* aFrame
,
724 ScrollAxis aVertical
,
725 ScrollAxis aHorizontal
,
726 uint32_t aFlags
) = 0;
729 * Determine if a rectangle specified in the frame's coordinate system
730 * intersects the viewport "enough" to be considered visible.
731 * @param aFrame frame that aRect coordinates are specified relative to
732 * @param aRect rectangle in twips to test for visibility
733 * @param aMinTwips is the minimum distance in from the edge of the viewport
734 * that an object must be to be counted visible
735 * @return nsRectVisibility_kVisible if the rect is visible
736 * nsRectVisibility_kAboveViewport
737 * nsRectVisibility_kBelowViewport
738 * nsRectVisibility_kLeftOfViewport
739 * nsRectVisibility_kRightOfViewport rectangle is outside the viewport
740 * in the specified direction
742 virtual nsRectVisibility
GetRectVisibility(nsIFrame
*aFrame
,
744 nscoord aMinTwips
) const = 0;
747 * Suppress notification of the frame manager that frames are
750 virtual void SetIgnoreFrameDestruction(bool aIgnore
) = 0;
753 * Notification sent by a frame informing the pres shell that it is about to
755 * This allows any outstanding references to the frame to be cleaned up
757 virtual void NotifyDestroyingFrame(nsIFrame
* aFrame
) = 0;
760 * Get the touch caret, if it exists. AddRefs it.
762 virtual already_AddRefed
<mozilla::TouchCaret
> GetTouchCaret() const = 0;
765 * Returns the touch caret element of the presshell.
767 virtual mozilla::dom::Element
* GetTouchCaretElement() const = 0;
770 * Will be called when touch caret visibility has changed.
771 * Set the mMayHaveTouchCaret flag to aSet.
773 virtual void SetMayHaveTouchCaret(bool aSet
) = 0;
776 * Get the mMayHaveTouchCaret flag.
778 virtual bool MayHaveTouchCaret() = 0;
781 * Get the selection caret, if it exists. AddRefs it.
783 virtual already_AddRefed
<mozilla::SelectionCarets
> GetSelectionCarets() const = 0;
786 * Returns the start part of selection caret element of the presshell.
788 virtual mozilla::dom::Element
* GetSelectionCaretsStartElement() const = 0;
791 * Returns the end part of selection caret element of the presshell.
793 virtual mozilla::dom::Element
* GetSelectionCaretsEndElement() const = 0;
796 * Get the caret, if it exists. AddRefs it.
798 virtual already_AddRefed
<nsCaret
> GetCaret() const = 0;
801 * Set the current caret to a new caret. To undo this, call RestoreCaret.
803 virtual void SetCaret(nsCaret
*aNewCaret
) = 0;
806 * Restore the caret to the original caret that this pres shell was created
809 virtual void RestoreCaret() = 0;
812 * Should the images have borders etc. Actual visual effects are determined
813 * by the frames. Visual effects may not effect layout, only display.
814 * Takes effect on next repaint, does not force a repaint itself.
816 * @param aInEnable if true, visual selection effects are enabled
817 * if false visual selection effects are disabled
819 NS_IMETHOD
SetSelectionFlags(int16_t aInEnable
) = 0;
822 * Gets the current state of non text selection effects
823 * @return current state of non text selection,
824 * as set by SetDisplayNonTextSelection
826 int16_t GetSelectionFlags() const { return mSelectionFlags
; }
828 virtual mozilla::dom::Selection
* GetCurrentSelection(SelectionType aType
) = 0;
831 * Interface to dispatch events via the presshell
832 * @note The caller must have a strong reference to the PresShell.
834 virtual nsresult
HandleEventWithTarget(
835 mozilla::WidgetEvent
* aEvent
,
837 nsIContent
* aContent
,
838 nsEventStatus
* aStatus
) = 0;
841 * Dispatch event to content only (NOT full processing)
842 * @note The caller must have a strong reference to the PresShell.
844 virtual nsresult
HandleDOMEventWithTarget(
845 nsIContent
* aTargetContent
,
846 mozilla::WidgetEvent
* aEvent
,
847 nsEventStatus
* aStatus
) = 0;
850 * Dispatch event to content only (NOT full processing)
851 * @note The caller must have a strong reference to the PresShell.
853 virtual nsresult
HandleDOMEventWithTarget(nsIContent
* aTargetContent
,
855 nsEventStatus
* aStatus
) = 0;
858 * Gets the current target event frame from the PresShell
860 virtual nsIFrame
* GetEventTargetFrame() = 0;
863 * Gets the current target event frame from the PresShell
865 virtual already_AddRefed
<nsIContent
> GetEventTargetContent(
866 mozilla::WidgetEvent
* aEvent
) = 0;
869 * Get and set the history state for the current document
872 virtual nsresult
CaptureHistoryState(nsILayoutHistoryState
** aLayoutHistoryState
) = 0;
875 * Determine if reflow is currently locked
876 * returns true if reflow is locked, false otherwise
878 bool IsReflowLocked() const { return mIsReflowing
; }
881 * Called to find out if painting is suppressed for this presshell. If it is suppressd,
882 * we don't allow the painting of any layer but the background, and we don't
883 * recur into our children.
885 bool IsPaintingSuppressed() const { return mPaintingSuppressed
; }
888 * Pause painting by freezing the refresh driver of this and all parent
889 * presentations. This may not have the desired effect if this pres shell
890 * has its own refresh driver.
892 virtual void PausePainting() = 0;
895 * Resume painting by thawing the refresh driver of this and all parent
896 * presentations. This may not have the desired effect if this pres shell
897 * has its own refresh driver.
899 virtual void ResumePainting() = 0;
902 * Unsuppress painting.
904 virtual void UnsuppressPainting() = 0;
907 * Called to disable nsITheme support in a specific presshell.
909 void DisableThemeSupport()
911 // Doesn't have to be dynamic. Just set the bool.
912 mIsThemeSupportDisabled
= true;
916 * Indicates whether theme support is enabled.
918 bool IsThemeSupportEnabled() const { return !mIsThemeSupportDisabled
; }
921 * Get the set of agent style sheets for this presentation
923 virtual nsresult
GetAgentStyleSheets(nsCOMArray
<nsIStyleSheet
>& aSheets
) = 0;
926 * Replace the set of agent style sheets
928 virtual nsresult
SetAgentStyleSheets(const nsCOMArray
<nsIStyleSheet
>& aSheets
) = 0;
931 * Add an override style sheet for this presentation
933 virtual nsresult
AddOverrideStyleSheet(nsIStyleSheet
*aSheet
) = 0;
936 * Remove an override style sheet
938 virtual nsresult
RemoveOverrideStyleSheet(nsIStyleSheet
*aSheet
) = 0;
941 * Reconstruct frames for all elements in the document
943 virtual nsresult
ReconstructFrames() = 0;
946 * Notify that a content node's state has changed
948 virtual void ContentStateChanged(nsIDocument
* aDocument
,
949 nsIContent
* aContent
,
950 mozilla::EventStates aStateMask
) = 0;
953 * See if reflow verification is enabled. To enable reflow verification add
954 * "verifyreflow:1" to your NSPR_LOG_MODULES environment variable
955 * (any non-zero debug level will work). Or, call SetVerifyReflowEnable
958 static bool GetVerifyReflowEnable();
961 * Set the verify-reflow enable flag.
963 static void SetVerifyReflowEnable(bool aEnabled
);
965 virtual nsIFrame
* GetAbsoluteContainingBlock(nsIFrame
* aFrame
);
967 #ifdef MOZ_REFLOW_PERF
968 virtual void DumpReflows() = 0;
969 virtual void CountReflows(const char * aName
, nsIFrame
* aFrame
) = 0;
970 virtual void PaintCount(const char * aName
,
971 nsRenderingContext
* aRenderingContext
,
972 nsPresContext
* aPresContext
,
974 const nsPoint
& aOffset
,
975 uint32_t aColor
) = 0;
976 virtual void SetPaintFrameCount(bool aOn
) = 0;
977 virtual bool IsPaintingFrameCounts() = 0;
982 virtual void ListStyleContexts(nsIFrame
*aRootFrame
, FILE *out
,
983 int32_t aIndent
= 0) = 0;
985 virtual void ListStyleSheets(FILE *out
, int32_t aIndent
= 0) = 0;
986 virtual void VerifyStyleTree() = 0;
991 * Return true if accessibility is active.
993 static bool IsAccessibilityActive();
996 * Return accessibility service if accessibility is active.
998 static nsAccessibilityService
* AccService();
1002 * Stop all active elements (plugins and the caret) in this presentation and
1003 * in the presentations of subdocuments. Resets painting to a suppressed state.
1004 * XXX this should include image animations
1006 virtual void Freeze() = 0;
1007 bool IsFrozen() { return mFrozen
; }
1010 * Restarts active elements (plugins) in this presentation and in the
1011 * presentations of subdocuments, then do a full invalidate of the content area.
1013 virtual void Thaw() = 0;
1015 virtual void FireOrClearDelayedEvents(bool aFireEvents
) = 0;
1018 * When this shell is disconnected from its containing docshell, we
1019 * lose our container pointer. However, we'd still like to be able to target
1020 * user events at the docshell's parent. This pointer allows us to do that.
1021 * It should not be used for any other purpose.
1023 void SetForwardingContainer(const mozilla::WeakPtr
<nsDocShell
> &aContainer
);
1026 * Render the document into an arbitrary gfxContext
1027 * Designed for getting a picture of a document or a piece of a document
1028 * Note that callers will generally want to call FlushPendingNotifications
1029 * to get an up-to-date view of the document
1030 * @param aRect is the region to capture into the offscreen buffer, in the
1031 * root frame's coordinate system (if aIgnoreViewportScrolling is false)
1032 * or in the root scrolled frame's coordinate system
1033 * (if aIgnoreViewportScrolling is true). The coordinates are in appunits.
1034 * @param aFlags see below;
1035 * set RENDER_IS_UNTRUSTED if the contents may be passed to malicious
1036 * agents. E.g. we might choose not to paint the contents of sensitive widgets
1037 * such as the file name in a file upload widget, and we might choose not
1039 * set RENDER_IGNORE_VIEWPORT_SCROLLING to ignore
1040 * clipping/scrolling/scrollbar painting due to scrolling in the viewport
1041 * set RENDER_CARET to draw the caret if one would be visible
1042 * (by default the caret is never drawn)
1043 * set RENDER_USE_LAYER_MANAGER to force rendering to go through
1044 * the layer manager for the window. This may be unexpectedly slow
1045 * (if the layer manager must read back data from the GPU) or low-quality
1046 * (if the layer manager reads back pixel data and scales it
1047 * instead of rendering using the appropriate scaling). It may also
1048 * slow everything down if the area rendered does not correspond to the
1049 * normal visible area of the window.
1050 * set RENDER_ASYNC_DECODE_IMAGES to avoid having images synchronously
1051 * decoded during rendering.
1052 * (by default images decode synchronously with RenderDocument)
1053 * set RENDER_DOCUMENT_RELATIVE to interpret |aRect| relative to the
1054 * document instead of the CSS viewport
1055 * @param aBackgroundColor a background color to render onto
1056 * @param aRenderedContext the gfxContext to render to. We render so that
1057 * one CSS pixel in the source document is rendered to one unit in the current
1061 RENDER_IS_UNTRUSTED
= 0x01,
1062 RENDER_IGNORE_VIEWPORT_SCROLLING
= 0x02,
1063 RENDER_CARET
= 0x04,
1064 RENDER_USE_WIDGET_LAYERS
= 0x08,
1065 RENDER_ASYNC_DECODE_IMAGES
= 0x10,
1066 RENDER_DOCUMENT_RELATIVE
= 0x20,
1067 RENDER_DRAWWINDOW_NOT_FLUSHING
= 0x40
1069 virtual nsresult
RenderDocument(const nsRect
& aRect
, uint32_t aFlags
,
1070 nscolor aBackgroundColor
,
1071 gfxContext
* aRenderedContext
) = 0;
1074 * Renders a node aNode to a surface and returns it. The aRegion may be used
1075 * to clip the rendering. This region is measured in CSS pixels from the
1076 * edge of the presshell area. The aPoint, aScreenRect and aSurface
1077 * arguments function in a similar manner as RenderSelection.
1079 virtual mozilla::TemporaryRef
<SourceSurface
>
1080 RenderNode(nsIDOMNode
* aNode
,
1081 nsIntRegion
* aRegion
,
1083 nsIntRect
* aScreenRect
) = 0;
1086 * Renders a selection to a surface and returns it. This method is primarily
1087 * intended to create the drag feedback when dragging a selection.
1089 * aScreenRect will be filled in with the bounding rectangle of the
1090 * selection area on screen.
1092 * If the area of the selection is large, the image will be scaled down.
1093 * The argument aPoint is used in this case as a reference point when
1094 * determining the new screen rectangle after scaling. Typically, this
1095 * will be the mouse position, so that the screen rectangle is positioned
1096 * such that the mouse is over the same point in the scaled image as in
1097 * the original. When scaling does not occur, the mouse point isn't used
1098 * as the position can be determined from the displayed frames.
1100 virtual mozilla::TemporaryRef
<SourceSurface
>
1101 RenderSelection(nsISelection
* aSelection
,
1103 nsIntRect
* aScreenRect
) = 0;
1105 void AddWeakFrameInternal(nsWeakFrame
* aWeakFrame
);
1106 virtual void AddWeakFrameExternal(nsWeakFrame
* aWeakFrame
);
1108 void AddWeakFrame(nsWeakFrame
* aWeakFrame
)
1110 #ifdef MOZILLA_INTERNAL_API
1111 AddWeakFrameInternal(aWeakFrame
);
1113 AddWeakFrameExternal(aWeakFrame
);
1117 void RemoveWeakFrameInternal(nsWeakFrame
* aWeakFrame
);
1118 virtual void RemoveWeakFrameExternal(nsWeakFrame
* aWeakFrame
);
1120 void RemoveWeakFrame(nsWeakFrame
* aWeakFrame
)
1122 #ifdef MOZILLA_INTERNAL_API
1123 RemoveWeakFrameInternal(aWeakFrame
);
1125 RemoveWeakFrameExternal(aWeakFrame
);
1130 nsIFrame
* GetDrawEventTargetFrame() { return mDrawEventTargetFrame
; }
1134 * Stop or restart non synthetic test mouse event handling on *all*
1137 * @param aDisable If true, disable all non synthetic test mouse
1138 * events on all presShells. Otherwise, enable them.
1140 virtual void DisableNonTestMouseEvents(bool aDisable
) = 0;
1143 * Record the background color of the most recently drawn canvas. This color
1144 * is composited on top of the user's default background color and then used
1145 * to draw the background color of the canvas. See PresShell::Paint,
1146 * PresShell::PaintDefaultBackground, and nsDocShell::SetupNewViewer;
1147 * bug 488242, bug 476557 and other bugs mentioned there.
1149 void SetCanvasBackground(nscolor aColor
) { mCanvasBackgroundColor
= aColor
; }
1150 nscolor
GetCanvasBackground() { return mCanvasBackgroundColor
; }
1153 * Use the current frame tree (if it exists) to update the background
1154 * color of the most recently drawn canvas.
1156 virtual void UpdateCanvasBackground() = 0;
1159 * Add a solid color item to the bottom of aList with frame aFrame and bounds
1160 * aBounds. Checks first if this needs to be done by checking if aFrame is a
1161 * canvas frame (if the FORCE_DRAW flag is passed then this check is skipped).
1162 * aBackstopColor is composed behind the background color of the canvas, it is
1163 * transparent by default.
1168 virtual void AddCanvasBackgroundColorItem(nsDisplayListBuilder
& aBuilder
,
1169 nsDisplayList
& aList
,
1171 const nsRect
& aBounds
,
1172 nscolor aBackstopColor
= NS_RGBA(0,0,0,0),
1173 uint32_t aFlags
= 0) = 0;
1177 * Add a solid color item to the bottom of aList with frame aFrame and
1178 * bounds aBounds representing the dark grey background behind the page of a
1179 * print preview presentation.
1181 virtual void AddPrintPreviewBackgroundItem(nsDisplayListBuilder
& aBuilder
,
1182 nsDisplayList
& aList
,
1184 const nsRect
& aBounds
) = 0;
1187 * Computes the backstop color for the view: transparent if in a transparent
1188 * widget, otherwise the PresContext default background color. This color is
1189 * only visible if the contents of the view as a whole are translucent.
1191 virtual nscolor
ComputeBackstopColor(nsView
* aDisplayRoot
) = 0;
1193 void ObserveNativeAnonMutationsForPrint(bool aObserve
)
1195 mObservesMutationsForPrint
= aObserve
;
1197 bool ObservesNativeAnonMutationsForPrint()
1199 return mObservesMutationsForPrint
;
1202 virtual nsresult
SetIsActive(bool aIsActive
) = 0;
1211 static CapturingContentInfo gCaptureInfo
;
1213 static nsRefPtrHashtable
<nsUint32HashKey
, mozilla::dom::Touch
>* gCaptureTouchList
;
1214 static bool gPreventMouseEvents
;
1216 // Keeps a map between pointerId and element that currently capturing pointer
1217 // with such pointerId. If pointerId is absent in this map then nobody is
1219 static nsRefPtrHashtable
<nsUint32HashKey
, nsIContent
>* gPointerCaptureList
;
1224 uint16_t mPointerType
;
1225 PointerInfo(bool aActiveState
, uint16_t aPointerType
) :
1226 mActiveState(aActiveState
), mPointerType(aPointerType
) {}
1228 // Keeps information about pointers such as pointerId, activeState, pointerType
1229 static nsClassHashtable
<nsUint32HashKey
, PointerInfo
>* gActivePointersIds
;
1231 static void DispatchGotOrLostPointerCaptureEvent(bool aIsGotCapture
,
1232 uint32_t aPointerId
,
1233 nsIContent
* aCaptureTarget
);
1234 static void SetPointerCapturingContent(uint32_t aPointerId
, nsIContent
* aContent
);
1235 static void ReleasePointerCapturingContent(uint32_t aPointerId
, nsIContent
* aContent
);
1236 static nsIContent
* GetPointerCapturingContent(uint32_t aPointerId
);
1238 // GetPointerInfo returns true if pointer with aPointerId is situated in device, false otherwise.
1239 // aActiveState is additional information, which shows state of pointer like button state for mouse.
1240 static bool GetPointerInfo(uint32_t aPointerId
, bool& aActiveState
);
1243 * When capturing content is set, it traps all mouse events and retargets
1244 * them at this content node. If capturing is not allowed
1245 * (gCaptureInfo.mAllowed is false), then capturing is not set. However, if
1246 * the CAPTURE_IGNOREALLOWED flag is set, the allowed state is ignored and
1247 * capturing is set regardless. To disable capture, pass null for the value
1250 * If CAPTURE_RETARGETTOELEMENT is set, all mouse events are targeted at
1251 * aContent only. Otherwise, mouse events are targeted at aContent or its
1252 * descendants. That is, descendants of aContent receive mouse events as
1253 * they normally would, but mouse events outside of aContent are retargeted
1256 * If CAPTURE_PREVENTDRAG is set then drags are prevented from starting while
1257 * this capture is active.
1259 * If CAPTURE_POINTERLOCK is set, similar to CAPTURE_RETARGETTOELEMENT, then
1260 * events are targeted at aContent, but capturing is held more strongly (i.e.,
1261 * calls to SetCapturingContent won't unlock unless CAPTURE_POINTERLOCK is
1264 static void SetCapturingContent(nsIContent
* aContent
, uint8_t aFlags
);
1267 * Return the active content currently capturing the mouse if any.
1269 static nsIContent
* GetCapturingContent()
1271 return gCaptureInfo
.mContent
;
1275 * Allow or disallow mouse capturing.
1277 static void AllowMouseCapture(bool aAllowed
)
1279 gCaptureInfo
.mAllowed
= aAllowed
;
1283 * Returns true if there is an active mouse capture that wants to prevent
1286 static bool IsMouseCapturePreventingDrag()
1288 return gCaptureInfo
.mPreventDrag
&& gCaptureInfo
.mContent
;
1292 * Keep track of how many times this presshell has been rendered to
1295 uint64_t GetPaintCount() { return mPaintCount
; }
1296 void IncrementPaintCount() { ++mPaintCount
; }
1299 * Get the root DOM window of this presShell.
1301 virtual already_AddRefed
<nsPIDOMWindow
> GetRootWindow() = 0;
1304 * Get the layer manager for the widget of the root view, if it has
1307 virtual LayerManager
* GetLayerManager() = 0;
1310 * Track whether we're ignoring viewport scrolling for the purposes
1311 * of painting. If we are ignoring, then layers aren't clipped to
1312 * the CSS viewport and scrollbars aren't drawn.
1314 virtual void SetIgnoreViewportScrolling(bool aIgnore
) = 0;
1315 bool IgnoringViewportScrolling() const
1316 { return mRenderFlags
& STATE_IGNORING_VIEWPORT_SCROLLING
; }
1319 * Set a "resolution" for the document, which if not 1.0 will
1320 * allocate more or fewer pixels for rescalable content by a factor
1321 * of |resolution| in both dimensions. Return NS_OK iff the
1322 * resolution bounds are sane, and the resolution of this was
1325 * The resolution defaults to 1.0.
1327 virtual nsresult
SetResolution(float aXResolution
, float aYResolution
) = 0;
1328 gfxSize
GetResolution() { return gfxSize(mXResolution
, mYResolution
); }
1329 float GetXResolution() { return mXResolution
; }
1330 float GetYResolution() { return mYResolution
; }
1331 virtual gfxSize
GetCumulativeResolution() = 0;
1334 * Returns whether we are in a DrawWindow() call that used the
1335 * DRAWWINDOW_DO_NOT_FLUSH flag.
1337 bool InDrawWindowNotFlushing() const
1338 { return mRenderFlags
& STATE_DRAWWINDOW_NOT_FLUSHING
; }
1341 * Set the isFirstPaint flag.
1343 void SetIsFirstPaint(bool aIsFirstPaint
) { mIsFirstPaint
= aIsFirstPaint
; }
1346 * Get the isFirstPaint flag.
1348 bool GetIsFirstPaint() const { return mIsFirstPaint
; }
1350 uint32_t GetPresShellId() { return mPresShellId
; }
1353 * Dispatch a mouse move event based on the most recent mouse position if
1354 * this PresShell is visible. This is used when the contents of the page
1355 * moved (aFromScroll is false) or scrolled (aFromScroll is true).
1357 virtual void SynthesizeMouseMove(bool aFromScroll
) = 0;
1360 /* Update the layer tree and paint ThebesLayers. If this is not specified,
1361 * we may still have to do it if the layer tree lost ThebesLayer contents
1362 * we need for compositing. */
1363 PAINT_LAYERS
= 0x01,
1364 /* Composite layers to the window. */
1365 PAINT_COMPOSITE
= 0x02,
1367 virtual void Paint(nsView
* aViewToPaint
, const nsRegion
& aDirtyRegion
,
1368 uint32_t aFlags
) = 0;
1369 virtual nsresult
HandleEvent(nsIFrame
* aFrame
,
1370 mozilla::WidgetGUIEvent
* aEvent
,
1371 bool aDontRetargetEvents
,
1372 nsEventStatus
* aEventStatus
) = 0;
1373 virtual bool ShouldIgnoreInvalidation() = 0;
1375 * Notify that we're going to call Paint with PAINT_LAYERS
1376 * on the pres shell for a widget (which might not be this one, since
1377 * WillPaint is called on all presshells in the same toplevel window as the
1378 * painted widget). This is issued at a time when it's safe to modify
1381 virtual void WillPaint() = 0;
1383 * Notify that we're going to call Paint with PAINT_COMPOSITE.
1384 * Fires on the presshell for the painted widget.
1385 * This is issued at a time when it's safe to modify widget geometry.
1387 virtual void WillPaintWindow() = 0;
1389 * Notify that we called Paint with PAINT_COMPOSITE.
1390 * Fires on the presshell for the painted widget.
1391 * This is issued at a time when it's safe to modify widget geometry.
1393 virtual void DidPaintWindow() = 0;
1396 * Ensures that the refresh driver is running, and schedules a view
1397 * manager flush on the next tick.
1399 * @param aType PAINT_DELAYED_COMPRESS : Schedule a paint to be executed after a delay, and
1400 * put FrameLayerBuilder in 'compressed' mode that avoids short cut optimizations.
1404 PAINT_DELAYED_COMPRESS
1406 virtual void ScheduleViewManagerFlush(PaintType aType
= PAINT_DEFAULT
) = 0;
1407 virtual void ClearMouseCaptureOnView(nsView
* aView
) = 0;
1408 virtual bool IsVisible() = 0;
1409 virtual void DispatchSynthMouseMove(mozilla::WidgetGUIEvent
* aEvent
,
1410 bool aFlushOnHoverChange
) = 0;
1412 virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
,
1413 nsArenaMemoryStats
*aArenaObjectsSize
,
1414 size_t *aPresShellSize
,
1415 size_t *aStyleSetsSize
,
1416 size_t *aTextRunsSize
,
1417 size_t *aPresContextSize
) = 0;
1420 * Methods that retrieve the cached font inflation preferences.
1422 uint32_t FontSizeInflationEmPerLine() const {
1423 return mFontSizeInflationEmPerLine
;
1426 uint32_t FontSizeInflationMinTwips() const {
1427 return mFontSizeInflationMinTwips
;
1430 uint32_t FontSizeInflationLineThreshold() const {
1431 return mFontSizeInflationLineThreshold
;
1434 bool FontSizeInflationForceEnabled() const {
1435 return mFontSizeInflationForceEnabled
;
1438 bool FontSizeInflationDisabledInMasterProcess() const {
1439 return mFontSizeInflationDisabledInMasterProcess
;
1443 * Determine if font size inflation is enabled. This value is cached until
1446 * @returns true, if font size inflation is enabled; false otherwise.
1448 bool FontSizeInflationEnabled();
1451 * Notify the pres shell that an event occurred making the current value of
1452 * mFontSizeInflationEnabled invalid. This will schedule a recomputation of
1453 * whether font size inflation is enabled on the next call to
1454 * FontSizeInflationEnabled().
1456 void NotifyFontSizeInflationEnabledIsDirty()
1458 mFontSizeInflationEnabledIsDirty
= true;
1461 virtual void AddInvalidateHiddenPresShellObserver(nsRefreshDriver
*aDriver
) = 0;
1463 void InvalidatePresShellIfHidden();
1464 void CancelInvalidatePresShellIfHidden();
1466 // Schedule an update of the list of visible images.
1467 virtual void ScheduleImageVisibilityUpdate() = 0;
1469 // Clears the current list of visible images on this presshell and replaces it
1470 // with images that are in the display list aList.
1471 virtual void RebuildImageVisibilityDisplayList(const nsDisplayList
& aList
) = 0;
1472 virtual void RebuildImageVisibility(nsRect
* aRect
= nullptr) = 0;
1474 // Ensures the image is in the list of visible images.
1475 virtual void EnsureImageInVisibleList(nsIImageLoadingContent
* aImage
) = 0;
1477 // Removes the image from the list of visible images if it is present there.
1478 virtual void RemoveImageFromVisibleList(nsIImageLoadingContent
* aImage
) = 0;
1480 // Whether we should assume all images are visible.
1481 virtual bool AssumeAllImagesVisible() = 0;
1484 * Refresh observer management.
1487 virtual bool AddRefreshObserverExternal(nsARefreshObserver
* aObserver
,
1488 mozFlushType aFlushType
);
1489 bool AddRefreshObserverInternal(nsARefreshObserver
* aObserver
,
1490 mozFlushType aFlushType
);
1491 virtual bool RemoveRefreshObserverExternal(nsARefreshObserver
* aObserver
,
1492 mozFlushType aFlushType
);
1493 bool RemoveRefreshObserverInternal(nsARefreshObserver
* aObserver
,
1494 mozFlushType aFlushType
);
1497 * Do computations necessary to determine if font size inflation is enabled.
1498 * This value is cached after computation, as the computation is somewhat
1501 void RecomputeFontSizeInflationEnabled();
1504 bool AddRefreshObserver(nsARefreshObserver
* aObserver
,
1505 mozFlushType aFlushType
) {
1506 #ifdef MOZILLA_INTERNAL_API
1507 return AddRefreshObserverInternal(aObserver
, aFlushType
);
1509 return AddRefreshObserverExternal(aObserver
, aFlushType
);
1513 bool RemoveRefreshObserver(nsARefreshObserver
* aObserver
,
1514 mozFlushType aFlushType
) {
1515 #ifdef MOZILLA_INTERNAL_API
1516 return RemoveRefreshObserverInternal(aObserver
, aFlushType
);
1518 return RemoveRefreshObserverExternal(aObserver
, aFlushType
);
1522 virtual bool AddPostRefreshObserver(nsAPostRefreshObserver
* aObserver
);
1523 virtual bool RemovePostRefreshObserver(nsAPostRefreshObserver
* aObserver
);
1526 * Initialize and shut down static variables.
1528 static void InitializeStatics();
1529 static void ReleaseStatics();
1531 // If a frame in the subtree rooted at aFrame is capturing the mouse then
1532 // clears that capture.
1533 static void ClearMouseCapture(nsIFrame
* aFrame
);
1535 void SetScrollPositionClampingScrollPortSize(nscoord aWidth
, nscoord aHeight
);
1536 bool IsScrollPositionClampingScrollPortSizeSet() {
1537 return mScrollPositionClampingScrollPortSizeSet
;
1539 nsSize
GetScrollPositionClampingScrollPortSize() {
1540 NS_ASSERTION(mScrollPositionClampingScrollPortSizeSet
, "asking for scroll port when its not set?");
1541 return mScrollPositionClampingScrollPortSize
;
1544 void SetContentDocumentFixedPositionMargins(const nsMargin
& aMargins
);
1545 const nsMargin
& GetContentDocumentFixedPositionMargins() {
1546 return mContentDocumentFixedPositionMargins
;
1549 virtual void WindowSizeMoveDone() = 0;
1550 virtual void SysColorChanged() = 0;
1551 virtual void ThemeChanged() = 0;
1552 virtual void BackingScaleFactorChanged() = 0;
1554 nscoord
MaxLineBoxWidth() {
1555 return mMaxLineBoxWidth
;
1558 void SetMaxLineBoxWidth(nscoord aMaxLineBoxWidth
);
1561 * Returns whether or not there is a reflow on zoom event pending. A reflow
1562 * on zoom event is a change to the max line box width, followed by a reflow.
1563 * This subsequent reflow event should treat all frames as though they resized
1564 * horizontally (and thus reflow all their descendants), rather than marking
1565 * all frames dirty from the root. This is the way the pres shell indicates
1566 * that an hresize reflow should take place during reflow state construction.
1568 bool IsReflowOnZoomPending() {
1569 return mReflowOnZoomPending
;
1573 * Clear the flag indicating whether a reflow on zoom event is pending. This
1574 * is performed at the very end of DoReflow().
1576 void ClearReflowOnZoomPending() {
1577 mReflowOnZoomPending
= false;
1581 * Documents belonging to an invisible DocShell must not be painted ever.
1583 bool IsNeverPainting() {
1584 return mIsNeverPainting
;
1587 void SetNeverPainting(bool aNeverPainting
) {
1588 mIsNeverPainting
= aNeverPainting
;
1592 friend class nsRefreshDriver
;
1594 // IMPORTANT: The ownership implicit in the following member variables
1595 // has been explicitly checked. If you add any members to this class,
1596 // please make the ownership explicit (pinkerton, scc).
1598 // These are the same Document and PresContext owned by the DocViewer.
1599 // we must share ownership.
1600 nsIDocument
* mDocument
; // [STRONG]
1601 nsPresContext
* mPresContext
; // [STRONG]
1602 nsStyleSet
* mStyleSet
; // [OWNS]
1603 nsCSSFrameConstructor
* mFrameConstructor
; // [OWNS]
1604 nsViewManager
* mViewManager
; // [WEAK] docViewer owns it so I don't have to
1605 nsPresArena mFrameArena
;
1606 nsFrameSelection
* mSelection
;
1607 // Pointer into mFrameConstructor - this is purely so that FrameManager() and
1608 // GetRootFrame() can be inlined:
1609 nsFrameManagerBase
* mFrameManager
;
1610 mozilla::WeakPtr
<nsDocShell
> mForwardingContainer
;
1611 nsRefreshDriver
* mHiddenInvalidationObserverRefreshDriver
;
1612 #ifdef ACCESSIBILITY
1613 mozilla::a11y::DocAccessible
* mDocAccessible
;
1617 nsIFrame
* mDrawEventTargetFrame
;
1618 // Ensure that every allocation from the PresArena is eventually freed.
1619 uint32_t mPresArenaAllocCount
;
1622 // Count of the number of times this presshell has been painted to a window.
1623 uint64_t mPaintCount
;
1625 nsSize mScrollPositionClampingScrollPortSize
;
1627 // This margin is intended to be used when laying out fixed position children
1628 // on this PresShell's viewport frame. See the documentation of
1629 // nsIDOMWindowUtils.setContentDocumentFixedPositionMargins for details of
1631 nsMargin mContentDocumentFixedPositionMargins
;
1633 // A list of weak frames. This is a pointer to the last item in the list.
1634 nsWeakFrame
* mWeakFrames
;
1636 // Most recent canvas background color.
1637 nscolor mCanvasBackgroundColor
;
1639 // Used to force allocation and rendering of proportionally more or
1640 // less pixels in the given dimension.
1644 int16_t mSelectionFlags
;
1646 // Flags controlling how our document is rendered. These persist
1647 // between paints and so are tied with retained layer pixels.
1648 // PresShell flushes retained layers when the rendering state
1649 // changes in a way that prevents us from being able to (usefully)
1650 // re-use old pixels.
1651 RenderFlags mRenderFlags
;
1653 // Indicates that the whole document must be restyled. Changes to scoped
1654 // style sheets are recorded in mChangedScopeStyleRoots rather than here
1655 // in mStylesHaveChanged.
1656 bool mStylesHaveChanged
: 1;
1657 bool mDidInitialize
: 1;
1658 bool mIsDestroying
: 1;
1660 bool mIsReflowing
: 1;
1662 // For all documents we initially lock down painting.
1663 bool mPaintingSuppressed
: 1;
1665 // Whether or not form controls should use nsITheme in this shell.
1666 bool mIsThemeSupportDisabled
: 1;
1670 bool mIsFirstPaint
: 1;
1671 bool mObservesMutationsForPrint
: 1;
1673 // If true, we have a reflow scheduled. Guaranteed to be false if
1674 // mReflowContinueTimer is non-null.
1675 bool mReflowScheduled
: 1;
1677 bool mSuppressInterruptibleReflows
: 1;
1678 bool mScrollPositionClampingScrollPortSizeSet
: 1;
1680 uint32_t mPresShellId
;
1682 // List of subtrees rooted at style scope roots that need to be restyled.
1683 // When a change to a scoped style sheet is made, we add the style scope
1684 // root to this array rather than setting mStylesHaveChanged = true, since
1685 // we know we don't need to restyle the whole document. However, if in the
1686 // same update block we have already had other changes that require
1687 // the whole document to be restyled (i.e., mStylesHaveChanged is already
1688 // true), then we don't bother adding the scope root here.
1689 nsAutoTArray
<nsRefPtr
<mozilla::dom::Element
>,1> mChangedScopeStyleRoots
;
1691 static nsIContent
* gKeyDownTarget
;
1693 // Cached font inflation values. This is done to prevent changing of font
1694 // inflation until a page is reloaded.
1695 uint32_t mFontSizeInflationEmPerLine
;
1696 uint32_t mFontSizeInflationMinTwips
;
1697 uint32_t mFontSizeInflationLineThreshold
;
1698 bool mFontSizeInflationForceEnabled
;
1699 bool mFontSizeInflationDisabledInMasterProcess
;
1700 bool mFontSizeInflationEnabled
;
1701 bool mPaintingIsFrozen
;
1703 // Dirty bit indicating that mFontSizeInflationEnabled needs to be recomputed.
1704 bool mFontSizeInflationEnabledIsDirty
;
1706 // Flag to indicate whether or not there is a reflow on zoom event pending.
1707 // See IsReflowOnZoomPending() for more information.
1708 bool mReflowOnZoomPending
;
1710 // The maximum width of a line box. Text on a single line that exceeds this
1711 // width will be wrapped. A value of 0 indicates that no limit is enforced.
1712 nscoord mMaxLineBoxWidth
;
1714 // If a document belongs to an invisible DocShell, this flag must be set
1715 // to true, so we can avoid any paint calls for widget related to this
1717 bool mIsNeverPainting
;
1720 NS_DEFINE_STATIC_IID_ACCESSOR(nsIPresShell
, NS_IPRESSHELL_IID
)
1722 #endif /* nsIPresShell_h___ */