LCOV - code coverage report
Current view: directory - layout/base - nsPresContext.h (source / functions) Found Hit Coverage
Test: app.info Lines: 266 1 0.4 %
Date: 2012-06-02 Functions: 140 1 0.7 %

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

Generated by: LCOV version 1.7