Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* a presentation of a document, part 1 */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef nsPresContext_h___ |
michael@0 | 9 | #define nsPresContext_h___ |
michael@0 | 10 | |
michael@0 | 11 | #include "mozilla/Attributes.h" |
michael@0 | 12 | #include "mozilla/WeakPtr.h" |
michael@0 | 13 | #include "nsColor.h" |
michael@0 | 14 | #include "nsCoord.h" |
michael@0 | 15 | #include "nsCOMPtr.h" |
michael@0 | 16 | #include "nsIPresShell.h" |
michael@0 | 17 | #include "nsRect.h" |
michael@0 | 18 | #include "nsFont.h" |
michael@0 | 19 | #include "gfxFontConstants.h" |
michael@0 | 20 | #include "nsIAtom.h" |
michael@0 | 21 | #include "nsIObserver.h" |
michael@0 | 22 | #include "nsITimer.h" |
michael@0 | 23 | #include "nsCRT.h" |
michael@0 | 24 | #include "FramePropertyTable.h" |
michael@0 | 25 | #include "nsGkAtoms.h" |
michael@0 | 26 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 27 | #include "nsChangeHint.h" |
michael@0 | 28 | #include <algorithm> |
michael@0 | 29 | // This also pulls in gfxTypes.h, which we cannot include directly. |
michael@0 | 30 | #include "gfxRect.h" |
michael@0 | 31 | #include "nsTArray.h" |
michael@0 | 32 | #include "nsAutoPtr.h" |
michael@0 | 33 | #include "mozilla/MemoryReporting.h" |
michael@0 | 34 | #include "mozilla/TimeStamp.h" |
michael@0 | 35 | #include "mozilla/AppUnits.h" |
michael@0 | 36 | #include "prclist.h" |
michael@0 | 37 | #include "nsThreadUtils.h" |
michael@0 | 38 | #include "ScrollbarStyles.h" |
michael@0 | 39 | |
michael@0 | 40 | class nsBidiPresUtils; |
michael@0 | 41 | class nsAString; |
michael@0 | 42 | class nsIPrintSettings; |
michael@0 | 43 | class nsDocShell; |
michael@0 | 44 | class nsIDocShell; |
michael@0 | 45 | class nsIDocument; |
michael@0 | 46 | class nsILanguageAtomService; |
michael@0 | 47 | class nsITheme; |
michael@0 | 48 | class nsIContent; |
michael@0 | 49 | class nsIFrame; |
michael@0 | 50 | class nsFrameManager; |
michael@0 | 51 | class nsILinkHandler; |
michael@0 | 52 | class nsIAtom; |
michael@0 | 53 | class nsICSSPseudoComparator; |
michael@0 | 54 | struct nsStyleBackground; |
michael@0 | 55 | struct nsStyleBorder; |
michael@0 | 56 | class nsIRunnable; |
michael@0 | 57 | class gfxUserFontSet; |
michael@0 | 58 | class gfxTextPerfMetrics; |
michael@0 | 59 | class nsUserFontSet; |
michael@0 | 60 | struct nsFontFaceRuleContainer; |
michael@0 | 61 | class nsObjectFrame; |
michael@0 | 62 | class nsTransitionManager; |
michael@0 | 63 | class nsAnimationManager; |
michael@0 | 64 | class nsRefreshDriver; |
michael@0 | 65 | class nsIWidget; |
michael@0 | 66 | class nsDeviceContext; |
michael@0 | 67 | |
michael@0 | 68 | namespace mozilla { |
michael@0 | 69 | class EventStateManager; |
michael@0 | 70 | class RestyleManager; |
michael@0 | 71 | namespace dom { |
michael@0 | 72 | class MediaQueryList; |
michael@0 | 73 | } |
michael@0 | 74 | namespace layers { |
michael@0 | 75 | class ContainerLayer; |
michael@0 | 76 | } |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | // supported values for cached bool types |
michael@0 | 80 | enum nsPresContext_CachedBoolPrefType { |
michael@0 | 81 | kPresContext_UseDocumentColors = 1, |
michael@0 | 82 | kPresContext_UseDocumentFonts, |
michael@0 | 83 | kPresContext_UnderlineLinks |
michael@0 | 84 | }; |
michael@0 | 85 | |
michael@0 | 86 | // supported values for cached integer pref types |
michael@0 | 87 | enum nsPresContext_CachedIntPrefType { |
michael@0 | 88 | kPresContext_ScrollbarSide = 1, |
michael@0 | 89 | kPresContext_BidiDirection |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | // IDs for the default variable and fixed fonts (not to be changed, see nsFont.h) |
michael@0 | 93 | // To be used for Get/SetDefaultFont(). The other IDs in nsFont.h are also supported. |
michael@0 | 94 | const uint8_t kPresContext_DefaultVariableFont_ID = 0x00; // kGenericFont_moz_variable |
michael@0 | 95 | const uint8_t kPresContext_DefaultFixedFont_ID = 0x01; // kGenericFont_moz_fixed |
michael@0 | 96 | |
michael@0 | 97 | #ifdef DEBUG |
michael@0 | 98 | struct nsAutoLayoutPhase; |
michael@0 | 99 | |
michael@0 | 100 | enum nsLayoutPhase { |
michael@0 | 101 | eLayoutPhase_Paint, |
michael@0 | 102 | eLayoutPhase_Reflow, |
michael@0 | 103 | eLayoutPhase_FrameC, |
michael@0 | 104 | eLayoutPhase_COUNT |
michael@0 | 105 | }; |
michael@0 | 106 | #endif |
michael@0 | 107 | |
michael@0 | 108 | class nsInvalidateRequestList { |
michael@0 | 109 | public: |
michael@0 | 110 | struct Request { |
michael@0 | 111 | nsRect mRect; |
michael@0 | 112 | uint32_t mFlags; |
michael@0 | 113 | }; |
michael@0 | 114 | |
michael@0 | 115 | void TakeFrom(nsInvalidateRequestList* aList) |
michael@0 | 116 | { |
michael@0 | 117 | mRequests.MoveElementsFrom(aList->mRequests); |
michael@0 | 118 | } |
michael@0 | 119 | bool IsEmpty() { return mRequests.IsEmpty(); } |
michael@0 | 120 | |
michael@0 | 121 | nsTArray<Request> mRequests; |
michael@0 | 122 | }; |
michael@0 | 123 | |
michael@0 | 124 | /* Used by nsPresContext::HasAuthorSpecifiedRules */ |
michael@0 | 125 | #define NS_AUTHOR_SPECIFIED_BACKGROUND (1 << 0) |
michael@0 | 126 | #define NS_AUTHOR_SPECIFIED_BORDER (1 << 1) |
michael@0 | 127 | #define NS_AUTHOR_SPECIFIED_PADDING (1 << 2) |
michael@0 | 128 | #define NS_AUTHOR_SPECIFIED_TEXT_SHADOW (1 << 3) |
michael@0 | 129 | |
michael@0 | 130 | class nsRootPresContext; |
michael@0 | 131 | |
michael@0 | 132 | // An interface for presentation contexts. Presentation contexts are |
michael@0 | 133 | // objects that provide an outer context for a presentation shell. |
michael@0 | 134 | |
michael@0 | 135 | class nsPresContext : public nsIObserver { |
michael@0 | 136 | public: |
michael@0 | 137 | typedef mozilla::FramePropertyTable FramePropertyTable; |
michael@0 | 138 | |
michael@0 | 139 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 140 | NS_DECL_NSIOBSERVER |
michael@0 | 141 | NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW |
michael@0 | 142 | NS_DECL_CYCLE_COLLECTION_CLASS(nsPresContext) |
michael@0 | 143 | |
michael@0 | 144 | enum nsPresContextType { |
michael@0 | 145 | eContext_Galley, // unpaginated screen presentation |
michael@0 | 146 | eContext_PrintPreview, // paginated screen presentation |
michael@0 | 147 | eContext_Print, // paginated printer presentation |
michael@0 | 148 | eContext_PageLayout // paginated & editable. |
michael@0 | 149 | }; |
michael@0 | 150 | |
michael@0 | 151 | // Policies for rebuilding style data. |
michael@0 | 152 | enum StyleRebuildType { |
michael@0 | 153 | eRebuildStyleIfNeeded, |
michael@0 | 154 | eAlwaysRebuildStyle |
michael@0 | 155 | }; |
michael@0 | 156 | |
michael@0 | 157 | nsPresContext(nsIDocument* aDocument, nsPresContextType aType) NS_HIDDEN; |
michael@0 | 158 | |
michael@0 | 159 | /** |
michael@0 | 160 | * Initialize the presentation context from a particular device. |
michael@0 | 161 | */ |
michael@0 | 162 | NS_HIDDEN_(nsresult) Init(nsDeviceContext* aDeviceContext); |
michael@0 | 163 | |
michael@0 | 164 | /** |
michael@0 | 165 | * Set the presentation shell that this context is bound to. |
michael@0 | 166 | * A presentation context may only be bound to a single shell. |
michael@0 | 167 | */ |
michael@0 | 168 | NS_HIDDEN_(void) SetShell(nsIPresShell* aShell); |
michael@0 | 169 | |
michael@0 | 170 | |
michael@0 | 171 | NS_HIDDEN_(nsPresContextType) Type() const { return mType; } |
michael@0 | 172 | |
michael@0 | 173 | /** |
michael@0 | 174 | * Get the PresentationShell that this context is bound to. |
michael@0 | 175 | */ |
michael@0 | 176 | nsIPresShell* PresShell() const |
michael@0 | 177 | { |
michael@0 | 178 | NS_ASSERTION(mShell, "Null pres shell"); |
michael@0 | 179 | return mShell; |
michael@0 | 180 | } |
michael@0 | 181 | |
michael@0 | 182 | nsIPresShell* GetPresShell() const { return mShell; } |
michael@0 | 183 | |
michael@0 | 184 | /** |
michael@0 | 185 | * Returns the parent prescontext for this one. Returns null if this is a |
michael@0 | 186 | * root. |
michael@0 | 187 | */ |
michael@0 | 188 | nsPresContext* GetParentPresContext(); |
michael@0 | 189 | |
michael@0 | 190 | /** |
michael@0 | 191 | * Returns the prescontext of the toplevel content document that contains |
michael@0 | 192 | * this presentation, or null if there isn't one. |
michael@0 | 193 | */ |
michael@0 | 194 | nsPresContext* GetToplevelContentDocumentPresContext(); |
michael@0 | 195 | |
michael@0 | 196 | /** |
michael@0 | 197 | * Returns the nearest widget for the root frame of this. |
michael@0 | 198 | * |
michael@0 | 199 | * @param aOffset If non-null the offset from the origin of the root |
michael@0 | 200 | * frame's view to the widget's origin (usually positive) |
michael@0 | 201 | * expressed in appunits of this will be returned in |
michael@0 | 202 | * aOffset. |
michael@0 | 203 | */ |
michael@0 | 204 | nsIWidget* GetNearestWidget(nsPoint* aOffset = nullptr); |
michael@0 | 205 | |
michael@0 | 206 | /** |
michael@0 | 207 | * Returns the root widget for this. |
michael@0 | 208 | * Note that the widget is a mediater with IME. |
michael@0 | 209 | */ |
michael@0 | 210 | nsIWidget* GetRootWidget(); |
michael@0 | 211 | |
michael@0 | 212 | /** |
michael@0 | 213 | * Return the presentation context for the root of the view manager |
michael@0 | 214 | * hierarchy that contains this presentation context, or nullptr if it can't |
michael@0 | 215 | * be found (e.g. it's detached). |
michael@0 | 216 | */ |
michael@0 | 217 | nsRootPresContext* GetRootPresContext(); |
michael@0 | 218 | nsRootPresContext* GetDisplayRootPresContext(); |
michael@0 | 219 | virtual bool IsRoot() { return false; } |
michael@0 | 220 | |
michael@0 | 221 | nsIDocument* Document() const |
michael@0 | 222 | { |
michael@0 | 223 | NS_ASSERTION(!mShell || !mShell->GetDocument() || |
michael@0 | 224 | mShell->GetDocument() == mDocument, |
michael@0 | 225 | "nsPresContext doesn't have the same document as nsPresShell!"); |
michael@0 | 226 | return mDocument; |
michael@0 | 227 | } |
michael@0 | 228 | |
michael@0 | 229 | #ifdef MOZILLA_INTERNAL_API |
michael@0 | 230 | nsStyleSet* StyleSet() { return GetPresShell()->StyleSet(); } |
michael@0 | 231 | |
michael@0 | 232 | nsFrameManager* FrameManager() |
michael@0 | 233 | { return PresShell()->FrameManager(); } |
michael@0 | 234 | |
michael@0 | 235 | nsCSSFrameConstructor* FrameConstructor() |
michael@0 | 236 | { return PresShell()->FrameConstructor(); } |
michael@0 | 237 | |
michael@0 | 238 | nsTransitionManager* TransitionManager() { return mTransitionManager; } |
michael@0 | 239 | nsAnimationManager* AnimationManager() { return mAnimationManager; } |
michael@0 | 240 | |
michael@0 | 241 | nsRefreshDriver* RefreshDriver() { return mRefreshDriver; } |
michael@0 | 242 | |
michael@0 | 243 | mozilla::RestyleManager* RestyleManager() { return mRestyleManager; } |
michael@0 | 244 | #endif |
michael@0 | 245 | |
michael@0 | 246 | /** |
michael@0 | 247 | * Rebuilds all style data by throwing out the old rule tree and |
michael@0 | 248 | * building a new one, and additionally applying aExtraHint (which |
michael@0 | 249 | * must not contain nsChangeHint_ReconstructFrame) to the root frame. |
michael@0 | 250 | * Also rebuild the user font set. |
michael@0 | 251 | */ |
michael@0 | 252 | void RebuildAllStyleData(nsChangeHint aExtraHint); |
michael@0 | 253 | /** |
michael@0 | 254 | * Just like RebuildAllStyleData, except (1) asynchronous and (2) it |
michael@0 | 255 | * doesn't rebuild the user font set. |
michael@0 | 256 | */ |
michael@0 | 257 | void PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint); |
michael@0 | 258 | |
michael@0 | 259 | void MediaFeatureValuesChanged(StyleRebuildType aShouldRebuild, |
michael@0 | 260 | nsChangeHint aChangeHint = nsChangeHint(0)); |
michael@0 | 261 | void PostMediaFeatureValuesChangedEvent(); |
michael@0 | 262 | NS_HIDDEN_(void) HandleMediaFeatureValuesChangedEvent(); |
michael@0 | 263 | void FlushPendingMediaFeatureValuesChanged() { |
michael@0 | 264 | if (mPendingMediaFeatureValuesChanged) |
michael@0 | 265 | MediaFeatureValuesChanged(eRebuildStyleIfNeeded); |
michael@0 | 266 | } |
michael@0 | 267 | |
michael@0 | 268 | /** |
michael@0 | 269 | * Support for window.matchMedia() |
michael@0 | 270 | */ |
michael@0 | 271 | already_AddRefed<mozilla::dom::MediaQueryList> |
michael@0 | 272 | MatchMedia(const nsAString& aMediaQueryList); |
michael@0 | 273 | |
michael@0 | 274 | /** |
michael@0 | 275 | * Access compatibility mode for this context. This is the same as |
michael@0 | 276 | * our document's compatibility mode. |
michael@0 | 277 | */ |
michael@0 | 278 | nsCompatibility CompatibilityMode() const; |
michael@0 | 279 | |
michael@0 | 280 | /** |
michael@0 | 281 | * Notify the context that the document's compatibility mode has changed |
michael@0 | 282 | */ |
michael@0 | 283 | NS_HIDDEN_(void) CompatibilityModeChanged(); |
michael@0 | 284 | |
michael@0 | 285 | /** |
michael@0 | 286 | * Access the image animation mode for this context |
michael@0 | 287 | */ |
michael@0 | 288 | uint16_t ImageAnimationMode() const { return mImageAnimationMode; } |
michael@0 | 289 | virtual NS_HIDDEN_(void) SetImageAnimationModeExternal(uint16_t aMode); |
michael@0 | 290 | NS_HIDDEN_(void) SetImageAnimationModeInternal(uint16_t aMode); |
michael@0 | 291 | #ifdef MOZILLA_INTERNAL_API |
michael@0 | 292 | void SetImageAnimationMode(uint16_t aMode) |
michael@0 | 293 | { SetImageAnimationModeInternal(aMode); } |
michael@0 | 294 | #else |
michael@0 | 295 | void SetImageAnimationMode(uint16_t aMode) |
michael@0 | 296 | { SetImageAnimationModeExternal(aMode); } |
michael@0 | 297 | #endif |
michael@0 | 298 | |
michael@0 | 299 | /** |
michael@0 | 300 | * Get medium of presentation |
michael@0 | 301 | */ |
michael@0 | 302 | nsIAtom* Medium() { |
michael@0 | 303 | if (!mIsEmulatingMedia) |
michael@0 | 304 | return mMedium; |
michael@0 | 305 | return mMediaEmulated; |
michael@0 | 306 | } |
michael@0 | 307 | |
michael@0 | 308 | /* |
michael@0 | 309 | * Render the document as if being viewed on a device with the specified |
michael@0 | 310 | * media type. |
michael@0 | 311 | */ |
michael@0 | 312 | void EmulateMedium(const nsAString& aMediaType); |
michael@0 | 313 | |
michael@0 | 314 | /* |
michael@0 | 315 | * Restore the viewer's natural medium |
michael@0 | 316 | */ |
michael@0 | 317 | void StopEmulatingMedium(); |
michael@0 | 318 | |
michael@0 | 319 | void* AllocateFromShell(size_t aSize) |
michael@0 | 320 | { |
michael@0 | 321 | if (mShell) |
michael@0 | 322 | return mShell->AllocateMisc(aSize); |
michael@0 | 323 | return nullptr; |
michael@0 | 324 | } |
michael@0 | 325 | |
michael@0 | 326 | void FreeToShell(size_t aSize, void* aFreeChunk) |
michael@0 | 327 | { |
michael@0 | 328 | NS_ASSERTION(mShell, "freeing after shutdown"); |
michael@0 | 329 | if (mShell) |
michael@0 | 330 | mShell->FreeMisc(aSize, aFreeChunk); |
michael@0 | 331 | } |
michael@0 | 332 | |
michael@0 | 333 | /** |
michael@0 | 334 | * Get the default font for the given language and generic font ID. |
michael@0 | 335 | * If aLanguage is nullptr, the document's language is used. |
michael@0 | 336 | * |
michael@0 | 337 | * This object is read-only, you must copy the font to modify it. |
michael@0 | 338 | * |
michael@0 | 339 | * When aFontID is kPresContext_DefaultVariableFontID or |
michael@0 | 340 | * kPresContext_DefaultFixedFontID (which equals |
michael@0 | 341 | * kGenericFont_moz_fixed, which is used for the -moz-fixed generic), |
michael@0 | 342 | * the nsFont returned has its name as a CSS generic family (serif or |
michael@0 | 343 | * sans-serif for the former, monospace for the latter), and its size |
michael@0 | 344 | * as the default font size for variable or fixed fonts for the |
michael@0 | 345 | * language group. |
michael@0 | 346 | * |
michael@0 | 347 | * For aFontID corresponding to a CSS Generic, the nsFont returned has |
michael@0 | 348 | * its name set to that generic font's name, and its size set to |
michael@0 | 349 | * the user's preference for font size for that generic and the |
michael@0 | 350 | * given language. |
michael@0 | 351 | */ |
michael@0 | 352 | NS_HIDDEN_(const nsFont*) GetDefaultFont(uint8_t aFontID, |
michael@0 | 353 | nsIAtom *aLanguage) const; |
michael@0 | 354 | |
michael@0 | 355 | /** Get a cached boolean pref, by its type */ |
michael@0 | 356 | // * - initially created for bugs 31816, 20760, 22963 |
michael@0 | 357 | bool GetCachedBoolPref(nsPresContext_CachedBoolPrefType aPrefType) const |
michael@0 | 358 | { |
michael@0 | 359 | // If called with a constant parameter, the compiler should optimize |
michael@0 | 360 | // this switch statement away. |
michael@0 | 361 | switch (aPrefType) { |
michael@0 | 362 | case kPresContext_UseDocumentFonts: |
michael@0 | 363 | return mUseDocumentFonts; |
michael@0 | 364 | case kPresContext_UseDocumentColors: |
michael@0 | 365 | return mUseDocumentColors; |
michael@0 | 366 | case kPresContext_UnderlineLinks: |
michael@0 | 367 | return mUnderlineLinks; |
michael@0 | 368 | default: |
michael@0 | 369 | NS_ERROR("Invalid arg passed to GetCachedBoolPref"); |
michael@0 | 370 | } |
michael@0 | 371 | |
michael@0 | 372 | return false; |
michael@0 | 373 | } |
michael@0 | 374 | |
michael@0 | 375 | /** Get a cached integer pref, by its type */ |
michael@0 | 376 | // * - initially created for bugs 30910, 61883, 74186, 84398 |
michael@0 | 377 | int32_t GetCachedIntPref(nsPresContext_CachedIntPrefType aPrefType) const |
michael@0 | 378 | { |
michael@0 | 379 | // If called with a constant parameter, the compiler should optimize |
michael@0 | 380 | // this switch statement away. |
michael@0 | 381 | switch (aPrefType) { |
michael@0 | 382 | case kPresContext_ScrollbarSide: |
michael@0 | 383 | return mPrefScrollbarSide; |
michael@0 | 384 | case kPresContext_BidiDirection: |
michael@0 | 385 | return mPrefBidiDirection; |
michael@0 | 386 | default: |
michael@0 | 387 | NS_ERROR("invalid arg passed to GetCachedIntPref"); |
michael@0 | 388 | } |
michael@0 | 389 | |
michael@0 | 390 | return false; |
michael@0 | 391 | } |
michael@0 | 392 | |
michael@0 | 393 | /** |
michael@0 | 394 | * Get the default colors |
michael@0 | 395 | */ |
michael@0 | 396 | const nscolor DefaultColor() const { return mDefaultColor; } |
michael@0 | 397 | const nscolor DefaultBackgroundColor() const { return mBackgroundColor; } |
michael@0 | 398 | const nscolor DefaultLinkColor() const { return mLinkColor; } |
michael@0 | 399 | const nscolor DefaultActiveLinkColor() const { return mActiveLinkColor; } |
michael@0 | 400 | const nscolor DefaultVisitedLinkColor() const { return mVisitedLinkColor; } |
michael@0 | 401 | const nscolor FocusBackgroundColor() const { return mFocusBackgroundColor; } |
michael@0 | 402 | const nscolor FocusTextColor() const { return mFocusTextColor; } |
michael@0 | 403 | |
michael@0 | 404 | /** |
michael@0 | 405 | * Body text color, for use in quirks mode only. |
michael@0 | 406 | */ |
michael@0 | 407 | const nscolor BodyTextColor() const { return mBodyTextColor; } |
michael@0 | 408 | void SetBodyTextColor(nscolor aColor) { mBodyTextColor = aColor; } |
michael@0 | 409 | |
michael@0 | 410 | bool GetUseFocusColors() const { return mUseFocusColors; } |
michael@0 | 411 | uint8_t FocusRingWidth() const { return mFocusRingWidth; } |
michael@0 | 412 | bool GetFocusRingOnAnything() const { return mFocusRingOnAnything; } |
michael@0 | 413 | uint8_t GetFocusRingStyle() const { return mFocusRingStyle; } |
michael@0 | 414 | |
michael@0 | 415 | NS_HIDDEN_(void) SetContainer(nsIDocShell* aContainer); |
michael@0 | 416 | |
michael@0 | 417 | virtual nsISupports* GetContainerWeakExternal() const; |
michael@0 | 418 | nsISupports* GetContainerWeakInternal() const; |
michael@0 | 419 | #ifdef MOZILLA_INTERNAL_API |
michael@0 | 420 | nsISupports* GetContainerWeak() const |
michael@0 | 421 | { return GetContainerWeakInternal(); } |
michael@0 | 422 | #else |
michael@0 | 423 | nsISupports* GetContainerWeak() const |
michael@0 | 424 | { return GetContainerWeakExternal(); } |
michael@0 | 425 | #endif |
michael@0 | 426 | |
michael@0 | 427 | nsIDocShell* GetDocShell() const; |
michael@0 | 428 | |
michael@0 | 429 | // XXX this are going to be replaced with set/get container |
michael@0 | 430 | void SetLinkHandler(nsILinkHandler* aHandler) { mLinkHandler = aHandler; } |
michael@0 | 431 | nsILinkHandler* GetLinkHandler() { return mLinkHandler; } |
michael@0 | 432 | |
michael@0 | 433 | /** |
michael@0 | 434 | * Detach this pres context - i.e. cancel relevant timers, |
michael@0 | 435 | * SetLinkHandler(null), SetContainer(null) etc. |
michael@0 | 436 | * Only to be used by the DocumentViewer. |
michael@0 | 437 | */ |
michael@0 | 438 | virtual void Detach(); |
michael@0 | 439 | |
michael@0 | 440 | /** |
michael@0 | 441 | * Get the visible area associated with this presentation context. |
michael@0 | 442 | * This is the size of the visible area that is used for |
michael@0 | 443 | * presenting the document. The returned value is in the standard |
michael@0 | 444 | * nscoord units (as scaled by the device context). |
michael@0 | 445 | */ |
michael@0 | 446 | nsRect GetVisibleArea() { return mVisibleArea; } |
michael@0 | 447 | |
michael@0 | 448 | /** |
michael@0 | 449 | * Set the currently visible area. The units for r are standard |
michael@0 | 450 | * nscoord units (as scaled by the device context). |
michael@0 | 451 | */ |
michael@0 | 452 | void SetVisibleArea(const nsRect& r) { |
michael@0 | 453 | if (!r.IsEqualEdges(mVisibleArea)) { |
michael@0 | 454 | mVisibleArea = r; |
michael@0 | 455 | // Visible area does not affect media queries when paginated. |
michael@0 | 456 | if (!IsPaginated() && HasCachedStyleData()) { |
michael@0 | 457 | mPendingViewportChange = true; |
michael@0 | 458 | PostMediaFeatureValuesChangedEvent(); |
michael@0 | 459 | } |
michael@0 | 460 | } |
michael@0 | 461 | } |
michael@0 | 462 | |
michael@0 | 463 | /** |
michael@0 | 464 | * Return true if this presentation context is a paginated |
michael@0 | 465 | * context. |
michael@0 | 466 | */ |
michael@0 | 467 | bool IsPaginated() const { return mPaginated; } |
michael@0 | 468 | |
michael@0 | 469 | /** |
michael@0 | 470 | * Sets whether the presentation context can scroll for a paginated |
michael@0 | 471 | * context. |
michael@0 | 472 | */ |
michael@0 | 473 | NS_HIDDEN_(void) SetPaginatedScrolling(bool aResult); |
michael@0 | 474 | |
michael@0 | 475 | /** |
michael@0 | 476 | * Return true if this presentation context can scroll for paginated |
michael@0 | 477 | * context. |
michael@0 | 478 | */ |
michael@0 | 479 | bool HasPaginatedScrolling() const { return mCanPaginatedScroll; } |
michael@0 | 480 | |
michael@0 | 481 | /** |
michael@0 | 482 | * Get/set the size of a page |
michael@0 | 483 | */ |
michael@0 | 484 | nsSize GetPageSize() { return mPageSize; } |
michael@0 | 485 | void SetPageSize(nsSize aSize) { mPageSize = aSize; } |
michael@0 | 486 | |
michael@0 | 487 | /** |
michael@0 | 488 | * Get/set whether this document should be treated as having real pages |
michael@0 | 489 | * XXX This raises the obvious question of why a document that isn't a page |
michael@0 | 490 | * is paginated; there isn't a good reason except history |
michael@0 | 491 | */ |
michael@0 | 492 | bool IsRootPaginatedDocument() { return mIsRootPaginatedDocument; } |
michael@0 | 493 | void SetIsRootPaginatedDocument(bool aIsRootPaginatedDocument) |
michael@0 | 494 | { mIsRootPaginatedDocument = aIsRootPaginatedDocument; } |
michael@0 | 495 | |
michael@0 | 496 | /** |
michael@0 | 497 | * Get/set the print scaling level; used by nsPageFrame to scale up |
michael@0 | 498 | * pages. Set safe to call before reflow, get guaranteed to be set |
michael@0 | 499 | * properly after reflow. |
michael@0 | 500 | */ |
michael@0 | 501 | |
michael@0 | 502 | float GetPageScale() { return mPageScale; } |
michael@0 | 503 | void SetPageScale(float aScale) { mPageScale = aScale; } |
michael@0 | 504 | |
michael@0 | 505 | /** |
michael@0 | 506 | * Get/set the scaling facor to use when rendering the pages for print preview. |
michael@0 | 507 | * Only safe to get after print preview set up; safe to set anytime. |
michael@0 | 508 | * This is a scaling factor for the display of the print preview. It |
michael@0 | 509 | * does not affect layout. It only affects the size of the onscreen pages |
michael@0 | 510 | * in print preview. |
michael@0 | 511 | * XXX Temporary: see http://wiki.mozilla.org/Gecko:PrintPreview |
michael@0 | 512 | */ |
michael@0 | 513 | float GetPrintPreviewScale() { return mPPScale; } |
michael@0 | 514 | void SetPrintPreviewScale(float aScale) { mPPScale = aScale; } |
michael@0 | 515 | |
michael@0 | 516 | nsDeviceContext* DeviceContext() { return mDeviceContext; } |
michael@0 | 517 | mozilla::EventStateManager* EventStateManager() { return mEventManager; } |
michael@0 | 518 | nsIAtom* GetLanguageFromCharset() { return mLanguage; } |
michael@0 | 519 | |
michael@0 | 520 | float TextZoom() { return mTextZoom; } |
michael@0 | 521 | void SetTextZoom(float aZoom) { |
michael@0 | 522 | if (aZoom == mTextZoom) |
michael@0 | 523 | return; |
michael@0 | 524 | |
michael@0 | 525 | mTextZoom = aZoom; |
michael@0 | 526 | if (HasCachedStyleData()) { |
michael@0 | 527 | // Media queries could have changed, since we changed the meaning |
michael@0 | 528 | // of 'em' units in them. |
michael@0 | 529 | MediaFeatureValuesChanged(eAlwaysRebuildStyle, NS_STYLE_HINT_REFLOW); |
michael@0 | 530 | } |
michael@0 | 531 | } |
michael@0 | 532 | |
michael@0 | 533 | nsTArray<nsFont> mFontsUsed; // currently for font-count limiting only |
michael@0 | 534 | nsTArray<nsFont> mFontsTried; // currently for font-count limiting only |
michael@0 | 535 | void AddFontUse(const nsFont &font); |
michael@0 | 536 | void AddFontAttempt(const nsFont &font); |
michael@0 | 537 | PRBool FontUseCountReached(const nsFont &font); |
michael@0 | 538 | PRBool FontAttemptCountReached(const nsFont &font); |
michael@0 | 539 | |
michael@0 | 540 | /** |
michael@0 | 541 | * Get the minimum font size for the specified language. If aLanguage |
michael@0 | 542 | * is nullptr, then the document's language is used. This combines |
michael@0 | 543 | * the language-specific global preference with the per-presentation |
michael@0 | 544 | * base minimum font size. |
michael@0 | 545 | */ |
michael@0 | 546 | int32_t MinFontSize(nsIAtom *aLanguage) const { |
michael@0 | 547 | const LangGroupFontPrefs *prefs = GetFontPrefsForLang(aLanguage); |
michael@0 | 548 | return std::max(mBaseMinFontSize, prefs->mMinimumFontSize); |
michael@0 | 549 | } |
michael@0 | 550 | |
michael@0 | 551 | /** |
michael@0 | 552 | * Get the per-presentation base minimum font size. This size is |
michael@0 | 553 | * independent of the language-specific global preference. |
michael@0 | 554 | */ |
michael@0 | 555 | int32_t BaseMinFontSize() const { |
michael@0 | 556 | return mBaseMinFontSize; |
michael@0 | 557 | } |
michael@0 | 558 | |
michael@0 | 559 | /** |
michael@0 | 560 | * Set the per-presentation base minimum font size. This size is |
michael@0 | 561 | * independent of the language-specific global preference. |
michael@0 | 562 | */ |
michael@0 | 563 | void SetBaseMinFontSize(int32_t aMinFontSize) { |
michael@0 | 564 | if (aMinFontSize == mBaseMinFontSize) |
michael@0 | 565 | return; |
michael@0 | 566 | |
michael@0 | 567 | mBaseMinFontSize = aMinFontSize; |
michael@0 | 568 | if (HasCachedStyleData()) { |
michael@0 | 569 | // Media queries could have changed, since we changed the meaning |
michael@0 | 570 | // of 'em' units in them. |
michael@0 | 571 | MediaFeatureValuesChanged(eAlwaysRebuildStyle, NS_STYLE_HINT_REFLOW); |
michael@0 | 572 | } |
michael@0 | 573 | } |
michael@0 | 574 | |
michael@0 | 575 | float GetFullZoom() { return mFullZoom; } |
michael@0 | 576 | void SetFullZoom(float aZoom); |
michael@0 | 577 | |
michael@0 | 578 | nscoord GetAutoQualityMinFontSize() { |
michael@0 | 579 | return DevPixelsToAppUnits(mAutoQualityMinFontSizePixelsPref); |
michael@0 | 580 | } |
michael@0 | 581 | |
michael@0 | 582 | /** |
michael@0 | 583 | * Return the device's screen width in inches, for font size |
michael@0 | 584 | * inflation. |
michael@0 | 585 | * |
michael@0 | 586 | * If |aChanged| is non-null, then aChanged is filled in with whether |
michael@0 | 587 | * the return value has changed since either: |
michael@0 | 588 | * a. the last time the function was called with non-null aChanged, or |
michael@0 | 589 | * b. the first time the function was called. |
michael@0 | 590 | */ |
michael@0 | 591 | float ScreenWidthInchesForFontInflation(bool* aChanged = nullptr); |
michael@0 | 592 | |
michael@0 | 593 | static int32_t AppUnitsPerCSSPixel() { return mozilla::AppUnitsPerCSSPixel(); } |
michael@0 | 594 | int32_t AppUnitsPerDevPixel() const; |
michael@0 | 595 | static int32_t AppUnitsPerCSSInch() { return mozilla::AppUnitsPerCSSInch(); } |
michael@0 | 596 | |
michael@0 | 597 | static nscoord CSSPixelsToAppUnits(int32_t aPixels) |
michael@0 | 598 | { return NSToCoordRoundWithClamp(float(aPixels) * |
michael@0 | 599 | float(AppUnitsPerCSSPixel())); } |
michael@0 | 600 | |
michael@0 | 601 | static nscoord CSSPixelsToAppUnits(float aPixels) |
michael@0 | 602 | { return NSToCoordRoundWithClamp(aPixels * |
michael@0 | 603 | float(AppUnitsPerCSSPixel())); } |
michael@0 | 604 | |
michael@0 | 605 | static int32_t AppUnitsToIntCSSPixels(nscoord aAppUnits) |
michael@0 | 606 | { return NSAppUnitsToIntPixels(aAppUnits, |
michael@0 | 607 | float(AppUnitsPerCSSPixel())); } |
michael@0 | 608 | |
michael@0 | 609 | static float AppUnitsToFloatCSSPixels(nscoord aAppUnits) |
michael@0 | 610 | { return NSAppUnitsToFloatPixels(aAppUnits, |
michael@0 | 611 | float(AppUnitsPerCSSPixel())); } |
michael@0 | 612 | |
michael@0 | 613 | nscoord DevPixelsToAppUnits(int32_t aPixels) const |
michael@0 | 614 | { return NSIntPixelsToAppUnits(aPixels, AppUnitsPerDevPixel()); } |
michael@0 | 615 | |
michael@0 | 616 | int32_t AppUnitsToDevPixels(nscoord aAppUnits) const |
michael@0 | 617 | { return NSAppUnitsToIntPixels(aAppUnits, |
michael@0 | 618 | float(AppUnitsPerDevPixel())); } |
michael@0 | 619 | |
michael@0 | 620 | int32_t CSSPixelsToDevPixels(int32_t aPixels) |
michael@0 | 621 | { return AppUnitsToDevPixels(CSSPixelsToAppUnits(aPixels)); } |
michael@0 | 622 | |
michael@0 | 623 | float CSSPixelsToDevPixels(float aPixels) |
michael@0 | 624 | { |
michael@0 | 625 | return NSAppUnitsToFloatPixels(CSSPixelsToAppUnits(aPixels), |
michael@0 | 626 | float(AppUnitsPerDevPixel())); |
michael@0 | 627 | } |
michael@0 | 628 | |
michael@0 | 629 | int32_t DevPixelsToIntCSSPixels(int32_t aPixels) |
michael@0 | 630 | { return AppUnitsToIntCSSPixels(DevPixelsToAppUnits(aPixels)); } |
michael@0 | 631 | |
michael@0 | 632 | float DevPixelsToFloatCSSPixels(int32_t aPixels) |
michael@0 | 633 | { return AppUnitsToFloatCSSPixels(DevPixelsToAppUnits(aPixels)); } |
michael@0 | 634 | |
michael@0 | 635 | // If there is a remainder, it is rounded to nearest app units. |
michael@0 | 636 | nscoord GfxUnitsToAppUnits(gfxFloat aGfxUnits) const; |
michael@0 | 637 | |
michael@0 | 638 | gfxFloat AppUnitsToGfxUnits(nscoord aAppUnits) const; |
michael@0 | 639 | |
michael@0 | 640 | gfxRect AppUnitsToGfxUnits(const nsRect& aAppRect) const |
michael@0 | 641 | { return gfxRect(AppUnitsToGfxUnits(aAppRect.x), |
michael@0 | 642 | AppUnitsToGfxUnits(aAppRect.y), |
michael@0 | 643 | AppUnitsToGfxUnits(aAppRect.width), |
michael@0 | 644 | AppUnitsToGfxUnits(aAppRect.height)); } |
michael@0 | 645 | |
michael@0 | 646 | static nscoord CSSTwipsToAppUnits(float aTwips) |
michael@0 | 647 | { return NSToCoordRoundWithClamp( |
michael@0 | 648 | mozilla::AppUnitsPerCSSInch() * NS_TWIPS_TO_INCHES(aTwips)); } |
michael@0 | 649 | |
michael@0 | 650 | // Margin-specific version, since they often need TwipsToAppUnits |
michael@0 | 651 | static nsMargin CSSTwipsToAppUnits(const nsIntMargin &marginInTwips) |
michael@0 | 652 | { return nsMargin(CSSTwipsToAppUnits(float(marginInTwips.top)), |
michael@0 | 653 | CSSTwipsToAppUnits(float(marginInTwips.right)), |
michael@0 | 654 | CSSTwipsToAppUnits(float(marginInTwips.bottom)), |
michael@0 | 655 | CSSTwipsToAppUnits(float(marginInTwips.left))); } |
michael@0 | 656 | |
michael@0 | 657 | static nscoord CSSPointsToAppUnits(float aPoints) |
michael@0 | 658 | { return NSToCoordRound(aPoints * mozilla::AppUnitsPerCSSInch() / |
michael@0 | 659 | POINTS_PER_INCH_FLOAT); } |
michael@0 | 660 | |
michael@0 | 661 | nscoord RoundAppUnitsToNearestDevPixels(nscoord aAppUnits) const |
michael@0 | 662 | { return DevPixelsToAppUnits(AppUnitsToDevPixels(aAppUnits)); } |
michael@0 | 663 | |
michael@0 | 664 | void SetViewportOverflowOverride(uint8_t aX, uint8_t aY) |
michael@0 | 665 | { |
michael@0 | 666 | mViewportStyleOverflow.mHorizontal = aX; |
michael@0 | 667 | mViewportStyleOverflow.mVertical = aY; |
michael@0 | 668 | } |
michael@0 | 669 | mozilla::ScrollbarStyles GetViewportOverflowOverride() |
michael@0 | 670 | { |
michael@0 | 671 | return mViewportStyleOverflow; |
michael@0 | 672 | } |
michael@0 | 673 | |
michael@0 | 674 | /** |
michael@0 | 675 | * Set and get methods for controlling the background drawing |
michael@0 | 676 | */ |
michael@0 | 677 | bool GetBackgroundImageDraw() const { return mDrawImageBackground; } |
michael@0 | 678 | void SetBackgroundImageDraw(bool aCanDraw) |
michael@0 | 679 | { |
michael@0 | 680 | mDrawImageBackground = aCanDraw; |
michael@0 | 681 | } |
michael@0 | 682 | |
michael@0 | 683 | bool GetBackgroundColorDraw() const { return mDrawColorBackground; } |
michael@0 | 684 | void SetBackgroundColorDraw(bool aCanDraw) |
michael@0 | 685 | { |
michael@0 | 686 | mDrawColorBackground = aCanDraw; |
michael@0 | 687 | } |
michael@0 | 688 | |
michael@0 | 689 | /** |
michael@0 | 690 | * Getter and setter for OMTA time counters |
michael@0 | 691 | */ |
michael@0 | 692 | bool ThrottledTransitionStyleIsUpToDate() const; |
michael@0 | 693 | void TickLastUpdateThrottledTransitionStyle(); |
michael@0 | 694 | bool ThrottledAnimationStyleIsUpToDate() const; |
michael@0 | 695 | void TickLastUpdateThrottledAnimationStyle(); |
michael@0 | 696 | bool StyleUpdateForAllAnimationsIsUpToDate(); |
michael@0 | 697 | void TickLastStyleUpdateForAllAnimations(); |
michael@0 | 698 | |
michael@0 | 699 | /** |
michael@0 | 700 | * Check if bidi enabled (set depending on the presence of RTL |
michael@0 | 701 | * characters or when default directionality is RTL). |
michael@0 | 702 | * If enabled, we should apply the Unicode Bidi Algorithm |
michael@0 | 703 | * |
michael@0 | 704 | * @lina 07/12/2000 |
michael@0 | 705 | */ |
michael@0 | 706 | #ifdef MOZILLA_INTERNAL_API |
michael@0 | 707 | bool BidiEnabled() const { return BidiEnabledInternal(); } |
michael@0 | 708 | #else |
michael@0 | 709 | bool BidiEnabled() const { return BidiEnabledExternal(); } |
michael@0 | 710 | #endif |
michael@0 | 711 | virtual bool BidiEnabledExternal() const; |
michael@0 | 712 | bool BidiEnabledInternal() const; |
michael@0 | 713 | |
michael@0 | 714 | /** |
michael@0 | 715 | * Set bidi enabled. This means we should apply the Unicode Bidi Algorithm |
michael@0 | 716 | * |
michael@0 | 717 | * @lina 07/12/2000 |
michael@0 | 718 | */ |
michael@0 | 719 | NS_HIDDEN_(void) SetBidiEnabled() const; |
michael@0 | 720 | |
michael@0 | 721 | /** |
michael@0 | 722 | * Set visual or implicit mode into the pres context. |
michael@0 | 723 | * |
michael@0 | 724 | * Visual directionality is a presentation method that displays text |
michael@0 | 725 | * as if it were a uni-directional, according to the primary display |
michael@0 | 726 | * direction only. |
michael@0 | 727 | * |
michael@0 | 728 | * Implicit directionality is a presentation method in which the |
michael@0 | 729 | * direction is determined by the Bidi algorithm according to the |
michael@0 | 730 | * category of the characters and the category of the adjacent |
michael@0 | 731 | * characters, and according to their primary direction. |
michael@0 | 732 | * |
michael@0 | 733 | * @lina 05/02/2000 |
michael@0 | 734 | */ |
michael@0 | 735 | void SetVisualMode(bool aIsVisual) |
michael@0 | 736 | { |
michael@0 | 737 | mIsVisual = aIsVisual; |
michael@0 | 738 | } |
michael@0 | 739 | |
michael@0 | 740 | /** |
michael@0 | 741 | * Check whether the content should be treated as visual. |
michael@0 | 742 | * |
michael@0 | 743 | * @lina 05/02/2000 |
michael@0 | 744 | */ |
michael@0 | 745 | bool IsVisualMode() const { return mIsVisual; } |
michael@0 | 746 | |
michael@0 | 747 | //Mohamed |
michael@0 | 748 | |
michael@0 | 749 | /** |
michael@0 | 750 | * Set the Bidi options for the presentation context |
michael@0 | 751 | */ |
michael@0 | 752 | NS_HIDDEN_(void) SetBidi(uint32_t aBidiOptions, |
michael@0 | 753 | bool aForceRestyle = false); |
michael@0 | 754 | |
michael@0 | 755 | /** |
michael@0 | 756 | * Get the Bidi options for the presentation context |
michael@0 | 757 | * Not inline so consumers of nsPresContext are not forced to |
michael@0 | 758 | * include nsIDocument. |
michael@0 | 759 | */ |
michael@0 | 760 | NS_HIDDEN_(uint32_t) GetBidi() const; |
michael@0 | 761 | |
michael@0 | 762 | /** |
michael@0 | 763 | * Render only Selection |
michael@0 | 764 | */ |
michael@0 | 765 | void SetIsRenderingOnlySelection(bool aResult) |
michael@0 | 766 | { |
michael@0 | 767 | mIsRenderingOnlySelection = aResult; |
michael@0 | 768 | } |
michael@0 | 769 | |
michael@0 | 770 | bool IsRenderingOnlySelection() const { return mIsRenderingOnlySelection; } |
michael@0 | 771 | |
michael@0 | 772 | NS_HIDDEN_(bool) IsTopLevelWindowInactive(); |
michael@0 | 773 | |
michael@0 | 774 | /* |
michael@0 | 775 | * Obtain a native them for rendering our widgets (both form controls and html) |
michael@0 | 776 | */ |
michael@0 | 777 | NS_HIDDEN_(nsITheme*) GetTheme(); |
michael@0 | 778 | |
michael@0 | 779 | /* |
michael@0 | 780 | * Notify the pres context that the theme has changed. An internal switch |
michael@0 | 781 | * means it's one of our Mozilla themes that changed (e.g., Modern to Classic). |
michael@0 | 782 | * Otherwise, the OS is telling us that the native theme for the platform |
michael@0 | 783 | * has changed. |
michael@0 | 784 | */ |
michael@0 | 785 | NS_HIDDEN_(void) ThemeChanged(); |
michael@0 | 786 | |
michael@0 | 787 | /* |
michael@0 | 788 | * Notify the pres context that the resolution of the user interface has |
michael@0 | 789 | * changed. This happens if a window is moved between HiDPI and non-HiDPI |
michael@0 | 790 | * displays, so that the ratio of points to device pixels changes. |
michael@0 | 791 | */ |
michael@0 | 792 | NS_HIDDEN_(void) UIResolutionChanged(); |
michael@0 | 793 | |
michael@0 | 794 | /* |
michael@0 | 795 | * Notify the pres context that a system color has changed |
michael@0 | 796 | */ |
michael@0 | 797 | NS_HIDDEN_(void) SysColorChanged(); |
michael@0 | 798 | |
michael@0 | 799 | /** Printing methods below should only be used for Medium() == print **/ |
michael@0 | 800 | NS_HIDDEN_(void) SetPrintSettings(nsIPrintSettings *aPrintSettings); |
michael@0 | 801 | |
michael@0 | 802 | nsIPrintSettings* GetPrintSettings() { return mPrintSettings; } |
michael@0 | 803 | |
michael@0 | 804 | /* Accessor for table of frame properties */ |
michael@0 | 805 | FramePropertyTable* PropertyTable() { return &mPropertyTable; } |
michael@0 | 806 | |
michael@0 | 807 | /* Helper function that ensures that this prescontext is shown in its |
michael@0 | 808 | docshell if it's the most recent prescontext for the docshell. Returns |
michael@0 | 809 | whether the prescontext is now being shown. |
michael@0 | 810 | */ |
michael@0 | 811 | NS_HIDDEN_(bool) EnsureVisible(); |
michael@0 | 812 | |
michael@0 | 813 | #ifdef MOZ_REFLOW_PERF |
michael@0 | 814 | NS_HIDDEN_(void) CountReflows(const char * aName, |
michael@0 | 815 | nsIFrame * aFrame); |
michael@0 | 816 | #endif |
michael@0 | 817 | |
michael@0 | 818 | /** |
michael@0 | 819 | * This table maps border-width enums 'thin', 'medium', 'thick' |
michael@0 | 820 | * to actual nscoord values. |
michael@0 | 821 | */ |
michael@0 | 822 | const nscoord* GetBorderWidthTable() { return mBorderWidthTable; } |
michael@0 | 823 | |
michael@0 | 824 | gfxTextPerfMetrics *GetTextPerfMetrics() { return mTextPerf; } |
michael@0 | 825 | |
michael@0 | 826 | bool IsDynamic() { return (mType == eContext_PageLayout || mType == eContext_Galley); } |
michael@0 | 827 | bool IsScreen() { return (mMedium == nsGkAtoms::screen || |
michael@0 | 828 | mType == eContext_PageLayout || |
michael@0 | 829 | mType == eContext_PrintPreview); } |
michael@0 | 830 | |
michael@0 | 831 | // Is this presentation in a chrome docshell? |
michael@0 | 832 | bool IsChrome() const { return mIsChrome; } |
michael@0 | 833 | bool IsChromeOriginImage() const { return mIsChromeOriginImage; } |
michael@0 | 834 | void UpdateIsChrome(); |
michael@0 | 835 | |
michael@0 | 836 | // Public API for native theme code to get style internals. |
michael@0 | 837 | virtual bool HasAuthorSpecifiedRules(nsIFrame *aFrame, uint32_t ruleTypeMask) const; |
michael@0 | 838 | |
michael@0 | 839 | // Is it OK to let the page specify colors and backgrounds? |
michael@0 | 840 | bool UseDocumentColors() const { |
michael@0 | 841 | return GetCachedBoolPref(kPresContext_UseDocumentColors) || IsChrome() || IsChromeOriginImage(); |
michael@0 | 842 | } |
michael@0 | 843 | |
michael@0 | 844 | // Explicitly enable and disable paint flashing. |
michael@0 | 845 | void SetPaintFlashing(bool aPaintFlashing) { |
michael@0 | 846 | mPaintFlashing = aPaintFlashing; |
michael@0 | 847 | mPaintFlashingInitialized = true; |
michael@0 | 848 | } |
michael@0 | 849 | |
michael@0 | 850 | // This method should be used instead of directly accessing mPaintFlashing, |
michael@0 | 851 | // as that value may be out of date when mPaintFlashingInitialized is false. |
michael@0 | 852 | bool GetPaintFlashing() const; |
michael@0 | 853 | |
michael@0 | 854 | bool SupressingResizeReflow() const { return mSupressResizeReflow; } |
michael@0 | 855 | |
michael@0 | 856 | virtual NS_HIDDEN_(gfxUserFontSet*) GetUserFontSetExternal(); |
michael@0 | 857 | NS_HIDDEN_(gfxUserFontSet*) GetUserFontSetInternal(); |
michael@0 | 858 | #ifdef MOZILLA_INTERNAL_API |
michael@0 | 859 | gfxUserFontSet* GetUserFontSet() { return GetUserFontSetInternal(); } |
michael@0 | 860 | #else |
michael@0 | 861 | gfxUserFontSet* GetUserFontSet() { return GetUserFontSetExternal(); } |
michael@0 | 862 | #endif |
michael@0 | 863 | |
michael@0 | 864 | void FlushUserFontSet(); |
michael@0 | 865 | void RebuildUserFontSet(); // asynchronously |
michael@0 | 866 | |
michael@0 | 867 | // Should be called whenever the set of fonts available in the user |
michael@0 | 868 | // font set changes (e.g., because a new font loads, or because the |
michael@0 | 869 | // user font set is changed and fonts become unavailable). |
michael@0 | 870 | void UserFontSetUpdated(); |
michael@0 | 871 | |
michael@0 | 872 | // Ensure that it is safe to hand out CSS rules outside the layout |
michael@0 | 873 | // engine by ensuring that all CSS style sheets have unique inners |
michael@0 | 874 | // and, if necessary, synchronously rebuilding all style data. |
michael@0 | 875 | void EnsureSafeToHandOutCSSRules(); |
michael@0 | 876 | |
michael@0 | 877 | void NotifyInvalidation(uint32_t aFlags); |
michael@0 | 878 | void NotifyInvalidation(const nsRect& aRect, uint32_t aFlags); |
michael@0 | 879 | // aRect is in device pixels |
michael@0 | 880 | void NotifyInvalidation(const nsIntRect& aRect, uint32_t aFlags); |
michael@0 | 881 | // aFlags are nsIPresShell::PAINT_ flags |
michael@0 | 882 | void NotifyDidPaintForSubtree(uint32_t aFlags); |
michael@0 | 883 | void FireDOMPaintEvent(nsInvalidateRequestList* aList); |
michael@0 | 884 | |
michael@0 | 885 | // Callback for catching invalidations in ContainerLayers |
michael@0 | 886 | // Passed to LayerProperties::ComputeDifference |
michael@0 | 887 | static void NotifySubDocInvalidation(mozilla::layers::ContainerLayer* aContainer, |
michael@0 | 888 | const nsIntRegion& aRegion); |
michael@0 | 889 | void SetNotifySubDocInvalidationData(mozilla::layers::ContainerLayer* aContainer); |
michael@0 | 890 | static void ClearNotifySubDocInvalidationData(mozilla::layers::ContainerLayer* aContainer); |
michael@0 | 891 | bool IsDOMPaintEventPending(); |
michael@0 | 892 | void ClearMozAfterPaintEvents() { |
michael@0 | 893 | mInvalidateRequestsSinceLastPaint.mRequests.Clear(); |
michael@0 | 894 | mUndeliveredInvalidateRequestsBeforeLastPaint.mRequests.Clear(); |
michael@0 | 895 | mAllInvalidated = false; |
michael@0 | 896 | } |
michael@0 | 897 | |
michael@0 | 898 | bool IsProcessingRestyles() const { |
michael@0 | 899 | return mProcessingRestyles; |
michael@0 | 900 | } |
michael@0 | 901 | |
michael@0 | 902 | void SetProcessingRestyles(bool aProcessing) { |
michael@0 | 903 | NS_ASSERTION(aProcessing != bool(mProcessingRestyles), |
michael@0 | 904 | "should never nest"); |
michael@0 | 905 | mProcessingRestyles = aProcessing; |
michael@0 | 906 | } |
michael@0 | 907 | |
michael@0 | 908 | bool IsProcessingAnimationStyleChange() const { |
michael@0 | 909 | return mProcessingAnimationStyleChange; |
michael@0 | 910 | } |
michael@0 | 911 | |
michael@0 | 912 | void SetProcessingAnimationStyleChange(bool aProcessing) { |
michael@0 | 913 | NS_ASSERTION(aProcessing != bool(mProcessingAnimationStyleChange), |
michael@0 | 914 | "should never nest"); |
michael@0 | 915 | mProcessingAnimationStyleChange = aProcessing; |
michael@0 | 916 | } |
michael@0 | 917 | |
michael@0 | 918 | /** |
michael@0 | 919 | * Notify the prescontext that the presshell is about to reflow a reflow root. |
michael@0 | 920 | * The single argument indicates whether this reflow should be interruptible. |
michael@0 | 921 | * If aInterruptible is false then CheckForInterrupt and HasPendingInterrupt |
michael@0 | 922 | * will always return false. If aInterruptible is true then CheckForInterrupt |
michael@0 | 923 | * will return true when a pending event is detected. This is for use by the |
michael@0 | 924 | * presshell only. Reflow code wanting to prevent interrupts should use |
michael@0 | 925 | * InterruptPreventer. |
michael@0 | 926 | */ |
michael@0 | 927 | void ReflowStarted(bool aInterruptible); |
michael@0 | 928 | |
michael@0 | 929 | /** |
michael@0 | 930 | * A class that can be used to temporarily disable reflow interruption. |
michael@0 | 931 | */ |
michael@0 | 932 | class InterruptPreventer; |
michael@0 | 933 | friend class InterruptPreventer; |
michael@0 | 934 | class MOZ_STACK_CLASS InterruptPreventer { |
michael@0 | 935 | public: |
michael@0 | 936 | InterruptPreventer(nsPresContext* aCtx) : |
michael@0 | 937 | mCtx(aCtx), |
michael@0 | 938 | mInterruptsEnabled(aCtx->mInterruptsEnabled), |
michael@0 | 939 | mHasPendingInterrupt(aCtx->mHasPendingInterrupt) |
michael@0 | 940 | { |
michael@0 | 941 | mCtx->mInterruptsEnabled = false; |
michael@0 | 942 | mCtx->mHasPendingInterrupt = false; |
michael@0 | 943 | } |
michael@0 | 944 | ~InterruptPreventer() { |
michael@0 | 945 | mCtx->mInterruptsEnabled = mInterruptsEnabled; |
michael@0 | 946 | mCtx->mHasPendingInterrupt = mHasPendingInterrupt; |
michael@0 | 947 | } |
michael@0 | 948 | |
michael@0 | 949 | private: |
michael@0 | 950 | nsPresContext* mCtx; |
michael@0 | 951 | bool mInterruptsEnabled; |
michael@0 | 952 | bool mHasPendingInterrupt; |
michael@0 | 953 | }; |
michael@0 | 954 | |
michael@0 | 955 | /** |
michael@0 | 956 | * Check for interrupts. This may return true if a pending event is |
michael@0 | 957 | * detected. Once it has returned true, it will keep returning true |
michael@0 | 958 | * until ReflowStarted is called. In all cases where this returns true, |
michael@0 | 959 | * the passed-in frame (which should be the frame whose reflow will be |
michael@0 | 960 | * interrupted if true is returned) will be passed to |
michael@0 | 961 | * nsIPresShell::FrameNeedsToContinueReflow. |
michael@0 | 962 | */ |
michael@0 | 963 | bool CheckForInterrupt(nsIFrame* aFrame); |
michael@0 | 964 | /** |
michael@0 | 965 | * Returns true if CheckForInterrupt has returned true since the last |
michael@0 | 966 | * ReflowStarted call. Cannot itself trigger an interrupt check. |
michael@0 | 967 | */ |
michael@0 | 968 | bool HasPendingInterrupt() { return mHasPendingInterrupt; } |
michael@0 | 969 | |
michael@0 | 970 | /** |
michael@0 | 971 | * If we have a presshell, and if the given content's current |
michael@0 | 972 | * document is the same as our presshell's document, return the |
michael@0 | 973 | * content's primary frame. Otherwise, return null. Only use this |
michael@0 | 974 | * if you care about which presshell the primary frame is in. |
michael@0 | 975 | */ |
michael@0 | 976 | nsIFrame* GetPrimaryFrameFor(nsIContent* aContent); |
michael@0 | 977 | |
michael@0 | 978 | void NotifyDestroyingFrame(nsIFrame* aFrame) |
michael@0 | 979 | { |
michael@0 | 980 | PropertyTable()->DeleteAllFor(aFrame); |
michael@0 | 981 | } |
michael@0 | 982 | |
michael@0 | 983 | virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 984 | virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { |
michael@0 | 985 | return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); |
michael@0 | 986 | } |
michael@0 | 987 | |
michael@0 | 988 | bool IsRootContentDocument(); |
michael@0 | 989 | bool IsCrossProcessRootContentDocument(); |
michael@0 | 990 | |
michael@0 | 991 | bool IsGlyph() const { |
michael@0 | 992 | return mIsGlyph; |
michael@0 | 993 | } |
michael@0 | 994 | |
michael@0 | 995 | void SetIsGlyph(bool aValue) { |
michael@0 | 996 | mIsGlyph = aValue; |
michael@0 | 997 | } |
michael@0 | 998 | |
michael@0 | 999 | bool UsesRootEMUnits() const { |
michael@0 | 1000 | return mUsesRootEMUnits; |
michael@0 | 1001 | } |
michael@0 | 1002 | |
michael@0 | 1003 | void SetUsesRootEMUnits(bool aValue) { |
michael@0 | 1004 | mUsesRootEMUnits = aValue; |
michael@0 | 1005 | } |
michael@0 | 1006 | |
michael@0 | 1007 | bool UsesViewportUnits() const { |
michael@0 | 1008 | return mUsesViewportUnits; |
michael@0 | 1009 | } |
michael@0 | 1010 | |
michael@0 | 1011 | void SetUsesViewportUnits(bool aValue) { |
michael@0 | 1012 | mUsesViewportUnits = aValue; |
michael@0 | 1013 | } |
michael@0 | 1014 | |
michael@0 | 1015 | // true if there are OMTA transition updates for the current document which |
michael@0 | 1016 | // have been throttled, and therefore some style information may not be up |
michael@0 | 1017 | // to date |
michael@0 | 1018 | bool ExistThrottledUpdates() const { |
michael@0 | 1019 | return mExistThrottledUpdates; |
michael@0 | 1020 | } |
michael@0 | 1021 | |
michael@0 | 1022 | void SetExistThrottledUpdates(bool aExistThrottledUpdates) { |
michael@0 | 1023 | mExistThrottledUpdates = aExistThrottledUpdates; |
michael@0 | 1024 | } |
michael@0 | 1025 | |
michael@0 | 1026 | bool IsDeviceSizePageSize(); |
michael@0 | 1027 | |
michael@0 | 1028 | bool HasWarnedAboutPositionedTableParts() const { |
michael@0 | 1029 | return mHasWarnedAboutPositionedTableParts; |
michael@0 | 1030 | } |
michael@0 | 1031 | |
michael@0 | 1032 | void SetHasWarnedAboutPositionedTableParts() { |
michael@0 | 1033 | mHasWarnedAboutPositionedTableParts = true; |
michael@0 | 1034 | } |
michael@0 | 1035 | |
michael@0 | 1036 | protected: |
michael@0 | 1037 | friend class nsRunnableMethod<nsPresContext>; |
michael@0 | 1038 | NS_HIDDEN_(void) ThemeChangedInternal(); |
michael@0 | 1039 | NS_HIDDEN_(void) SysColorChangedInternal(); |
michael@0 | 1040 | NS_HIDDEN_(void) UIResolutionChangedInternal(); |
michael@0 | 1041 | |
michael@0 | 1042 | static NS_HIDDEN_(bool) |
michael@0 | 1043 | UIResolutionChangedSubdocumentCallback(nsIDocument* aDocument, void* aData); |
michael@0 | 1044 | |
michael@0 | 1045 | NS_HIDDEN_(void) SetImgAnimations(nsIContent *aParent, uint16_t aMode); |
michael@0 | 1046 | NS_HIDDEN_(void) SetSMILAnimations(nsIDocument *aDoc, uint16_t aNewMode, |
michael@0 | 1047 | uint16_t aOldMode); |
michael@0 | 1048 | NS_HIDDEN_(void) GetDocumentColorPreferences(); |
michael@0 | 1049 | |
michael@0 | 1050 | NS_HIDDEN_(void) PreferenceChanged(const char* aPrefName); |
michael@0 | 1051 | static NS_HIDDEN_(void) PrefChangedCallback(const char*, void*); |
michael@0 | 1052 | |
michael@0 | 1053 | NS_HIDDEN_(void) UpdateAfterPreferencesChanged(); |
michael@0 | 1054 | static NS_HIDDEN_(void) PrefChangedUpdateTimerCallback(nsITimer *aTimer, void *aClosure); |
michael@0 | 1055 | |
michael@0 | 1056 | NS_HIDDEN_(void) GetUserPreferences(); |
michael@0 | 1057 | |
michael@0 | 1058 | // Allow nsAutoPtr<LangGroupFontPrefs> dtor to access this protected struct's |
michael@0 | 1059 | // dtor: |
michael@0 | 1060 | struct LangGroupFontPrefs; |
michael@0 | 1061 | friend class nsAutoPtr<LangGroupFontPrefs>; |
michael@0 | 1062 | struct LangGroupFontPrefs { |
michael@0 | 1063 | // Font sizes default to zero; they will be set in GetFontPreferences |
michael@0 | 1064 | LangGroupFontPrefs() |
michael@0 | 1065 | : mLangGroup(nullptr) |
michael@0 | 1066 | , mMinimumFontSize(0) |
michael@0 | 1067 | , mDefaultVariableFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, |
michael@0 | 1068 | NS_FONT_WEIGHT_NORMAL, NS_FONT_STRETCH_NORMAL, 0, 0) |
michael@0 | 1069 | , mDefaultFixedFont("monospace", NS_FONT_STYLE_NORMAL, |
michael@0 | 1070 | NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, |
michael@0 | 1071 | NS_FONT_STRETCH_NORMAL, 0, 0) |
michael@0 | 1072 | , mDefaultSerifFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, |
michael@0 | 1073 | NS_FONT_WEIGHT_NORMAL, NS_FONT_STRETCH_NORMAL, 0, 0) |
michael@0 | 1074 | , mDefaultSansSerifFont("sans-serif", NS_FONT_STYLE_NORMAL, |
michael@0 | 1075 | NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, |
michael@0 | 1076 | NS_FONT_STRETCH_NORMAL, 0, 0) |
michael@0 | 1077 | , mDefaultMonospaceFont("monospace", NS_FONT_STYLE_NORMAL, |
michael@0 | 1078 | NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, |
michael@0 | 1079 | NS_FONT_STRETCH_NORMAL, 0, 0) |
michael@0 | 1080 | , mDefaultCursiveFont("cursive", NS_FONT_STYLE_NORMAL, |
michael@0 | 1081 | NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, |
michael@0 | 1082 | NS_FONT_STRETCH_NORMAL, 0, 0) |
michael@0 | 1083 | , mDefaultFantasyFont("fantasy", NS_FONT_STYLE_NORMAL, |
michael@0 | 1084 | NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, |
michael@0 | 1085 | NS_FONT_STRETCH_NORMAL, 0, 0) |
michael@0 | 1086 | {} |
michael@0 | 1087 | |
michael@0 | 1088 | size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { |
michael@0 | 1089 | size_t n = 0; |
michael@0 | 1090 | LangGroupFontPrefs *curr = mNext; |
michael@0 | 1091 | while (curr) { |
michael@0 | 1092 | n += aMallocSizeOf(curr); |
michael@0 | 1093 | |
michael@0 | 1094 | // Measurement of the following members may be added later if DMD finds |
michael@0 | 1095 | // it is worthwhile: |
michael@0 | 1096 | // - mLangGroup |
michael@0 | 1097 | // - mDefault*Font |
michael@0 | 1098 | |
michael@0 | 1099 | curr = curr->mNext; |
michael@0 | 1100 | } |
michael@0 | 1101 | return n; |
michael@0 | 1102 | } |
michael@0 | 1103 | |
michael@0 | 1104 | nsCOMPtr<nsIAtom> mLangGroup; |
michael@0 | 1105 | nscoord mMinimumFontSize; |
michael@0 | 1106 | nsFont mDefaultVariableFont; |
michael@0 | 1107 | nsFont mDefaultFixedFont; |
michael@0 | 1108 | nsFont mDefaultSerifFont; |
michael@0 | 1109 | nsFont mDefaultSansSerifFont; |
michael@0 | 1110 | nsFont mDefaultMonospaceFont; |
michael@0 | 1111 | nsFont mDefaultCursiveFont; |
michael@0 | 1112 | nsFont mDefaultFantasyFont; |
michael@0 | 1113 | nsAutoPtr<LangGroupFontPrefs> mNext; |
michael@0 | 1114 | }; |
michael@0 | 1115 | |
michael@0 | 1116 | /** |
michael@0 | 1117 | * Fetch the user's font preferences for the given aLanguage's |
michael@0 | 1118 | * langugage group. |
michael@0 | 1119 | */ |
michael@0 | 1120 | const LangGroupFontPrefs* GetFontPrefsForLang(nsIAtom *aLanguage) const; |
michael@0 | 1121 | |
michael@0 | 1122 | void ResetCachedFontPrefs() { |
michael@0 | 1123 | // Throw away any other LangGroupFontPrefs objects: |
michael@0 | 1124 | mLangGroupFontPrefs.mNext = nullptr; |
michael@0 | 1125 | |
michael@0 | 1126 | // Make GetFontPreferences reinitialize mLangGroupFontPrefs: |
michael@0 | 1127 | mLangGroupFontPrefs.mLangGroup = nullptr; |
michael@0 | 1128 | } |
michael@0 | 1129 | |
michael@0 | 1130 | NS_HIDDEN_(void) UpdateCharSet(const nsCString& aCharSet); |
michael@0 | 1131 | |
michael@0 | 1132 | public: |
michael@0 | 1133 | void DoChangeCharSet(const nsCString& aCharSet); |
michael@0 | 1134 | |
michael@0 | 1135 | /** |
michael@0 | 1136 | * Checks for MozAfterPaint listeners on the document |
michael@0 | 1137 | */ |
michael@0 | 1138 | bool MayHavePaintEventListener(); |
michael@0 | 1139 | |
michael@0 | 1140 | /** |
michael@0 | 1141 | * Checks for MozAfterPaint listeners on the document and |
michael@0 | 1142 | * any subdocuments, except for subdocuments that are non-top-level |
michael@0 | 1143 | * content documents. |
michael@0 | 1144 | */ |
michael@0 | 1145 | bool MayHavePaintEventListenerInSubDocument(); |
michael@0 | 1146 | |
michael@0 | 1147 | protected: |
michael@0 | 1148 | void InvalidateThebesLayers(); |
michael@0 | 1149 | void AppUnitsPerDevPixelChanged(); |
michael@0 | 1150 | |
michael@0 | 1151 | void HandleRebuildUserFontSet() { |
michael@0 | 1152 | mPostedFlushUserFontSet = false; |
michael@0 | 1153 | FlushUserFontSet(); |
michael@0 | 1154 | } |
michael@0 | 1155 | |
michael@0 | 1156 | bool HavePendingInputEvent(); |
michael@0 | 1157 | |
michael@0 | 1158 | // Can't be inline because we can't include nsStyleSet.h. |
michael@0 | 1159 | bool HasCachedStyleData(); |
michael@0 | 1160 | |
michael@0 | 1161 | bool IsChromeSlow() const; |
michael@0 | 1162 | |
michael@0 | 1163 | // IMPORTANT: The ownership implicit in the following member variables |
michael@0 | 1164 | // has been explicitly checked. If you add any members to this class, |
michael@0 | 1165 | // please make the ownership explicit (pinkerton, scc). |
michael@0 | 1166 | |
michael@0 | 1167 | nsPresContextType mType; |
michael@0 | 1168 | nsIPresShell* mShell; // [WEAK] |
michael@0 | 1169 | nsCOMPtr<nsIDocument> mDocument; |
michael@0 | 1170 | nsRefPtr<nsDeviceContext> mDeviceContext; // [STRONG] could be weak, but |
michael@0 | 1171 | // better safe than sorry. |
michael@0 | 1172 | // Cannot reintroduce cycles |
michael@0 | 1173 | // since there is no dependency |
michael@0 | 1174 | // from gfx back to layout. |
michael@0 | 1175 | nsRefPtr<mozilla::EventStateManager> mEventManager; |
michael@0 | 1176 | nsRefPtr<nsRefreshDriver> mRefreshDriver; |
michael@0 | 1177 | nsRefPtr<nsTransitionManager> mTransitionManager; |
michael@0 | 1178 | nsRefPtr<nsAnimationManager> mAnimationManager; |
michael@0 | 1179 | nsRefPtr<mozilla::RestyleManager> mRestyleManager; |
michael@0 | 1180 | nsIAtom* mMedium; // initialized by subclass ctors; |
michael@0 | 1181 | // weak pointer to static atom |
michael@0 | 1182 | nsCOMPtr<nsIAtom> mMediaEmulated; |
michael@0 | 1183 | |
michael@0 | 1184 | nsILinkHandler* mLinkHandler; // [WEAK] |
michael@0 | 1185 | |
michael@0 | 1186 | // Formerly mLangGroup; moving from charset-oriented langGroup to |
michael@0 | 1187 | // maintaining actual language settings everywhere (see bug 524107). |
michael@0 | 1188 | // This may in fact hold a langGroup such as x-western rather than |
michael@0 | 1189 | // a specific language, however (e.g, if it is inferred from the |
michael@0 | 1190 | // charset rather than explicitly specified as a lang attribute). |
michael@0 | 1191 | nsCOMPtr<nsIAtom> mLanguage; |
michael@0 | 1192 | |
michael@0 | 1193 | public: |
michael@0 | 1194 | // The following are public member variables so that we can use them |
michael@0 | 1195 | // with mozilla::AutoToggle or mozilla::AutoRestore. |
michael@0 | 1196 | |
michael@0 | 1197 | // Should we disable font size inflation because we're inside of |
michael@0 | 1198 | // shrink-wrapping calculations on an inflation container? |
michael@0 | 1199 | bool mInflationDisabledForShrinkWrap; |
michael@0 | 1200 | |
michael@0 | 1201 | protected: |
michael@0 | 1202 | |
michael@0 | 1203 | mozilla::WeakPtr<nsDocShell> mContainer; |
michael@0 | 1204 | |
michael@0 | 1205 | PRCList mDOMMediaQueryLists; |
michael@0 | 1206 | |
michael@0 | 1207 | // Base minimum font size, independent of the language-specific global preference. Defaults to 0 |
michael@0 | 1208 | int32_t mBaseMinFontSize; |
michael@0 | 1209 | float mTextZoom; // Text zoom, defaults to 1.0 |
michael@0 | 1210 | float mFullZoom; // Page zoom, defaults to 1.0 |
michael@0 | 1211 | |
michael@0 | 1212 | float mLastFontInflationScreenWidth; |
michael@0 | 1213 | |
michael@0 | 1214 | int32_t mCurAppUnitsPerDevPixel; |
michael@0 | 1215 | int32_t mAutoQualityMinFontSizePixelsPref; |
michael@0 | 1216 | |
michael@0 | 1217 | nsCOMPtr<nsITheme> mTheme; |
michael@0 | 1218 | nsCOMPtr<nsILanguageAtomService> mLangService; |
michael@0 | 1219 | nsCOMPtr<nsIPrintSettings> mPrintSettings; |
michael@0 | 1220 | nsCOMPtr<nsITimer> mPrefChangedTimer; |
michael@0 | 1221 | |
michael@0 | 1222 | FramePropertyTable mPropertyTable; |
michael@0 | 1223 | |
michael@0 | 1224 | nsInvalidateRequestList mInvalidateRequestsSinceLastPaint; |
michael@0 | 1225 | nsInvalidateRequestList mUndeliveredInvalidateRequestsBeforeLastPaint; |
michael@0 | 1226 | |
michael@0 | 1227 | // container for per-context fonts (downloadable, SVG, etc.) |
michael@0 | 1228 | nsUserFontSet* mUserFontSet; |
michael@0 | 1229 | |
michael@0 | 1230 | // text performance metrics |
michael@0 | 1231 | nsAutoPtr<gfxTextPerfMetrics> mTextPerf; |
michael@0 | 1232 | |
michael@0 | 1233 | nsRect mVisibleArea; |
michael@0 | 1234 | nsSize mPageSize; |
michael@0 | 1235 | float mPageScale; |
michael@0 | 1236 | float mPPScale; |
michael@0 | 1237 | |
michael@0 | 1238 | nscolor mDefaultColor; |
michael@0 | 1239 | nscolor mBackgroundColor; |
michael@0 | 1240 | |
michael@0 | 1241 | nscolor mLinkColor; |
michael@0 | 1242 | nscolor mActiveLinkColor; |
michael@0 | 1243 | nscolor mVisitedLinkColor; |
michael@0 | 1244 | |
michael@0 | 1245 | nscolor mFocusBackgroundColor; |
michael@0 | 1246 | nscolor mFocusTextColor; |
michael@0 | 1247 | |
michael@0 | 1248 | nscolor mBodyTextColor; |
michael@0 | 1249 | |
michael@0 | 1250 | mozilla::ScrollbarStyles mViewportStyleOverflow; |
michael@0 | 1251 | uint8_t mFocusRingWidth; |
michael@0 | 1252 | |
michael@0 | 1253 | bool mExistThrottledUpdates; |
michael@0 | 1254 | |
michael@0 | 1255 | uint16_t mImageAnimationMode; |
michael@0 | 1256 | uint16_t mImageAnimationModePref; |
michael@0 | 1257 | |
michael@0 | 1258 | LangGroupFontPrefs mLangGroupFontPrefs; |
michael@0 | 1259 | |
michael@0 | 1260 | nscoord mBorderWidthTable[3]; |
michael@0 | 1261 | |
michael@0 | 1262 | uint32_t mInterruptChecksToSkip; |
michael@0 | 1263 | |
michael@0 | 1264 | mozilla::TimeStamp mReflowStartTime; |
michael@0 | 1265 | PRInt32 mMaxFontAttempts; |
michael@0 | 1266 | PRInt32 mMaxFonts; |
michael@0 | 1267 | |
michael@0 | 1268 | // last time animations styles were flushed to their primary frames |
michael@0 | 1269 | mozilla::TimeStamp mLastUpdateThrottledAnimationStyle; |
michael@0 | 1270 | // last time transition styles were flushed to their primary frames |
michael@0 | 1271 | mozilla::TimeStamp mLastUpdateThrottledTransitionStyle; |
michael@0 | 1272 | // last time we did a full style flush |
michael@0 | 1273 | mozilla::TimeStamp mLastStyleUpdateForAllAnimations; |
michael@0 | 1274 | |
michael@0 | 1275 | unsigned mHasPendingInterrupt : 1; |
michael@0 | 1276 | unsigned mInterruptsEnabled : 1; |
michael@0 | 1277 | unsigned mUseDocumentFonts : 1; |
michael@0 | 1278 | unsigned mUseDocumentColors : 1; |
michael@0 | 1279 | unsigned mUnderlineLinks : 1; |
michael@0 | 1280 | unsigned mSendAfterPaintToContent : 1; |
michael@0 | 1281 | unsigned mUseFocusColors : 1; |
michael@0 | 1282 | unsigned mFocusRingOnAnything : 1; |
michael@0 | 1283 | unsigned mFocusRingStyle : 1; |
michael@0 | 1284 | unsigned mDrawImageBackground : 1; |
michael@0 | 1285 | unsigned mDrawColorBackground : 1; |
michael@0 | 1286 | unsigned mNeverAnimate : 1; |
michael@0 | 1287 | unsigned mIsRenderingOnlySelection : 1; |
michael@0 | 1288 | unsigned mPaginated : 1; |
michael@0 | 1289 | unsigned mCanPaginatedScroll : 1; |
michael@0 | 1290 | unsigned mDoScaledTwips : 1; |
michael@0 | 1291 | unsigned mIsRootPaginatedDocument : 1; |
michael@0 | 1292 | unsigned mPrefBidiDirection : 1; |
michael@0 | 1293 | unsigned mPrefScrollbarSide : 2; |
michael@0 | 1294 | unsigned mPendingSysColorChanged : 1; |
michael@0 | 1295 | unsigned mPendingThemeChanged : 1; |
michael@0 | 1296 | unsigned mPendingUIResolutionChanged : 1; |
michael@0 | 1297 | unsigned mPendingMediaFeatureValuesChanged : 1; |
michael@0 | 1298 | unsigned mPrefChangePendingNeedsReflow : 1; |
michael@0 | 1299 | unsigned mIsEmulatingMedia : 1; |
michael@0 | 1300 | // True if the requests in mInvalidateRequestsSinceLastPaint cover the |
michael@0 | 1301 | // entire viewport |
michael@0 | 1302 | unsigned mAllInvalidated : 1; |
michael@0 | 1303 | |
michael@0 | 1304 | // Are we currently drawing an SVG glyph? |
michael@0 | 1305 | unsigned mIsGlyph : 1; |
michael@0 | 1306 | |
michael@0 | 1307 | // Does the associated document use root-em (rem) units? |
michael@0 | 1308 | unsigned mUsesRootEMUnits : 1; |
michael@0 | 1309 | // Does the associated document use viewport units (vw/vh/vmin/vmax)? |
michael@0 | 1310 | unsigned mUsesViewportUnits : 1; |
michael@0 | 1311 | |
michael@0 | 1312 | // Has there been a change to the viewport's dimensions? |
michael@0 | 1313 | unsigned mPendingViewportChange : 1; |
michael@0 | 1314 | |
michael@0 | 1315 | // Is the current mUserFontSet valid? |
michael@0 | 1316 | unsigned mUserFontSetDirty : 1; |
michael@0 | 1317 | // Has GetUserFontSet() been called? |
michael@0 | 1318 | unsigned mGetUserFontSetCalled : 1; |
michael@0 | 1319 | // Do we currently have an event posted to call FlushUserFontSet? |
michael@0 | 1320 | unsigned mPostedFlushUserFontSet : 1; |
michael@0 | 1321 | |
michael@0 | 1322 | // resize reflow is suppressed when the only change has been to zoom |
michael@0 | 1323 | // the document rather than to change the document's dimensions |
michael@0 | 1324 | unsigned mSupressResizeReflow : 1; |
michael@0 | 1325 | |
michael@0 | 1326 | unsigned mIsVisual : 1; |
michael@0 | 1327 | |
michael@0 | 1328 | unsigned mProcessingRestyles : 1; |
michael@0 | 1329 | unsigned mProcessingAnimationStyleChange : 1; |
michael@0 | 1330 | |
michael@0 | 1331 | unsigned mFireAfterPaintEvents : 1; |
michael@0 | 1332 | |
michael@0 | 1333 | unsigned mIsChrome : 1; |
michael@0 | 1334 | unsigned mIsChromeOriginImage : 1; |
michael@0 | 1335 | |
michael@0 | 1336 | // Should we paint flash in this context? Do not use this variable directly. |
michael@0 | 1337 | // Use GetPaintFlashing() method instead. |
michael@0 | 1338 | mutable unsigned mPaintFlashing : 1; |
michael@0 | 1339 | mutable unsigned mPaintFlashingInitialized : 1; |
michael@0 | 1340 | |
michael@0 | 1341 | unsigned mHasWarnedAboutPositionedTableParts : 1; |
michael@0 | 1342 | |
michael@0 | 1343 | #ifdef DEBUG |
michael@0 | 1344 | bool mInitialized; |
michael@0 | 1345 | #endif |
michael@0 | 1346 | |
michael@0 | 1347 | |
michael@0 | 1348 | protected: |
michael@0 | 1349 | |
michael@0 | 1350 | virtual ~nsPresContext() NS_HIDDEN; |
michael@0 | 1351 | |
michael@0 | 1352 | // these are private, use the list in nsFont.h if you want a public list |
michael@0 | 1353 | enum { |
michael@0 | 1354 | eDefaultFont_Variable, |
michael@0 | 1355 | eDefaultFont_Fixed, |
michael@0 | 1356 | eDefaultFont_Serif, |
michael@0 | 1357 | eDefaultFont_SansSerif, |
michael@0 | 1358 | eDefaultFont_Monospace, |
michael@0 | 1359 | eDefaultFont_Cursive, |
michael@0 | 1360 | eDefaultFont_Fantasy, |
michael@0 | 1361 | eDefaultFont_COUNT |
michael@0 | 1362 | }; |
michael@0 | 1363 | |
michael@0 | 1364 | nscolor MakeColorPref(const nsString& aColor); |
michael@0 | 1365 | |
michael@0 | 1366 | void LastRelease(); |
michael@0 | 1367 | |
michael@0 | 1368 | #ifdef DEBUG |
michael@0 | 1369 | private: |
michael@0 | 1370 | friend struct nsAutoLayoutPhase; |
michael@0 | 1371 | uint32_t mLayoutPhaseCount[eLayoutPhase_COUNT]; |
michael@0 | 1372 | public: |
michael@0 | 1373 | uint32_t LayoutPhaseCount(nsLayoutPhase aPhase) { |
michael@0 | 1374 | return mLayoutPhaseCount[aPhase]; |
michael@0 | 1375 | } |
michael@0 | 1376 | #endif |
michael@0 | 1377 | |
michael@0 | 1378 | }; |
michael@0 | 1379 | |
michael@0 | 1380 | class nsRootPresContext MOZ_FINAL : public nsPresContext { |
michael@0 | 1381 | public: |
michael@0 | 1382 | nsRootPresContext(nsIDocument* aDocument, nsPresContextType aType) NS_HIDDEN; |
michael@0 | 1383 | virtual ~nsRootPresContext(); |
michael@0 | 1384 | virtual void Detach() MOZ_OVERRIDE; |
michael@0 | 1385 | |
michael@0 | 1386 | /** |
michael@0 | 1387 | * Ensure that NotifyDidPaintForSubtree is eventually called on this |
michael@0 | 1388 | * object after a timeout. |
michael@0 | 1389 | */ |
michael@0 | 1390 | void EnsureEventualDidPaintEvent(); |
michael@0 | 1391 | |
michael@0 | 1392 | void CancelDidPaintTimer() |
michael@0 | 1393 | { |
michael@0 | 1394 | if (mNotifyDidPaintTimer) { |
michael@0 | 1395 | mNotifyDidPaintTimer->Cancel(); |
michael@0 | 1396 | mNotifyDidPaintTimer = nullptr; |
michael@0 | 1397 | } |
michael@0 | 1398 | } |
michael@0 | 1399 | |
michael@0 | 1400 | /** |
michael@0 | 1401 | * Registers a plugin to receive geometry updates (position and clip |
michael@0 | 1402 | * region) so it can update its widget. |
michael@0 | 1403 | * Callers must call UnregisterPluginForGeometryUpdates before |
michael@0 | 1404 | * the aPlugin frame is destroyed. |
michael@0 | 1405 | */ |
michael@0 | 1406 | void RegisterPluginForGeometryUpdates(nsIContent* aPlugin); |
michael@0 | 1407 | /** |
michael@0 | 1408 | * Stops a plugin receiving geometry updates (position and clip |
michael@0 | 1409 | * region). If the plugin was not already registered, this does |
michael@0 | 1410 | * nothing. |
michael@0 | 1411 | */ |
michael@0 | 1412 | void UnregisterPluginForGeometryUpdates(nsIContent* aPlugin); |
michael@0 | 1413 | |
michael@0 | 1414 | bool NeedToComputePluginGeometryUpdates() |
michael@0 | 1415 | { |
michael@0 | 1416 | return mRegisteredPlugins.Count() > 0; |
michael@0 | 1417 | } |
michael@0 | 1418 | /** |
michael@0 | 1419 | * Compute geometry updates for each plugin given that aList is the display |
michael@0 | 1420 | * list for aFrame. The updates are not yet applied; |
michael@0 | 1421 | * ApplyPluginGeometryUpdates is responsible for that. In the meantime they |
michael@0 | 1422 | * are stored on each nsObjectFrame. |
michael@0 | 1423 | * This needs to be called even when aFrame is a popup, since although |
michael@0 | 1424 | * windowed plugins aren't allowed in popups, windowless plugins are |
michael@0 | 1425 | * and ComputePluginGeometryUpdates needs to be called for them. |
michael@0 | 1426 | */ |
michael@0 | 1427 | void ComputePluginGeometryUpdates(nsIFrame* aFrame, |
michael@0 | 1428 | nsDisplayListBuilder* aBuilder, |
michael@0 | 1429 | nsDisplayList* aList); |
michael@0 | 1430 | |
michael@0 | 1431 | /** |
michael@0 | 1432 | * Apply the stored plugin geometry updates. This should normally be called |
michael@0 | 1433 | * in DidPaint so the plugins are moved/clipped immediately after we've |
michael@0 | 1434 | * updated our window, so they look in sync with our window. |
michael@0 | 1435 | */ |
michael@0 | 1436 | void ApplyPluginGeometryUpdates(); |
michael@0 | 1437 | |
michael@0 | 1438 | virtual bool IsRoot() MOZ_OVERRIDE { return true; } |
michael@0 | 1439 | |
michael@0 | 1440 | /** |
michael@0 | 1441 | * Increment DOM-modification generation counter to indicate that |
michael@0 | 1442 | * the DOM has changed in a way that might lead to style changes/ |
michael@0 | 1443 | * reflows/frame creation and destruction. |
michael@0 | 1444 | */ |
michael@0 | 1445 | void IncrementDOMGeneration() { mDOMGeneration++; } |
michael@0 | 1446 | |
michael@0 | 1447 | /** |
michael@0 | 1448 | * Get the current DOM generation counter. |
michael@0 | 1449 | * |
michael@0 | 1450 | * See nsFrameManagerBase::GetGlobalGenerationNumber() for a |
michael@0 | 1451 | * global generation number. |
michael@0 | 1452 | */ |
michael@0 | 1453 | uint32_t GetDOMGeneration() { return mDOMGeneration; } |
michael@0 | 1454 | |
michael@0 | 1455 | /** |
michael@0 | 1456 | * Add a runnable that will get called before the next paint. They will get |
michael@0 | 1457 | * run eventually even if painting doesn't happen. They might run well before |
michael@0 | 1458 | * painting happens. |
michael@0 | 1459 | */ |
michael@0 | 1460 | void AddWillPaintObserver(nsIRunnable* aRunnable); |
michael@0 | 1461 | |
michael@0 | 1462 | /** |
michael@0 | 1463 | * Run all runnables that need to get called before the next paint. |
michael@0 | 1464 | */ |
michael@0 | 1465 | void FlushWillPaintObservers(); |
michael@0 | 1466 | |
michael@0 | 1467 | virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; |
michael@0 | 1468 | |
michael@0 | 1469 | protected: |
michael@0 | 1470 | /** |
michael@0 | 1471 | * Start a timer to ensure we eventually run ApplyPluginGeometryUpdates. |
michael@0 | 1472 | */ |
michael@0 | 1473 | void InitApplyPluginGeometryTimer(); |
michael@0 | 1474 | /** |
michael@0 | 1475 | * Cancel the timer that ensures we eventually run ApplyPluginGeometryUpdates. |
michael@0 | 1476 | */ |
michael@0 | 1477 | void CancelApplyPluginGeometryTimer(); |
michael@0 | 1478 | |
michael@0 | 1479 | class RunWillPaintObservers : public nsRunnable { |
michael@0 | 1480 | public: |
michael@0 | 1481 | RunWillPaintObservers(nsRootPresContext* aPresContext) : mPresContext(aPresContext) {} |
michael@0 | 1482 | void Revoke() { mPresContext = nullptr; } |
michael@0 | 1483 | NS_IMETHOD Run() MOZ_OVERRIDE |
michael@0 | 1484 | { |
michael@0 | 1485 | if (mPresContext) { |
michael@0 | 1486 | mPresContext->FlushWillPaintObservers(); |
michael@0 | 1487 | } |
michael@0 | 1488 | return NS_OK; |
michael@0 | 1489 | } |
michael@0 | 1490 | nsRootPresContext* mPresContext; |
michael@0 | 1491 | }; |
michael@0 | 1492 | |
michael@0 | 1493 | friend class nsPresContext; |
michael@0 | 1494 | |
michael@0 | 1495 | nsCOMPtr<nsITimer> mNotifyDidPaintTimer; |
michael@0 | 1496 | nsCOMPtr<nsITimer> mApplyPluginGeometryTimer; |
michael@0 | 1497 | nsTHashtable<nsRefPtrHashKey<nsIContent> > mRegisteredPlugins; |
michael@0 | 1498 | nsTArray<nsCOMPtr<nsIRunnable> > mWillPaintObservers; |
michael@0 | 1499 | nsRevocableEventPtr<RunWillPaintObservers> mWillPaintFallbackEvent; |
michael@0 | 1500 | uint32_t mDOMGeneration; |
michael@0 | 1501 | }; |
michael@0 | 1502 | |
michael@0 | 1503 | #ifdef MOZ_REFLOW_PERF |
michael@0 | 1504 | |
michael@0 | 1505 | #define DO_GLOBAL_REFLOW_COUNT(_name) \ |
michael@0 | 1506 | aPresContext->CountReflows((_name), (nsIFrame*)this); |
michael@0 | 1507 | #else |
michael@0 | 1508 | #define DO_GLOBAL_REFLOW_COUNT(_name) |
michael@0 | 1509 | #endif // MOZ_REFLOW_PERF |
michael@0 | 1510 | |
michael@0 | 1511 | #endif /* nsPresContext_h___ */ |