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 1 */
9 #ifndef nsPresContext_h___
10 #define nsPresContext_h___
12 #include "mozilla/intl/Bidi.h"
13 #include "mozilla/AppUnits.h"
14 #include "mozilla/Attributes.h"
15 #include "mozilla/DepthOrderedFrameList.h"
16 #include "mozilla/EnumeratedArray.h"
17 #include "mozilla/MediaEmulationData.h"
18 #include "mozilla/MemoryReporting.h"
19 #include "mozilla/NotNull.h"
20 #include "mozilla/PreferenceSheet.h"
21 #include "mozilla/PresShellForwards.h"
22 #include "mozilla/ScrollStyles.h"
23 #include "mozilla/TimeStamp.h"
24 #include "mozilla/UniquePtr.h"
25 #include "mozilla/WeakPtr.h"
26 #include "mozilla/widget/ThemeChangeKind.h"
28 #include "nsCompatibility.h"
31 #include "nsFontMetrics.h"
32 #include "nsHashKeys.h"
34 #include "nsStringFwd.h"
35 #include "nsTHashSet.h"
36 #include "nsTHashtable.h"
38 #include "nsIWidgetListener.h" // for nsSizeMode
39 #include "nsGkAtoms.h"
40 #include "nsCycleCollectionParticipant.h"
41 #include "nsChangeHint.h"
45 #include "nsThreadUtils.h"
48 class nsIPrintSettings
;
59 class gfxFontFeatureValueSet
;
60 class gfxUserFontEntry
;
62 class gfxTextPerfMetrics
;
63 class nsCSSFontFeatureValuesRule
;
64 class nsCSSFrameConstructor
;
66 class nsTransitionManager
;
67 class nsAnimationManager
;
68 class nsRefreshDriver
;
70 class nsDeviceContext
;
71 class gfxMissingFontRecorder
;
74 class AnimationEventDispatcher
;
75 class EffectCompositor
;
77 class EventStateManager
;
78 class CounterStyleManager
;
79 class ManagedPostRefreshObserver
;
84 class TimelineManager
;
85 struct MediaFeatureChange
;
86 enum class MediaFeatureChangePropagation
: uint8_t;
87 enum class ColorScheme
: uint8_t;
95 enum class PrefersColorSchemeOverride
: uint8_t;
98 class FontPaletteValueSet
;
100 } // namespace mozilla
102 // supported values for cached integer pref types
103 enum nsPresContext_CachedIntPrefType
{
104 kPresContext_ScrollbarSide
= 1,
105 kPresContext_BidiDirection
108 // IDs for the default variable and fixed fonts (not to be changed, see
109 // nsFont.h) To be used for Get/SetDefaultFont(). The other IDs in nsFont.h are
112 // kGenericFont_moz_variable
113 const uint8_t kPresContext_DefaultVariableFont_ID
= 0x00;
114 // kGenericFont_moz_fixed
115 const uint8_t kPresContext_DefaultFixedFont_ID
= 0x01;
118 struct nsAutoLayoutPhase
;
120 enum class nsLayoutPhase
: uint8_t {
122 DisplayListBuilding
, // sometimes a subset of the paint phase
129 class nsRootPresContext
;
131 // An interface for presentation contexts. Presentation contexts are
132 // objects that provide an outer context for a presentation shell.
134 class nsPresContext
: public nsISupports
, public mozilla::SupportsWeakPtr
{
136 using Encoding
= mozilla::Encoding
;
137 template <typename T
>
138 using NotNull
= mozilla::NotNull
<T
>;
139 template <typename T
>
140 using Maybe
= mozilla::Maybe
<T
>;
141 using MediaEmulationData
= mozilla::MediaEmulationData
;
143 typedef mozilla::ScrollStyles ScrollStyles
;
144 using TransactionId
= mozilla::layers::TransactionId
;
146 NS_DECL_CYCLE_COLLECTING_ISUPPORTS_FINAL
147 NS_DECL_CYCLE_COLLECTION_CLASS(nsPresContext
)
149 enum nsPresContextType
: uint8_t {
150 eContext_Galley
, // unpaginated screen presentation
151 eContext_PrintPreview
, // paginated screen presentation
152 eContext_Print
, // paginated printer presentation
153 eContext_PageLayout
// paginated & editable.
156 nsPresContext(mozilla::dom::Document
* aDocument
, nsPresContextType aType
);
159 * Initialize the presentation context from a particular device.
161 nsresult
Init(nsDeviceContext
* aDeviceContext
);
164 * Initialize the font cache if it hasn't been initialized yet.
167 void InitFontCache();
169 void UpdateFontCacheUserFonts(gfxUserFontSet
* aUserFontSet
);
171 FontVisibility
GetFontVisibility() const { return mFontVisibility
; }
172 void ReportBlockedFontFamily(const mozilla::fontlist::Family
& aFamily
);
173 void ReportBlockedFontFamily(const gfxFontFamily
& aFamily
);
176 * Get the nsFontMetrics that describe the properties of
178 * @param aFont font description to obtain metrics for
180 already_AddRefed
<nsFontMetrics
> GetMetricsFor(
181 const nsFont
& aFont
, const nsFontMetrics::Params
& aParams
);
184 * Notification when a font metrics instance created for this context is
185 * about to be deleted
187 nsresult
FontMetricsDeleted(const nsFontMetrics
* aFontMetrics
);
190 * Attempt to free up resources by flushing out any fonts no longer
191 * referenced by anything other than the font cache itself.
192 * @return error status
194 nsresult
FlushFontCache();
197 * Set and detach presentation shell that this context is bound to.
198 * A presentation context may only be bound to a single shell.
200 void AttachPresShell(mozilla::PresShell
* aPresShell
);
201 void DetachPresShell();
203 nsPresContextType
Type() const { return mType
; }
206 * Get the PresentationShell that this context is bound to.
208 mozilla::PresShell
* PresShell() const {
209 NS_ASSERTION(mPresShell
, "Null pres shell");
213 mozilla::PresShell
* GetPresShell() const { return mPresShell
; }
215 void DocumentCharSetChanged(NotNull
<const Encoding
*> aCharSet
);
218 * Returns the parent prescontext for this one. Returns null if this is a
221 nsPresContext
* GetParentPresContext() const;
224 * Returns the prescontext of the root content document in the same process
225 * that contains this presentation, or null if there isn't one.
227 nsPresContext
* GetInProcessRootContentDocumentPresContext();
230 * Returns the nearest widget for the root frame or view of this.
232 * @param aOffset If non-null the offset from the origin of the root
233 * frame's view to the widget's origin (usually positive)
234 * expressed in appunits of this will be returned in
237 nsIWidget
* GetNearestWidget(nsPoint
* aOffset
= nullptr);
240 * Returns the root widget for this.
242 nsIWidget
* GetRootWidget() const;
245 * Returns the widget which may have native focus and handles text input
246 * like keyboard input, IME, etc.
248 nsIWidget
* GetTextInputHandlingWidget() const {
249 // Currently, root widget for each PresContext handles text input.
250 return GetRootWidget();
254 * Return the presentation context for the root of the view manager
255 * hierarchy that contains this presentation context, or nullptr if it can't
256 * be found (e.g. it's detached).
258 nsRootPresContext
* GetRootPresContext() const;
260 virtual bool IsRoot() { return false; }
262 mozilla::dom::Document
* Document() const {
264 ValidatePresShellAndDocumentReleation();
265 #endif // #ifdef DEBUG
269 inline mozilla::ServoStyleSet
* StyleSet() const;
271 bool HasPendingMediaQueryUpdates() const {
272 return !!mPendingMediaFeatureValuesChange
;
275 inline nsCSSFrameConstructor
* FrameConstructor() const;
277 mozilla::AnimationEventDispatcher
* AnimationEventDispatcher() {
278 return mAnimationEventDispatcher
;
281 mozilla::EffectCompositor
* EffectCompositor() { return mEffectCompositor
; }
282 nsTransitionManager
* TransitionManager() { return mTransitionManager
.get(); }
283 nsAnimationManager
* AnimationManager() { return mAnimationManager
.get(); }
284 const nsAnimationManager
* AnimationManager() const {
285 return mAnimationManager
.get();
287 mozilla::TimelineManager
* TimelineManager() { return mTimelineManager
.get(); }
289 nsRefreshDriver
* RefreshDriver() { return mRefreshDriver
; }
291 mozilla::RestyleManager
* RestyleManager() {
292 MOZ_ASSERT(mRestyleManager
);
293 return mRestyleManager
.get();
296 mozilla::CounterStyleManager
* CounterStyleManager() const {
297 return mCounterStyleManager
;
301 * Rebuilds all style data by throwing out the old rule tree and
302 * building a new one, and additionally applying a change hint (which must not
303 * contain nsChangeHint_ReconstructFrame) to the root frame.
305 * For the restyle hint argument, see RestyleManager::RebuildAllStyleData.
306 * Also rebuild the user font set and counter style manager.
308 * FIXME(emilio): The name of this is an utter lie. We should probably call
309 * this PostGlobalStyleChange or something, as it doesn't really rebuild
310 * anything unless you tell it to via the change hint / restyle hint
313 void RebuildAllStyleData(nsChangeHint
, const mozilla::RestyleHint
&);
315 * Just like RebuildAllStyleData, except (1) asynchronous and (2) it
316 * doesn't rebuild the user font set / counter-style manager / etc.
318 void PostRebuildAllStyleDataEvent(nsChangeHint
, const mozilla::RestyleHint
&);
320 void ContentLanguageChanged();
322 /** Returns whether any media query changed. */
323 bool FlushPendingMediaFeatureValuesChanged();
326 * Schedule a media feature change for this document, and potentially for
327 * other subdocuments and images (depending on the arguments).
329 void MediaFeatureValuesChanged(const mozilla::MediaFeatureChange
&,
330 mozilla::MediaFeatureChangePropagation
);
333 * Updates the size mode on all remote children and recursively notifies this
334 * document and all subdocuments (including remote children) that a media
335 * feature value has changed.
337 void SizeModeChanged(nsSizeMode aSizeMode
);
340 * Access compatibility mode for this context. This is the same as
341 * our document's compatibility mode.
343 nsCompatibility
CompatibilityMode() const;
346 * Access the image animation mode for this context
348 uint16_t ImageAnimationMode() const { return mImageAnimationMode
; }
349 void SetImageAnimationMode(uint16_t aMode
);
352 * Get medium of presentation
354 const nsAtom
* Medium() const {
356 return mMediaEmulationData
.mMedium
? mMediaEmulationData
.mMedium
.get()
361 * Render the document as if being viewed on a device with the specified
364 * If passed null, it stops emulating.
366 void EmulateMedium(nsAtom
* aMediaType
);
368 /** Get a cached integer pref, by its type */
369 // * - initially created for bugs 30910, 61883, 74186, 84398
370 int32_t GetCachedIntPref(nsPresContext_CachedIntPrefType aPrefType
) const {
371 // If called with a constant parameter, the compiler should optimize
372 // this switch statement away.
374 case kPresContext_ScrollbarSide
:
375 return mPrefScrollbarSide
;
376 case kPresContext_BidiDirection
:
377 return mPrefBidiDirection
;
379 NS_ERROR("invalid arg passed to GetCachedIntPref");
385 const mozilla::PreferenceSheet::Prefs
& PrefSheetPrefs() const {
386 return mozilla::PreferenceSheet::PrefsFor(*mDocument
);
389 bool ForcingColors() const {
390 return mozilla::PreferenceSheet::MayForceColors() &&
391 !PrefSheetPrefs().mUseDocumentColors
;
394 mozilla::ColorScheme
DefaultBackgroundColorScheme() const;
395 nscolor
DefaultBackgroundColor() const;
397 nsISupports
* GetContainerWeak() const;
399 nsDocShell
* GetDocShell() const;
402 * Get the visible area associated with this presentation context.
403 * This is the size of the visible area that is used for
404 * presenting the document. The returned value is in the standard
405 * nscoord units (as scaled by the device context).
407 nsRect
GetVisibleArea() const { return mVisibleArea
; }
410 * Set the currently visible area. The units for r are standard
411 * nscoord units (as scaled by the device context).
413 void SetVisibleArea(const nsRect
& r
);
415 nsSize
GetSizeForViewportUnits() const { return mSizeForViewportUnits
; }
418 * Set the maximum height of the dynamic toolbar in nscoord units.
421 void SetDynamicToolbarMaxHeight(mozilla::ScreenIntCoord aHeight
);
423 mozilla::ScreenIntCoord
GetDynamicToolbarMaxHeight() const {
424 MOZ_ASSERT(IsRootContentDocumentCrossProcess());
425 return mDynamicToolbarMaxHeight
;
429 * Returns true if we are using the dynamic toolbar.
431 bool HasDynamicToolbar() const {
432 MOZ_ASSERT(IsRootContentDocumentCrossProcess());
433 return mDynamicToolbarMaxHeight
> 0;
437 * |aOffset| must be offset from the bottom edge of the ICB and it's negative.
439 void UpdateDynamicToolbarOffset(mozilla::ScreenIntCoord aOffset
);
440 mozilla::ScreenIntCoord
GetDynamicToolbarHeight() const {
441 MOZ_ASSERT(IsRootContentDocumentCrossProcess());
442 return mDynamicToolbarHeight
;
446 * Returns the state of the dynamic toolbar.
448 mozilla::DynamicToolbarState
GetDynamicToolbarState() const;
451 * Return true if this presentation context is a paginated
454 bool IsPaginated() const { return mPaginated
; }
457 * Sets whether the presentation context can scroll for a paginated
460 void SetPaginatedScrolling(bool aResult
);
463 * Return true if this presentation context can scroll for paginated
466 bool HasPaginatedScrolling() const { return mCanPaginatedScroll
; }
469 * Get/set the size of a page
471 const nsSize
& GetPageSize() const { return mPageSize
; }
472 const nsMargin
& GetDefaultPageMargin() const { return mDefaultPageMargin
; }
473 void SetPageSize(nsSize aSize
) { mPageSize
= aSize
; }
476 * Get/set whether this document should be treated as having real pages
477 * XXX This raises the obvious question of why a document that isn't a page
478 * is paginated; there isn't a good reason except history
480 bool IsRootPaginatedDocument() { return mIsRootPaginatedDocument
; }
481 void SetIsRootPaginatedDocument(bool aIsRootPaginatedDocument
) {
482 mIsRootPaginatedDocument
= aIsRootPaginatedDocument
;
486 * Get/set the print scaling level; used by nsPageFrame to scale up
487 * pages. Set safe to call before reflow, get guaranteed to be set
488 * properly after reflow.
491 float GetPageScale() { return mPageScale
; }
492 void SetPageScale(float aScale
) { mPageScale
= aScale
; }
495 * Get/set the scaling factor to use when rendering the pages for print
496 * preview. Only safe to get after print preview set up; safe to set anytime.
497 * This is a scaling factor for the display of the print preview. It
498 * does not affect layout. It only affects the size of the onscreen pages
501 * The getter should only be used by the page sequence frame, which is the
502 * frame responsible for applying the scaling. Other callers should use
503 * nsPageSequenceFrame::GetPrintPreviewScale() if needed, instead of this API.
505 * XXX Temporary: see http://wiki.mozilla.org/Gecko:PrintPreview
507 float GetPrintPreviewScaleForSequenceFrameOrScrollbars() const {
510 void SetPrintPreviewScale(float aScale
) { mPPScale
= aScale
; }
512 nsDeviceContext
* DeviceContext() const { return mDeviceContext
; }
513 mozilla::EventStateManager
* EventStateManager() { return mEventManager
; }
515 // Get the text zoom factor in use.
516 float TextZoom() const { return mTextZoom
; }
519 * Notify the pres context that the safe area insets have changed.
521 void SetSafeAreaInsets(const mozilla::ScreenIntMargin
& aInsets
);
523 mozilla::ScreenIntMargin
GetSafeAreaInsets() const { return mSafeAreaInsets
; }
525 void RegisterManagedPostRefreshObserver(mozilla::ManagedPostRefreshObserver
*);
526 void UnregisterManagedPostRefreshObserver(
527 mozilla::ManagedPostRefreshObserver
*);
530 void CancelManagedPostRefreshObservers();
533 void ValidatePresShellAndDocumentReleation() const;
534 #endif // #ifdef DEBUG
536 void SetTextZoom(float aZoom
);
537 void SetFullZoom(float aZoom
);
538 void SetOverrideDPPX(float);
539 void SetInRDMPane(bool aInRDMPane
);
542 float GetFullZoom() { return mFullZoom
; }
544 * Device full zoom differs from full zoom because it gets the zoom from
545 * the device context, which may be using a different zoom due to rounding
546 * of app units to device pixels.
548 float GetDeviceFullZoom();
550 float GetOverrideDPPX() const { return mMediaEmulationData
.mDPPX
; }
552 // Gets the forced color-scheme if any via either our embedder, or DevTools
553 // emulation, or printing.
555 // NOTE(emilio): This might be called from an stylo thread.
556 Maybe
<mozilla::ColorScheme
> GetOverriddenOrEmbedderColorScheme() const;
559 * Recomputes the data dependent on the browsing context, like zoom and text
562 void RecomputeBrowsingContextDependentData();
565 * Sets the effective color scheme override, and invalidate stuff as needed.
567 void SetColorSchemeOverride(mozilla::dom::PrefersColorSchemeOverride
);
570 * Return the device's screen size in inches, for font size
573 * If |aChanged| is non-null, then aChanged is filled in with whether
574 * the screen size value has changed since either:
575 * a. the last time the function was called with non-null aChanged, or
576 * b. the first time the function was called.
578 gfxSize
ScreenSizeInchesForFontInflation(bool* aChanged
= nullptr);
580 int32_t AppUnitsPerDevPixel() const { return mCurAppUnitsPerDevPixel
; }
582 static nscoord
CSSPixelsToAppUnits(int32_t aPixels
) {
583 return NSToCoordRoundWithClamp(float(aPixels
) *
584 float(mozilla::AppUnitsPerCSSPixel()));
587 static nscoord
CSSPixelsToAppUnits(float aPixels
) {
588 return NSToCoordRoundWithClamp(aPixels
*
589 float(mozilla::AppUnitsPerCSSPixel()));
592 static int32_t AppUnitsToIntCSSPixels(nscoord aAppUnits
) {
593 return NSAppUnitsToIntPixels(aAppUnits
,
594 float(mozilla::AppUnitsPerCSSPixel()));
597 static float AppUnitsToFloatCSSPixels(nscoord aAppUnits
) {
598 return NSAppUnitsToFloatPixels(aAppUnits
,
599 float(mozilla::AppUnitsPerCSSPixel()));
602 static double AppUnitsToDoubleCSSPixels(nscoord aAppUnits
) {
603 return NSAppUnitsToDoublePixels(aAppUnits
,
604 double(mozilla::AppUnitsPerCSSPixel()));
607 nscoord
DevPixelsToAppUnits(int32_t aPixels
) const {
608 return NSIntPixelsToAppUnits(aPixels
, AppUnitsPerDevPixel());
611 int32_t AppUnitsToDevPixels(nscoord aAppUnits
) const {
612 return NSAppUnitsToIntPixels(aAppUnits
, float(AppUnitsPerDevPixel()));
615 float AppUnitsToFloatDevPixels(nscoord aAppUnits
) {
616 return aAppUnits
/ float(AppUnitsPerDevPixel());
619 int32_t CSSPixelsToDevPixels(int32_t aPixels
) {
620 return AppUnitsToDevPixels(CSSPixelsToAppUnits(aPixels
));
623 float CSSPixelsToDevPixels(float aPixels
) {
624 return NSAppUnitsToFloatPixels(CSSPixelsToAppUnits(aPixels
),
625 float(AppUnitsPerDevPixel()));
628 int32_t DevPixelsToIntCSSPixels(int32_t aPixels
) {
629 return AppUnitsToIntCSSPixels(DevPixelsToAppUnits(aPixels
));
632 static nscoord
RoundDownAppUnitsToCSSPixel(nscoord aAppUnits
) {
633 return mozilla::RoundDownToMultiple(aAppUnits
,
634 mozilla::AppUnitsPerCSSPixel());
636 static nscoord
RoundUpAppUnitsToCSSPixel(nscoord aAppUnits
) {
637 return mozilla::RoundUpToMultiple(aAppUnits
,
638 mozilla::AppUnitsPerCSSPixel());
640 static nscoord
RoundAppUnitsToCSSPixel(nscoord aAppUnits
) {
641 return mozilla::RoundToMultiple(aAppUnits
, mozilla::AppUnitsPerCSSPixel());
644 nscoord
RoundDownAppUnitsToDevPixel(nscoord aAppUnits
) const {
645 return mozilla::RoundDownToMultiple(aAppUnits
, AppUnitsPerDevPixel());
647 nscoord
RoundUpAppUnitsToDevPixel(nscoord aAppUnits
) const {
648 return mozilla::RoundUpToMultiple(aAppUnits
, AppUnitsPerDevPixel());
650 nscoord
RoundAppUnitsToDevPixel(nscoord aAppUnits
) const {
651 return mozilla::RoundToMultiple(aAppUnits
, AppUnitsPerDevPixel());
654 mozilla::CSSIntPoint
DevPixelsToIntCSSPixels(
655 const mozilla::LayoutDeviceIntPoint
& aPoint
) {
656 return mozilla::CSSIntPoint(
657 AppUnitsToIntCSSPixels(DevPixelsToAppUnits(aPoint
.x
)),
658 AppUnitsToIntCSSPixels(DevPixelsToAppUnits(aPoint
.y
)));
661 float DevPixelsToFloatCSSPixels(int32_t aPixels
) const {
662 return AppUnitsToFloatCSSPixels(DevPixelsToAppUnits(aPixels
));
665 mozilla::CSSToLayoutDeviceScale
CSSToDevPixelScale() const {
666 return mozilla::CSSToLayoutDeviceScale(
667 float(mozilla::AppUnitsPerCSSPixel()) / float(AppUnitsPerDevPixel()));
670 // If there is a remainder, it is rounded to nearest app units.
671 nscoord
GfxUnitsToAppUnits(gfxFloat aGfxUnits
) const;
673 gfxFloat
AppUnitsToGfxUnits(nscoord aAppUnits
) const;
675 gfxRect
AppUnitsToGfxUnits(const nsRect
& aAppRect
) const {
676 return gfxRect(AppUnitsToGfxUnits(aAppRect
.x
),
677 AppUnitsToGfxUnits(aAppRect
.y
),
678 AppUnitsToGfxUnits(aAppRect
.Width()),
679 AppUnitsToGfxUnits(aAppRect
.Height()));
682 static nscoord
CSSTwipsToAppUnits(float aTwips
) {
683 return NSToCoordRoundWithClamp(mozilla::AppUnitsPerCSSInch() *
684 NS_TWIPS_TO_INCHES(aTwips
));
687 // Margin-specific version, since they often need TwipsToAppUnits
688 static nsMargin
CSSTwipsToAppUnits(const nsIntMargin
& marginInTwips
) {
689 return nsMargin(CSSTwipsToAppUnits(float(marginInTwips
.top
)),
690 CSSTwipsToAppUnits(float(marginInTwips
.right
)),
691 CSSTwipsToAppUnits(float(marginInTwips
.bottom
)),
692 CSSTwipsToAppUnits(float(marginInTwips
.left
)));
695 static nscoord
CSSPointsToAppUnits(float aPoints
) {
696 return NSToCoordRound(aPoints
* mozilla::AppUnitsPerCSSInch() /
697 POINTS_PER_INCH_FLOAT
);
700 nscoord
PhysicalMillimetersToAppUnits(float aMM
) const;
702 nscoord
RoundAppUnitsToNearestDevPixels(nscoord aAppUnits
) const {
703 return DevPixelsToAppUnits(AppUnitsToDevPixels(aAppUnits
));
707 * This checks the root element and the HTML BODY, if any, for an "overflow"
708 * property that should be applied to the viewport. If one is found then we
709 * return the element that we took the overflow from (which should then be
710 * treated as "overflow: visible"), and we store the overflow style here.
711 * If the document is in fullscreen, and the fullscreen element is not the
712 * root, the scrollbar of viewport will be suppressed.
713 * @return if scroll was propagated from some content node, the content node
714 * it was propagated from.
716 mozilla::dom::Element
* UpdateViewportScrollStylesOverride();
719 * Returns the cached result from the last call to
720 * UpdateViewportScrollStylesOverride() -- i.e. return the node
721 * whose scrollbar styles we have propagated to the viewport (or nullptr if
722 * there is no such node).
724 mozilla::dom::Element
* GetViewportScrollStylesOverrideElement() const {
725 return mViewportScrollOverrideElement
;
728 const ScrollStyles
& GetViewportScrollStylesOverride() const {
729 return mViewportScrollStyles
;
733 * Check whether the given element would propagate its scrollbar styles to the
734 * viewport in non-paginated mode.
736 bool ElementWouldPropagateScrollStyles(const mozilla::dom::Element
&);
739 * Methods for controlling the background drawing.
741 bool GetBackgroundImageDraw() const { return mDrawImageBackground
; }
742 bool GetBackgroundColorDraw() const { return mDrawColorBackground
; }
745 * Check if bidi enabled (set depending on the presence of RTL
746 * characters or when default directionality is RTL).
747 * If enabled, we should apply the Unicode Bidi Algorithm
751 bool BidiEnabled() const;
754 * Set bidi enabled. This means we should apply the Unicode Bidi Algorithm
758 void SetBidiEnabled() const;
761 * Set visual or implicit mode into the pres context.
763 * Visual directionality is a presentation method that displays text
764 * as if it were a uni-directional, according to the primary display
767 * Implicit directionality is a presentation method in which the
768 * direction is determined by the Bidi algorithm according to the
769 * category of the characters and the category of the adjacent
770 * characters, and according to their primary direction.
774 void SetVisualMode(bool aIsVisual
) { mIsVisual
= aIsVisual
; }
777 * Check whether the content should be treated as visual.
781 bool IsVisualMode() const { return mIsVisual
; }
783 enum class InteractionType
: uint32_t {
786 MouseMoveInteraction
,
790 void RecordInteractionTime(InteractionType aType
,
791 const mozilla::TimeStamp
& aTimeStamp
);
793 void DisableInteractionTimeRecording() { mInteractionTimeEnabled
= false; }
798 * Set the Bidi options for the presentation context
800 void SetBidi(uint32_t aBidiOptions
);
803 * Get the Bidi options for the presentation context
804 * Not inline so consumers of nsPresContext are not forced to
807 uint32_t GetBidi() const;
809 nsITheme
* Theme() const MOZ_NONNULL_RETURN
;
811 void RecomputeTheme();
813 bool UseOverlayScrollbars() const;
816 * Notify the pres context that the theme has changed. An internal switch
817 * means it's one of our Mozilla themes that changed (e.g., Modern to
818 * Classic). Otherwise, the OS is telling us that the native theme for the
819 * platform has changed.
821 void ThemeChanged(mozilla::widget::ThemeChangeKind
);
824 * Notify the pres context that the resolution of the user interface has
825 * changed. This happens if a window is moved between HiDPI and non-HiDPI
826 * displays, so that the ratio of points to device pixels changes.
827 * The notification happens asynchronously.
829 void UIResolutionChanged();
832 * Like UIResolutionChanged() but invalidates values immediately.
834 void UIResolutionChangedSync();
836 /** Printing methods below should only be used for Medium() == print **/
837 void SetPrintSettings(nsIPrintSettings
* aPrintSettings
);
839 nsIPrintSettings
* GetPrintSettings() { return mPrintSettings
; }
841 /* Helper function that ensures that this prescontext is shown in its
842 docshell if it's the most recent prescontext for the docshell. Returns
843 whether the prescontext is now being shown.
845 bool EnsureVisible();
847 #ifdef MOZ_REFLOW_PERF
848 void CountReflows(const char* aName
, nsIFrame
* aFrame
);
851 void ConstructedFrame() { ++mFramesConstructed
; }
852 void ReflowedFrame() { ++mFramesReflowed
; }
854 uint64_t FramesConstructedCount() { return mFramesConstructed
; }
855 uint64_t FramesReflowedCount() { return mFramesReflowed
; }
857 static nscoord
GetBorderWidthForKeyword(unsigned int aBorderWidthKeyword
) {
858 // This table maps border-width enums 'thin', 'medium', 'thick'
859 // to actual nscoord values.
860 static const nscoord kBorderWidths
[] = {
861 CSSPixelsToAppUnits(1), CSSPixelsToAppUnits(3), CSSPixelsToAppUnits(5)};
862 MOZ_ASSERT(size_t(aBorderWidthKeyword
) <
863 mozilla::ArrayLength(kBorderWidths
));
865 return kBorderWidths
[aBorderWidthKeyword
];
868 gfxTextPerfMetrics
* GetTextPerfMetrics() { return mTextPerf
.get(); }
870 bool IsDynamic() const {
871 return mType
== eContext_PageLayout
|| mType
== eContext_Galley
;
873 bool IsScreen() const {
874 return mMedium
== nsGkAtoms::screen
|| mType
== eContext_PageLayout
||
875 mType
== eContext_PrintPreview
;
877 bool IsPrintingOrPrintPreview() const {
878 return mType
== eContext_Print
|| mType
== eContext_PrintPreview
;
881 bool IsPrintPreview() const { return mType
== eContext_PrintPreview
; }
883 // Is this presentation in a chrome docshell?
884 bool IsChrome() const;
886 gfxUserFontSet
* GetUserFontSet();
888 // Should be called whenever the set of fonts available in the user
889 // font set changes (e.g., because a new font loads, or because the
890 // user font set is changed and fonts become unavailable).
891 void UserFontSetUpdated(gfxUserFontEntry
* aUpdatedFont
= nullptr);
893 gfxMissingFontRecorder
* MissingFontRecorder() { return mMissingFonts
.get(); }
895 void NotifyMissingFonts();
897 void FlushCounterStyles();
898 void MarkCounterStylesDirty();
900 void FlushFontFeatureValues();
901 void MarkFontFeatureValuesDirty() { mFontFeatureValuesDirty
= true; }
903 void FlushFontPaletteValues();
904 void MarkFontPaletteValuesDirty() { mFontPaletteValuesDirty
= true; }
906 // Ensure that it is safe to hand out CSS rules outside the layout
907 // engine by ensuring that all CSS style sheets have unique inners
908 // and, if necessary, synchronously rebuilding all style data.
909 void EnsureSafeToHandOutCSSRules();
911 // Mark an area as invalidated, associated with a given transaction id
912 // (allocated by nsRefreshDriver::GetTransactionId). Invalidated regions will
913 // be dispatched to MozAfterPaint events when NotifyDidPaintForSubtree is
914 // called for the transaction id (or any higher id).
915 void NotifyInvalidation(TransactionId aTransactionId
, const nsRect
& aRect
);
916 // aRect is in device pixels
917 void NotifyInvalidation(TransactionId aTransactionId
, const nsIntRect
& aRect
);
918 void NotifyDidPaintForSubtree(
919 TransactionId aTransactionId
= TransactionId
{0},
920 const mozilla::TimeStamp
& aTimeStamp
= mozilla::TimeStamp());
921 void NotifyRevokingDidPaint(TransactionId aTransactionId
);
922 // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230)
923 MOZ_CAN_RUN_SCRIPT_BOUNDARY
void FireDOMPaintEvent(
924 nsTArray
<nsRect
>* aList
, TransactionId aTransactionId
,
925 mozilla::TimeStamp aTimeStamp
= mozilla::TimeStamp());
927 bool IsDOMPaintEventPending();
930 * Returns the RestyleManager's restyle generation counter.
932 uint64_t GetRestyleGeneration() const;
933 uint64_t GetUndisplayedRestyleGeneration() const;
936 * Returns whether there are any pending restyles or reflows.
938 bool HasPendingRestyleOrReflow();
941 * Notify the prescontext that the presshell is about to reflow a reflow root.
942 * The single argument indicates whether this reflow should be interruptible.
943 * If aInterruptible is false then CheckForInterrupt and HasPendingInterrupt
944 * will always return false. If aInterruptible is true then CheckForInterrupt
945 * will return true when a pending event is detected. This is for use by the
946 * presshell only. Reflow code wanting to prevent interrupts should use
947 * InterruptPreventer.
949 void ReflowStarted(bool aInterruptible
);
952 * A class that can be used to temporarily disable reflow interruption.
954 class InterruptPreventer
;
955 friend class InterruptPreventer
;
956 class MOZ_STACK_CLASS InterruptPreventer
{
958 explicit InterruptPreventer(nsPresContext
* aCtx
)
960 mInterruptsEnabled(aCtx
->mInterruptsEnabled
),
961 mHasPendingInterrupt(aCtx
->mHasPendingInterrupt
) {
962 mCtx
->mInterruptsEnabled
= false;
963 mCtx
->mHasPendingInterrupt
= false;
965 ~InterruptPreventer() {
966 mCtx
->mInterruptsEnabled
= mInterruptsEnabled
;
967 mCtx
->mHasPendingInterrupt
= mHasPendingInterrupt
;
972 bool mInterruptsEnabled
;
973 bool mHasPendingInterrupt
;
977 * Check for interrupts. This may return true if a pending event is
978 * detected. Once it has returned true, it will keep returning true
979 * until ReflowStarted is called. In all cases where this returns true,
980 * the passed-in frame (which should be the frame whose reflow will be
981 * interrupted if true is returned) will be passed to
982 * PresShell::FrameNeedsToContinueReflow.
984 bool CheckForInterrupt(nsIFrame
* aFrame
);
986 * Returns true if CheckForInterrupt has returned true since the last
987 * ReflowStarted call. Cannot itself trigger an interrupt check.
989 bool HasPendingInterrupt() { return mHasPendingInterrupt
; }
991 * Sets a flag that will trip a reflow interrupt. This only bypasses the
992 * interrupt timeout and the pending event check; other checks such as whether
993 * interrupts are enabled and the interrupt check skipping still take effect.
995 void SetPendingInterruptFromTest() { mPendingInterruptFromTest
= true; }
998 * If we have a presshell, and if the given content's current
999 * document is the same as our presshell's document, return the
1000 * content's primary frame. Otherwise, return null. Only use this
1001 * if you care about which presshell the primary frame is in.
1003 nsIFrame
* GetPrimaryFrameFor(nsIContent
* aContent
);
1005 virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf
) const;
1006 virtual size_t SizeOfIncludingThis(
1007 mozilla::MallocSizeOf aMallocSizeOf
) const {
1008 return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf
);
1012 * We are a root content document in process if: we are not a resource doc, we
1013 * are not chrome, and we either have no parent in the current process or our
1016 bool IsRootContentDocumentInProcess() const;
1019 * We are a root content document cross process if: we are not a resource doc,
1020 * we are not chrome, and we either have no parent in any process or our
1023 bool IsRootContentDocumentCrossProcess() const;
1025 bool HadNonBlankPaint() const { return mHadNonBlankPaint
; }
1026 bool HadFirstContentfulPaint() const { return mHadFirstContentfulPaint
; }
1027 void NotifyNonBlankPaint();
1028 void NotifyContentfulPaint();
1029 void NotifyPaintStatusReset();
1030 void NotifyDOMContentFlushed();
1032 bool HasEverBuiltInvisibleText() const { return mHasEverBuiltInvisibleText
; }
1033 void SetBuiltInvisibleText() { mHasEverBuiltInvisibleText
= true; }
1035 bool HasWarnedAboutTooLargeDashedOrDottedRadius() const {
1036 return mHasWarnedAboutTooLargeDashedOrDottedRadius
;
1039 void SetHasWarnedAboutTooLargeDashedOrDottedRadius() {
1040 mHasWarnedAboutTooLargeDashedOrDottedRadius
= true;
1043 void RegisterContainerQueryFrame(nsIFrame
* aFrame
);
1044 void UnregisterContainerQueryFrame(nsIFrame
* aFrame
);
1045 bool HasContainerQueryFrames() const {
1046 return !mContainerQueryFrames
.IsEmpty();
1049 void FinishedContainerQueryUpdate();
1051 bool UpdateContainerQueryStyles();
1053 mozilla::intl::Bidi
& BidiEngine();
1055 gfxFontFeatureValueSet
* GetFontFeatureValuesLookup() const {
1056 return mFontFeatureValuesLookup
;
1059 mozilla::gfx::FontPaletteValueSet
* GetFontPaletteValueSet() const {
1060 return mFontPaletteValueSet
;
1064 friend class nsRunnableMethod
<nsPresContext
>;
1065 void ThemeChangedInternal();
1066 void RefreshSystemMetrics();
1068 // Update device context's resolution from the widget
1069 void UIResolutionChangedInternal();
1071 void SetImgAnimations(nsIContent
* aParent
, uint16_t aMode
);
1072 void SetSMILAnimations(mozilla::dom::Document
* aDoc
, uint16_t aNewMode
,
1075 static void PreferenceChanged(const char* aPrefName
, void* aSelf
);
1076 void PreferenceChanged(const char* aPrefName
);
1078 void GetUserPreferences();
1080 void UpdateCharSet(NotNull
<const Encoding
*> aCharSet
);
1082 void DoForceReflowForFontInfoUpdateFromStyle();
1085 // Used by the PresShell to force a reflow when some aspect of font info
1086 // has been updated, potentially affecting font selection and layout.
1087 void ForceReflowForFontInfoUpdate(bool aNeedsReframe
);
1088 void ForceReflowForFontInfoUpdateFromStyle();
1091 * Checks for MozAfterPaint listeners on the document
1093 bool MayHavePaintEventListener();
1095 void InvalidatePaintedLayers();
1097 uint32_t GetNextFrameRateMultiplier() const {
1098 return mNextFrameRateMultiplier
;
1101 void DidUseFrameRateMultiplier() {
1102 // This heuristic is used to reduce frame rate between fcp and the end of
1104 if (mNextFrameRateMultiplier
< 8) {
1105 ++mNextFrameRateMultiplier
;
1110 // May be called multiple times (unlink, destructor)
1113 void AppUnitsPerDevPixelChanged();
1115 bool HavePendingInputEvent();
1117 // Creates a one-shot timer with the given aCallback & aDelay.
1118 // Returns a refcounted pointer to the timer (or nullptr on failure).
1119 already_AddRefed
<nsITimer
> CreateTimer(nsTimerCallbackFunc aCallback
,
1120 const char* aName
, uint32_t aDelay
);
1122 struct TransactionInvalidations
{
1123 TransactionId mTransactionId
;
1124 nsTArray
<nsRect
> mInvalidations
;
1125 bool mIsWaitingForPreviousTransaction
= false;
1127 TransactionInvalidations
* GetInvalidations(TransactionId aTransactionId
);
1129 // This should be called only when we update mVisibleArea or
1130 // mDynamicToolbarMaxHeight or `app units per device pixels` changes.
1131 void AdjustSizeForViewportUnits();
1133 // Call in response to prefs changes that might affect what fonts should be
1134 // visibile to CSS. Returns whether the current visibility value actually
1135 // changed (in which case content should be reflowed).
1136 bool UpdateFontVisibility();
1137 void ReportBlockedFontFamilyName(const nsCString
& aFamily
,
1138 FontVisibility aVisibility
);
1140 // IMPORTANT: The ownership implicit in the following member variables
1141 // has been explicitly checked. If you add any members to this class,
1142 // please make the ownership explicit (pinkerton, scc).
1144 // the PresShell owns a strong reference to the nsPresContext, and is
1145 // responsible for nulling this pointer before it is destroyed
1146 mozilla::PresShell
* MOZ_NON_OWNING_REF mPresShell
; // [WEAK]
1147 RefPtr
<mozilla::dom::Document
> mDocument
;
1148 RefPtr
<nsDeviceContext
> mDeviceContext
; // [STRONG] could be weak, but
1149 // better safe than sorry.
1150 // Cannot reintroduce cycles
1151 // since there is no dependency
1152 // from gfx back to layout.
1153 RefPtr
<nsFontCache
> mFontCache
;
1154 RefPtr
<mozilla::EventStateManager
> mEventManager
;
1155 RefPtr
<nsRefreshDriver
> mRefreshDriver
;
1156 RefPtr
<mozilla::AnimationEventDispatcher
> mAnimationEventDispatcher
;
1157 RefPtr
<mozilla::EffectCompositor
> mEffectCompositor
;
1158 mozilla::UniquePtr
<nsTransitionManager
> mTransitionManager
;
1159 mozilla::UniquePtr
<nsAnimationManager
> mAnimationManager
;
1160 mozilla::UniquePtr
<mozilla::TimelineManager
> mTimelineManager
;
1161 mozilla::UniquePtr
<mozilla::RestyleManager
> mRestyleManager
;
1162 RefPtr
<mozilla::CounterStyleManager
> mCounterStyleManager
;
1163 const nsStaticAtom
* mMedium
;
1164 RefPtr
<gfxFontFeatureValueSet
> mFontFeatureValuesLookup
;
1165 RefPtr
<mozilla::gfx::FontPaletteValueSet
> mFontPaletteValueSet
;
1167 // TODO(emilio): Maybe lazily create and put under a UniquePtr if this grows a
1169 MediaEmulationData mMediaEmulationData
;
1171 float mTextZoom
; // Text zoom, defaults to 1.0
1172 float mFullZoom
; // Page zoom, defaults to 1.0
1173 gfxSize mLastFontInflationScreenSize
;
1175 int32_t mCurAppUnitsPerDevPixel
;
1176 int32_t mAutoQualityMinFontSizePixelsPref
;
1178 nsCOMPtr
<nsITheme
> mTheme
;
1179 nsCOMPtr
<nsIPrintSettings
> mPrintSettings
;
1181 mozilla::UniquePtr
<mozilla::intl::Bidi
> mBidiEngine
;
1183 AutoTArray
<TransactionInvalidations
, 4> mTransactions
;
1185 // text performance metrics
1186 mozilla::UniquePtr
<gfxTextPerfMetrics
> mTextPerf
;
1188 mozilla::UniquePtr
<gfxMissingFontRecorder
> mMissingFonts
;
1190 nsRect mVisibleArea
;
1191 // This value is used to resolve viewport units.
1192 // On mobile this size is including the dynamic toolbar maximum height below.
1193 // On desktops this size is pretty much the same as |mVisibleArea|.
1194 nsSize mSizeForViewportUnits
;
1195 // The maximum height of the dynamic toolbar on mobile.
1196 mozilla::ScreenIntCoord mDynamicToolbarMaxHeight
;
1197 mozilla::ScreenIntCoord mDynamicToolbarHeight
;
1198 // Safe area insets support
1199 mozilla::ScreenIntMargin mSafeAreaInsets
;
1202 // The computed page margins from the print settings.
1204 // This margin will be used for each page in the current print operation, by
1205 // default (i.e. unless overridden by @page rules).
1207 // FIXME(emilio): Maybe we could let a global @page rule do that, though it's
1208 // sketchy at best, see https://github.com/w3c/csswg-drafts/issues/5437 for
1210 nsMargin mDefaultPageMargin
;
1214 // This is a non-owning pointer. May be null. If non-null, it's guaranteed to
1215 // be pointing to an element that's still alive, because we'll reset it in
1216 // UpdateViewportScrollStylesOverride() as part of the cleanup code when
1217 // this element is removed from the document. (For <body> and the root
1218 // element, this call happens in nsCSSFrameConstructor::ContentRemoved(). For
1219 // fullscreen elements, it happens in the fullscreen-specific cleanup invoked
1220 // by Element::UnbindFromTree().)
1221 mozilla::dom::Element
* MOZ_NON_OWNING_REF mViewportScrollOverrideElement
;
1223 // Counters for tests and tools that want to detect frame construction
1225 uint64_t mElementsRestyled
;
1226 uint64_t mFramesConstructed
;
1227 uint64_t mFramesReflowed
;
1229 mozilla::TimeStamp mReflowStartTime
;
1231 Maybe
<TransactionId
> mFirstContentfulPaintTransactionId
;
1233 mozilla::UniquePtr
<mozilla::MediaFeatureChange
>
1234 mPendingMediaFeatureValuesChange
;
1236 // Time of various first interaction types, used to report time from
1237 // first paint of the top level content pres shell to first interaction.
1238 mozilla::TimeStamp mFirstNonBlankPaintTime
;
1239 mozilla::TimeStamp mFirstClickTime
;
1240 mozilla::TimeStamp mFirstKeyTime
;
1241 mozilla::TimeStamp mFirstMouseMoveTime
;
1242 mozilla::TimeStamp mFirstScrollTime
;
1244 // last time we did a full style flush
1245 mozilla::TimeStamp mLastStyleUpdateForAllAnimations
;
1247 uint32_t mInterruptChecksToSkip
;
1249 // During page load we use slower frame rate.
1250 uint32_t mNextFrameRateMultiplier
;
1252 nsTArray
<RefPtr
<mozilla::ManagedPostRefreshObserver
>>
1253 mManagedPostRefreshObservers
;
1255 // If we block the use of a font-family that is explicitly requested,
1256 // due to font visibility settings, we log a message to the web console;
1257 // this hash-set keeps track of names we've logged for this context, so
1258 // that we can avoid repeatedly reporting the same font.
1259 nsTHashSet
<nsCString
> mBlockedFonts
;
1261 // The set of container query boxes currently in the document, sorted by
1263 mozilla::DepthOrderedFrameList mContainerQueryFrames
;
1264 // The set of container query elements currently in the document that have
1265 // been updated so far. This is necessary to avoid reentering on container
1266 // query style changes which cause us to do frame reconstruction.
1267 nsTHashSet
<nsIContent
*> mUpdatedContainerQueryContents
;
1269 ScrollStyles mViewportScrollStyles
;
1271 uint16_t mImageAnimationMode
;
1272 uint16_t mImageAnimationModePref
;
1274 nsPresContextType mType
;
1277 // The following are public member variables so that we can use them
1278 // with mozilla::AutoToggle or mozilla::AutoRestore.
1280 // Should we disable font size inflation because we're inside of
1281 // shrink-wrapping calculations on an inflation container?
1282 bool mInflationDisabledForShrinkWrap
;
1285 static constexpr size_t kThemeChangeKindBits
= 2;
1286 static_assert(unsigned(mozilla::widget::ThemeChangeKind::AllBits
) <=
1287 (1u << kThemeChangeKindBits
) - 1,
1288 "theme change kind doesn't fit");
1290 unsigned mInteractionTimeEnabled
: 1;
1291 unsigned mHasPendingInterrupt
: 1;
1292 unsigned mHasEverBuiltInvisibleText
: 1;
1293 unsigned mPendingInterruptFromTest
: 1;
1294 unsigned mInterruptsEnabled
: 1;
1295 unsigned mSendAfterPaintToContent
: 1;
1296 unsigned mDrawImageBackground
: 1;
1297 unsigned mDrawColorBackground
: 1;
1298 unsigned mNeverAnimate
: 1;
1299 unsigned mPaginated
: 1;
1300 unsigned mCanPaginatedScroll
: 1;
1301 unsigned mDoScaledTwips
: 1;
1302 unsigned mIsRootPaginatedDocument
: 1;
1303 unsigned mPrefBidiDirection
: 1;
1304 unsigned mPrefScrollbarSide
: 2;
1305 unsigned mPendingThemeChanged
: 1;
1306 // widget::ThemeChangeKind
1307 unsigned mPendingThemeChangeKind
: kThemeChangeKindBits
;
1308 unsigned mPendingUIResolutionChanged
: 1;
1309 unsigned mPendingFontInfoUpdateReflowFromStyle
: 1;
1311 // Are we currently drawing an SVG glyph?
1312 unsigned mIsGlyph
: 1;
1314 // Is the current mCounterStyleManager valid?
1315 unsigned mCounterStylesDirty
: 1;
1317 // Is the current mFontFeatureValuesLookup valid?
1318 unsigned mFontFeatureValuesDirty
: 1;
1320 // Is the current mFontFeatureValueSet valid?
1321 unsigned mFontPaletteValuesDirty
: 1;
1323 unsigned mIsVisual
: 1;
1325 // Are we in the RDM pane?
1326 unsigned mInRDMPane
: 1;
1328 unsigned mHasWarnedAboutTooLargeDashedOrDottedRadius
: 1;
1330 // Have we added quirk.css to the style set?
1331 unsigned mQuirkSheetAdded
: 1;
1333 // Has NotifyNonBlankPaint been called on this PresContext?
1334 unsigned mHadNonBlankPaint
: 1;
1335 // Has NotifyContentfulPaint been called on this PresContext?
1336 unsigned mHadFirstContentfulPaint
: 1;
1337 // True when a contentful paint has happened and this paint doesn't
1338 // come from the regular tick process. Usually this means a
1339 // contentful paint was triggered manually.
1340 unsigned mHadNonTickContentfulPaint
: 1;
1342 // Has NotifyDidPaintForSubtree been called for a contentful paint?
1343 unsigned mHadContentfulPaintComposite
: 1;
1346 unsigned mInitialized
: 1;
1349 // FIXME(emilio): These would be better packed on top of the bitfields, but
1350 // that breaks bindgen in win32.
1351 FontVisibility mFontVisibility
= FontVisibility::Unknown
;
1352 mozilla::dom::PrefersColorSchemeOverride mOverriddenOrEmbedderColorScheme
;
1355 virtual ~nsPresContext();
1363 friend struct nsAutoLayoutPhase
;
1364 mozilla::EnumeratedArray
<nsLayoutPhase
, nsLayoutPhase::COUNT
, uint32_t>
1368 uint32_t LayoutPhaseCount(nsLayoutPhase aPhase
) {
1369 return mLayoutPhaseCount
[aPhase
];
1374 class nsRootPresContext final
: public nsPresContext
{
1376 nsRootPresContext(mozilla::dom::Document
* aDocument
, nsPresContextType aType
);
1377 virtual bool IsRoot() override
{ return true; }
1380 * Add a runnable that will get called before the next paint. They will get
1381 * run eventually even if painting doesn't happen. They might run well before
1384 void AddWillPaintObserver(nsIRunnable
* aRunnable
);
1387 * Run all runnables that need to get called before the next paint.
1389 void FlushWillPaintObservers();
1391 virtual size_t SizeOfExcludingThis(
1392 mozilla::MallocSizeOf aMallocSizeOf
) const override
;
1395 class RunWillPaintObservers
: public mozilla::Runnable
{
1397 explicit RunWillPaintObservers(nsRootPresContext
* aPresContext
)
1398 : Runnable("nsPresContextType::RunWillPaintObservers"),
1399 mPresContext(aPresContext
) {}
1400 void Revoke() { mPresContext
= nullptr; }
1401 NS_IMETHOD
Run() override
{
1403 mPresContext
->FlushWillPaintObservers();
1407 // The lifetime of this reference is handled by an nsRevocableEventPtr
1408 nsRootPresContext
* MOZ_NON_OWNING_REF mPresContext
;
1411 friend class nsPresContext
;
1413 nsTArray
<nsCOMPtr
<nsIRunnable
>> mWillPaintObservers
;
1414 nsRevocableEventPtr
<RunWillPaintObservers
> mWillPaintFallbackEvent
;
1417 #ifdef MOZ_REFLOW_PERF
1419 # define DO_GLOBAL_REFLOW_COUNT(_name) \
1420 aPresContext->CountReflows((_name), (nsIFrame*)this);
1422 # define DO_GLOBAL_REFLOW_COUNT(_name)
1423 #endif // MOZ_REFLOW_PERF
1425 #endif /* nsPresContext_h___ */