1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* a presentation of a document, part 2 */
9 #ifndef mozilla_PresShell_h
10 #define mozilla_PresShell_h
12 #include "DepthOrderedFrameList.h"
13 #include "mozilla/PresShellForwards.h"
15 #include <stdio.h> // for FILE definition
16 #include "FrameMetrics.h"
17 #include "LayoutConstants.h"
18 #include "TouchManager.h"
20 #include "Visibility.h"
21 #include "mozilla/ArenaObjectID.h"
22 #include "mozilla/Attributes.h"
23 #include "mozilla/FlushType.h"
24 #include "mozilla/Logging.h"
25 #include "mozilla/MemoryReporting.h"
26 #include "mozilla/ScrollTypes.h"
27 #include "mozilla/StaticPtr.h"
28 #include "mozilla/UniquePtr.h"
29 #include "mozilla/WeakPtr.h"
30 #include "mozilla/dom/DocumentBinding.h"
31 #include "mozilla/layers/FocusTarget.h"
32 #include "mozilla/layout/LayoutTelemetryTools.h"
33 #include "mozilla/widget/ThemeChangeKind.h"
35 #include "nsCOMArray.h"
37 #include "nsDOMNavigationTiming.h"
38 #include "nsFrameManager.h"
39 #include "nsFrameState.h"
40 #include "nsIContent.h"
41 #include "nsIObserver.h"
42 #include "nsISelectionController.h"
43 #include "nsQueryFrame.h"
44 #include "nsPresArena.h"
45 #include "nsPresContext.h"
47 #include "nsRefreshObservers.h"
48 #include "nsStringFwd.h"
49 #include "nsStubDocumentObserver.h"
50 #include "nsTHashSet.h"
51 #include "nsThreadUtils.h"
52 #include "nsWeakReference.h"
54 # include "nsAccessibilityService.h"
57 class AutoPointerEventTargetUpdater
;
60 class MobileViewportManager
;
61 class nsAutoCauseReflowNotifier
;
64 class nsCSSFrameConstructor
;
66 class nsFrameSelection
;
69 class nsILayoutHistoryState
;
71 class nsPageSequenceFrame
;
72 class nsIReflowCallback
;
73 class nsIScrollableFrame
;
75 class nsPIDOMWindowOuter
;
76 class nsPresShellEventCB
;
78 class nsRefreshDriver
;
83 struct RangePaintInfo
;
84 #ifdef MOZ_REFLOW_PERF
88 class ZoomConstraintsClient
;
90 struct nsCallbackEventRequest
;
94 class nsDisplayListBuilder
;
95 class FallbackRenderer
;
97 class AccessibleCaretEventHub
;
98 class GeckoMVMContext
;
99 class OverflowChangedTracker
;
102 class ProfileChunkedBuffer
;
114 class HTMLSlotElement
;
125 } // namespace layers
128 class ScrollAnchorContainer
;
129 } // namespace layout
131 // 039d8ffc-fa55-42d7-a53a-388cb129b052
132 #define NS_PRESSHELL_IID \
134 0x039d8ffc, 0xfa55, 0x42d7, { \
135 0xa5, 0x3a, 0x38, 0x8c, 0xb1, 0x29, 0xb0, 0x52 \
139 #undef NOISY_INTERRUPTIBLE_REFLOW
142 * Presentation shell. Presentation shells are the controlling point for
143 * managing the presentation of a document. The presentation shell holds a
144 * live reference to the document, the presentation context, the style
145 * manager, the style set and the root frame.
147 * When this object is Release'd, it will release the document, the
148 * presentation context, the style manager, the style set and the root frame.
151 class PresShell final
: public nsStubDocumentObserver
,
152 public nsISelectionController
,
154 public nsSupportsWeakReference
{
155 typedef dom::Document Document
;
156 typedef dom::Element Element
;
157 typedef gfx::SourceSurface SourceSurface
;
158 typedef layers::FocusTarget FocusTarget
;
159 typedef layers::FrameMetrics FrameMetrics
;
160 typedef layers::LayerManager LayerManager
;
162 // A set type for tracking visible frames, for use by the visibility code in
163 // PresShell. The set contains nsIFrame* pointers.
164 typedef nsTHashSet
<nsIFrame
*> VisibleFrames
;
167 explicit PresShell(Document
* aDocument
);
172 NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRESSHELL_IID
)
174 static bool AccessibleCaretEnabled(nsIDocShell
* aDocShell
);
177 * Return the active content currently capturing the mouse if any.
179 static nsIContent
* GetCapturingContent() {
180 return sCapturingContentInfo
.mContent
;
185 static dom::BrowserParent
* GetCapturingRemoteTarget() {
186 MOZ_ASSERT(XRE_IsParentProcess());
187 return sCapturingContentInfo
.mRemoteTarget
;
191 * Allow or disallow mouse capturing.
193 static void AllowMouseCapture(bool aAllowed
) {
194 sCapturingContentInfo
.mAllowed
= aAllowed
;
198 * Returns true if there is an active mouse capture that wants to prevent
201 static bool IsMouseCapturePreventingDrag() {
202 return sCapturingContentInfo
.mPreventDrag
&& sCapturingContentInfo
.mContent
;
205 static void ClearMouseCaptureOnView(nsView
* aView
);
207 // Clear the capture content if it exists in this process.
208 static void ClearMouseCapture();
210 // If a frame in the subtree rooted at aFrame is capturing the mouse then
211 // clears that capture.
213 // NOTE(emilio): This is needed only so that mouse events captured by a remote
214 // frame don't remain being captured by the frame while hidden, see
215 // dom/events/test/browser_mouse_enterleave_switch_tab.js, which is the only
216 // test that meaningfully exercises this code path.
218 // We could consider maybe removing this, since the capturing content gets
219 // reset on mouse/pointerdown? Or maybe exposing an API so that the front-end
221 static void ClearMouseCapture(nsIFrame
* aFrame
);
225 * Return the document accessible for this PresShell if there is one.
227 a11y::DocAccessible
* GetDocAccessible() const { return mDocAccessible
; }
230 * Set the document accessible for this PresShell.
232 void SetDocAccessible(a11y::DocAccessible
* aDocAccessible
) {
233 mDocAccessible
= aDocAccessible
;
235 #endif // #ifdef ACCESSIBILITY
238 * See `mLastOverWindowPointerLocation`.
240 const nsPoint
& GetLastOverWindowPointerLocation() const {
241 return mLastOverWindowPointerLocation
;
244 MOZ_CAN_RUN_SCRIPT
void Init(nsPresContext
*, nsViewManager
*);
247 * All callers are responsible for calling |Destroy| after calling
248 * |EndObservingDocument|. It needs to be separate only because form
249 * controls incorrectly store their data in the frames rather than the
250 * content model and printing calls |EndObservingDocument| multiple
251 * times to make form controls behave nicely when printed.
255 bool IsDestroying() { return mIsDestroying
; }
258 * All frames owned by the shell are allocated from an arena. They
259 * are also recycled using free lists. Separate free lists are
260 * maintained for each frame type (aID), which must always correspond
261 * to the same aSize value. AllocateFrame is infallible and will abort
264 void* AllocateFrame(nsQueryFrame::FrameIID aID
, size_t aSize
) {
265 #define FRAME_ID(classname, ...) \
266 static_assert(size_t(nsQueryFrame::FrameIID::classname##_id) == \
267 size_t(eArenaObjectID_##classname), \
269 #define ABSTRACT_FRAME_ID(classname) \
270 static_assert(size_t(nsQueryFrame::FrameIID::classname##_id) == \
271 size_t(eArenaObjectID_##classname), \
273 #include "mozilla/FrameIdList.h"
275 #undef ABSTRACT_FRAME_ID
276 return AllocateByObjectID(ArenaObjectID(size_t(aID
)), aSize
);
279 void FreeFrame(nsQueryFrame::FrameIID aID
, void* aPtr
) {
280 return FreeByObjectID(ArenaObjectID(size_t(aID
)), aPtr
);
283 void* AllocateByObjectID(ArenaObjectID aID
, size_t aSize
) {
284 void* result
= mFrameArena
.Allocate(aID
, aSize
);
289 void FreeByObjectID(ArenaObjectID aID
, void* aPtr
) {
291 if (!mIsDestroying
) {
292 mFrameArena
.Free(aID
, aPtr
);
296 Document
* GetDocument() const { return mDocument
; }
298 nsPresContext
* GetPresContext() const { return mPresContext
; }
300 nsViewManager
* GetViewManager() const { return mViewManager
; }
302 nsRefreshDriver
* GetRefreshDriver() const;
304 nsCSSFrameConstructor
* FrameConstructor() const {
305 return mFrameConstructor
.get();
309 * FrameSelection will return the Frame based selection API.
310 * You cannot go back and forth anymore with QI between nsIDOM sel and
313 already_AddRefed
<nsFrameSelection
> FrameSelection();
316 * ConstFrameSelection returns an object which methods are safe to use for
317 * example in nsIFrame code.
319 const nsFrameSelection
* ConstFrameSelection() const { return mSelection
; }
321 // Start receiving notifications from our document. If called after Destroy,
322 // this will be ignored.
323 void BeginObservingDocument();
325 // Stop receiving notifications from our document. If called after Destroy,
326 // this will be ignored.
327 void EndObservingDocument();
329 bool IsObservingDocument() const { return mIsObservingDocument
; }
332 * Return whether Initialize() was previously called.
334 bool DidInitialize() const { return mDidInitialize
; }
337 * Perform initialization. Constructs the frame for the root content
338 * object and then enqueues a reflow of the frame model.
340 * Callers of this method must hold a reference to this shell that
341 * is guaranteed to survive through arbitrary script execution.
342 * Calling Initialize can execute arbitrary script.
344 MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
Initialize();
347 * Schedule a reflow for the frame model into a new width and height. The
348 * coordinates for aWidth and aHeight must be in standard nscoord's.
350 * Returns whether layout might have changed.
352 MOZ_CAN_RUN_SCRIPT
void ResizeReflow(
353 nscoord aWidth
, nscoord aHeight
,
354 ResizeReflowOptions
= ResizeReflowOptions::NoOption
);
355 MOZ_CAN_RUN_SCRIPT
bool ResizeReflowIgnoreOverride(
356 nscoord aWidth
, nscoord aHeight
,
357 ResizeReflowOptions
= ResizeReflowOptions::NoOption
);
358 MOZ_CAN_RUN_SCRIPT
void ForceResizeReflowWithCurrentDimensions();
361 * Add this pres shell to the refresh driver to be observed for resize
362 * event if applicable.
364 void AddResizeEventFlushObserverIfNeeded();
367 * Returns true if the document hosted by this presShell is in a devtools
368 * Responsive Design Mode browsing context.
372 #if defined(MOZ_WIDGET_ANDROID)
374 * If the dynamic toolbar is not expanded, notify the app to do so.
376 void MaybeNotifyShowDynamicToolbar();
377 #endif // defined(MOZ_WIDGET_ANDROID)
379 void RefreshZoomConstraintsForScreenSizeChange();
383 * This is what ResizeReflowIgnoreOverride does when not shrink-wrapping (that
384 * is, when ResizeReflowOptions::BSizeLimit is not specified).
386 bool SimpleResizeReflow(nscoord aWidth
, nscoord aHeight
);
388 bool CanHandleUserInputEvents(WidgetGUIEvent
* aGUIEvent
);
392 * Updates pending layout, assuming reasonable (up-to-date, or mid-update for
393 * container queries) styling of the page. Returns whether a reflow did not
394 * get interrupted (and thus layout should be considered fully up-to-date).
396 MOZ_CAN_RUN_SCRIPT_BOUNDARY
bool DoFlushLayout(bool aInterruptible
);
399 * Note that the assumptions that determine whether we need a mobile viewport
400 * manager may have changed.
402 MOZ_CAN_RUN_SCRIPT
void MaybeRecreateMobileViewportManager(
403 bool aAfterInitialization
);
406 * Returns true if this document uses mobile viewport sizing (including
407 * processing of <meta name="viewport"> tags).
409 * Note that having a MobileViewportManager does not necessarily mean using
410 * mobile viewport sizing, as with desktop zooming we can have a
411 * MobileViewportManager on desktop, but we only want to do mobile viewport
412 * sizing on mobile. (TODO: Rename MobileViewportManager to reflect its more
415 bool UsesMobileViewportSizing() const;
418 * Get the MobileViewportManager used to manage the document's mobile
419 * viewport. Will return null in situations where we don't have a mobile
420 * viewport, and for documents that are not the root content document.
422 RefPtr
<MobileViewportManager
> GetMobileViewportManager() const;
425 * Return true if the presshell expects layout flush.
427 bool IsLayoutFlushObserver();
430 * Called when document load completes.
434 * This calls through to the frame manager to get the root frame.
436 nsIFrame
* GetRootFrame() const { return mFrameManager
->GetRootFrame(); }
439 * Get root scroll frame from FrameManager()->GetRootFrame().
441 nsIFrame
* GetRootScrollFrame() const;
444 * The same as GetRootScrollFrame, but returns an nsIScrollableFrame
446 nsIScrollableFrame
* GetRootScrollFrameAsScrollable() const;
449 * Get the current focused content or DOM selection that should be the
450 * target for scrolling.
452 already_AddRefed
<nsIContent
> GetContentForScrolling() const;
455 * Get the DOM selection that should be the target for scrolling, if there
456 * is no focused content.
458 already_AddRefed
<nsIContent
> GetSelectedContentForScrolling() const;
461 * Gets nearest scrollable frame from the specified content node. The frame
462 * is scrollable with overflow:scroll or overflow:auto in some direction when
463 * aDirection is eEither. Otherwise, this returns a nearest frame that is
464 * scrollable in the specified direction.
466 nsIScrollableFrame
* GetScrollableFrameToScrollForContent(
467 nsIContent
* aContent
, layers::ScrollDirections aDirections
);
470 * Gets nearest scrollable frame from current focused content or DOM
471 * selection if there is no focused content. The frame is scrollable with
472 * overflow:scroll or overflow:auto in some direction when aDirection is
473 * eEither. Otherwise, this returns a nearest frame that is scrollable in
474 * the specified direction.
476 nsIScrollableFrame
* GetScrollableFrameToScroll(
477 layers::ScrollDirections aDirections
);
480 * Returns the page sequence frame associated with the frame hierarchy.
481 * Returns nullptr if not a paginated view.
483 nsPageSequenceFrame
* GetPageSequenceFrame() const;
486 * Returns the canvas frame associated with the frame hierarchy.
487 * Returns nullptr if is XUL document.
489 nsCanvasFrame
* GetCanvasFrame() const;
491 void PostPendingScrollAnchorSelection(
492 layout::ScrollAnchorContainer
* aContainer
);
493 void FlushPendingScrollAnchorSelections();
494 void PostPendingScrollAnchorAdjustment(
495 layout::ScrollAnchorContainer
* aContainer
);
497 void PostPendingScrollResnap(nsIScrollableFrame
* aScrollableFrame
);
498 void FlushPendingScrollResnap();
500 void CancelAllPendingReflows();
502 MOZ_CAN_RUN_SCRIPT_BOUNDARY
void NotifyCounterStylesAreDirty();
504 bool FrameIsAncestorOfDirtyRoot(nsIFrame
* aFrame
) const;
507 * Destroy the frames for aElement, and reconstruct them asynchronously if
510 * Note that this may destroy frames for an arbitrary ancestor, depending on
511 * the frame tree structure.
513 void DestroyFramesForAndRestyle(Element
* aElement
);
516 * Called when a ShadowRoot will be attached to an element (and thus the flat
517 * tree children will go away).
519 void ShadowRootWillBeAttached(Element
& aElement
);
522 * Handles all the layout stuff needed when the slot assignment for an element
523 * is about to change.
525 * Only called when the slot attribute of the element changes, the rest of
526 * the changes should be handled in ShadowRoot.
528 void SlotAssignmentWillChange(Element
& aElement
,
529 dom::HTMLSlotElement
* aOldSlot
,
530 dom::HTMLSlotElement
* aNewSlot
);
532 void PostRecreateFramesFor(Element
*);
533 void RestyleForAnimation(Element
*, RestyleHint
);
536 * Determine if it is safe to flush all pending notifications.
538 bool IsSafeToFlush() const;
541 * Informs the document's FontFaceSet that the refresh driver ticked,
542 * flushing style and layout.
544 void NotifyFontFaceSetOnRefresh();
546 // Removes ourself from the list of layout / style / and resize refresh driver
549 // Right now this is only used for documents in the BFCache, so if you want to
550 // use this for anything else you need to ensure we don't end up in those
551 // lists after calling this, but before calling StartObservingRefreshDriver
554 // That is handled by the mDocument->GetBFCacheEntry checks in
555 // DoObserve*Flushes functions, though that could conceivably become a boolean
556 // member in the shell if needed.
558 // Callers are responsible of manually calling StartObservingRefreshDriver
560 void StopObservingRefreshDriver();
561 void StartObservingRefreshDriver();
563 bool ObservingStyleFlushes() const { return mObservingStyleFlushes
; }
564 bool ObservingLayoutFlushes() const { return mObservingLayoutFlushes
; }
566 void ObserveStyleFlushes() {
567 if (!ObservingStyleFlushes()) {
568 DoObserveStyleFlushes();
573 * Callbacks will be called even if reflow itself fails for
576 nsresult
PostReflowCallback(nsIReflowCallback
* aCallback
);
577 void CancelReflowCallback(nsIReflowCallback
* aCallback
);
579 void ScheduleBeforeFirstPaint();
580 void UnsuppressAndInvalidate();
582 void ClearFrameRefs(nsIFrame
* aFrame
);
584 // Clears the selection of the older focused frame selection if any.
585 void FrameSelectionWillTakeFocus(nsFrameSelection
&);
587 // Clears and repaint mFocusedFrameSelection if it matches the argument.
588 void FrameSelectionWillLoseFocus(nsFrameSelection
&);
591 * Get a reference rendering context. This is a context that should not
592 * be rendered to, but is suitable for measuring text and performing
593 * other non-rendering operations. Guaranteed to return non-null.
595 mozilla::UniquePtr
<gfxContext
> CreateReferenceRenderingContext();
598 * Scrolls the view of the document so that the given area of a frame
599 * is visible, if possible. Layout is not flushed before scrolling.
601 * @param aRect Relative to aTargetFrame. If none, the bounding box of
602 * aTargetFrame will be used. The rect edges will be respected even if the
604 * @param aVertical see ScrollContentIntoView and ScrollAxis
605 * @param aHorizontal see ScrollContentIntoView and ScrollAxis
606 * @param aScrollFlags if ScrollFirstAncestorOnly is set, only the
607 * nearest scrollable ancestor is scrolled, otherwise all
608 * scrollable ancestors may be scrolled if necessary
609 * if ScrollOverflowHidden is set then we may scroll in a direction
610 * even if overflow:hidden is specified in that direction; otherwise
611 * we will not scroll in that direction when overflow:hidden is
612 * set for that direction
613 * If ScrollNoParentFrames is set then we only scroll
614 * nodes in this document, not in any parent documents which
615 * contain this document in a iframe or the like.
616 * @return true if any scrolling happened, false if no scrolling happened
619 bool ScrollFrameIntoView(nsIFrame
* aTargetFrame
,
620 const Maybe
<nsRect
>& aKnownRectRelativeToTarget
,
621 ScrollAxis aVertical
, ScrollAxis aHorizontal
,
622 ScrollFlags aScrollFlags
);
625 * Suppress notification of the frame manager that frames are
628 void SetIgnoreFrameDestruction(bool aIgnore
);
631 * Get the AccessibleCaretEventHub, if it exists. AddRefs it.
633 already_AddRefed
<AccessibleCaretEventHub
> GetAccessibleCaretEventHub() const;
636 * Get the caret, if it exists. AddRefs it.
638 already_AddRefed
<nsCaret
> GetCaret() const;
641 * Set the current caret to a new caret. To undo this, call RestoreCaret.
643 void SetCaret(nsCaret
* aNewCaret
);
646 * Restore the caret to the original caret that this pres shell was created
651 dom::Selection
* GetCurrentSelection(SelectionType aSelectionType
);
654 * Gets the last selection that took focus in this document. This is basically
655 * the frame selection that's visible to the user.
657 nsFrameSelection
* GetLastFocusedFrameSelection();
660 * Interface to dispatch events via the presshell
661 * @note The caller must have a strong reference to the PresShell.
664 nsresult
HandleEventWithTarget(WidgetEvent
* aEvent
, nsIFrame
* aFrame
,
665 nsIContent
* aContent
,
666 nsEventStatus
* aEventStatus
,
667 bool aIsHandlingNativeEvent
= false,
668 nsIContent
** aTargetContent
= nullptr,
669 nsIContent
* aOverrideClickTarget
= nullptr) {
671 EventHandler
eventHandler(*this);
672 return eventHandler
.HandleEventWithTarget(
673 aEvent
, aFrame
, aContent
, aEventStatus
, aIsHandlingNativeEvent
,
674 aTargetContent
, aOverrideClickTarget
);
678 * Dispatch event to content only (NOT full processing)
681 nsresult
HandleDOMEventWithTarget(nsIContent
* aTargetContent
,
683 nsEventStatus
* aStatus
);
686 * Dispatch event to content only (NOT full processing)
689 nsresult
HandleDOMEventWithTarget(nsIContent
* aTargetContent
,
690 dom::Event
* aEvent
, nsEventStatus
* aStatus
);
693 * Return whether or not the event is valid to be dispatched
695 bool CanDispatchEvent(const WidgetGUIEvent
* aEvent
= nullptr) const;
698 * Gets the current target event frame from the PresShell
700 nsIFrame
* GetCurrentEventFrame();
703 * Gets the current target event frame from the PresShell
705 already_AddRefed
<nsIContent
> GetEventTargetContent(WidgetEvent
* aEvent
);
708 * Get and set the history state for the current document
710 nsresult
CaptureHistoryState(nsILayoutHistoryState
** aLayoutHistoryState
);
713 * Determine if reflow is currently locked
714 * returns true if reflow is locked, false otherwise
716 bool IsReflowLocked() const { return mIsReflowing
; }
719 * Called to find out if painting is suppressed for this presshell. If it is
720 * suppressd, we don't allow the painting of any layer but the background, and
721 * we don't recur into our children.
723 bool IsPaintingSuppressed() const { return mPaintingSuppressed
; }
725 void TryUnsuppressPaintingSoon();
727 void UnsuppressPainting();
728 void InitPaintSuppressionTimer();
729 void CancelPaintSuppressionTimer();
732 * Reconstruct frames for all elements in the document
734 MOZ_CAN_RUN_SCRIPT
void ReconstructFrames();
737 * See if reflow verification is enabled. To enable reflow verification add
738 * "verifyreflow:1" to your MOZ_LOG environment variable (any non-zero
739 * debug level will work). Or, call SetVerifyReflowEnable with true.
741 static bool GetVerifyReflowEnable();
744 * Set the verify-reflow enable flag.
746 static void SetVerifyReflowEnable(bool aEnabled
);
748 nsIFrame
* GetAbsoluteContainingBlock(nsIFrame
* aFrame
);
750 #ifdef MOZ_REFLOW_PERF
752 void CountReflows(const char* aName
, nsIFrame
* aFrame
);
753 void PaintCount(const char* aName
, gfxContext
* aRenderingContext
,
754 nsPresContext
* aPresContext
, nsIFrame
* aFrame
,
755 const nsPoint
& aOffset
, uint32_t aColor
);
756 void SetPaintFrameCount(bool aOn
);
757 bool IsPaintingFrameCounts();
758 #endif // #ifdef MOZ_REFLOW_PERF
762 void ListComputedStyles(FILE* out
, int32_t aIndent
= 0);
764 #if defined(DEBUG) || defined(MOZ_LAYOUT_DEBUGGER)
765 void ListStyleSheets(FILE* out
, int32_t aIndent
= 0);
769 * Stop all refresh drivers and carets in this presentation and
770 * in the presentations of subdocuments. Resets painting to a suppressed
772 * XXX this should include image animations
774 void Freeze(bool aIncludeSubDocuments
= true);
775 bool IsFrozen() { return mFrozen
; }
778 * Restarts refresh drivers in this presentation and in the
779 * presentations of subdocuments, then do a full invalidate of the content
782 void Thaw(bool aIncludeSubDocuments
= true);
784 void FireOrClearDelayedEvents(bool aFireEvents
);
787 * When this shell is disconnected from its containing docshell, we
788 * lose our container pointer. However, we'd still like to be able to target
789 * user events at the docshell's parent. This pointer allows us to do that.
790 * It should not be used for any other purpose.
792 void SetForwardingContainer(const WeakPtr
<nsDocShell
>& aContainer
);
795 * Render the document into an arbitrary gfxContext
796 * Designed for getting a picture of a document or a piece of a document
797 * Note that callers will generally want to call FlushPendingNotifications
798 * to get an up-to-date view of the document
799 * @param aRect is the region to capture into the offscreen buffer, in the
800 * root frame's coordinate system (if aIgnoreViewportScrolling is false)
801 * or in the root scrolled frame's coordinate system
802 * (if aIgnoreViewportScrolling is true). The coordinates are in appunits.
803 * @param aFlags see below;
804 * set RenderDocumentFlags::IsUntrusted if the contents may be passed to
805 * malicious agents. E.g. we might choose not to paint the contents of
806 * sensitive widgets such as the file name in a file upload widget, and we
807 * might choose not to paint themes.
808 * set RenderDocumentFlags::IgnoreViewportScrolling to ignore clipping and
809 * scrollbar painting due to scrolling in the viewport
810 * set RenderDocumentFlags::ResetViewportScrolling to temporarily set the
811 * viewport scroll position to 0 so that position:fixed elements are drawn
812 * at their initial position.
813 * set RenderDocumentFlags::DrawCaret to draw the caret if one would be
814 * visible (by default the caret is never drawn)
815 * set RenderDocumentFlags::UseWidgetLayers to force rendering to go
816 * through the layer manager for the window. This may be unexpectedly slow
817 * (if the layer manager must read back data from the GPU) or low-quality
818 * (if the layer manager reads back pixel data and scales it
819 * instead of rendering using the appropriate scaling). It may also
820 * slow everything down if the area rendered does not correspond to the
821 * normal visible area of the window.
822 * set RenderDocumentFlags::AsyncDecodeImages to avoid having images
823 * synchronously decoded during rendering.
824 * (by default images decode synchronously with RenderDocument)
825 * set RenderDocumentFlags::DocumentRelative to render the document as if
826 * there has been no scrolling and interpret |aRect| relative to the document
827 * instead of the CSS viewport. Only considered if
828 * RenderDocumentFlags::IgnoreViewportScrolling is set or the document is in
829 * ignore viewport scrolling mode
830 * (PresShell::SetIgnoreViewportScrolling/IgnoringViewportScrolling).
831 * set RenderDocumentFlags::UseHighQualityScaling to enable downscale on
833 * @param aBackgroundColor a background color to render onto
834 * @param aRenderedContext the gfxContext to render to. We render so that
835 * one CSS pixel in the source document is rendered to one unit in the current
838 nsresult
RenderDocument(const nsRect
& aRect
, RenderDocumentFlags aFlags
,
839 nscolor aBackgroundColor
,
840 gfxContext
* aRenderedContext
);
843 * Renders a node aNode to a surface and returns it. The aRegion may be used
844 * to clip the rendering. This region is measured in CSS pixels from the
845 * edge of the presshell area. The aPoint, aScreenRect and aFlags arguments
846 * function in a similar manner as RenderSelection.
848 already_AddRefed
<SourceSurface
> RenderNode(nsINode
* aNode
,
849 const Maybe
<CSSIntRegion
>& aRegion
,
850 const LayoutDeviceIntPoint aPoint
,
851 LayoutDeviceIntRect
* aScreenRect
,
852 RenderImageFlags aFlags
);
855 * Renders a selection to a surface and returns it. This method is primarily
856 * intended to create the drag feedback when dragging a selection.
858 * aScreenRect will be filled in with the bounding rectangle of the
859 * selection area on screen.
861 * If the area of the selection is large and the RenderImageFlags::AutoScale
862 * is set, the image will be scaled down. The argument aPoint is used in this
863 * case as a reference point when determining the new screen rectangle after
864 * scaling. Typically, this will be the mouse position, so that the screen
865 * rectangle is positioned such that the mouse is over the same point in the
866 * scaled image as in the original. When scaling does not occur, the mouse
867 * point isn't used because the position can be determined from the displayed
870 already_AddRefed
<SourceSurface
> RenderSelection(
871 dom::Selection
* aSelection
, const LayoutDeviceIntPoint aPoint
,
872 LayoutDeviceIntRect
* aScreenRect
, RenderImageFlags aFlags
);
874 void AddAutoWeakFrame(AutoWeakFrame
* aWeakFrame
);
875 void AddWeakFrame(WeakFrame
* aWeakFrame
);
877 void RemoveAutoWeakFrame(AutoWeakFrame
* aWeakFrame
);
878 void RemoveWeakFrame(WeakFrame
* aWeakFrame
);
881 * Stop or restart non synthetic test mouse event handling on *all*
884 * @param aDisable If true, disable all non synthetic test mouse
885 * events on all presShells. Otherwise, enable them.
887 void DisableNonTestMouseEvents(bool aDisable
);
890 * Record the background color of the most recently drawn canvas. This color
891 * is composited on top of the user's default background color and then used
892 * to draw the background color of the canvas. See PresShell::Paint,
893 * PresShell::PaintDefaultBackground, and nsDocShell::SetupNewViewer;
894 * bug 488242, bug 476557 and other bugs mentioned there.
896 void SetCanvasBackground(nscolor aColor
) {
897 mCanvasBackground
.mViewportColor
= aColor
;
899 nscolor
GetCanvasBackground() const {
900 return mCanvasBackground
.mViewportColor
;
903 struct CanvasBackground
{
904 // The canvas frame background for the whole viewport.
905 nscolor mViewportColor
= 0;
906 // The canvas frame background for a printed page. Note that when
907 // print-previewing / in paged mode we have multiple canvas frames (one for
908 // the viewport, one for each page).
909 nscolor mPageColor
= 0;
910 bool mCSSSpecified
= false;
913 // Use the current frame tree (if it exists) to update the background color of
914 // the canvas frames.
915 CanvasBackground
ComputeCanvasBackground() const;
916 void UpdateCanvasBackground();
919 * Computes the backstop color for the view: transparent if in a transparent
920 * widget, otherwise the PresContext default background color. This color is
921 * only visible if the contents of the view as a whole are translucent.
923 nscolor
ComputeBackstopColor(nsView
* aDisplayRoot
);
925 void ObserveNativeAnonMutationsForPrint(bool aObserve
) {
926 mObservesMutationsForPrint
= aObserve
;
928 bool ObservesNativeAnonMutationsForPrint() {
929 return mObservesMutationsForPrint
;
932 void ActivenessMaybeChanged();
933 bool IsActive() const { return mIsActive
; }
936 * Keep track of how many times this presshell has been rendered to
939 uint64_t GetPaintCount() { return mPaintCount
; }
940 void IncrementPaintCount() { ++mPaintCount
; }
943 * Get the root DOM window of this presShell.
945 already_AddRefed
<nsPIDOMWindowOuter
> GetRootWindow();
948 * This returns the focused DOM window under our top level window.
949 * I.e., when we are deactive, this returns the *last* focused DOM window.
951 already_AddRefed
<nsPIDOMWindowOuter
> GetFocusedDOMWindowInOurWindow();
954 * Get the focused content under this window.
956 already_AddRefed
<nsIContent
> GetFocusedContentInOurWindow() const;
959 * Get the window renderer for the widget of the root view, if it has
962 WindowRenderer
* GetWindowRenderer();
965 * Return true iff there is a widget rendering this presShell and that
966 * widget is APZ-enabled.
968 bool AsyncPanZoomEnabled();
971 * Track whether we're ignoring viewport scrolling for the purposes
972 * of painting. If we are ignoring, then layers aren't clipped to
973 * the CSS viewport and scrollbars aren't drawn.
975 bool IgnoringViewportScrolling() const {
976 return !!(mRenderingStateFlags
&
977 RenderingStateFlags::IgnoringViewportScrolling
);
980 float GetResolution() const { return mResolution
.valueOr(1.0); }
981 float GetCumulativeResolution() const;
984 * Accessors for a flag that tracks whether the most recent change to
985 * the pres shell's resolution was originated by the main thread.
987 bool IsResolutionUpdated() const { return mResolutionUpdated
; }
988 void SetResolutionUpdated(bool aUpdated
) { mResolutionUpdated
= aUpdated
; }
991 * Returns true if the resolution has ever been changed by APZ.
993 bool IsResolutionUpdatedByApz() const { return mResolutionUpdatedByApz
; }
996 * Used by session restore code to restore a resolution before the first
999 void SetRestoreResolution(float aResolution
,
1000 LayoutDeviceIntSize aDisplaySize
);
1003 * Returns whether we are in a DrawWindow() call that used the
1004 * DRAWWINDOW_DO_NOT_FLUSH flag.
1006 bool InDrawWindowNotFlushing() const {
1007 return !!(mRenderingStateFlags
&
1008 RenderingStateFlags::DrawWindowNotFlushing
);
1012 * Set the isFirstPaint flag.
1014 void SetIsFirstPaint(bool aIsFirstPaint
) { mIsFirstPaint
= aIsFirstPaint
; }
1017 * Get the isFirstPaint flag.
1019 bool GetIsFirstPaint() const { return mIsFirstPaint
; }
1021 uint32_t GetPresShellId() { return mPresShellId
; }
1024 * Dispatch a mouse move event based on the most recent mouse position if
1025 * this PresShell is visible. This is used when the contents of the page
1026 * moved (aFromScroll is false) or scrolled (aFromScroll is true).
1028 void SynthesizeMouseMove(bool aFromScroll
);
1031 nsresult
HandleEvent(nsIFrame
* aFrame
, WidgetGUIEvent
* aEvent
,
1032 bool aDontRetargetEvents
, nsEventStatus
* aEventStatus
);
1033 bool ShouldIgnoreInvalidation();
1035 * Notify that we called Paint with PaintFlags::PaintComposite.
1036 * Fires on the presshell for the painted widget.
1037 * This is issued at a time when it's safe to modify widget geometry.
1039 MOZ_CAN_RUN_SCRIPT
void DidPaintWindow();
1041 bool IsVisible() const;
1042 bool IsUnderHiddenEmbedderElement() const {
1043 return mUnderHiddenEmbedderElement
;
1045 void SetIsUnderHiddenEmbedderElement(bool aUnderHiddenEmbedderElement
) {
1046 mUnderHiddenEmbedderElement
= aUnderHiddenEmbedderElement
;
1050 void DispatchSynthMouseMove(WidgetGUIEvent
* aEvent
);
1052 /* Temporarily ignore the Displayport for better paint performance. We
1053 * trigger a repaint once suppression is disabled. Without that
1054 * the displayport may get left at the suppressed size for an extended
1055 * period of time and result in unnecessary checkerboarding (see bug
1057 void SuppressDisplayport(bool aEnabled
);
1059 /* Whether or not displayport suppression should be turned on. Note that
1060 * this only affects the return value of |IsDisplayportSuppressed()|, and
1061 * doesn't change the value of the internal counter.
1063 void RespectDisplayportSuppression(bool aEnabled
);
1065 /* Whether or not the displayport is currently suppressed. */
1066 bool IsDisplayportSuppressed();
1068 void AddSizeOfIncludingThis(nsWindowSizes
& aWindowSizes
) const;
1071 * Methods that retrieve the cached font inflation preferences.
1073 uint32_t FontSizeInflationEmPerLine() const {
1074 return mFontSizeInflationEmPerLine
;
1077 uint32_t FontSizeInflationMinTwips() const {
1078 return mFontSizeInflationMinTwips
;
1081 uint32_t FontSizeInflationLineThreshold() const {
1082 return mFontSizeInflationLineThreshold
;
1085 bool FontSizeInflationForceEnabled() const {
1086 return mFontSizeInflationForceEnabled
;
1089 bool FontSizeInflationDisabledInMasterProcess() const {
1090 return mFontSizeInflationDisabledInMasterProcess
;
1093 bool FontSizeInflationEnabled() const { return mFontSizeInflationEnabled
; }
1096 * Recomputes whether font-size inflation is enabled.
1098 void RecomputeFontSizeInflationEnabled();
1101 * Return true if the most recent interruptible reflow was interrupted.
1103 bool IsReflowInterrupted() const { return mWasLastReflowInterrupted
; }
1106 * Return true if the the interruptible reflows have to be suppressed.
1107 * This may happen only if if the most recent reflow was interrupted.
1109 bool SuppressInterruptibleReflows() const {
1110 return mWasLastReflowInterrupted
;
1113 //////////////////////////////////////////////////////////////////////////////
1114 // Approximate frame visibility tracking public API.
1115 //////////////////////////////////////////////////////////////////////////////
1118 * Schedule an update of the list of approximately visible frames "soon".
1119 * This lets the refresh driver know that we want a visibility update in the
1120 * near future. The refresh driver applies its own heuristics and throttling
1121 * to decide when to actually perform the visibility update.
1123 void ScheduleApproximateFrameVisibilityUpdateSoon();
1126 * Schedule an update of the list of approximately visible frames "now". The
1127 * update runs asynchronously, but it will be posted to the event loop
1128 * immediately. Prefer the "soon" variation of this method when possible, as
1129 * this variation ignores the refresh driver's heuristics.
1131 void ScheduleApproximateFrameVisibilityUpdateNow();
1134 * Clears the current list of approximately visible frames on this pres shell
1135 * and replaces it with frames that are in the display list @aList.
1137 void RebuildApproximateFrameVisibilityDisplayList(const nsDisplayList
& aList
);
1138 void RebuildApproximateFrameVisibility(nsRect
* aRect
= nullptr,
1139 bool aRemoveOnly
= false);
1142 * Ensures @aFrame is in the list of approximately visible frames.
1144 void EnsureFrameInApproximatelyVisibleList(nsIFrame
* aFrame
);
1146 /// Removes @aFrame from the list of approximately visible frames if present.
1147 void RemoveFrameFromApproximatelyVisibleList(nsIFrame
* aFrame
);
1149 /// Whether we should assume all frames are visible.
1150 bool AssumeAllFramesVisible();
1153 * Returns whether the document's style set's rule processor for the
1154 * specified level of the cascade is shared by multiple style sets.
1156 * @param aSheetType One of the nsIStyleSheetService.*_SHEET constants.
1158 nsresult
HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType
,
1162 * Returns whether or not the document has ever handled user input
1164 bool HasHandledUserInput() const { return mHasHandledUserInput
; }
1166 MOZ_CAN_RUN_SCRIPT
void FireResizeEvent();
1167 MOZ_CAN_RUN_SCRIPT
void FireResizeEventSync();
1169 void NativeAnonymousContentRemoved(nsIContent
* aAnonContent
);
1172 * See HTMLDocument.setKeyPressEventModel() in HTMLDocument.webidl for the
1175 void SetKeyPressEventModel(uint16_t aKeyPressEventModel
) {
1176 mForceUseLegacyKeyCodeAndCharCodeValues
|=
1177 aKeyPressEventModel
==
1178 dom::Document_Binding::KEYPRESS_EVENT_MODEL_SPLIT
;
1181 bool AddRefreshObserver(nsARefreshObserver
* aObserver
, FlushType aFlushType
,
1182 const char* aObserverDescription
);
1183 bool RemoveRefreshObserver(nsARefreshObserver
* aObserver
,
1184 FlushType aFlushType
);
1186 bool AddPostRefreshObserver(nsAPostRefreshObserver
*);
1187 bool AddPostRefreshObserver(mozilla::ManagedPostRefreshObserver
*) = delete;
1188 bool RemovePostRefreshObserver(nsAPostRefreshObserver
*);
1189 bool RemovePostRefreshObserver(mozilla::ManagedPostRefreshObserver
*) = delete;
1191 // Represents an update to the visual scroll offset that will be sent to APZ.
1192 // The update type is used to determine priority compared to other scroll
1194 struct VisualScrollUpdate
{
1195 nsPoint mVisualScrollOffset
;
1196 FrameMetrics::ScrollOffsetUpdateType mUpdateType
;
1197 bool mAcknowledged
= false;
1200 // Ask APZ in the next transaction to scroll to the given visual viewport
1201 // offset (relative to the document).
1202 // This is intended to be used when desired in cases where the browser
1203 // internally triggers scrolling; scrolling triggered explicitly by web
1204 // content (such as via window.scrollTo() should scroll the layout viewport
1206 // If scrolling "far away", i.e. not just within the existing layout
1207 // viewport, it's recommended to use both nsIScrollableFrame.ScrollTo*()
1208 // (via window.scrollTo if calling from JS) *and* this function; otherwise,
1209 // temporary checkerboarding may result. If doing this:
1210 // * Be sure to call ScrollTo*() first, as a subsequent layout scroll
1211 // in the same transaction will cancel the pending visual scroll.
1212 // * Keep in mind that ScrollTo*() can tear down the pres shell and
1213 // frame tree. Depending on how the pres shell is obtained for the
1214 // subsequent ScrollToVisual() call, AutoWeakFrame or similar may
1216 // Please request APZ review if adding a new call site.
1217 void ScrollToVisual(const nsPoint
& aVisualViewportOffset
,
1218 FrameMetrics::ScrollOffsetUpdateType aUpdateType
,
1220 void AcknowledgePendingVisualScrollUpdate();
1221 void ClearPendingVisualScrollUpdate();
1222 const Maybe
<VisualScrollUpdate
>& GetPendingVisualScrollUpdate() const {
1223 return mPendingVisualScrollUpdate
;
1226 nsPoint
GetLayoutViewportOffset() const;
1227 nsSize
GetLayoutViewportSize() const;
1230 * Documents belonging to an invisible DocShell must not be painted ever.
1232 bool IsNeverPainting() { return mIsNeverPainting
; }
1234 void SetNeverPainting(bool aNeverPainting
) {
1235 mIsNeverPainting
= aNeverPainting
;
1239 * True if a reflow event has been scheduled, or is going to be scheduled
1240 * to run in the future.
1242 bool HasPendingReflow() const {
1243 return mObservingLayoutFlushes
|| mReflowContinueTimer
;
1246 void SyncWindowProperties(bool aSync
);
1247 struct WindowSizeConstraints
{
1251 WindowSizeConstraints
GetWindowSizeConstraints();
1253 Document
* GetPrimaryContentDocument();
1255 struct MOZ_RAII AutoAssertNoFlush
{
1256 explicit AutoAssertNoFlush(PresShell
& aPresShell
)
1257 : mPresShell(aPresShell
), mOldForbidden(mPresShell
.mForbiddenToFlush
) {
1258 mPresShell
.mForbiddenToFlush
= true;
1261 ~AutoAssertNoFlush() { mPresShell
.mForbiddenToFlush
= mOldForbidden
; }
1263 PresShell
& mPresShell
;
1264 const bool mOldForbidden
;
1267 NS_IMETHOD
GetSelectionFromScript(RawSelectionType aRawSelectionType
,
1268 dom::Selection
** aSelection
) override
;
1269 dom::Selection
* GetSelection(RawSelectionType aRawSelectionType
) override
;
1271 NS_IMETHOD
SetDisplaySelection(int16_t aToggle
) override
;
1272 NS_IMETHOD
GetDisplaySelection(int16_t* aToggle
) override
;
1273 NS_IMETHOD
ScrollSelectionIntoView(RawSelectionType aRawSelectionType
,
1274 SelectionRegion aRegion
,
1275 int16_t aFlags
) override
;
1276 NS_IMETHOD
RepaintSelection(RawSelectionType aRawSelectionType
) override
;
1277 void SelectionWillTakeFocus() override
;
1278 void SelectionWillLoseFocus() override
;
1280 // Implements the "focus fix-up rule". Returns true if the focus moved (in
1281 // which case we might need to update layout again).
1282 // See https://github.com/whatwg/html/issues/8225
1283 MOZ_CAN_RUN_SCRIPT
bool FixUpFocus();
1286 * Set a "resolution" for the document, which if not 1.0 will
1287 * allocate more or fewer pixels for rescalable content by a factor
1288 * of |resolution| in both dimensions. Return NS_OK iff the
1289 * resolution bounds are sane, and the resolution of this was
1292 * Also increase the scale of the content by the same amount
1293 * (that's the "AndScaleTo" part).
1295 * The resolution defaults to 1.0.
1297 * |aOrigin| specifies who originated the resolution change. For changes
1298 * sent by APZ, pass ResolutionChangeOrigin::Apz. For changes sent by
1299 * the main thread, pass ResolutionChangeOrigin::MainThreadAdjustment (similar
1300 * to the |aOrigin| parameter of nsIScrollableFrame::ScrollToCSSPixels()).
1302 nsresult
SetResolutionAndScaleTo(float aResolution
,
1303 ResolutionChangeOrigin aOrigin
);
1305 ResolutionChangeOrigin
GetLastResolutionChangeOrigin() {
1306 return mLastResolutionChangeOrigin
;
1309 // Widget notificiations
1310 void WindowSizeMoveDone();
1312 void BackingScaleFactorChanged() { mPresContext
->UIResolutionChangedSync(); }
1315 * Does any painting work required to update retained paint state, and pushes
1316 * it the compositor (if any). Requests a composite, either by scheduling a
1317 * remote composite, or invalidating the widget so that we get a call to
1318 * SyncPaintFallback from the widget paint event.
1321 void PaintAndRequestComposite(nsView
* aView
, PaintFlags aFlags
);
1324 * Does an immediate paint+composite using the FallbackRenderer (which must
1325 * be the current WindowRenderer for the root frame's widget).
1328 void SyncPaintFallback(nsView
* aView
);
1331 * Notify that we're going to call Paint with PaintFlags::PaintLayers
1332 * on the pres shell for a widget (which might not be this one, since
1333 * WillPaint is called on all presshells in the same toplevel window as the
1334 * painted widget). This is issued at a time when it's safe to modify
1337 MOZ_CAN_RUN_SCRIPT
void WillPaint();
1340 * Ensures that the refresh driver is running, and schedules a view
1341 * manager flush on the next tick.
1343 void ScheduleViewManagerFlush();
1346 NS_IMETHOD
SetCaretEnabled(bool aInEnable
) override
;
1347 NS_IMETHOD
SetCaretReadOnly(bool aReadOnly
) override
;
1348 NS_IMETHOD
GetCaretEnabled(bool* aOutEnabled
) override
;
1349 NS_IMETHOD
SetCaretVisibilityDuringSelection(bool aVisibility
) override
;
1350 NS_IMETHOD
GetCaretVisible(bool* _retval
) override
;
1353 * Should the images have borders etc. Actual visual effects are determined
1354 * by the frames. Visual effects may not effect layout, only display.
1355 * Takes effect on next repaint, does not force a repaint itself.
1357 * @param aFlags may be multiple of nsISelectionDisplay::DISPLAY_*.
1359 NS_IMETHOD
SetSelectionFlags(int16_t aFlags
) override
;
1360 NS_IMETHOD
GetSelectionFlags(int16_t* aFlags
) override
;
1363 * Gets the current state of non text selection effects
1364 * @return current state of non text selection,
1365 * as set by SetDisplayNonTextSelection
1367 int16_t GetSelectionFlags() const { return mSelectionFlags
; }
1369 // nsISelectionController
1371 NS_IMETHOD
PhysicalMove(int16_t aDirection
, int16_t aAmount
,
1372 bool aExtend
) override
;
1373 NS_IMETHOD
CharacterMove(bool aForward
, bool aExtend
) override
;
1374 MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHOD
WordMove(bool aForward
,
1375 bool aExtend
) override
;
1376 MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHOD
LineMove(bool aForward
,
1377 bool aExtend
) override
;
1378 NS_IMETHOD
IntraLineMove(bool aForward
, bool aExtend
) override
;
1380 NS_IMETHOD
PageMove(bool aForward
, bool aExtend
) override
;
1381 NS_IMETHOD
ScrollPage(bool aForward
) override
;
1382 NS_IMETHOD
ScrollLine(bool aForward
) override
;
1383 NS_IMETHOD
ScrollCharacter(bool aRight
) override
;
1384 NS_IMETHOD
CompleteScroll(bool aForward
) override
;
1385 MOZ_CAN_RUN_SCRIPT NS_IMETHOD
CompleteMove(bool aForward
,
1386 bool aExtend
) override
;
1388 // Notifies that the state of the document has changed.
1389 void DocumentStatesChanged(dom::DocumentState
);
1391 // nsIDocumentObserver
1392 NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD
1393 NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD
1394 NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED
1396 // nsIMutationObserver
1397 NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
1398 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE
1399 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
1400 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
1401 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
1402 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
1406 // Inline methods defined in PresShellInlines.h
1407 inline void EnsureStyleFlush();
1408 inline void SetNeedStyleFlush();
1409 inline void SetNeedLayoutFlush();
1410 inline void SetNeedThrottledAnimationFlush();
1411 inline ServoStyleSet
* StyleSet() const;
1414 * Whether we might need a flush for the given flush type. If this
1415 * function returns false, we definitely don't need to flush.
1417 * @param aFlushType The flush type to check. This must be
1418 * >= FlushType::Style. This also returns true if a throttled
1419 * animation flush is required.
1421 bool NeedFlush(FlushType aType
) const {
1422 // We check mInFlush to handle re-entrant calls to FlushPendingNotifications
1423 // by reporting that we always need a flush in that case. Otherwise,
1424 // we could end up missing needed flushes, since we clear the mNeedXXXFlush
1425 // flags at the top of FlushPendingNotifications.
1426 MOZ_ASSERT(aType
>= FlushType::Style
);
1427 return mNeedStyleFlush
||
1428 (mNeedLayoutFlush
&& aType
>= FlushType::InterruptibleLayout
) ||
1429 aType
>= FlushType::Display
|| mNeedThrottledAnimationFlush
||
1434 * Returns true if we might need to flush layout, even if we haven't scheduled
1435 * one yet (as opposed to HasPendingReflow, which returns true if a flush is
1436 * scheduled or will soon be scheduled).
1438 bool NeedLayoutFlush() const { return mNeedLayoutFlush
; }
1440 bool NeedStyleFlush() const { return mNeedStyleFlush
; }
1443 * Flush pending notifications of the type specified. This method
1444 * will not affect the content model; it'll just affect style and
1445 * frames. Callers that actually want up-to-date presentation (other
1446 * than the document itself) should probably be calling
1447 * Document::FlushPendingNotifications.
1449 * This method can execute script, which can destroy this presshell object
1450 * unless someone is holding a reference to it on the stack. The presshell
1451 * itself will ensure it lives up until the method returns, but callers who
1452 * plan to use the presshell after this call should hold a strong ref
1455 * @param aType the type of notifications to flush
1458 void FlushPendingNotifications(FlushType aType
) {
1459 if (!NeedFlush(aType
)) {
1463 DoFlushPendingNotifications(aType
);
1467 void FlushPendingNotifications(ChangesToFlush aType
) {
1468 if (!NeedFlush(aType
.mFlushType
)) {
1472 DoFlushPendingNotifications(aType
);
1476 * Tell the pres shell that a frame needs to be marked dirty and needs
1477 * Reflow. It's OK if this is an ancestor of the frame needing reflow as
1478 * long as the ancestor chain between them doesn't cross a reflow root.
1480 * The bit to add should be NS_FRAME_IS_DIRTY, NS_FRAME_HAS_DIRTY_CHILDREN
1481 * or nsFrameState(0); passing 0 means that dirty bits won't be set on the
1482 * frame or its ancestors/descendants, but that intrinsic widths will still
1483 * be marked dirty. Passing aIntrinsicDirty = eResize and aBitToAdd = 0
1484 * would result in no work being done, so don't do that.
1486 void FrameNeedsReflow(
1487 nsIFrame
* aFrame
, IntrinsicDirty aIntrinsicDirty
, nsFrameState aBitToAdd
,
1488 ReflowRootHandling aRootHandling
= ReflowRootHandling::InferFromBitToAdd
);
1491 * Calls FrameNeedsReflow on all fixed position children of the root frame.
1493 void MarkFixedFramesForReflow(IntrinsicDirty aIntrinsicDirty
);
1495 void MaybeReflowForInflationScreenSizeChange();
1497 // This function handles all the work after VisualViewportSize is set
1499 void CompleteChangeToVisualViewportSize();
1502 * The return value indicates whether the offset actually changed.
1504 bool SetVisualViewportOffset(const nsPoint
& aScrollOffset
,
1505 const nsPoint
& aPrevLayoutScrollPos
);
1507 void ResetVisualViewportOffset();
1508 nsPoint
GetVisualViewportOffset() const {
1509 if (mVisualViewportOffset
.isSome()) {
1510 return *mVisualViewportOffset
;
1512 return GetLayoutViewportOffset();
1514 bool IsVisualViewportOffsetSet() const {
1515 return mVisualViewportOffset
.isSome();
1518 void SetVisualViewportSize(nscoord aWidth
, nscoord aHeight
);
1519 void ResetVisualViewportSize();
1520 bool IsVisualViewportSizeSet() { return mVisualViewportSizeSet
; }
1521 nsSize
GetVisualViewportSize() {
1522 NS_ASSERTION(mVisualViewportSizeSet
,
1523 "asking for visual viewport size when its not set?");
1524 return mVisualViewportSize
;
1527 nsPoint
GetVisualViewportOffsetRelativeToLayoutViewport() const;
1529 // Returns state of the dynamic toolbar.
1530 DynamicToolbarState
GetDynamicToolbarState() const {
1531 if (!mPresContext
) {
1532 return DynamicToolbarState::None
;
1535 return mPresContext
->GetDynamicToolbarState();
1537 // Returns the visual viewport size during the dynamic toolbar is being
1539 nsSize
GetVisualViewportSizeUpdatedByDynamicToolbar() const;
1541 /* Enable/disable author style level. Disabling author style disables the
1542 * entire author level of the cascade, including the HTML preshint level.
1544 // XXX these could easily be inlined, but there is a circular #include
1545 // problem with nsStyleSet.
1546 void SetAuthorStyleDisabled(bool aDisabled
);
1547 bool GetAuthorStyleDisabled() const;
1550 * Update the style set somehow to take into account changed prefs which
1551 * affect document styling.
1553 void UpdatePreferenceStyles();
1555 // aSheetType is one of the nsIStyleSheetService *_SHEET constants.
1556 void NotifyStyleSheetServiceSheetAdded(StyleSheet
* aSheet
,
1557 uint32_t aSheetType
);
1558 void NotifyStyleSheetServiceSheetRemoved(StyleSheet
* aSheet
,
1559 uint32_t aSheetType
);
1561 // DoReflow returns whether the reflow finished without interruption
1562 // If aFrame is not the root frame, the caller must pass a non-null
1563 // aOverflowTracker.
1564 bool DoReflow(nsIFrame
* aFrame
, bool aInterruptible
,
1565 OverflowChangedTracker
* aOverflowTracker
);
1568 * Add a solid color item to the bottom of aList with frame aFrame and bounds
1569 * aBounds. aBackstopColor is composed behind the background color of the
1570 * canvas, and it is transparent by default.
1572 * We attempt to make the background color part of the scrolled canvas (to
1573 * reduce transparent layers), and if async scrolling is enabled (and the
1574 * background is opaque) then we add a second, unscrolled item to handle the
1575 * checkerboarding case.
1577 void AddCanvasBackgroundColorItem(
1578 nsDisplayListBuilder
* aBuilder
, nsDisplayList
* aList
, nsIFrame
* aFrame
,
1579 const nsRect
& aBounds
, nscolor aBackstopColor
= NS_RGBA(0, 0, 0, 0));
1581 size_t SizeOfTextRuns(MallocSizeOf aMallocSizeOf
) const;
1583 static PresShell
* GetShellForEventTarget(nsIFrame
* aFrame
,
1584 nsIContent
* aContent
);
1585 static PresShell
* GetShellForTouchEvent(WidgetGUIEvent
* aEvent
);
1588 * Informs the pres shell that the document is now at the anchor with
1589 * the given name. If |aScroll| is true, scrolls the view of the
1590 * document so that the anchor with the specified name is displayed at
1591 * the top of the window. If |aAnchorName| is empty, then this informs
1592 * the pres shell that there is no current target, and |aScroll| must
1593 * be false. If |aAdditionalScrollFlags| is ScrollFlags::ScrollSmoothAuto
1594 * and |aScroll| is true, the scrolling may be performed with an animation.
1597 nsresult
GoToAnchor(const nsAString
& aAnchorName
, bool aScroll
,
1598 ScrollFlags aAdditionalScrollFlags
= ScrollFlags::None
);
1601 * Tells the presshell to scroll again to the last anchor scrolled to by
1602 * GoToAnchor, if any. This scroll only happens if the scroll
1603 * position has not changed since the last GoToAnchor (modulo scroll anchoring
1604 * adjustments). This is called by nsDocumentViewer::LoadComplete. This clears
1605 * the last anchor scrolled to by GoToAnchor (we don't want to keep it alive
1606 * if it's removed from the DOM), so don't call this more than once.
1608 MOZ_CAN_RUN_SCRIPT nsresult
ScrollToAnchor();
1611 * When scroll anchoring adjusts positions in the root frame during page load,
1612 * it may move our scroll position in the root frame.
1614 * While that's generally desirable, when scrolling to an anchor via an id-ref
1615 * we have a more direct target. If the id-ref points to something that cannot
1616 * be selected as a scroll anchor container (like an image or an inline), we
1617 * may select a node following it as a scroll anchor, and if then stuff is
1618 * inserted on top, we may end up moving the id-ref element offscreen to the
1619 * top inadvertently.
1621 * On page load, the document viewer will call ScrollToAnchor(), and will only
1622 * scroll to the anchor again if the scroll position is not changed. We don't
1623 * want scroll anchoring adjustments to prevent this, so account for them.
1625 void RootScrollFrameAdjusted(nscoord aYAdjustment
) {
1626 if (mLastAnchorScrolledTo
) {
1627 mLastAnchorScrollPositionY
+= aYAdjustment
;
1632 * Scrolls the view of the document so that the primary frame of the content
1633 * is displayed in the window. Layout is flushed before scrolling.
1635 * @param aContent The content object of which primary frame should be
1636 * scrolled into view.
1637 * @param aVertical How to align the frame vertically and when to do so.
1638 * This is a ScrollAxis of Where and When.
1639 * @param aHorizontal How to align the frame horizontally and when to do so.
1640 * This is a ScrollAxis of Where and When.
1641 * @param aScrollFlags If ScrollFlags::ScrollFirstAncestorOnly is set,
1642 * only the nearest scrollable ancestor is scrolled,
1643 * otherwise all scrollable ancestors may be scrolled
1644 * if necessary. If ScrollFlags::ScrollOverflowHidden
1645 * is set then we may scroll in a direction even if
1646 * overflow:hidden is specified in that direction;
1647 * otherwise we will not scroll in that direction when
1648 * overflow:hidden is set for that direction. If
1649 * ScrollFlags::ScrollNoParentFrames is set then we
1650 * only scroll nodes in this document, not in any
1651 * parent documents which contain this document in a
1652 * iframe or the like. If ScrollFlags::ScrollSmooth
1653 * is set and CSSOM-VIEW scroll-behavior is enabled,
1654 * we will scroll smoothly using
1655 * nsIScrollableFrame::ScrollMode::SMOOTH_MSD;
1656 * otherwise, nsIScrollableFrame::ScrollMode::INSTANT
1657 * will be used. If ScrollFlags::ScrollSmoothAuto is
1658 * set, the CSSOM-View scroll-behavior attribute is
1659 * set to 'smooth' on the scroll frame, and CSSOM-VIEW
1660 * scroll-behavior is enabled, we will scroll smoothly
1661 * using nsIScrollableFrame::ScrollMode::SMOOTH_MSD;
1662 * otherwise, nsIScrollableFrame::ScrollMode::INSTANT
1666 nsresult
ScrollContentIntoView(nsIContent
* aContent
, ScrollAxis aVertical
,
1667 ScrollAxis aHorizontal
,
1668 ScrollFlags aScrollFlags
);
1671 * When capturing content is set, it traps all mouse events and retargets
1672 * them at this content node. If capturing is not allowed
1673 * (gCaptureInfo.mAllowed is false), then capturing is not set. However, if
1674 * the CaptureFlags::IgnoreAllowedState is set, the allowed state is ignored
1675 * and capturing is set regardless. To disable capture, pass null for the
1676 * value of aContent.
1678 * If CaptureFlags::RetargetedToElement is set, all mouse events are
1679 * targeted at aContent only. Otherwise, mouse events are targeted at
1680 * aContent or its descendants. That is, descendants of aContent receive
1681 * mouse events as they normally would, but mouse events outside of aContent
1682 * are retargeted to aContent.
1684 * If CaptureFlags::PreventDragStart is set then drags are prevented from
1685 * starting while this capture is active.
1687 * If CaptureFlags::PointerLock is set, similar to
1688 * CaptureFlags::RetargetToElement, then events are targeted at aContent,
1689 * but capturing is held more strongly (i.e., calls to SetCapturingContent()
1690 * won't unlock unless CaptureFlags::PointerLock is set again).
1692 static void SetCapturingContent(nsIContent
* aContent
, CaptureFlags aFlags
,
1693 WidgetEvent
* aEvent
= nullptr);
1696 * Alias for SetCapturingContent(nullptr, CaptureFlags::None) for making
1697 * callers what they do clearer.
1699 static void ReleaseCapturingContent() {
1700 PresShell::SetCapturingContent(nullptr, CaptureFlags::None
);
1703 static void ReleaseCapturingRemoteTarget(dom::BrowserParent
* aBrowserParent
) {
1704 MOZ_ASSERT(XRE_IsParentProcess());
1705 if (sCapturingContentInfo
.mRemoteTarget
== aBrowserParent
) {
1706 sCapturingContentInfo
.mRemoteTarget
= nullptr;
1710 // Called at the end of nsLayoutUtils::PaintFrame() if we were painting to
1712 // This is used to clear any pending visual scroll updates that have been
1713 // acknowledged, to make sure they don't stick around for the next paint.
1717 * Tell the presshell that the given frame's reflow was interrupted. This
1718 * will mark as having dirty children a path from the given frame (inclusive)
1719 * to the nearest ancestor with a dirty subtree, or to the reflow root
1720 * currently being reflowed if no such ancestor exists (inclusive). This is
1721 * to be done immediately after reflow of the current reflow root completes.
1722 * This method must only be called during reflow, and the frame it's being
1723 * called on must be in the process of being reflowed when it's called. This
1724 * method doesn't mark any intrinsic widths dirty and doesn't add any bits
1725 * other than NS_FRAME_HAS_DIRTY_CHILDREN.
1727 void FrameNeedsToContinueReflow(nsIFrame
* aFrame
);
1730 * Notification sent by a frame informing the pres shell that it is about to
1732 * This allows any outstanding references to the frame to be cleaned up
1734 void NotifyDestroyingFrame(nsIFrame
* aFrame
);
1736 bool GetZoomableByAPZ() const;
1739 * If this frame has content hidden via `content-visibilty` that has a pending
1740 * reflow, force the content to reflow immediately.
1742 void EnsureReflowIfFrameHasHiddenContent(nsIFrame
*);
1745 * Whether or not this presshell is is forcing a reflow of hidden content in
1746 * this frame via EnsureReflowIfFrameHasHiddenContent().
1748 bool IsForcingLayoutForHiddenContent(const nsIFrame
*) const;
1750 void RegisterContentVisibilityAutoFrame(nsIFrame
* aFrame
) {
1751 mContentVisibilityAutoFrames
.Insert(aFrame
);
1754 void UpdateRelevancyOfContentVisibilityAutoFrames();
1755 void ScheduleContentRelevancyUpdate(ContentRelevancyReason aReason
);
1760 void SetIsActive(bool aIsActive
);
1761 bool ComputeActiveness() const;
1764 void PaintInternal(nsView
* aViewToPaint
, PaintInternalFlags aFlags
);
1767 * Refresh observer management.
1769 void DoObserveStyleFlushes();
1770 void DoObserveLayoutFlushes();
1773 * Does the actual work of figuring out the current state of font size
1776 bool DetermineFontSizeInflationState();
1778 void RecordAlloc(void* aPtr
) {
1780 if (!mAllocatedPointers
) {
1781 return; // Hash set was presumably freed to avert OOM.
1783 MOZ_ASSERT(!mAllocatedPointers
->Contains(aPtr
));
1784 if (!mAllocatedPointers
->Insert(aPtr
, fallible
)) {
1785 // Yikes! We're nearly out of memory, and this insertion would've pushed
1786 // us over the ledge. At this point, we discard & stop using this set,
1787 // since we don't have enough memory to keep it accurate from this point
1788 // onwards. Hopefully this helps relieve the memory pressure a bit, too.
1789 mAllocatedPointers
= nullptr;
1794 void RecordFree(void* aPtr
) {
1796 if (!mAllocatedPointers
) {
1797 return; // Hash set was presumably freed to avert OOM.
1799 MOZ_ASSERT(mAllocatedPointers
->Contains(aPtr
));
1800 mAllocatedPointers
->Remove(aPtr
);
1804 void PushCurrentEventInfo(nsIFrame
* aFrame
, nsIContent
* aContent
);
1805 void PopCurrentEventInfo();
1806 nsIContent
* GetCurrentEventContent();
1808 friend class ::nsRefreshDriver
;
1809 friend class ::nsAutoCauseReflowNotifier
;
1811 void WillCauseReflow();
1812 MOZ_CAN_RUN_SCRIPT
void DidCauseReflow();
1814 void CancelPostedReflowCallbacks();
1815 void FlushPendingScrollAnchorAdjustments();
1817 void SetPendingVisualScrollUpdate(
1818 const nsPoint
& aVisualViewportOffset
,
1819 FrameMetrics::ScrollOffsetUpdateType aUpdateType
);
1821 #ifdef MOZ_REFLOW_PERF
1822 UniquePtr
<ReflowCountMgr
> mReflowCountMgr
;
1825 void WillDoReflow();
1827 // This data is stored as a content property (nsGkAtoms::scrolling) on
1828 // mContentToScrollTo when we have a pending ScrollIntoView.
1829 struct ScrollIntoViewData
{
1830 ScrollAxis mContentScrollVAxis
;
1831 ScrollAxis mContentScrollHAxis
;
1832 ScrollFlags mContentToScrollToFlags
;
1835 static LazyLogModule gLog
;
1837 DOMHighResTimeStamp
GetPerformanceNowUnclamped();
1839 // The callback for the mReflowContinueTimer timer.
1840 static void sReflowContinueCallback(nsITimer
* aTimer
, void* aPresShell
);
1841 bool ScheduleReflowOffTimer();
1842 // MaybeScheduleReflow checks if posting a reflow is needed, then checks if
1843 // the last reflow was interrupted. In the interrupted case ScheduleReflow is
1844 // called off a timer, otherwise it is called directly.
1845 void MaybeScheduleReflow();
1846 // Actually schedules a reflow. This should only be called by
1847 // MaybeScheduleReflow and the reflow timer ScheduleReflowOffTimer
1849 void ScheduleReflow();
1851 friend class ::AutoPointerEventTargetUpdater
;
1853 // ProcessReflowCommands returns whether we processed all our dirty roots
1854 // without interruptions.
1855 MOZ_CAN_RUN_SCRIPT
bool ProcessReflowCommands(bool aInterruptible
);
1858 * Callback handler for whether reflow happened.
1860 * @param aInterruptible Whether or not reflow interruption is allowed.
1862 MOZ_CAN_RUN_SCRIPT
void DidDoReflow(bool aInterruptible
);
1864 MOZ_CAN_RUN_SCRIPT
void HandlePostedReflowCallbacks(bool aInterruptible
);
1867 * Helper for ScrollContentIntoView()
1869 MOZ_CAN_RUN_SCRIPT
void DoScrollContentIntoView();
1872 * Methods to handle changes to user and UA sheet lists that we get
1875 void AddUserSheet(StyleSheet
*);
1876 void AddAgentSheet(StyleSheet
*);
1877 void AddAuthorSheet(StyleSheet
*);
1878 void RemovePreferenceStyles();
1881 * Initialize cached font inflation preference values and do an initial
1882 * computation to determine if font inflation is enabled.
1884 * @see nsLayoutUtils::sFontSizeInflationEmPerLine
1885 * @see nsLayoutUtils::sFontSizeInflationMinTwips
1886 * @see nsLayoutUtils::sFontSizeInflationLineThreshold
1888 void SetupFontInflation();
1891 * Implementation methods for FlushPendingNotifications.
1893 MOZ_CAN_RUN_SCRIPT
void DoFlushPendingNotifications(FlushType aType
);
1894 MOZ_CAN_RUN_SCRIPT
void DoFlushPendingNotifications(ChangesToFlush aType
);
1896 struct RenderingState
{
1897 explicit RenderingState(PresShell
* aPresShell
)
1898 : mResolution(aPresShell
->mResolution
),
1899 mRenderingStateFlags(aPresShell
->mRenderingStateFlags
) {}
1900 Maybe
<float> mResolution
;
1901 RenderingStateFlags mRenderingStateFlags
;
1904 struct AutoSaveRestoreRenderingState
{
1905 explicit AutoSaveRestoreRenderingState(PresShell
* aPresShell
)
1906 : mPresShell(aPresShell
), mOldState(aPresShell
) {}
1908 ~AutoSaveRestoreRenderingState() {
1909 mPresShell
->mRenderingStateFlags
= mOldState
.mRenderingStateFlags
;
1910 mPresShell
->mResolution
= mOldState
.mResolution
;
1911 #ifdef ACCESSIBILITY
1912 if (nsAccessibilityService
* accService
= GetAccService()) {
1913 accService
->NotifyOfResolutionChange(mPresShell
,
1914 mPresShell
->GetResolution());
1919 PresShell
* mPresShell
;
1920 RenderingState mOldState
;
1922 void SetRenderingState(const RenderingState
& aState
);
1924 friend class ::nsPresShellEventCB
;
1926 // methods for painting a range to an offscreen buffer
1928 // given a display list, clip the items within the list to
1930 nsRect
ClipListToRange(nsDisplayListBuilder
* aBuilder
, nsDisplayList
* aList
,
1933 // create a RangePaintInfo for the range aRange containing the
1934 // display list needed to paint the range to a surface
1935 UniquePtr
<RangePaintInfo
> CreateRangePaintInfo(nsRange
* aRange
,
1936 nsRect
& aSurfaceRect
,
1937 bool aForPrimarySelection
);
1940 * Paint the items to a new surface and return it.
1942 * aSelection - selection being painted, if any
1943 * aRegion - clip region, if any
1944 * aArea - area that the surface occupies, relative to the root frame
1945 * aPoint - reference point, typically the mouse position
1946 * aScreenRect - [out] set to the area of the screen the painted area should
1948 * aFlags - set RenderImageFlags::AutoScale to scale down large images, but
1949 * it must not be set if a custom image was specified
1951 already_AddRefed
<SourceSurface
> PaintRangePaintInfo(
1952 const nsTArray
<UniquePtr
<RangePaintInfo
>>& aItems
,
1953 dom::Selection
* aSelection
, const Maybe
<CSSIntRegion
>& aRegion
,
1954 nsRect aArea
, const LayoutDeviceIntPoint aPoint
,
1955 LayoutDeviceIntRect
* aScreenRect
, RenderImageFlags aFlags
);
1957 // Hide a view if it is a popup
1958 void HideViewIfPopup(nsView
* aView
);
1960 // Utility method to restore the root scrollframe state
1961 void RestoreRootScrollPosition();
1963 MOZ_CAN_RUN_SCRIPT_BOUNDARY
void MaybeReleaseCapturingContent();
1965 class DelayedEvent
{
1967 virtual ~DelayedEvent() = default;
1968 virtual void Dispatch() {}
1969 virtual bool IsKeyPressEvent() { return false; }
1972 class DelayedInputEvent
: public DelayedEvent
{
1974 void Dispatch() override
;
1977 DelayedInputEvent();
1978 ~DelayedInputEvent() override
;
1980 WidgetInputEvent
* mEvent
;
1983 class DelayedMouseEvent
: public DelayedInputEvent
{
1985 explicit DelayedMouseEvent(WidgetMouseEvent
* aEvent
);
1988 class DelayedKeyEvent
: public DelayedInputEvent
{
1990 explicit DelayedKeyEvent(WidgetKeyboardEvent
* aEvent
);
1991 bool IsKeyPressEvent() override
;
1995 * return the nsPoint represents the location of the mouse event relative to
1996 * the root document in visual coordinates
1998 nsPoint
GetEventLocation(const WidgetMouseEvent
& aEvent
) const;
2000 // Check if aEvent is a mouse event and record the mouse location for later
2001 // synth mouse moves.
2002 void RecordPointerLocation(WidgetGUIEvent
* aEvent
);
2003 inline bool MouseLocationWasSetBySynthesizedMouseEventForTests() const;
2004 class nsSynthMouseMoveEvent final
: public nsARefreshObserver
{
2006 nsSynthMouseMoveEvent(PresShell
* aPresShell
, bool aFromScroll
)
2007 : mPresShell(aPresShell
), mFromScroll(aFromScroll
) {
2008 NS_ASSERTION(mPresShell
, "null parameter");
2012 // Private destructor, to discourage deletion outside of Release():
2013 ~nsSynthMouseMoveEvent() { Revoke(); }
2016 NS_INLINE_DECL_REFCOUNTING(nsSynthMouseMoveEvent
, override
)
2021 void WillRefresh(TimeStamp aTime
) override
{
2023 RefPtr
<PresShell
> shell
= mPresShell
;
2024 shell
->ProcessSynthMouseMoveEvent(mFromScroll
);
2029 PresShell
* mPresShell
;
2032 MOZ_CAN_RUN_SCRIPT
void ProcessSynthMouseMoveEvent(bool aFromScroll
);
2034 void UpdateImageLockingState();
2036 already_AddRefed
<PresShell
> GetParentPresShellForEventHandling();
2039 * EventHandler is implementation of PresShell::HandleEvent().
2041 class MOZ_STACK_CLASS EventHandler final
{
2043 EventHandler() = delete;
2044 EventHandler(const EventHandler
& aOther
) = delete;
2045 explicit EventHandler(PresShell
& aPresShell
)
2046 : mPresShell(aPresShell
), mCurrentEventInfoSetter(nullptr) {}
2047 explicit EventHandler(RefPtr
<PresShell
>&& aPresShell
)
2048 : mPresShell(std::move(aPresShell
)), mCurrentEventInfoSetter(nullptr) {}
2051 * HandleEvent() may dispatch aGUIEvent. This may redirect the event to
2052 * another PresShell, or the event may be handled by other classes like
2053 * AccessibleCaretEventHub, or discarded. Otherwise, this sets current
2054 * event info of mPresShell and calls HandleEventWithCurrentEventInfo()
2055 * to dispatch the event into the DOM tree.
2057 * @param aFrameForPresShell The frame for PresShell. If PresShell
2058 * has root frame, it should be set.
2059 * Otherwise, a frame which contains the
2060 * PresShell should be set instead. I.e.,
2061 * in the latter case, the frame is in
2062 * a parent document.
2063 * @param aGUIEvent Event to be handled. Must be a trusted
2065 * @param aDontRetargetEvents true if this shouldn't redirect the
2066 * event to different PresShell.
2067 * false if this can redirect the event to
2068 * different PresShell.
2069 * @param aEventStatus [in/out] EventStatus of aGUIEvent.
2072 nsresult
HandleEvent(nsIFrame
* aFrameForPresShell
,
2073 WidgetGUIEvent
* aGUIEvent
, bool aDontRetargetEvents
,
2074 nsEventStatus
* aEventStatus
);
2077 * HandleEventWithTarget() tries to dispatch aEvent on aContent after
2078 * setting current event target content to aNewEventContent and current
2079 * event frame to aNewEventFrame temporarily. Note that this supports
2080 * WidgetEvent, not WidgetGUIEvent. So, you can dispatch a simple event
2083 * @param aEvent Event to be dispatched. Must be a
2085 * @param aNewEventFrame Temporal new event frame.
2086 * @param aNewEventContent Temporal new event content.
2087 * @param aEventStatus [in/out] EventStuatus of aEvent.
2088 * @param aIsHandlingNativeEvent true if aEvent represents a native
2090 * @param aTargetContent This is used only when aEvent is a
2092 * PresShell::mPointerEventTarget is
2093 * changed during dispatching aEvent,
2094 * this is set to the new target.
2095 * @param aOverrideClickTarget Override click event target.
2098 nsresult
HandleEventWithTarget(WidgetEvent
* aEvent
,
2099 nsIFrame
* aNewEventFrame
,
2100 nsIContent
* aNewEventContent
,
2101 nsEventStatus
* aEventStatus
,
2102 bool aIsHandlingNativeEvent
,
2103 nsIContent
** aTargetContent
,
2104 nsIContent
* aOverrideClickTarget
);
2107 * OnPresShellDestroy() is called when every PresShell instance is being
2110 static inline void OnPresShellDestroy(Document
* aDocument
);
2113 static bool InZombieDocument(nsIContent
* aContent
);
2114 static nsIFrame
* GetNearestFrameContainingPresShell(PresShell
* aPresShell
);
2115 static nsIPrincipal
* GetDocumentPrincipalToCompareWithBlacklist(
2116 PresShell
& aPresShell
);
2119 * HandleEventUsingCoordinates() handles aGUIEvent whose
2120 * IsUsingCoordinates() returns true with the following helper methods.
2122 * @param aFrameForPresShell The frame for PresShell. See
2123 * explanation of HandleEvent() for the
2125 * @param aGUIEvent The handling event. Make sure that
2126 * its IsUsingCoordinates() returns true.
2127 * @param aEventStatus The status of aGUIEvent.
2128 * @param aDontRetargetEvents true if we've already retarget document.
2132 nsresult
HandleEventUsingCoordinates(nsIFrame
* aFrameForPresShell
,
2133 WidgetGUIEvent
* aGUIEvent
,
2134 nsEventStatus
* aEventStatus
,
2135 bool aDontRetargetEvents
);
2138 * EventTargetData struct stores a set of a PresShell (event handler),
2139 * a frame (to handle the event) and a content (event target for the frame).
2141 struct MOZ_STACK_CLASS EventTargetData final
{
2142 EventTargetData() = delete;
2143 EventTargetData(const EventTargetData
& aOther
) = delete;
2144 explicit EventTargetData(nsIFrame
* aFrameToHandleEvent
) {
2145 SetFrameAndComputePresShell(aFrameToHandleEvent
);
2148 void SetFrameAndComputePresShell(nsIFrame
* aFrameToHandleEvent
);
2149 void SetFrameAndComputePresShellAndContent(nsIFrame
* aFrameToHandleEvent
,
2150 WidgetGUIEvent
* aGUIEvent
);
2151 void SetContentForEventFromFrame(WidgetGUIEvent
* aGUIEvent
);
2153 nsPresContext
* GetPresContext() const {
2154 return mPresShell
? mPresShell
->GetPresContext() : nullptr;
2156 EventStateManager
* GetEventStateManager() const {
2157 nsPresContext
* presContext
= GetPresContext();
2158 return presContext
? presContext
->EventStateManager() : nullptr;
2160 Document
* GetDocument() const {
2161 return mPresShell
? mPresShell
->GetDocument() : nullptr;
2163 nsIContent
* GetFrameContent() const;
2166 * MaybeRetargetToActiveDocument() tries retarget aGUIEvent into
2167 * active document if there is. Note that this does not support to
2168 * retarget mContent. Make sure it is nullptr before calling this.
2170 * @param aGUIEvent The handling event.
2171 * @return true if retargetted.
2173 bool MaybeRetargetToActiveDocument(WidgetGUIEvent
* aGUIEvent
);
2176 * ComputeElementFromFrame() computes mContent for aGUIEvent. If
2177 * mContent is set by this method, mContent is always nullptr or an
2180 * @param aGUIEvent The handling event.
2181 * @return true if caller can keep handling the event.
2183 * Note that even if this returns true, mContent
2186 bool ComputeElementFromFrame(WidgetGUIEvent
* aGUIEvent
);
2189 * UpdateTouchEventTarget() updates mFrame, mPresShell and mContent if
2190 * aGUIEvent is a touch event and there is new proper target.
2192 * @param aGUIEvent The handled event. If it's not a touch event,
2193 * this method does nothing.
2195 void UpdateTouchEventTarget(WidgetGUIEvent
* aGUIEvent
);
2198 * UpdateWheelEventTarget() updates mFrame, mPresShell, and mContent if
2199 * aGUIEvent is a wheel event and aGUIEvent should be grouped with prior
2202 * @param aGUIEvent The handled event. If it's not a wheel event,
2203 * this method does nothing.
2205 void UpdateWheelEventTarget(WidgetGUIEvent
* aGUIEvent
);
2207 RefPtr
<PresShell
> mPresShell
;
2208 nsIFrame
* mFrame
= nullptr;
2209 nsCOMPtr
<nsIContent
> mContent
;
2210 nsCOMPtr
<nsIContent
> mOverrideClickTarget
;
2214 * MaybeFlushPendingNotifications() maybe flush pending notifications if
2215 * aGUIEvent should be handled with the latest layout.
2217 * @param aGUIEvent The handling event.
2218 * @return true if this actually flushes pending
2219 * layout and that has caused changing the
2223 bool MaybeFlushPendingNotifications(WidgetGUIEvent
* aGUIEvent
);
2226 * GetFrameToHandleNonTouchEvent() returns a frame to handle the event.
2227 * This may flush pending layout if the target is in child PresShell.
2229 * @param aRootFrameToHandleEvent The root frame to handle the event.
2230 * @param aGUIEvent The handling event.
2231 * @return The frame which should handle the
2232 * event. nullptr if the caller should
2233 * stop handling the event.
2236 nsIFrame
* GetFrameToHandleNonTouchEvent(nsIFrame
* aRootFrameToHandleEvent
,
2237 WidgetGUIEvent
* aGUIEvent
);
2240 * ComputeEventTargetFrameAndPresShellAtEventPoint() computes event
2241 * target frame at the event point of aGUIEvent and set it to
2244 * @param aRootFrameToHandleEvent The root frame to handle aGUIEvent.
2245 * @param aGUIEvent The handling event.
2246 * @param aEventTargetData [out] Its frame and PresShell will
2248 * @return true if the caller can handle the
2249 * event. Otherwise, false.
2252 bool ComputeEventTargetFrameAndPresShellAtEventPoint(
2253 nsIFrame
* aRootFrameToHandleEvent
, WidgetGUIEvent
* aGUIEvent
,
2254 EventTargetData
* aEventTargetData
);
2257 * DispatchPrecedingPointerEvent() dispatches preceding pointer event for
2258 * aGUIEvent if Pointer Events is enabled.
2260 * @param aFrameForPresShell The frame for PresShell. See
2261 * explanation of HandleEvent() for the
2263 * @param aGUIEvent The handled event.
2264 * @param aPointerCapturingContent The content which is capturing pointer
2265 * events if there is. Otherwise, nullptr.
2266 * @param aDontRetargetEvents Set aDontRetargetEvents of
2267 * HandleEvent() which called this method.
2268 * @param aEventTargetData [in/out] Event target data of
2269 * aGUIEvent. If pointer event listeners
2270 * change the DOM tree or reframe the
2271 * target, updated by this method.
2272 * @param aEventStatus [in/out] The event status of aGUIEvent.
2273 * @return true if the caller can handle the
2274 * event. Otherwise, false.
2277 bool DispatchPrecedingPointerEvent(nsIFrame
* aFrameForPresShell
,
2278 WidgetGUIEvent
* aGUIEvent
,
2279 nsIContent
* aPointerCapturingContent
,
2280 bool aDontRetargetEvents
,
2281 EventTargetData
* aEventTargetData
,
2282 nsEventStatus
* aEventStatus
);
2285 * MaybeDiscardEvent() checks whether it's safe to handle aGUIEvent right
2286 * now. If it's not safe, this may notify somebody of discarding event if
2289 * @param aGUIEvent Handling event.
2290 * @return true if it's not safe to handle the event.
2292 bool MaybeDiscardEvent(WidgetGUIEvent
* aGUIEvent
);
2295 * GetCapturingContentFor() returns capturing content for aGUIEvent.
2296 * If aGUIEvent is not related to capturing, this returns nullptr.
2298 static nsIContent
* GetCapturingContentFor(WidgetGUIEvent
* aGUIEvent
);
2301 * GetRetargetEventDocument() returns a document if aGUIEvent should be
2302 * handled in another document.
2304 * @param aGUIEvent Handling event.
2305 * @param aRetargetEventDocument Document which should handle aGUIEvent.
2306 * @return true if caller can keep handling
2309 bool GetRetargetEventDocument(WidgetGUIEvent
* aGUIEvent
,
2310 Document
** aRetargetEventDocument
);
2313 * GetFrameForHandlingEventWith() returns a frame which should be used as
2314 * aFrameForPresShell of HandleEvent(). See @return for the details.
2316 * @param aGUIEvent Handling event.
2317 * @param aRetargetDocument Document which aGUIEvent should be
2318 * fired on. Typically, should be result
2319 * of GetRetargetEventDocument().
2320 * @param aFrameForPresShell The frame for PresShell. See
2321 * explanation of HandleEvent() for the
2323 * @return nullptr if caller should stop handling
2325 * aFrameForPresShell if caller should
2326 * keep handling the event by itself.
2327 * Otherwise, caller should handle it with
2328 * another PresShell which is result of
2329 * nsIFrame::PresContext()->GetPresShell().
2331 nsIFrame
* GetFrameForHandlingEventWith(WidgetGUIEvent
* aGUIEvent
,
2332 Document
* aRetargetDocument
,
2333 nsIFrame
* aFrameForPresShell
);
2336 * MaybeHandleEventWithAnotherPresShell() may handle aGUIEvent with another
2339 * @param aFrameForPresShell The frame for PresShell. See
2340 * explanation of HandleEvent() for the
2342 * @param aGUIEvent Handling event.
2343 * @param aEventStatus [in/out] EventStatus of aGUIEvent.
2344 * @param aRv [out] Returns error if this gets an
2345 * error handling the event.
2346 * @return false if caller needs to keep handling
2347 * the event by itself.
2348 * true if caller shouldn't keep handling
2349 * the event. Note that when no PresShell
2350 * can handle the event, this returns true.
2353 bool MaybeHandleEventWithAnotherPresShell(nsIFrame
* aFrameForPresShell
,
2354 WidgetGUIEvent
* aGUIEvent
,
2355 nsEventStatus
* aEventStatus
,
2359 nsresult
RetargetEventToParent(WidgetGUIEvent
* aGUIEvent
,
2360 nsEventStatus
* aEventStatus
);
2363 * MaybeHandleEventWithAccessibleCaret() may handle aGUIEvent with
2364 * AccessibleCaretEventHub if it's necessary.
2366 * @param aFrameForPresShell The frame for PresShell. See explanation of
2367 * HandleEvent() for the details.
2368 * @param aGUIEvent Event may be handled by AccessibleCaretEventHub.
2369 * @param aEventStatus [in/out] EventStatus of aGUIEvent.
2370 * @return true if AccessibleCaretEventHub handled the
2371 * event and caller shouldn't keep handling it.
2374 bool MaybeHandleEventWithAccessibleCaret(nsIFrame
* aFrameForPresShell
,
2375 WidgetGUIEvent
* aGUIEvent
,
2376 nsEventStatus
* aEventStatus
);
2379 * MaybeDiscardOrDelayKeyboardEvent() may discared or put aGUIEvent into
2380 * the delayed event queue if it's a keyboard event and if we should do so.
2381 * If aGUIEvent is not a keyboard event, this does nothing.
2383 * @param aGUIEvent The handling event.
2384 * @return true if this method discard the event or
2385 * put it into the delayed event queue.
2387 bool MaybeDiscardOrDelayKeyboardEvent(WidgetGUIEvent
* aGUIEvent
);
2390 * MaybeDiscardOrDelayMouseEvent() may discard or put aGUIEvent into the
2391 * delayed event queue if it's a mouse event and if we should do so.
2392 * If aGUIEvent is not a mouse event, this does nothing.
2393 * If there is suppressed event listener like debugger of devtools, this
2394 * notifies it of the event after discard or put it into the delayed
2397 * @param aFrameToHandleEvent The frame to handle aGUIEvent.
2398 * @param aGUIEvent The handling event.
2399 * @return true if this method discard the event
2400 * or put it into the delayed event queue.
2402 bool MaybeDiscardOrDelayMouseEvent(nsIFrame
* aFrameToHandleEvent
,
2403 WidgetGUIEvent
* aGUIEvent
);
2406 * MaybeFlushThrottledStyles() tries to flush pending animation. If it's
2407 * flushed and then aFrameForPresShell is destroyed, returns new frame
2408 * which contains mPresShell.
2410 * @param aFrameForPresShell The frame for PresShell. See
2411 * explanation of HandleEvent() for the
2412 * details. This can be nullptr.
2413 * @return Maybe new frame for mPresShell.
2414 * If aFrameForPresShell is not nullptr
2415 * and hasn't been destroyed, returns
2416 * aFrameForPresShell as-is.
2419 nsIFrame
* MaybeFlushThrottledStyles(nsIFrame
* aFrameForPresShell
);
2422 * ComputeRootFrameToHandleEvent() returns root frame to handle the event.
2423 * For example, if there is a popup, this returns the popup frame.
2424 * If there is capturing content and it's in a scrolled frame, returns
2425 * the scrolled frame.
2427 * @param aFrameForPresShell The frame for PresShell. See
2428 * explanation of HandleEvent() for
2430 * @param aGUIEvent The handling event.
2431 * @param aCapturingContent Capturing content if there is.
2432 * nullptr, otherwise.
2433 * @param aIsCapturingContentIgnored [out] true if aCapturingContent
2434 * is not nullptr but it should be
2435 * ignored to handle the event.
2436 * @param aIsCaptureRetargeted [out] true if aCapturingContent
2437 * is not nullptr but it's
2439 * @return Root frame to handle the event.
2441 nsIFrame
* ComputeRootFrameToHandleEvent(nsIFrame
* aFrameForPresShell
,
2442 WidgetGUIEvent
* aGUIEvent
,
2443 nsIContent
* aCapturingContent
,
2444 bool* aIsCapturingContentIgnored
,
2445 bool* aIsCaptureRetargeted
);
2448 * ComputeRootFrameToHandleEventWithPopup() returns popup frame if there
2449 * is a popup and we should handle the event in it. Otherwise, returns
2450 * aRootFrameToHandleEvent.
2452 * @param aRootFrameToHandleEvent Candidate root frame to handle
2454 * @param aGUIEvent The handling event.
2455 * @param aCapturingContent Capturing content if there is.
2456 * nullptr, otherwise.
2457 * @param aIsCapturingContentIgnored [out] true if aCapturingContent
2458 * is not nullptr but it should be
2459 * ignored to handle the event.
2460 * @return A popup frame if there is a
2461 * popup and we should handle the
2462 * event in it. Otherwise,
2463 * aRootFrameToHandleEvent.
2464 * I.e., never returns nullptr.
2466 nsIFrame
* ComputeRootFrameToHandleEventWithPopup(
2467 nsIFrame
* aRootFrameToHandleEvent
, WidgetGUIEvent
* aGUIEvent
,
2468 nsIContent
* aCapturingContent
, bool* aIsCapturingContentIgnored
);
2471 * ComputeRootFrameToHandleEventWithCapturingContent() returns root frame
2472 * to handle event for the capturing content, or aRootFrameToHandleEvent
2473 * if it should be ignored.
2475 * @param aRootFrameToHandleEvent Candidate root frame to handle
2477 * @param aCapturingContent Capturing content. nullptr is
2479 * @param aIsCapturingContentIgnored [out] true if aCapturingContent
2480 * is not nullptr but it should be
2481 * ignored to handle the event.
2482 * @param aIsCaptureRetargeted [out] true if aCapturingContent
2483 * is not nullptr but it's
2485 * @return A popup frame if there is a
2486 * popup and we should handle the
2487 * event in it. Otherwise,
2488 * aRootFrameToHandleEvent.
2489 * I.e., never returns nullptr.
2491 nsIFrame
* ComputeRootFrameToHandleEventWithCapturingContent(
2492 nsIFrame
* aRootFrameToHandleEvent
, nsIContent
* aCapturingContent
,
2493 bool* aIsCapturingContentIgnored
, bool* aIsCaptureRetargeted
);
2496 * HandleEventWithPointerCapturingContentWithoutItsFrame() handles
2497 * aGUIEvent with aPointerCapturingContent when it does not have primary
2500 * @param aFrameForPresShell The frame for PresShell. See
2501 * explanation of HandleEvent() for the
2503 * @param aGUIEvent The handling event.
2504 * @param aPointerCapturingContent Current pointer capturing content.
2505 * Must not be nullptr.
2506 * @param aEventStatus [in/out] The event status of aGUIEvent.
2507 * @return Basically, result of
2508 * HandeEventWithTraget().
2511 nsresult
HandleEventWithPointerCapturingContentWithoutItsFrame(
2512 nsIFrame
* aFrameForPresShell
, WidgetGUIEvent
* aGUIEvent
,
2513 nsIContent
* aPointerCapturingContent
, nsEventStatus
* aEventStatus
);
2516 * HandleEventAtFocusedContent() handles aGUIEvent at focused content.
2518 * @param aGUIEvent The handling event which should be handled at
2520 * @param aEventStatus [in/out] The event status of aGUIEvent.
2523 nsresult
HandleEventAtFocusedContent(WidgetGUIEvent
* aGUIEvent
,
2524 nsEventStatus
* aEventStatus
);
2527 * ComputeFocusedEventTargetElement() returns event target element for
2528 * aGUIEvent which should be handled with focused content.
2529 * This may set/unset sLastKeyDownEventTarget if necessary.
2531 * @param aGUIEvent The handling event.
2532 * @return The element which should be the event
2533 * target of aGUIEvent.
2535 dom::Element
* ComputeFocusedEventTargetElement(WidgetGUIEvent
* aGUIEvent
);
2538 * MaybeHandleEventWithAnotherPresShell() may handle aGUIEvent with another
2541 * @param aEventTargetElement The event target element of aGUIEvent.
2542 * @param aGUIEvent Handling event.
2543 * @param aEventStatus [in/out] EventStatus of aGUIEvent.
2544 * @param aRv [out] Returns error if this gets an
2545 * error handling the event.
2546 * @return false if caller needs to keep handling
2547 * the event by itself.
2548 * true if caller shouldn't keep handling
2549 * the event. Note that when no PresShell
2550 * can handle the event, this returns true.
2553 bool MaybeHandleEventWithAnotherPresShell(dom::Element
* aEventTargetElement
,
2554 WidgetGUIEvent
* aGUIEvent
,
2555 nsEventStatus
* aEventStatus
,
2559 * HandleRetargetedEvent() dispatches aGUIEvent on the PresShell without
2560 * retargetting. This should be used only when caller computes final
2561 * target of aGUIEvent.
2563 * @param aGUIEvent Event to be dispatched.
2564 * @param aEventStatus [in/out] EventStatus of aGUIEvent.
2565 * @param aTarget The final target of aGUIEvent.
2568 nsresult
HandleRetargetedEvent(WidgetGUIEvent
* aGUIEvent
,
2569 nsEventStatus
* aEventStatus
,
2570 nsIContent
* aTarget
) {
2571 AutoCurrentEventInfoSetter
eventInfoSetter(*this, nullptr, aTarget
);
2572 if (!mPresShell
->GetCurrentEventFrame()) {
2575 nsCOMPtr
<nsIContent
> overrideClickTarget
;
2576 return HandleEventWithCurrentEventInfo(aGUIEvent
, aEventStatus
, true,
2577 overrideClickTarget
);
2581 * HandleEventWithFrameForPresShell() handles aGUIEvent with the frame
2584 * @param aFrameForPresShell The frame for mPresShell.
2585 * @param aGUIEvent The handling event. It shouldn't be
2586 * handled with using coordinates nor
2587 * handled at focused content.
2588 * @param aEventStatus [in/out] The status of aGUIEvent.
2591 nsresult
HandleEventWithFrameForPresShell(nsIFrame
* aFrameForPresShell
,
2592 WidgetGUIEvent
* aGUIEvent
,
2593 nsEventStatus
* aEventStatus
);
2596 * HandleEventWithCurrentEventInfo() prepares to dispatch aEvent into the
2597 * DOM, dispatches aEvent into the DOM with using current event info of
2598 * mPresShell and notifies EventStateManager of that.
2600 * @param aEvent Event to be dispatched.
2601 * @param aEventStatus [in/out] EventStatus of aEvent.
2602 * @param aIsHandlingNativeEvent true if aGUIEvent represents a native
2604 * @param aOverrideClickTarget Override click event target.
2607 nsresult
HandleEventWithCurrentEventInfo(WidgetEvent
* aEvent
,
2608 nsEventStatus
* aEventStatus
,
2609 bool aIsHandlingNativeEvent
,
2610 nsIContent
* aOverrideClickTarget
);
2613 * HandlingTimeAccumulator() may accumulate handling time of telemetry
2614 * for each type of events.
2616 class MOZ_STACK_CLASS HandlingTimeAccumulator final
{
2618 HandlingTimeAccumulator() = delete;
2619 HandlingTimeAccumulator(const HandlingTimeAccumulator
& aOther
) = delete;
2620 HandlingTimeAccumulator(const EventHandler
& aEventHandler
,
2621 const WidgetEvent
* aEvent
);
2622 ~HandlingTimeAccumulator();
2625 const EventHandler
& mEventHandler
;
2626 const WidgetEvent
* mEvent
;
2627 TimeStamp mHandlingStartTime
;
2631 * RecordEventPreparationPerformance() records event preparation performance
2632 * with telemetry only when aEvent is a trusted event.
2634 * @param aEvent The handling event which we've finished
2635 * preparing something to dispatch.
2637 void RecordEventPreparationPerformance(const WidgetEvent
* aEvent
);
2640 * RecordEventHandlingResponsePerformance() records event handling response
2641 * performance with telemetry.
2643 * @param aEvent The handled event.
2645 void RecordEventHandlingResponsePerformance(const WidgetEvent
* aEvent
);
2648 * PrepareToDispatchEvent() prepares to dispatch aEvent.
2650 * @param aEvent The handling event.
2651 * @param aEventStatus [in/out] The status of aEvent.
2652 * @param aTouchIsNew [out] Set to true if the event is an
2653 * eTouchMove event and it represents new
2654 * touch. Otherwise, set to false.
2655 * @return true if the caller can dispatch the
2656 * event into the DOM.
2659 bool PrepareToDispatchEvent(WidgetEvent
* aEvent
,
2660 nsEventStatus
* aEventStatus
, bool* aTouchIsNew
);
2663 * MaybeHandleKeyboardEventBeforeDispatch() may handle aKeyboardEvent
2664 * if it should do something before dispatched into the DOM.
2666 * @param aKeyboardEvent The handling keyboard event.
2669 void MaybeHandleKeyboardEventBeforeDispatch(
2670 WidgetKeyboardEvent
* aKeyboardEvent
);
2673 * This and the next two helper methods are used to target and position the
2674 * context menu when the keyboard shortcut is used to open it.
2676 * If another menu is open, the context menu is opened relative to the
2677 * active menuitem within the menu, or the menu itself if no item is active.
2678 * Otherwise, if the caret is visible, the menu is opened near the caret.
2679 * Otherwise, if a selectable list such as a listbox is focused, the
2680 * current item within the menu is opened relative to this item.
2681 * Otherwise, the context menu is opened at the topleft corner of the
2684 * Returns true if the context menu event should fire and false if it should
2688 bool AdjustContextMenuKeyEvent(WidgetMouseEvent
* aMouseEvent
);
2691 bool PrepareToUseCaretPosition(nsIWidget
* aEventWidget
,
2692 LayoutDeviceIntPoint
& aTargetPt
);
2695 * Get the selected item and coordinates in device pixels relative to root
2696 * document's root view for element, first ensuring the element is onscreen.
2699 void GetCurrentItemAndPositionForElement(dom::Element
* aFocusedElement
,
2700 nsIContent
** aTargetToUse
,
2701 LayoutDeviceIntPoint
& aTargetPt
,
2702 nsIWidget
* aRootWidget
);
2704 nsIContent
* GetOverrideClickTarget(WidgetGUIEvent
* aGUIEvent
,
2708 * DispatchEvent() tries to dispatch aEvent and notifies aEventStateManager
2711 * @param aEventStateManager EventStateManager which should handle
2712 * the event before/after dispatching
2713 * aEvent into the DOM.
2714 * @param aEvent The handling event.
2715 * @param aTouchIsNew Set this to true when the message is
2716 * eTouchMove and it's newly touched.
2717 * Then, the "touchmove" event becomes
2719 * @param aEventStatus [in/out] The status of aEvent.
2720 * @param aOverrideClickTarget Override click event target.
2722 MOZ_CAN_RUN_SCRIPT nsresult
2723 DispatchEvent(EventStateManager
* aEventStateManager
, WidgetEvent
* aEvent
,
2724 bool aTouchIsNew
, nsEventStatus
* aEventStatus
,
2725 nsIContent
* aOverrideClickTarget
);
2728 * DispatchEventToDOM() actually dispatches aEvent into the DOM tree.
2730 * @param aEvent Event to be dispatched into the DOM tree.
2731 * @param aEventStatus [in/out] EventStatus of aEvent.
2732 * @param aEventCB The callback kicked when the event moves
2733 * from the default group to the system group.
2735 MOZ_CAN_RUN_SCRIPT nsresult
2736 DispatchEventToDOM(WidgetEvent
* aEvent
, nsEventStatus
* aEventStatus
,
2737 nsPresShellEventCB
* aEventCB
);
2740 * DispatchTouchEventToDOM() dispatches touch events into the DOM tree.
2742 * @param aEvent The source of events to be dispatched into the
2744 * @param aEventStatus [in/out] EventStatus of aEvent.
2745 * @param aEventCB The callback kicked when the events move
2746 * from the default group to the system group.
2747 * @param aTouchIsNew Set this to true when the message is eTouchMove
2748 * and it's newly touched. Then, the "touchmove"
2749 * event becomes cancelable.
2751 MOZ_CAN_RUN_SCRIPT
void DispatchTouchEventToDOM(
2752 WidgetEvent
* aEvent
, nsEventStatus
* aEventStatus
,
2753 nsPresShellEventCB
* aEventCB
, bool aTouchIsNew
);
2756 * FinalizeHandlingEvent() should be called after calling DispatchEvent()
2757 * and then, this cleans up the state of mPresShell and aEvent.
2759 * @param aEvent The handled event.
2761 MOZ_CAN_RUN_SCRIPT
void FinalizeHandlingEvent(WidgetEvent
* aEvent
);
2764 * AutoCurrentEventInfoSetter() pushes and pops current event info of
2765 * aEventHandler.mPresShell.
2767 struct MOZ_STACK_CLASS AutoCurrentEventInfoSetter final
{
2768 explicit AutoCurrentEventInfoSetter(EventHandler
& aEventHandler
)
2769 : mEventHandler(aEventHandler
) {
2770 MOZ_DIAGNOSTIC_ASSERT(!mEventHandler
.mCurrentEventInfoSetter
);
2771 mEventHandler
.mCurrentEventInfoSetter
= this;
2772 mEventHandler
.mPresShell
->PushCurrentEventInfo(nullptr, nullptr);
2774 AutoCurrentEventInfoSetter(EventHandler
& aEventHandler
, nsIFrame
* aFrame
,
2775 nsIContent
* aContent
)
2776 : mEventHandler(aEventHandler
) {
2777 MOZ_DIAGNOSTIC_ASSERT(!mEventHandler
.mCurrentEventInfoSetter
);
2778 mEventHandler
.mCurrentEventInfoSetter
= this;
2779 mEventHandler
.mPresShell
->PushCurrentEventInfo(aFrame
, aContent
);
2781 AutoCurrentEventInfoSetter(EventHandler
& aEventHandler
,
2782 EventTargetData
& aEventTargetData
)
2783 : mEventHandler(aEventHandler
) {
2784 MOZ_DIAGNOSTIC_ASSERT(!mEventHandler
.mCurrentEventInfoSetter
);
2785 mEventHandler
.mCurrentEventInfoSetter
= this;
2786 mEventHandler
.mPresShell
->PushCurrentEventInfo(
2787 aEventTargetData
.mFrame
, aEventTargetData
.mContent
);
2789 ~AutoCurrentEventInfoSetter() {
2790 mEventHandler
.mPresShell
->PopCurrentEventInfo();
2791 mEventHandler
.mCurrentEventInfoSetter
= nullptr;
2795 EventHandler
& mEventHandler
;
2799 * Wrapper methods to access methods of mPresShell.
2801 nsPresContext
* GetPresContext() const {
2802 return mPresShell
->GetPresContext();
2804 Document
* GetDocument() const { return mPresShell
->GetDocument(); }
2805 nsCSSFrameConstructor
* FrameConstructor() const {
2806 return mPresShell
->FrameConstructor();
2808 already_AddRefed
<nsPIDOMWindowOuter
> GetFocusedDOMWindowInOurWindow() {
2809 return mPresShell
->GetFocusedDOMWindowInOurWindow();
2811 already_AddRefed
<PresShell
> GetParentPresShellForEventHandling() {
2812 return mPresShell
->GetParentPresShellForEventHandling();
2814 OwningNonNull
<PresShell
> mPresShell
;
2815 AutoCurrentEventInfoSetter
* mCurrentEventInfoSetter
;
2816 static TimeStamp sLastInputCreated
;
2817 static TimeStamp sLastInputProcessed
;
2818 static StaticRefPtr
<dom::Element
> sLastKeyDownEventTargetElement
;
2821 PresShell
* GetRootPresShell() const;
2823 bool IsTransparentContainerElement() const;
2824 ColorScheme
DefaultBackgroundColorScheme() const;
2825 nscolor
GetDefaultBackgroundColorToDraw() const;
2827 //////////////////////////////////////////////////////////////////////////////
2828 // Approximate frame visibility tracking implementation.
2829 //////////////////////////////////////////////////////////////////////////////
2831 void UpdateApproximateFrameVisibility();
2832 void DoUpdateApproximateFrameVisibility(bool aRemoveOnly
);
2834 void ClearApproximatelyVisibleFramesList(
2835 const Maybe
<OnNonvisible
>& aNonvisibleAction
= Nothing());
2836 static void ClearApproximateFrameVisibilityVisited(nsView
* aView
,
2838 static void MarkFramesInListApproximatelyVisible(const nsDisplayList
& aList
);
2839 void MarkFramesInSubtreeApproximatelyVisible(nsIFrame
* aFrame
,
2840 const nsRect
& aRect
,
2841 bool aRemoveOnly
= false);
2843 void DecApproximateVisibleCount(
2844 VisibleFrames
& aFrames
,
2845 const Maybe
<OnNonvisible
>& aNonvisibleAction
= Nothing());
2847 nsRevocableEventPtr
<nsRunnableMethod
<PresShell
>>
2848 mUpdateApproximateFrameVisibilityEvent
;
2850 // A set of frames that were visible or could be visible soon at the time
2851 // that we last did an approximate frame visibility update.
2852 VisibleFrames mApproximatelyVisibleFrames
;
2855 MOZ_CAN_RUN_SCRIPT_BOUNDARY
bool VerifyIncrementalReflow();
2856 MOZ_CAN_RUN_SCRIPT_BOUNDARY
void DoVerifyReflow();
2857 void VerifyHasDirtyRootAncestor(nsIFrame
* aFrame
);
2859 bool mInVerifyReflow
= false;
2860 // The reflow root under which we're currently reflowing. Null when
2862 nsIFrame
* mCurrentReflowRoot
= nullptr;
2863 #endif // #ifdef DEBUG
2865 // Send, and reset, the current per tick telemetry. This includes:
2866 // * non-zero number of style and layout flushes
2867 // * non-zero ms duration spent in style and reflow since the last tick.
2868 void PingPerTickTelemetry(FlushType aFlushType
);
2871 // IMPORTANT: The ownership implicit in the following member variables
2872 // has been explicitly checked. If you add any members to this class,
2873 // please make the ownership explicit (pinkerton, scc).
2875 // These are the same Document and PresContext owned by the DocViewer.
2876 // we must share ownership.
2877 // mDocument and mPresContext should've never been cleared nor swapped with
2878 // another instance while PresShell instance is alive so that it's safe to
2879 // call their can-run- script methods without local RefPtr variables.
2880 MOZ_KNOWN_LIVE RefPtr
<Document
> const mDocument
;
2881 MOZ_KNOWN_LIVE RefPtr
<nsPresContext
> const mPresContext
;
2882 // The document's style set owns it but we maintain a ref, may be null.
2883 RefPtr
<StyleSheet
> mPrefStyleSheet
;
2884 UniquePtr
<nsCSSFrameConstructor
> mFrameConstructor
;
2885 nsViewManager
* mViewManager
; // [WEAK] docViewer owns it so I don't have to
2886 RefPtr
<nsFrameSelection
> mSelection
;
2887 // The frame selection that last took focus on this shell, which we need to
2888 // hide if we focus another selection. May or may not be the same as
2890 RefPtr
<nsFrameSelection
> mFocusedFrameSelection
;
2891 RefPtr
<nsCaret
> mCaret
;
2892 RefPtr
<nsCaret
> mOriginalCaret
;
2893 RefPtr
<AccessibleCaretEventHub
> mAccessibleCaretEventHub
;
2894 // Pointer into mFrameConstructor - this is purely so that GetRootFrame() can
2896 nsFrameManager
* mFrameManager
;
2897 WeakPtr
<nsDocShell
> mForwardingContainer
;
2899 // The `performance.now()` value when we last started to process reflows.
2900 DOMHighResTimeStamp mLastReflowStart
{0.0};
2902 // At least on Win32 and Mac after interupting a reflow we need to post
2903 // the resume reflow event off a timer to avoid event starvation because
2904 // posted messages are processed before other messages when the modal
2905 // moving/sizing loop is running, see bug 491700 for details.
2906 nsCOMPtr
<nsITimer
> mReflowContinueTimer
;
2909 // We track allocated pointers in a diagnostic hash set, to assert against
2910 // missing/double frees. This set is allocated infallibly in the PresShell
2911 // constructor's initialization list. The set can get quite large, so we use
2912 // fallible allocation when inserting into it; and if these operations ever
2913 // fail, then we just get rid of the set and stop using this diagnostic from
2914 // that point on. (There's not much else we can do, when the set grows
2915 // larger than the available memory.)
2916 UniquePtr
<nsTHashSet
<void*>> mAllocatedPointers
{
2917 MakeUnique
<nsTHashSet
<void*>>()};
2920 // A list of stack weak frames. This is a pointer to the last item in the
2922 AutoWeakFrame
* mAutoWeakFrames
;
2924 // A hash table of heap allocated weak frames.
2925 nsTHashSet
<WeakFrame
*> mWeakFrames
;
2927 // Reflow roots that need to be reflowed.
2928 DepthOrderedFrameList mDirtyRoots
;
2930 // These two fields capture call stacks of any changes that require a restyle
2931 // or a reflow. Only the first change per restyle / reflow is recorded (the
2932 // one that caused a call to SetNeedStyleFlush() / SetNeedLayoutFlush()).
2933 UniquePtr
<ProfileChunkedBuffer
> mStyleCause
;
2934 UniquePtr
<ProfileChunkedBuffer
> mReflowCause
;
2936 nsTArray
<UniquePtr
<DelayedEvent
>> mDelayedEvents
;
2938 nsRevocableEventPtr
<nsSynthMouseMoveEvent
> mSynthMouseMoveEvent
;
2940 TouchManager mTouchManager
;
2942 RefPtr
<ZoomConstraintsClient
> mZoomConstraintsClient
;
2943 RefPtr
<GeckoMVMContext
> mMVMContext
;
2944 RefPtr
<MobileViewportManager
> mMobileViewportManager
;
2946 // This timer controls painting suppression. Until it fires
2947 // or all frames are constructed, we won't paint anything but
2948 // our <body> background and scrollbars.
2949 nsCOMPtr
<nsITimer
> mPaintSuppressionTimer
;
2951 // Information about live content (which still stay in DOM tree).
2952 // Used in case we need re-dispatch event after sending pointer event,
2953 // when target of pointer event was deleted during executing user handlers.
2954 nsCOMPtr
<nsIContent
> mPointerEventTarget
;
2956 nsCOMPtr
<nsIContent
> mLastAnchorScrolledTo
;
2958 // Information needed to properly handle scrolling content into view if the
2959 // pre-scroll reflow flush can be interrupted. mContentToScrollTo is non-null
2960 // between the initial scroll attempt and the first time we finish processing
2961 // all our dirty roots. mContentToScrollTo has a content property storing the
2962 // details for the scroll operation, see ScrollIntoViewData above.
2963 nsCOMPtr
<nsIContent
> mContentToScrollTo
;
2965 #ifdef ACCESSIBILITY
2966 a11y::DocAccessible
* mDocAccessible
;
2967 #endif // #ifdef ACCESSIBILITY
2969 nsIFrame
* mCurrentEventFrame
;
2970 nsCOMPtr
<nsIContent
> mCurrentEventContent
;
2971 nsTArray
<nsIFrame
*> mCurrentEventFrameStack
;
2972 nsCOMArray
<nsIContent
> mCurrentEventContentStack
;
2973 // Set of frames that we should mark with NS_FRAME_HAS_DIRTY_CHILDREN after
2974 // we finish reflowing mCurrentReflowRoot.
2975 nsTHashSet
<nsIFrame
*> mFramesToDirty
;
2976 nsTHashSet
<nsIScrollableFrame
*> mPendingScrollAnchorSelection
;
2977 nsTHashSet
<nsIScrollableFrame
*> mPendingScrollAnchorAdjustment
;
2978 nsTHashSet
<nsIScrollableFrame
*> mPendingScrollResnap
;
2980 nsTHashSet
<nsIContent
*> mHiddenContentInForcedLayout
;
2982 nsTHashSet
<nsIFrame
*> mContentVisibilityAutoFrames
;
2984 // The type of content relevancy to update the next time content relevancy
2985 // updates are triggered for `content-visibility: auto` frames.
2986 ContentRelevancy mContentVisibilityRelevancyToUpdate
;
2988 nsCallbackEventRequest
* mFirstCallbackEventRequest
= nullptr;
2989 nsCallbackEventRequest
* mLastCallbackEventRequest
= nullptr;
2991 // This is used for synthetic mouse events that are sent when what is under
2992 // the mouse pointer may have changed without the mouse moving (eg scrolling,
2993 // change to the document contents).
2994 // It is set only on a presshell for a root document, this value represents
2995 // the last observed location of the mouse relative to that root document,
2996 // in visual coordinates. It is set to (NS_UNCONSTRAINEDSIZE,
2997 // NS_UNCONSTRAINEDSIZE) if the mouse isn't over our window or there is no
2998 // last observed mouse location for some reason.
2999 nsPoint mMouseLocation
;
3000 // The last observed pointer location relative to that root document in visual
3002 nsPoint mLastOverWindowPointerLocation
;
3003 // This is an APZ state variable that tracks the target guid for the last
3004 // mouse event that was processed (corresponding to mMouseLocation). This is
3005 // needed for the synthetic mouse events.
3006 layers::ScrollableLayerGuid mMouseEventTargetGuid
;
3008 // Only populated on root content documents.
3009 nsSize mVisualViewportSize
;
3011 // The focus information needed for async keyboard scrolling
3012 FocusTarget mAPZFocusTarget
;
3014 using Arena
= nsPresArena
<8192, ArenaObjectID
, eArenaObjectID_COUNT
>;
3017 Maybe
<nsPoint
> mVisualViewportOffset
;
3019 // A pending visual scroll offset that we will ask APZ to scroll to
3020 // during the next transaction. Cleared when we send the transaction.
3021 // Only applicable to the RCD pres shell.
3022 Maybe
<VisualScrollUpdate
> mPendingVisualScrollUpdate
;
3024 // Used to force allocation and rendering of proportionally more or
3025 // less pixels in both dimensions.
3026 Maybe
<float> mResolution
;
3027 ResolutionChangeOrigin mLastResolutionChangeOrigin
;
3029 TimeStamp mLoadBegin
; // used to time loads
3031 TimeStamp mLastOSWake
;
3033 // Count of the number of times this presshell has been painted to a window.
3034 uint64_t mPaintCount
;
3036 // The focus sequence number of the last processed input event
3037 uint64_t mAPZFocusSequenceNumber
;
3039 nscoord mLastAnchorScrollPositionY
= 0;
3041 // Most recent canvas background color.
3042 CanvasBackground mCanvasBackground
;
3044 int32_t mActiveSuppressDisplayport
;
3046 uint32_t mPresShellId
;
3048 // Cached font inflation values. This is done to prevent changing of font
3049 // inflation until a page is reloaded.
3050 uint32_t mFontSizeInflationEmPerLine
;
3051 uint32_t mFontSizeInflationMinTwips
;
3052 uint32_t mFontSizeInflationLineThreshold
;
3054 // Can be multiple of nsISelectionDisplay::DISPLAY_*.
3055 int16_t mSelectionFlags
;
3057 // This is used to protect ourselves from triggering reflow while in the
3058 // middle of frame construction and the like... it really shouldn't be
3059 // needed, one hopes, but it is for now.
3060 uint16_t mChangeNestCount
;
3062 // Flags controlling how our document is rendered. These persist
3063 // between paints and so are tied with retained layer pixels.
3064 // PresShell flushes retained layers when the rendering state
3065 // changes in a way that prevents us from being able to (usefully)
3066 // re-use old pixels.
3067 RenderingStateFlags mRenderingStateFlags
;
3069 // Whether we're currently under a FlushPendingNotifications.
3070 // This is used to handle flush reentry correctly.
3071 // NOTE: This can't be a bitfield since AutoRestore has a reference to this
3075 bool mCaretEnabled
: 1;
3077 // True if a layout flush might not be a no-op
3078 bool mNeedLayoutFlush
: 1;
3080 // True if a style flush might not be a no-op
3081 bool mNeedStyleFlush
: 1;
3083 // True if there are throttled animations that would be processed when
3084 // performing a flush with mFlushAnimations == true.
3085 bool mNeedThrottledAnimationFlush
: 1;
3087 bool mVisualViewportSizeSet
: 1;
3089 bool mDidInitialize
: 1;
3090 bool mIsDestroying
: 1;
3091 bool mIsReflowing
: 1;
3092 bool mIsObservingDocument
: 1;
3094 // Whether we shouldn't ever get to FlushPendingNotifications. This flag is
3095 // meant only to sanity-check / assert that FlushPendingNotifications doesn't
3096 // happen during certain periods of time. It shouldn't be made public nor used
3097 // for other purposes.
3098 bool mForbiddenToFlush
: 1;
3100 // We've been disconnected from the document. We will refuse to paint the
3101 // document until either our timer fires or all frames are constructed.
3102 bool mIsDocumentGone
: 1;
3103 bool mHaveShutDown
: 1;
3105 // For all documents we initially lock down painting.
3106 bool mPaintingSuppressed
: 1;
3108 bool mLastRootReflowHadUnconstrainedBSize
: 1;
3110 // Indicates that it is safe to unlock painting once all pending reflows
3111 // have been processed.
3112 bool mShouldUnsuppressPainting
: 1;
3114 bool mIgnoreFrameDestruction
: 1;
3118 bool mIsFirstPaint
: 1;
3119 bool mObservesMutationsForPrint
: 1;
3121 // Whether the most recent interruptible reflow was actually interrupted:
3122 bool mWasLastReflowInterrupted
: 1;
3124 // True if we're observing the refresh driver for style flushes.
3125 bool mObservingStyleFlushes
: 1;
3127 // True if we're observing the refresh driver for layout flushes, that is, if
3128 // we have a reflow scheduled.
3130 // Guaranteed to be false if mReflowContinueTimer is non-null.
3131 bool mObservingLayoutFlushes
: 1;
3133 bool mResizeEventPending
: 1;
3135 bool mFontSizeInflationForceEnabled
: 1;
3136 bool mFontSizeInflationDisabledInMasterProcess
: 1;
3137 bool mFontSizeInflationEnabled
: 1;
3139 // If a document belongs to an invisible DocShell, this flag must be set
3140 // to true, so we can avoid any paint calls for widget related to this
3142 bool mIsNeverPainting
: 1;
3144 // Whether the most recent change to the pres shell resolution was
3145 // originated by the main thread.
3146 bool mResolutionUpdated
: 1;
3148 // True if the resolution has been ever changed by APZ.
3149 bool mResolutionUpdatedByApz
: 1;
3151 // Whether this presshell is hidden by 'vibility:hidden' on an ancestor
3152 // nsSubDocumentFrame.
3153 bool mUnderHiddenEmbedderElement
: 1;
3155 bool mDocumentLoading
: 1;
3156 bool mNoDelayedMouseEvents
: 1;
3157 bool mNoDelayedKeyEvents
: 1;
3159 bool mApproximateFrameVisibilityVisited
: 1;
3161 // Whether the last chrome-only escape key event is consumed.
3162 bool mIsLastChromeOnlyEscapeKeyConsumed
: 1;
3164 // Whether the widget has received a paint message yet.
3165 bool mHasReceivedPaintMessage
: 1;
3167 bool mIsLastKeyDownCanceled
: 1;
3169 // Whether we have ever handled a user input event
3170 bool mHasHandledUserInput
: 1;
3172 // Whether we should dispatch keypress events even for non-printable keys
3173 // for keeping backward compatibility.
3174 bool mForceDispatchKeyPressEventsForNonPrintableKeys
: 1;
3175 // Whether we should set keyCode or charCode value of keypress events whose
3176 // value is zero to the other value or not. When this is set to true, we
3177 // should keep using legacy keyCode and charCode values (i.e., one of them
3179 bool mForceUseLegacyKeyCodeAndCharCodeValues
: 1;
3180 // Whether mForceDispatchKeyPressEventsForNonPrintableKeys and
3181 // mForceUseLegacyKeyCodeAndCharCodeValues are initialized.
3182 bool mInitializedWithKeyPressEventDispatchingBlacklist
: 1;
3184 // Set to true if mMouseLocation is set by a mouse event which is synthesized
3186 bool mMouseLocationWasSetBySynthesizedMouseEventForTests
: 1;
3188 bool mHasTriedFastUnsuppress
: 1;
3190 bool mProcessingReflowCommands
: 1;
3191 bool mPendingDidDoReflow
: 1;
3193 struct CapturingContentInfo final
{
3194 CapturingContentInfo()
3195 : mRemoteTarget(nullptr),
3197 mPointerLock(false),
3198 mRetargetToElement(false),
3199 mPreventDrag(false) {}
3201 // capture should only be allowed during a mousedown event
3202 StaticRefPtr
<nsIContent
> mContent
;
3203 dom::BrowserParent
* mRemoteTarget
;
3206 bool mRetargetToElement
;
3209 static CapturingContentInfo sCapturingContentInfo
;
3211 static bool sDisableNonTestMouseEvents
;
3213 static bool sProcessInteractable
;
3215 layout_telemetry::Data mLayoutTelemetry
;
3218 NS_DEFINE_STATIC_IID_ACCESSOR(PresShell
, NS_PRESSHELL_IID
)
3220 } // namespace mozilla
3222 #endif // mozilla_PresShell_h