2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* a presentation of a document, part 1 */
|
|
|
|
|
|
|
|
#ifndef nsPresContext_h___
|
|
|
|
#define nsPresContext_h___
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-11-20 11:18:25 -08:00
|
|
|
#include "mozilla/WeakPtr.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsColor.h"
|
|
|
|
#include "nsCoord.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsFont.h"
|
2013-09-01 15:21:01 -07:00
|
|
|
#include "gfxFontConstants.h"
|
2013-08-23 10:56:20 -07:00
|
|
|
#include "nsIAtom.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "nsCRT.h"
|
2010-03-28 18:46:55 -07:00
|
|
|
#include "FramePropertyTable.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsGkAtoms.h"
|
2007-08-10 14:25:24 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2008-02-08 11:52:46 -08:00
|
|
|
#include "nsChangeHint.h"
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
2008-07-06 19:28:24 -07:00
|
|
|
// This also pulls in gfxTypes.h, which we cannot include directly.
|
|
|
|
#include "gfxRect.h"
|
2008-11-25 15:22:38 -08:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2013-06-23 05:03:39 -07:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2009-10-02 11:05:32 -07:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2013-09-06 13:15:04 -07:00
|
|
|
#include "mozilla/AppUnits.h"
|
2011-04-21 20:17:31 -07:00
|
|
|
#include "prclist.h"
|
2013-08-14 04:33:03 -07:00
|
|
|
#include "nsThreadUtils.h"
|
2013-08-23 13:20:07 -07:00
|
|
|
#include "ScrollbarStyles.h"
|
2008-09-30 20:01:53 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
class nsBidiPresUtils;
|
|
|
|
#endif // IBMBIDI
|
|
|
|
|
2012-07-29 21:29:41 -07:00
|
|
|
class nsAString;
|
|
|
|
class nsIPrintSettings;
|
2013-11-20 11:18:25 -08:00
|
|
|
class nsDocShell;
|
|
|
|
class nsIDocShell;
|
2012-07-29 21:29:41 -07:00
|
|
|
class nsIDocument;
|
|
|
|
class nsILanguageAtomService;
|
|
|
|
class nsITheme;
|
|
|
|
class nsIContent;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIFrame;
|
|
|
|
class nsFrameManager;
|
|
|
|
class nsILinkHandler;
|
|
|
|
class nsIAtom;
|
|
|
|
class nsICSSPseudoComparator;
|
|
|
|
struct nsStyleBackground;
|
2009-02-19 11:03:28 -08:00
|
|
|
struct nsStyleBorder;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIRunnable;
|
2008-09-30 20:01:53 -07:00
|
|
|
class gfxUserFontSet;
|
2013-11-24 20:59:56 -08:00
|
|
|
class gfxTextPerfMetrics;
|
2009-01-19 01:21:29 -08:00
|
|
|
class nsUserFontSet;
|
2008-11-26 19:50:16 -08:00
|
|
|
struct nsFontFaceRuleContainer;
|
2009-07-21 17:45:00 -07:00
|
|
|
class nsObjectFrame;
|
2009-10-07 20:22:42 -07:00
|
|
|
class nsTransitionManager;
|
2011-04-11 23:18:44 -07:00
|
|
|
class nsAnimationManager;
|
2013-08-14 04:29:51 -07:00
|
|
|
class nsRefreshDriver;
|
2013-08-19 15:55:18 -07:00
|
|
|
class nsIWidget;
|
2013-09-23 04:52:25 -07:00
|
|
|
class nsDeviceContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-20 12:14:24 -07:00
|
|
|
namespace mozilla {
|
2014-03-31 21:09:23 -07:00
|
|
|
class EventStateManager;
|
2013-08-14 04:33:03 -07:00
|
|
|
class RestyleManager;
|
2013-12-16 06:03:34 -08:00
|
|
|
namespace dom {
|
|
|
|
class MediaQueryList;
|
|
|
|
}
|
2013-08-14 04:33:03 -07:00
|
|
|
namespace layers {
|
|
|
|
class ContainerLayer;
|
|
|
|
}
|
2013-07-20 12:14:24 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// supported values for cached bool types
|
|
|
|
enum nsPresContext_CachedBoolPrefType {
|
|
|
|
kPresContext_UseDocumentColors = 1,
|
|
|
|
kPresContext_UseDocumentFonts,
|
|
|
|
kPresContext_UnderlineLinks
|
|
|
|
};
|
|
|
|
|
|
|
|
// supported values for cached integer pref types
|
|
|
|
enum nsPresContext_CachedIntPrefType {
|
2012-01-25 15:52:26 -08:00
|
|
|
kPresContext_ScrollbarSide = 1,
|
2007-03-22 10:30:00 -07:00
|
|
|
kPresContext_BidiDirection
|
|
|
|
};
|
|
|
|
|
|
|
|
// IDs for the default variable and fixed fonts (not to be changed, see nsFont.h)
|
|
|
|
// To be used for Get/SetDefaultFont(). The other IDs in nsFont.h are also supported.
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint8_t kPresContext_DefaultVariableFont_ID = 0x00; // kGenericFont_moz_variable
|
|
|
|
const uint8_t kPresContext_DefaultFixedFont_ID = 0x01; // kGenericFont_moz_fixed
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
struct nsAutoLayoutPhase;
|
|
|
|
|
|
|
|
enum nsLayoutPhase {
|
|
|
|
eLayoutPhase_Paint,
|
|
|
|
eLayoutPhase_Reflow,
|
|
|
|
eLayoutPhase_FrameC,
|
|
|
|
eLayoutPhase_COUNT
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2009-09-03 21:49:18 -07:00
|
|
|
class nsInvalidateRequestList {
|
|
|
|
public:
|
|
|
|
struct Request {
|
|
|
|
nsRect mRect;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mFlags;
|
2009-09-03 21:49:18 -07:00
|
|
|
};
|
|
|
|
|
2012-10-18 21:50:34 -07:00
|
|
|
void TakeFrom(nsInvalidateRequestList* aList)
|
|
|
|
{
|
|
|
|
mRequests.MoveElementsFrom(aList->mRequests);
|
|
|
|
}
|
|
|
|
bool IsEmpty() { return mRequests.IsEmpty(); }
|
|
|
|
|
2009-09-03 21:49:18 -07:00
|
|
|
nsTArray<Request> mRequests;
|
|
|
|
};
|
|
|
|
|
2008-04-25 16:12:45 -07:00
|
|
|
/* Used by nsPresContext::HasAuthorSpecifiedRules */
|
|
|
|
#define NS_AUTHOR_SPECIFIED_BACKGROUND (1 << 0)
|
|
|
|
#define NS_AUTHOR_SPECIFIED_BORDER (1 << 1)
|
|
|
|
#define NS_AUTHOR_SPECIFIED_PADDING (1 << 2)
|
2012-08-04 11:52:21 -07:00
|
|
|
#define NS_AUTHOR_SPECIFIED_TEXT_SHADOW (1 << 3)
|
2008-04-25 16:12:45 -07:00
|
|
|
|
2009-07-21 17:44:54 -07:00
|
|
|
class nsRootPresContext;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// An interface for presentation contexts. Presentation contexts are
|
|
|
|
// objects that provide an outer context for a presentation shell.
|
|
|
|
|
|
|
|
class nsPresContext : public nsIObserver {
|
|
|
|
public:
|
2010-03-28 18:46:55 -07:00
|
|
|
typedef mozilla::FramePropertyTable FramePropertyTable;
|
|
|
|
|
2007-08-10 14:25:24 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
2007-08-10 14:25:24 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(nsPresContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
enum nsPresContextType {
|
|
|
|
eContext_Galley, // unpaginated screen presentation
|
|
|
|
eContext_PrintPreview, // paginated screen presentation
|
|
|
|
eContext_Print, // paginated printer presentation
|
|
|
|
eContext_PageLayout // paginated & editable.
|
|
|
|
};
|
|
|
|
|
2012-11-08 22:40:41 -08:00
|
|
|
// Policies for rebuilding style data.
|
|
|
|
enum StyleRebuildType {
|
|
|
|
eRebuildStyleIfNeeded,
|
|
|
|
eAlwaysRebuildStyle
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsPresContext(nsIDocument* aDocument, nsPresContextType aType) NS_HIDDEN;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the presentation context from a particular device.
|
|
|
|
*/
|
2011-04-16 18:22:44 -07:00
|
|
|
NS_HIDDEN_(nsresult) Init(nsDeviceContext* aDeviceContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the presentation shell that this context is bound to.
|
|
|
|
* A presentation context may only be bound to a single shell.
|
|
|
|
*/
|
|
|
|
NS_HIDDEN_(void) SetShell(nsIPresShell* aShell);
|
|
|
|
|
|
|
|
|
|
|
|
NS_HIDDEN_(nsPresContextType) Type() const { return mType; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the PresentationShell that this context is bound to.
|
|
|
|
*/
|
|
|
|
nsIPresShell* PresShell() const
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mShell, "Null pres shell");
|
|
|
|
return mShell;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIPresShell* GetPresShell() const { return mShell; }
|
|
|
|
|
2012-05-03 22:00:57 -07:00
|
|
|
/**
|
|
|
|
* Returns the parent prescontext for this one. Returns null if this is a
|
|
|
|
* root.
|
|
|
|
*/
|
|
|
|
nsPresContext* GetParentPresContext();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the prescontext of the toplevel content document that contains
|
|
|
|
* this presentation, or null if there isn't one.
|
|
|
|
*/
|
|
|
|
nsPresContext* GetToplevelContentDocumentPresContext();
|
|
|
|
|
2012-09-25 22:47:45 -07:00
|
|
|
/**
|
|
|
|
* Returns the nearest widget for the root frame of this.
|
|
|
|
*
|
|
|
|
* @param aOffset If non-null the offset from the origin of the root
|
|
|
|
* frame's view to the widget's origin (usually positive)
|
|
|
|
* expressed in appunits of this will be returned in
|
|
|
|
* aOffset.
|
|
|
|
*/
|
|
|
|
nsIWidget* GetNearestWidget(nsPoint* aOffset = nullptr);
|
|
|
|
|
2013-02-05 18:50:02 -08:00
|
|
|
/**
|
|
|
|
* Returns the root widget for this.
|
|
|
|
* Note that the widget is a mediater with IME.
|
|
|
|
*/
|
|
|
|
nsIWidget* GetRootWidget();
|
|
|
|
|
2010-01-26 05:10:12 -08:00
|
|
|
/**
|
|
|
|
* Return the presentation context for the root of the view manager
|
2012-07-30 07:20:58 -07:00
|
|
|
* hierarchy that contains this presentation context, or nullptr if it can't
|
2010-01-26 05:10:12 -08:00
|
|
|
* be found (e.g. it's detached).
|
|
|
|
*/
|
|
|
|
nsRootPresContext* GetRootPresContext();
|
2012-07-17 10:03:51 -07:00
|
|
|
nsRootPresContext* GetDisplayRootPresContext();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsRoot() { return false; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsIDocument* Document() const
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mShell || !mShell->GetDocument() ||
|
|
|
|
mShell->GetDocument() == mDocument,
|
|
|
|
"nsPresContext doesn't have the same document as nsPresShell!");
|
|
|
|
return mDocument;
|
|
|
|
}
|
|
|
|
|
2013-03-15 21:31:38 -07:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
|
|
|
nsStyleSet* StyleSet() { return GetPresShell()->StyleSet(); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsFrameManager* FrameManager()
|
2013-07-20 12:14:25 -07:00
|
|
|
{ return PresShell()->FrameManager(); }
|
|
|
|
|
|
|
|
nsCSSFrameConstructor* FrameConstructor()
|
|
|
|
{ return PresShell()->FrameConstructor(); }
|
2009-10-07 20:22:42 -07:00
|
|
|
|
|
|
|
nsTransitionManager* TransitionManager() { return mTransitionManager; }
|
2011-04-11 23:18:44 -07:00
|
|
|
nsAnimationManager* AnimationManager() { return mAnimationManager; }
|
2009-10-07 20:22:42 -07:00
|
|
|
|
2009-12-23 11:10:30 -08:00
|
|
|
nsRefreshDriver* RefreshDriver() { return mRefreshDriver; }
|
2013-07-20 12:14:24 -07:00
|
|
|
|
|
|
|
mozilla::RestyleManager* RestyleManager() { return mRestyleManager; }
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2008-12-04 08:09:53 -08:00
|
|
|
/**
|
|
|
|
* Rebuilds all style data by throwing out the old rule tree and
|
|
|
|
* building a new one, and additionally applying aExtraHint (which
|
|
|
|
* must not contain nsChangeHint_ReconstructFrame) to the root frame.
|
|
|
|
* Also rebuild the user font set.
|
|
|
|
*/
|
2008-02-08 11:52:46 -08:00
|
|
|
void RebuildAllStyleData(nsChangeHint aExtraHint);
|
2008-12-04 08:09:53 -08:00
|
|
|
/**
|
|
|
|
* Just like RebuildAllStyleData, except (1) asynchronous and (2) it
|
|
|
|
* doesn't rebuild the user font set.
|
|
|
|
*/
|
|
|
|
void PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint);
|
2008-01-09 01:38:28 -08:00
|
|
|
|
2012-11-08 22:40:41 -08:00
|
|
|
void MediaFeatureValuesChanged(StyleRebuildType aShouldRebuild,
|
|
|
|
nsChangeHint aChangeHint = nsChangeHint(0));
|
2008-07-26 09:14:48 -07:00
|
|
|
void PostMediaFeatureValuesChangedEvent();
|
|
|
|
NS_HIDDEN_(void) HandleMediaFeatureValuesChangedEvent();
|
|
|
|
void FlushPendingMediaFeatureValuesChanged() {
|
|
|
|
if (mPendingMediaFeatureValuesChanged)
|
2012-11-08 22:40:41 -08:00
|
|
|
MediaFeatureValuesChanged(eRebuildStyleIfNeeded);
|
2008-07-26 09:14:48 -07:00
|
|
|
}
|
|
|
|
|
2011-04-21 20:17:31 -07:00
|
|
|
/**
|
|
|
|
* Support for window.matchMedia()
|
|
|
|
*/
|
2013-12-16 06:03:34 -08:00
|
|
|
already_AddRefed<mozilla::dom::MediaQueryList>
|
2013-10-08 08:51:42 -07:00
|
|
|
MatchMedia(const nsAString& aMediaQueryList);
|
2011-04-21 20:17:31 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Access compatibility mode for this context. This is the same as
|
|
|
|
* our document's compatibility mode.
|
|
|
|
*/
|
2012-07-29 21:29:41 -07:00
|
|
|
nsCompatibility CompatibilityMode() const;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Notify the context that the document's compatibility mode has changed
|
|
|
|
*/
|
|
|
|
NS_HIDDEN_(void) CompatibilityModeChanged();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Access the image animation mode for this context
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t ImageAnimationMode() const { return mImageAnimationMode; }
|
|
|
|
virtual NS_HIDDEN_(void) SetImageAnimationModeExternal(uint16_t aMode);
|
|
|
|
NS_HIDDEN_(void) SetImageAnimationModeInternal(uint16_t aMode);
|
2013-03-15 21:31:38 -07:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetImageAnimationMode(uint16_t aMode)
|
2007-03-22 10:30:00 -07:00
|
|
|
{ SetImageAnimationModeInternal(aMode); }
|
|
|
|
#else
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetImageAnimationMode(uint16_t aMode)
|
2007-03-22 10:30:00 -07:00
|
|
|
{ SetImageAnimationModeExternal(aMode); }
|
|
|
|
#endif
|
|
|
|
|
2014-03-19 23:49:25 -07:00
|
|
|
/**
|
2007-03-22 10:30:00 -07:00
|
|
|
* Get medium of presentation
|
|
|
|
*/
|
2013-07-17 08:39:19 -07:00
|
|
|
nsIAtom* Medium() {
|
|
|
|
if (!mIsEmulatingMedia)
|
|
|
|
return mMedium;
|
|
|
|
return mMediaEmulated;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Render the document as if being viewed on a device with the specified
|
|
|
|
* media type.
|
|
|
|
*/
|
|
|
|
void EmulateMedium(const nsAString& aMediaType);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore the viewer's natural medium
|
|
|
|
*/
|
|
|
|
void StopEmulatingMedium();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void* AllocateFromShell(size_t aSize)
|
|
|
|
{
|
|
|
|
if (mShell)
|
2009-08-17 20:21:06 -07:00
|
|
|
return mShell->AllocateMisc(aSize);
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeToShell(size_t aSize, void* aFreeChunk)
|
|
|
|
{
|
2009-01-29 20:39:23 -08:00
|
|
|
NS_ASSERTION(mShell, "freeing after shutdown");
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mShell)
|
2009-08-17 20:21:06 -07:00
|
|
|
mShell->FreeMisc(aSize, aFreeChunk);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-01-25 15:52:26 -08:00
|
|
|
* Get the default font for the given language and generic font ID.
|
2012-07-30 07:20:58 -07:00
|
|
|
* If aLanguage is nullptr, the document's language is used.
|
2012-01-25 15:52:26 -08:00
|
|
|
*
|
|
|
|
* This object is read-only, you must copy the font to modify it.
|
2014-03-19 23:49:25 -07:00
|
|
|
*
|
2007-07-25 16:12:38 -07:00
|
|
|
* When aFontID is kPresContext_DefaultVariableFontID or
|
|
|
|
* kPresContext_DefaultFixedFontID (which equals
|
|
|
|
* kGenericFont_moz_fixed, which is used for the -moz-fixed generic),
|
|
|
|
* the nsFont returned has its name as a CSS generic family (serif or
|
|
|
|
* sans-serif for the former, monospace for the latter), and its size
|
2012-01-25 15:52:26 -08:00
|
|
|
* as the default font size for variable or fixed fonts for the
|
|
|
|
* language group.
|
2007-07-25 16:12:38 -07:00
|
|
|
*
|
2012-01-25 15:52:26 -08:00
|
|
|
* For aFontID corresponding to a CSS Generic, the nsFont returned has
|
|
|
|
* its name set to that generic font's name, and its size set to
|
|
|
|
* the user's preference for font size for that generic and the
|
|
|
|
* given language.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_HIDDEN_(const nsFont*) GetDefaultFont(uint8_t aFontID,
|
2012-01-25 15:52:26 -08:00
|
|
|
nsIAtom *aLanguage) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** Get a cached boolean pref, by its type */
|
|
|
|
// * - initially created for bugs 31816, 20760, 22963
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetCachedBoolPref(nsPresContext_CachedBoolPrefType aPrefType) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// If called with a constant parameter, the compiler should optimize
|
|
|
|
// this switch statement away.
|
|
|
|
switch (aPrefType) {
|
|
|
|
case kPresContext_UseDocumentFonts:
|
|
|
|
return mUseDocumentFonts;
|
|
|
|
case kPresContext_UseDocumentColors:
|
|
|
|
return mUseDocumentColors;
|
|
|
|
case kPresContext_UnderlineLinks:
|
|
|
|
return mUnderlineLinks;
|
|
|
|
default:
|
|
|
|
NS_ERROR("Invalid arg passed to GetCachedBoolPref");
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Get a cached integer pref, by its type */
|
|
|
|
// * - initially created for bugs 30910, 61883, 74186, 84398
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetCachedIntPref(nsPresContext_CachedIntPrefType aPrefType) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// If called with a constant parameter, the compiler should optimize
|
|
|
|
// this switch statement away.
|
|
|
|
switch (aPrefType) {
|
|
|
|
case kPresContext_ScrollbarSide:
|
|
|
|
return mPrefScrollbarSide;
|
|
|
|
case kPresContext_BidiDirection:
|
|
|
|
return mPrefBidiDirection;
|
|
|
|
default:
|
|
|
|
NS_ERROR("invalid arg passed to GetCachedIntPref");
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:49:25 -07:00
|
|
|
/**
|
2007-03-22 10:30:00 -07:00
|
|
|
* Get the default colors
|
|
|
|
*/
|
|
|
|
const nscolor DefaultColor() const { return mDefaultColor; }
|
|
|
|
const nscolor DefaultBackgroundColor() const { return mBackgroundColor; }
|
|
|
|
const nscolor DefaultLinkColor() const { return mLinkColor; }
|
|
|
|
const nscolor DefaultActiveLinkColor() const { return mActiveLinkColor; }
|
|
|
|
const nscolor DefaultVisitedLinkColor() const { return mVisitedLinkColor; }
|
|
|
|
const nscolor FocusBackgroundColor() const { return mFocusBackgroundColor; }
|
|
|
|
const nscolor FocusTextColor() const { return mFocusTextColor; }
|
|
|
|
|
2011-06-01 04:43:31 -07:00
|
|
|
/**
|
|
|
|
* Body text color, for use in quirks mode only.
|
|
|
|
*/
|
|
|
|
const nscolor BodyTextColor() const { return mBodyTextColor; }
|
|
|
|
void SetBodyTextColor(nscolor aColor) { mBodyTextColor = aColor; }
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetUseFocusColors() const { return mUseFocusColors; }
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t FocusRingWidth() const { return mFocusRingWidth; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetFocusRingOnAnything() const { return mFocusRingOnAnything; }
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t GetFocusRingStyle() const { return mFocusRingStyle; }
|
2008-10-08 16:28:31 -07:00
|
|
|
|
2013-11-20 11:18:25 -08:00
|
|
|
NS_HIDDEN_(void) SetContainer(nsIDocShell* aContainer);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-11-20 11:18:25 -08:00
|
|
|
virtual nsISupports* GetContainerWeakExternal() const;
|
|
|
|
nsISupports* GetContainerWeakInternal() const;
|
2013-03-15 21:31:38 -07:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2013-11-20 11:18:25 -08:00
|
|
|
nsISupports* GetContainerWeak() const
|
|
|
|
{ return GetContainerWeakInternal(); }
|
2007-03-22 10:30:00 -07:00
|
|
|
#else
|
2013-11-20 11:18:25 -08:00
|
|
|
nsISupports* GetContainerWeak() const
|
|
|
|
{ return GetContainerWeakExternal(); }
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2013-11-20 11:18:25 -08:00
|
|
|
nsIDocShell* GetDocShell() const;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// XXX this are going to be replaced with set/get container
|
|
|
|
void SetLinkHandler(nsILinkHandler* aHandler) { mLinkHandler = aHandler; }
|
|
|
|
nsILinkHandler* GetLinkHandler() { return mLinkHandler; }
|
|
|
|
|
2014-02-03 15:47:57 -08:00
|
|
|
/**
|
|
|
|
* Detach this pres context - i.e. cancel relevant timers,
|
|
|
|
* SetLinkHandler(null), SetContainer(null) etc.
|
|
|
|
* Only to be used by the DocumentViewer.
|
|
|
|
*/
|
|
|
|
virtual void Detach();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Get the visible area associated with this presentation context.
|
2008-12-08 16:33:46 -08:00
|
|
|
* This is the size of the visible area that is used for
|
2007-03-22 10:30:00 -07:00
|
|
|
* presenting the document. The returned value is in the standard
|
|
|
|
* nscoord units (as scaled by the device context).
|
|
|
|
*/
|
|
|
|
nsRect GetVisibleArea() { return mVisibleArea; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the currently visible area. The units for r are standard
|
|
|
|
* nscoord units (as scaled by the device context).
|
|
|
|
*/
|
2008-07-26 09:14:48 -07:00
|
|
|
void SetVisibleArea(const nsRect& r) {
|
2011-04-18 20:07:23 -07:00
|
|
|
if (!r.IsEqualEdges(mVisibleArea)) {
|
2008-12-29 07:07:37 -08:00
|
|
|
mVisibleArea = r;
|
|
|
|
// Visible area does not affect media queries when paginated.
|
2012-10-19 16:21:06 -07:00
|
|
|
if (!IsPaginated() && HasCachedStyleData()) {
|
|
|
|
mPendingViewportChange = true;
|
2008-12-29 07:07:37 -08:00
|
|
|
PostMediaFeatureValuesChangedEvent();
|
2012-10-19 16:21:06 -07:00
|
|
|
}
|
2008-12-29 07:07:37 -08:00
|
|
|
}
|
2008-07-26 09:14:48 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if this presentation context is a paginated
|
|
|
|
* context.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsPaginated() const { return mPaginated; }
|
2014-03-19 23:49:25 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Sets whether the presentation context can scroll for a paginated
|
|
|
|
* context.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_HIDDEN_(void) SetPaginatedScrolling(bool aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if this presentation context can scroll for paginated
|
|
|
|
* context.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasPaginatedScrolling() const { return mCanPaginatedScroll; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get/set the size of a page
|
|
|
|
*/
|
|
|
|
nsSize GetPageSize() { return mPageSize; }
|
|
|
|
void SetPageSize(nsSize aSize) { mPageSize = aSize; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get/set whether this document should be treated as having real pages
|
|
|
|
* XXX This raises the obvious question of why a document that isn't a page
|
|
|
|
* is paginated; there isn't a good reason except history
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsRootPaginatedDocument() { return mIsRootPaginatedDocument; }
|
|
|
|
void SetIsRootPaginatedDocument(bool aIsRootPaginatedDocument)
|
2007-03-22 10:30:00 -07:00
|
|
|
{ mIsRootPaginatedDocument = aIsRootPaginatedDocument; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get/set the print scaling level; used by nsPageFrame to scale up
|
|
|
|
* pages. Set safe to call before reflow, get guaranteed to be set
|
|
|
|
* properly after reflow.
|
|
|
|
*/
|
|
|
|
|
|
|
|
float GetPageScale() { return mPageScale; }
|
|
|
|
void SetPageScale(float aScale) { mPageScale = aScale; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get/set the scaling facor to use when rendering the pages for print preview.
|
|
|
|
* Only safe to get after print preview set up; safe to set anytime.
|
|
|
|
* This is a scaling factor for the display of the print preview. It
|
|
|
|
* does not affect layout. It only affects the size of the onscreen pages
|
|
|
|
* in print preview.
|
|
|
|
* XXX Temporary: see http://wiki.mozilla.org/Gecko:PrintPreview
|
|
|
|
*/
|
|
|
|
float GetPrintPreviewScale() { return mPPScale; }
|
|
|
|
void SetPrintPreviewScale(float aScale) { mPPScale = aScale; }
|
|
|
|
|
2011-04-16 18:22:44 -07:00
|
|
|
nsDeviceContext* DeviceContext() { return mDeviceContext; }
|
2014-03-31 21:09:23 -07:00
|
|
|
mozilla::EventStateManager* EventStateManager() { return mEventManager; }
|
2010-02-26 06:20:35 -08:00
|
|
|
nsIAtom* GetLanguageFromCharset() { return mLanguage; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
float TextZoom() { return mTextZoom; }
|
2007-07-25 20:34:16 -07:00
|
|
|
void SetTextZoom(float aZoom) {
|
2009-01-16 13:32:08 -08:00
|
|
|
if (aZoom == mTextZoom)
|
|
|
|
return;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
mTextZoom = aZoom;
|
2009-01-16 13:32:08 -08:00
|
|
|
if (HasCachedStyleData()) {
|
2012-01-25 15:52:26 -08:00
|
|
|
// Media queries could have changed, since we changed the meaning
|
2009-01-16 13:32:08 -08:00
|
|
|
// of 'em' units in them.
|
2012-11-08 22:40:41 -08:00
|
|
|
MediaFeatureValuesChanged(eAlwaysRebuildStyle, NS_STYLE_HINT_REFLOW);
|
2009-01-16 13:32:08 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-07-25 20:34:16 -07:00
|
|
|
|
2012-01-25 15:52:26 -08:00
|
|
|
/**
|
|
|
|
* Get the minimum font size for the specified language. If aLanguage
|
2014-02-25 11:07:47 -08:00
|
|
|
* is nullptr, then the document's language is used. This combines
|
|
|
|
* the language-specific global preference with the per-presentation
|
|
|
|
* base minimum font size.
|
2012-01-25 15:52:26 -08:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t MinFontSize(nsIAtom *aLanguage) const {
|
2012-01-25 15:52:26 -08:00
|
|
|
const LangGroupFontPrefs *prefs = GetFontPrefsForLang(aLanguage);
|
2014-02-25 11:07:47 -08:00
|
|
|
return std::max(mBaseMinFontSize, prefs->mMinimumFontSize);
|
2011-03-10 20:33:43 -08:00
|
|
|
}
|
2014-03-19 23:49:25 -07:00
|
|
|
|
2014-02-25 11:07:47 -08:00
|
|
|
/**
|
|
|
|
* Get the per-presentation base minimum font size. This size is
|
|
|
|
* independent of the language-specific global preference.
|
|
|
|
*/
|
|
|
|
int32_t BaseMinFontSize() const {
|
|
|
|
return mBaseMinFontSize;
|
|
|
|
}
|
2014-03-19 23:49:25 -07:00
|
|
|
|
2014-02-25 11:07:47 -08:00
|
|
|
/**
|
|
|
|
* Set the per-presentation base minimum font size. This size is
|
|
|
|
* independent of the language-specific global preference.
|
|
|
|
*/
|
|
|
|
void SetBaseMinFontSize(int32_t aMinFontSize) {
|
|
|
|
if (aMinFontSize == mBaseMinFontSize)
|
2011-03-10 20:33:43 -08:00
|
|
|
return;
|
|
|
|
|
2014-02-25 11:07:47 -08:00
|
|
|
mBaseMinFontSize = aMinFontSize;
|
2011-03-10 20:33:43 -08:00
|
|
|
if (HasCachedStyleData()) {
|
2012-01-25 15:52:26 -08:00
|
|
|
// Media queries could have changed, since we changed the meaning
|
2011-03-10 20:33:43 -08:00
|
|
|
// of 'em' units in them.
|
2012-11-08 22:40:41 -08:00
|
|
|
MediaFeatureValuesChanged(eAlwaysRebuildStyle, NS_STYLE_HINT_REFLOW);
|
2011-03-10 20:33:43 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-07 13:38:35 -07:00
|
|
|
float GetFullZoom() { return mFullZoom; }
|
2007-07-25 20:34:16 -07:00
|
|
|
void SetFullZoom(float aZoom);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-26 02:47:43 -07:00
|
|
|
nscoord GetAutoQualityMinFontSize() {
|
|
|
|
return DevPixelsToAppUnits(mAutoQualityMinFontSizePixelsPref);
|
|
|
|
}
|
2012-05-05 06:25:45 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the device's screen width in inches, for font size
|
|
|
|
* inflation.
|
|
|
|
*
|
2012-06-11 22:43:31 -07:00
|
|
|
* If |aChanged| is non-null, then aChanged is filled in with whether
|
|
|
|
* the return value has changed since either:
|
|
|
|
* a. the last time the function was called with non-null aChanged, or
|
|
|
|
* b. the first time the function was called.
|
2012-05-05 06:25:45 -07:00
|
|
|
*/
|
2012-07-30 07:20:58 -07:00
|
|
|
float ScreenWidthInchesForFontInflation(bool* aChanged = nullptr);
|
2012-05-05 06:25:45 -07:00
|
|
|
|
2013-09-06 13:15:04 -07:00
|
|
|
static int32_t AppUnitsPerCSSPixel() { return mozilla::AppUnitsPerCSSPixel(); }
|
2013-09-23 04:52:25 -07:00
|
|
|
int32_t AppUnitsPerDevPixel() const;
|
|
|
|
static int32_t AppUnitsPerCSSInch() { return mozilla::AppUnitsPerCSSInch(); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static nscoord CSSPixelsToAppUnits(int32_t aPixels)
|
2013-08-04 19:58:41 -07:00
|
|
|
{ return NSToCoordRoundWithClamp(float(aPixels) *
|
2013-09-06 13:15:04 -07:00
|
|
|
float(AppUnitsPerCSSPixel())); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static nscoord CSSPixelsToAppUnits(float aPixels)
|
2013-08-04 19:58:41 -07:00
|
|
|
{ return NSToCoordRoundWithClamp(aPixels *
|
2013-09-06 13:15:04 -07:00
|
|
|
float(AppUnitsPerCSSPixel())); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t AppUnitsToIntCSSPixels(nscoord aAppUnits)
|
2007-03-22 10:30:00 -07:00
|
|
|
{ return NSAppUnitsToIntPixels(aAppUnits,
|
2013-09-06 13:15:04 -07:00
|
|
|
float(AppUnitsPerCSSPixel())); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static float AppUnitsToFloatCSSPixels(nscoord aAppUnits)
|
|
|
|
{ return NSAppUnitsToFloatPixels(aAppUnits,
|
2013-09-06 13:15:04 -07:00
|
|
|
float(AppUnitsPerCSSPixel())); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nscoord DevPixelsToAppUnits(int32_t aPixels) const
|
2013-09-23 04:52:25 -07:00
|
|
|
{ return NSIntPixelsToAppUnits(aPixels, AppUnitsPerDevPixel()); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t AppUnitsToDevPixels(nscoord aAppUnits) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{ return NSAppUnitsToIntPixels(aAppUnits,
|
2013-09-06 13:15:04 -07:00
|
|
|
float(AppUnitsPerDevPixel())); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t CSSPixelsToDevPixels(int32_t aPixels)
|
2009-06-18 01:35:11 -07:00
|
|
|
{ return AppUnitsToDevPixels(CSSPixelsToAppUnits(aPixels)); }
|
|
|
|
|
|
|
|
float CSSPixelsToDevPixels(float aPixels)
|
|
|
|
{
|
|
|
|
return NSAppUnitsToFloatPixels(CSSPixelsToAppUnits(aPixels),
|
2013-09-23 04:52:25 -07:00
|
|
|
float(AppUnitsPerDevPixel()));
|
2009-06-18 01:35:11 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t DevPixelsToIntCSSPixels(int32_t aPixels)
|
2009-06-18 01:35:11 -07:00
|
|
|
{ return AppUnitsToIntCSSPixels(DevPixelsToAppUnits(aPixels)); }
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
float DevPixelsToFloatCSSPixels(int32_t aPixels)
|
2009-06-18 01:35:11 -07:00
|
|
|
{ return AppUnitsToFloatCSSPixels(DevPixelsToAppUnits(aPixels)); }
|
|
|
|
|
2008-02-16 07:31:27 -08:00
|
|
|
// If there is a remainder, it is rounded to nearest app units.
|
2013-09-23 04:52:25 -07:00
|
|
|
nscoord GfxUnitsToAppUnits(gfxFloat aGfxUnits) const;
|
2008-02-16 07:31:27 -08:00
|
|
|
|
2013-09-23 04:52:25 -07:00
|
|
|
gfxFloat AppUnitsToGfxUnits(nscoord aAppUnits) const;
|
2007-08-22 04:13:46 -07:00
|
|
|
|
2008-07-06 19:28:24 -07:00
|
|
|
gfxRect AppUnitsToGfxUnits(const nsRect& aAppRect) const
|
|
|
|
{ return gfxRect(AppUnitsToGfxUnits(aAppRect.x),
|
|
|
|
AppUnitsToGfxUnits(aAppRect.y),
|
|
|
|
AppUnitsToGfxUnits(aAppRect.width),
|
|
|
|
AppUnitsToGfxUnits(aAppRect.height)); }
|
|
|
|
|
2010-08-13 02:58:04 -07:00
|
|
|
static nscoord CSSTwipsToAppUnits(float aTwips)
|
2010-08-13 02:58:01 -07:00
|
|
|
{ return NSToCoordRoundWithClamp(
|
2013-09-23 04:52:25 -07:00
|
|
|
mozilla::AppUnitsPerCSSInch() * NS_TWIPS_TO_INCHES(aTwips)); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-03-19 13:51:42 -07:00
|
|
|
// Margin-specific version, since they often need TwipsToAppUnits
|
2010-08-13 02:58:04 -07:00
|
|
|
static nsMargin CSSTwipsToAppUnits(const nsIntMargin &marginInTwips)
|
2013-03-06 00:05:55 -08:00
|
|
|
{ return nsMargin(CSSTwipsToAppUnits(float(marginInTwips.top)),
|
2010-08-20 05:45:07 -07:00
|
|
|
CSSTwipsToAppUnits(float(marginInTwips.right)),
|
2013-03-06 00:05:55 -08:00
|
|
|
CSSTwipsToAppUnits(float(marginInTwips.bottom)),
|
|
|
|
CSSTwipsToAppUnits(float(marginInTwips.left))); }
|
2010-08-13 02:58:04 -07:00
|
|
|
|
|
|
|
static nscoord CSSPointsToAppUnits(float aPoints)
|
2013-09-23 04:52:25 -07:00
|
|
|
{ return NSToCoordRound(aPoints * mozilla::AppUnitsPerCSSInch() /
|
2008-04-07 17:27:10 -07:00
|
|
|
POINTS_PER_INCH_FLOAT); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-08-14 09:39:54 -07:00
|
|
|
nscoord RoundAppUnitsToNearestDevPixels(nscoord aAppUnits) const
|
|
|
|
{ return DevPixelsToAppUnits(AppUnitsToDevPixels(aAppUnits)); }
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetViewportOverflowOverride(uint8_t aX, uint8_t aY)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
mViewportStyleOverflow.mHorizontal = aX;
|
|
|
|
mViewportStyleOverflow.mVertical = aY;
|
|
|
|
}
|
2013-08-23 13:20:07 -07:00
|
|
|
mozilla::ScrollbarStyles GetViewportOverflowOverride()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return mViewportStyleOverflow;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set and get methods for controlling the background drawing
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetBackgroundImageDraw() const { return mDrawImageBackground; }
|
|
|
|
void SetBackgroundImageDraw(bool aCanDraw)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
mDrawImageBackground = aCanDraw;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetBackgroundColorDraw() const { return mDrawColorBackground; }
|
|
|
|
void SetBackgroundColorDraw(bool aCanDraw)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
mDrawColorBackground = aCanDraw;
|
|
|
|
}
|
2014-03-19 23:49:25 -07:00
|
|
|
|
2012-12-11 13:12:43 -08:00
|
|
|
/**
|
|
|
|
* Getter and setter for OMTA time counters
|
|
|
|
*/
|
2013-10-22 05:14:41 -07:00
|
|
|
bool ThrottledTransitionStyleIsUpToDate() const;
|
|
|
|
void TickLastUpdateThrottledTransitionStyle();
|
|
|
|
bool ThrottledAnimationStyleIsUpToDate() const;
|
|
|
|
void TickLastUpdateThrottledAnimationStyle();
|
2013-08-14 04:29:51 -07:00
|
|
|
bool StyleUpdateForAllAnimationsIsUpToDate();
|
|
|
|
void TickLastStyleUpdateForAllAnimations();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef IBMBIDI
|
|
|
|
/**
|
|
|
|
* Check if bidi enabled (set depending on the presence of RTL
|
|
|
|
* characters or when default directionality is RTL).
|
|
|
|
* If enabled, we should apply the Unicode Bidi Algorithm
|
|
|
|
*
|
|
|
|
* @lina 07/12/2000
|
|
|
|
*/
|
2013-03-15 21:31:38 -07:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2011-09-28 23:19:26 -07:00
|
|
|
bool BidiEnabled() const { return BidiEnabledInternal(); }
|
2007-03-22 10:30:00 -07:00
|
|
|
#else
|
2011-09-28 23:19:26 -07:00
|
|
|
bool BidiEnabled() const { return BidiEnabledExternal(); }
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2012-07-29 21:29:41 -07:00
|
|
|
virtual bool BidiEnabledExternal() const;
|
|
|
|
bool BidiEnabledInternal() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set bidi enabled. This means we should apply the Unicode Bidi Algorithm
|
|
|
|
*
|
|
|
|
* @lina 07/12/2000
|
|
|
|
*/
|
2008-06-16 02:28:17 -07:00
|
|
|
NS_HIDDEN_(void) SetBidiEnabled() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set visual or implicit mode into the pres context.
|
|
|
|
*
|
|
|
|
* Visual directionality is a presentation method that displays text
|
|
|
|
* as if it were a uni-directional, according to the primary display
|
2014-03-19 23:49:25 -07:00
|
|
|
* direction only.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* Implicit directionality is a presentation method in which the
|
|
|
|
* direction is determined by the Bidi algorithm according to the
|
|
|
|
* category of the characters and the category of the adjacent
|
|
|
|
* characters, and according to their primary direction.
|
|
|
|
*
|
|
|
|
* @lina 05/02/2000
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetVisualMode(bool aIsVisual)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
mIsVisual = aIsVisual;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether the content should be treated as visual.
|
|
|
|
*
|
|
|
|
* @lina 05/02/2000
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsVisualMode() const { return mIsVisual; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//Mohamed
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the Bidi options for the presentation context
|
2014-03-19 23:49:25 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_HIDDEN_(void) SetBidi(uint32_t aBidiOptions,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aForceRestyle = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Bidi options for the presentation context
|
|
|
|
* Not inline so consumers of nsPresContext are not forced to
|
|
|
|
* include nsIDocument.
|
2012-07-29 21:29:41 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_HIDDEN_(uint32_t) GetBidi() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // IBMBIDI
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render only Selection
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetIsRenderingOnlySelection(bool aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
mIsRenderingOnlySelection = aResult;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsRenderingOnlySelection() const { return mIsRenderingOnlySelection; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_HIDDEN_(bool) IsTopLevelWindowInactive();
|
2010-03-17 10:10:57 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* Obtain a native them for rendering our widgets (both form controls and html)
|
|
|
|
*/
|
|
|
|
NS_HIDDEN_(nsITheme*) GetTheme();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Notify the pres context that the theme has changed. An internal switch
|
|
|
|
* means it's one of our Mozilla themes that changed (e.g., Modern to Classic).
|
|
|
|
* Otherwise, the OS is telling us that the native theme for the platform
|
|
|
|
* has changed.
|
|
|
|
*/
|
|
|
|
NS_HIDDEN_(void) ThemeChanged();
|
|
|
|
|
2012-10-16 12:41:20 -07:00
|
|
|
/*
|
|
|
|
* Notify the pres context that the resolution of the user interface has
|
|
|
|
* changed. This happens if a window is moved between HiDPI and non-HiDPI
|
|
|
|
* displays, so that the ratio of points to device pixels changes.
|
|
|
|
*/
|
|
|
|
NS_HIDDEN_(void) UIResolutionChanged();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* Notify the pres context that a system color has changed
|
|
|
|
*/
|
|
|
|
NS_HIDDEN_(void) SysColorChanged();
|
|
|
|
|
|
|
|
/** Printing methods below should only be used for Medium() == print **/
|
|
|
|
NS_HIDDEN_(void) SetPrintSettings(nsIPrintSettings *aPrintSettings);
|
|
|
|
|
|
|
|
nsIPrintSettings* GetPrintSettings() { return mPrintSettings; }
|
|
|
|
|
|
|
|
/* Accessor for table of frame properties */
|
2010-03-28 18:46:55 -07:00
|
|
|
FramePropertyTable* PropertyTable() { return &mPropertyTable; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* Helper function that ensures that this prescontext is shown in its
|
|
|
|
docshell if it's the most recent prescontext for the docshell. Returns
|
|
|
|
whether the prescontext is now being shown.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_HIDDEN_(bool) EnsureVisible();
|
2014-03-19 23:49:25 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef MOZ_REFLOW_PERF
|
|
|
|
NS_HIDDEN_(void) CountReflows(const char * aName,
|
|
|
|
nsIFrame * aFrame);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This table maps border-width enums 'thin', 'medium', 'thick'
|
|
|
|
* to actual nscoord values.
|
|
|
|
*/
|
|
|
|
const nscoord* GetBorderWidthTable() { return mBorderWidthTable; }
|
|
|
|
|
2013-11-24 20:59:56 -08:00
|
|
|
gfxTextPerfMetrics *GetTextPerfMetrics() { return mTextPerf; }
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsDynamic() { return (mType == eContext_PageLayout || mType == eContext_Galley); }
|
|
|
|
bool IsScreen() { return (mMedium == nsGkAtoms::screen ||
|
2007-03-22 10:30:00 -07:00
|
|
|
mType == eContext_PageLayout ||
|
2007-04-23 07:21:53 -07:00
|
|
|
mType == eContext_PrintPreview); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-05-16 14:10:31 -07:00
|
|
|
// Is this presentation in a chrome docshell?
|
2014-02-06 19:08:49 -08:00
|
|
|
bool IsChrome() const { return mIsChrome; }
|
2014-03-06 20:02:59 -08:00
|
|
|
bool IsChromeOriginImage() const { return mIsChromeOriginImage; }
|
2014-02-06 19:08:49 -08:00
|
|
|
void UpdateIsChrome();
|
2007-05-16 14:10:31 -07:00
|
|
|
|
2007-10-08 16:11:01 -07:00
|
|
|
// Public API for native theme code to get style internals.
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool HasAuthorSpecifiedRules(nsIFrame *aFrame, uint32_t ruleTypeMask) const;
|
2007-10-08 16:11:01 -07:00
|
|
|
|
2007-11-15 19:46:42 -08:00
|
|
|
// Is it OK to let the page specify colors and backgrounds?
|
2011-09-28 23:19:26 -07:00
|
|
|
bool UseDocumentColors() const {
|
2014-03-06 20:02:59 -08:00
|
|
|
return GetCachedBoolPref(kPresContext_UseDocumentColors) || IsChrome() || IsChromeOriginImage();
|
2007-11-15 19:46:42 -08:00
|
|
|
}
|
|
|
|
|
2013-07-22 08:51:38 -07:00
|
|
|
// Explicitly enable and disable paint flashing.
|
|
|
|
void SetPaintFlashing(bool aPaintFlashing) {
|
|
|
|
mPaintFlashing = aPaintFlashing;
|
|
|
|
mPaintFlashingInitialized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method should be used instead of directly accessing mPaintFlashing,
|
|
|
|
// as that value may be out of date when mPaintFlashingInitialized is false.
|
|
|
|
bool GetPaintFlashing() const;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool SupressingResizeReflow() const { return mSupressResizeReflow; }
|
2014-03-19 23:49:25 -07:00
|
|
|
|
2008-12-04 08:09:53 -08:00
|
|
|
virtual NS_HIDDEN_(gfxUserFontSet*) GetUserFontSetExternal();
|
|
|
|
NS_HIDDEN_(gfxUserFontSet*) GetUserFontSetInternal();
|
2013-03-15 21:31:38 -07:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2008-12-04 08:09:53 -08:00
|
|
|
gfxUserFontSet* GetUserFontSet() { return GetUserFontSetInternal(); }
|
|
|
|
#else
|
|
|
|
gfxUserFontSet* GetUserFontSet() { return GetUserFontSetExternal(); }
|
|
|
|
#endif
|
|
|
|
|
2008-11-25 15:22:38 -08:00
|
|
|
void FlushUserFontSet();
|
|
|
|
void RebuildUserFontSet(); // asynchronously
|
2008-01-28 20:10:59 -08:00
|
|
|
|
2008-12-08 08:08:05 -08:00
|
|
|
// Should be called whenever the set of fonts available in the user
|
|
|
|
// font set changes (e.g., because a new font loads, or because the
|
|
|
|
// user font set is changed and fonts become unavailable).
|
|
|
|
void UserFontSetUpdated();
|
|
|
|
|
2009-12-31 07:56:33 -08:00
|
|
|
// Ensure that it is safe to hand out CSS rules outside the layout
|
|
|
|
// engine by ensuring that all CSS style sheets have unique inners
|
|
|
|
// and, if necessary, synchronously rebuilding all style data.
|
2013-11-11 00:00:33 -08:00
|
|
|
void EnsureSafeToHandOutCSSRules();
|
2009-12-31 07:56:33 -08:00
|
|
|
|
2012-08-28 22:48:44 -07:00
|
|
|
void NotifyInvalidation(uint32_t aFlags);
|
2012-08-22 08:56:38 -07:00
|
|
|
void NotifyInvalidation(const nsRect& aRect, uint32_t aFlags);
|
2012-08-28 22:47:18 -07:00
|
|
|
// aRect is in device pixels
|
|
|
|
void NotifyInvalidation(const nsIntRect& aRect, uint32_t aFlags);
|
2012-10-18 21:50:34 -07:00
|
|
|
// aFlags are nsIPresShell::PAINT_ flags
|
|
|
|
void NotifyDidPaintForSubtree(uint32_t aFlags);
|
|
|
|
void FireDOMPaintEvent(nsInvalidateRequestList* aList);
|
2011-01-15 01:40:33 -08:00
|
|
|
|
2012-08-28 22:47:18 -07:00
|
|
|
// Callback for catching invalidations in ContainerLayers
|
|
|
|
// Passed to LayerProperties::ComputeDifference
|
|
|
|
static void NotifySubDocInvalidation(mozilla::layers::ContainerLayer* aContainer,
|
|
|
|
const nsIntRegion& aRegion);
|
2013-08-14 04:33:03 -07:00
|
|
|
void SetNotifySubDocInvalidationData(mozilla::layers::ContainerLayer* aContainer);
|
|
|
|
static void ClearNotifySubDocInvalidationData(mozilla::layers::ContainerLayer* aContainer);
|
2012-08-28 22:47:18 -07:00
|
|
|
bool IsDOMPaintEventPending();
|
2009-02-26 16:21:55 -08:00
|
|
|
void ClearMozAfterPaintEvents() {
|
2012-10-18 21:50:34 -07:00
|
|
|
mInvalidateRequestsSinceLastPaint.mRequests.Clear();
|
|
|
|
mUndeliveredInvalidateRequestsBeforeLastPaint.mRequests.Clear();
|
2012-08-28 22:48:44 -07:00
|
|
|
mAllInvalidated = false;
|
2009-02-26 16:21:55 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsProcessingRestyles() const {
|
2010-03-01 11:31:45 -08:00
|
|
|
return mProcessingRestyles;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetProcessingRestyles(bool aProcessing) {
|
|
|
|
NS_ASSERTION(aProcessing != bool(mProcessingRestyles),
|
2010-03-01 11:31:45 -08:00
|
|
|
"should never nest");
|
|
|
|
mProcessingRestyles = aProcessing;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsProcessingAnimationStyleChange() const {
|
2009-09-11 03:46:36 -07:00
|
|
|
return mProcessingAnimationStyleChange;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetProcessingAnimationStyleChange(bool aProcessing) {
|
|
|
|
NS_ASSERTION(aProcessing != bool(mProcessingAnimationStyleChange),
|
2009-09-11 03:46:36 -07:00
|
|
|
"should never nest");
|
|
|
|
mProcessingAnimationStyleChange = aProcessing;
|
|
|
|
}
|
|
|
|
|
2009-04-21 16:53:52 -07:00
|
|
|
/**
|
|
|
|
* Notify the prescontext that the presshell is about to reflow a reflow root.
|
|
|
|
* The single argument indicates whether this reflow should be interruptible.
|
|
|
|
* If aInterruptible is false then CheckForInterrupt and HasPendingInterrupt
|
|
|
|
* will always return false. If aInterruptible is true then CheckForInterrupt
|
|
|
|
* will return true when a pending event is detected. This is for use by the
|
|
|
|
* presshell only. Reflow code wanting to prevent interrupts should use
|
|
|
|
* InterruptPreventer.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void ReflowStarted(bool aInterruptible);
|
2009-04-21 16:53:52 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A class that can be used to temporarily disable reflow interruption.
|
|
|
|
*/
|
|
|
|
class InterruptPreventer;
|
|
|
|
friend class InterruptPreventer;
|
2013-04-11 20:20:45 -07:00
|
|
|
class MOZ_STACK_CLASS InterruptPreventer {
|
2009-04-21 16:53:52 -07:00
|
|
|
public:
|
|
|
|
InterruptPreventer(nsPresContext* aCtx) :
|
|
|
|
mCtx(aCtx),
|
|
|
|
mInterruptsEnabled(aCtx->mInterruptsEnabled),
|
|
|
|
mHasPendingInterrupt(aCtx->mHasPendingInterrupt)
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
mCtx->mInterruptsEnabled = false;
|
|
|
|
mCtx->mHasPendingInterrupt = false;
|
2009-04-21 16:53:52 -07:00
|
|
|
}
|
|
|
|
~InterruptPreventer() {
|
|
|
|
mCtx->mInterruptsEnabled = mInterruptsEnabled;
|
|
|
|
mCtx->mHasPendingInterrupt = mHasPendingInterrupt;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsPresContext* mCtx;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mInterruptsEnabled;
|
|
|
|
bool mHasPendingInterrupt;
|
2009-04-21 16:53:52 -07:00
|
|
|
};
|
2014-03-19 23:49:25 -07:00
|
|
|
|
2009-04-21 16:53:52 -07:00
|
|
|
/**
|
|
|
|
* Check for interrupts. This may return true if a pending event is
|
2009-06-12 18:28:41 -07:00
|
|
|
* detected. Once it has returned true, it will keep returning true
|
|
|
|
* until ReflowStarted is called. In all cases where this returns true,
|
|
|
|
* the passed-in frame (which should be the frame whose reflow will be
|
|
|
|
* interrupted if true is returned) will be passed to
|
2009-04-21 16:53:52 -07:00
|
|
|
* nsIPresShell::FrameNeedsToContinueReflow.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool CheckForInterrupt(nsIFrame* aFrame);
|
2009-04-21 16:53:52 -07:00
|
|
|
/**
|
|
|
|
* Returns true if CheckForInterrupt has returned true since the last
|
2009-06-12 18:28:41 -07:00
|
|
|
* ReflowStarted call. Cannot itself trigger an interrupt check.
|
2009-04-21 16:53:52 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasPendingInterrupt() { return mHasPendingInterrupt; }
|
2009-04-21 16:53:52 -07:00
|
|
|
|
2009-12-24 13:20:05 -08:00
|
|
|
/**
|
|
|
|
* If we have a presshell, and if the given content's current
|
|
|
|
* document is the same as our presshell's document, return the
|
|
|
|
* content's primary frame. Otherwise, return null. Only use this
|
|
|
|
* if you care about which presshell the primary frame is in.
|
|
|
|
*/
|
2012-07-29 21:29:41 -07:00
|
|
|
nsIFrame* GetPrimaryFrameFor(nsIContent* aContent);
|
2009-12-24 13:20:05 -08:00
|
|
|
|
2010-07-15 14:08:08 -07:00
|
|
|
void NotifyDestroyingFrame(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
PropertyTable()->DeleteAllFor(aFrame);
|
|
|
|
}
|
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
|
|
|
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
|
2012-01-25 00:52:51 -08:00
|
|
|
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
2010-05-31 19:19:35 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsRootContentDocument();
|
2012-09-05 09:23:45 -07:00
|
|
|
bool IsCrossProcessRootContentDocument();
|
2010-09-11 11:24:50 -07:00
|
|
|
|
2012-09-05 21:58:44 -07:00
|
|
|
bool IsGlyph() const {
|
|
|
|
return mIsGlyph;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetIsGlyph(bool aValue) {
|
|
|
|
mIsGlyph = aValue;
|
|
|
|
}
|
|
|
|
|
2012-10-26 10:04:20 -07:00
|
|
|
bool UsesRootEMUnits() const {
|
|
|
|
return mUsesRootEMUnits;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetUsesRootEMUnits(bool aValue) {
|
|
|
|
mUsesRootEMUnits = aValue;
|
|
|
|
}
|
|
|
|
|
2012-10-19 16:21:06 -07:00
|
|
|
bool UsesViewportUnits() const {
|
|
|
|
return mUsesViewportUnits;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetUsesViewportUnits(bool aValue) {
|
|
|
|
mUsesViewportUnits = aValue;
|
|
|
|
}
|
|
|
|
|
2012-12-11 13:12:43 -08:00
|
|
|
// true if there are OMTA transition updates for the current document which
|
|
|
|
// have been throttled, and therefore some style information may not be up
|
|
|
|
// to date
|
|
|
|
bool ExistThrottledUpdates() const {
|
|
|
|
return mExistThrottledUpdates;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetExistThrottledUpdates(bool aExistThrottledUpdates) {
|
|
|
|
mExistThrottledUpdates = aExistThrottledUpdates;
|
|
|
|
}
|
|
|
|
|
2013-11-07 05:40:23 -08:00
|
|
|
bool IsDeviceSizePageSize();
|
|
|
|
|
2014-03-10 15:41:17 -07:00
|
|
|
bool HasWarnedAboutPositionedTableParts() const {
|
|
|
|
return mHasWarnedAboutPositionedTableParts;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetHasWarnedAboutPositionedTableParts() {
|
|
|
|
mHasWarnedAboutPositionedTableParts = true;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
friend class nsRunnableMethod<nsPresContext>;
|
|
|
|
NS_HIDDEN_(void) ThemeChangedInternal();
|
|
|
|
NS_HIDDEN_(void) SysColorChangedInternal();
|
2012-10-16 12:41:20 -07:00
|
|
|
NS_HIDDEN_(void) UIResolutionChangedInternal();
|
|
|
|
|
|
|
|
static NS_HIDDEN_(bool)
|
|
|
|
UIResolutionChangedSubdocumentCallback(nsIDocument* aDocument, void* aData);
|
2008-11-25 15:22:38 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_HIDDEN_(void) SetImgAnimations(nsIContent *aParent, uint16_t aMode);
|
|
|
|
NS_HIDDEN_(void) SetSMILAnimations(nsIDocument *aDoc, uint16_t aNewMode,
|
|
|
|
uint16_t aOldMode);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_HIDDEN_(void) GetDocumentColorPreferences();
|
|
|
|
|
|
|
|
NS_HIDDEN_(void) PreferenceChanged(const char* aPrefName);
|
2013-12-10 15:10:01 -08:00
|
|
|
static NS_HIDDEN_(void) PrefChangedCallback(const char*, void*);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_HIDDEN_(void) UpdateAfterPreferencesChanged();
|
2008-10-10 08:04:34 -07:00
|
|
|
static NS_HIDDEN_(void) PrefChangedUpdateTimerCallback(nsITimer *aTimer, void *aClosure);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_HIDDEN_(void) GetUserPreferences();
|
2012-01-25 15:52:26 -08:00
|
|
|
|
|
|
|
// Allow nsAutoPtr<LangGroupFontPrefs> dtor to access this protected struct's
|
|
|
|
// dtor:
|
|
|
|
struct LangGroupFontPrefs;
|
|
|
|
friend class nsAutoPtr<LangGroupFontPrefs>;
|
|
|
|
struct LangGroupFontPrefs {
|
|
|
|
// Font sizes default to zero; they will be set in GetFontPreferences
|
|
|
|
LangGroupFontPrefs()
|
2012-07-30 07:20:58 -07:00
|
|
|
: mLangGroup(nullptr)
|
2012-01-25 15:52:26 -08:00
|
|
|
, mMinimumFontSize(0)
|
|
|
|
, mDefaultVariableFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
|
|
|
NS_FONT_WEIGHT_NORMAL, NS_FONT_STRETCH_NORMAL, 0, 0)
|
|
|
|
, mDefaultFixedFont("monospace", NS_FONT_STYLE_NORMAL,
|
|
|
|
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL,
|
|
|
|
NS_FONT_STRETCH_NORMAL, 0, 0)
|
|
|
|
, mDefaultSerifFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
|
|
|
NS_FONT_WEIGHT_NORMAL, NS_FONT_STRETCH_NORMAL, 0, 0)
|
|
|
|
, mDefaultSansSerifFont("sans-serif", NS_FONT_STYLE_NORMAL,
|
|
|
|
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL,
|
|
|
|
NS_FONT_STRETCH_NORMAL, 0, 0)
|
|
|
|
, mDefaultMonospaceFont("monospace", NS_FONT_STYLE_NORMAL,
|
|
|
|
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL,
|
|
|
|
NS_FONT_STRETCH_NORMAL, 0, 0)
|
|
|
|
, mDefaultCursiveFont("cursive", NS_FONT_STYLE_NORMAL,
|
|
|
|
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL,
|
|
|
|
NS_FONT_STRETCH_NORMAL, 0, 0)
|
|
|
|
, mDefaultFantasyFont("fantasy", NS_FONT_STYLE_NORMAL,
|
|
|
|
NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL,
|
|
|
|
NS_FONT_STRETCH_NORMAL, 0, 0)
|
|
|
|
{}
|
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
|
2012-02-20 21:02:24 -08:00
|
|
|
size_t n = 0;
|
|
|
|
LangGroupFontPrefs *curr = mNext;
|
|
|
|
while (curr) {
|
|
|
|
n += aMallocSizeOf(curr);
|
|
|
|
|
|
|
|
// Measurement of the following members may be added later if DMD finds
|
|
|
|
// it is worthwhile:
|
|
|
|
// - mLangGroup
|
|
|
|
// - mDefault*Font
|
|
|
|
|
|
|
|
curr = curr->mNext;
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2012-01-25 15:52:26 -08:00
|
|
|
nsCOMPtr<nsIAtom> mLangGroup;
|
|
|
|
nscoord mMinimumFontSize;
|
|
|
|
nsFont mDefaultVariableFont;
|
|
|
|
nsFont mDefaultFixedFont;
|
|
|
|
nsFont mDefaultSerifFont;
|
|
|
|
nsFont mDefaultSansSerifFont;
|
|
|
|
nsFont mDefaultMonospaceFont;
|
|
|
|
nsFont mDefaultCursiveFont;
|
|
|
|
nsFont mDefaultFantasyFont;
|
|
|
|
nsAutoPtr<LangGroupFontPrefs> mNext;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetch the user's font preferences for the given aLanguage's
|
|
|
|
* langugage group.
|
|
|
|
*/
|
|
|
|
const LangGroupFontPrefs* GetFontPrefsForLang(nsIAtom *aLanguage) const;
|
|
|
|
|
|
|
|
void ResetCachedFontPrefs() {
|
|
|
|
// Throw away any other LangGroupFontPrefs objects:
|
2012-07-30 07:20:58 -07:00
|
|
|
mLangGroupFontPrefs.mNext = nullptr;
|
2012-01-25 15:52:26 -08:00
|
|
|
|
|
|
|
// Make GetFontPreferences reinitialize mLangGroupFontPrefs:
|
2012-07-30 07:20:58 -07:00
|
|
|
mLangGroupFontPrefs.mLangGroup = nullptr;
|
2012-01-25 15:52:26 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-11 12:58:44 -08:00
|
|
|
NS_HIDDEN_(void) UpdateCharSet(const nsCString& aCharSet);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-11 12:58:44 -08:00
|
|
|
public:
|
|
|
|
void DoChangeCharSet(const nsCString& aCharSet);
|
|
|
|
|
2012-08-28 22:47:18 -07:00
|
|
|
/**
|
|
|
|
* Checks for MozAfterPaint listeners on the document
|
|
|
|
*/
|
|
|
|
bool MayHavePaintEventListener();
|
|
|
|
|
|
|
|
/**
|
2014-03-19 23:49:25 -07:00
|
|
|
* Checks for MozAfterPaint listeners on the document and
|
2012-08-28 22:47:18 -07:00
|
|
|
* any subdocuments, except for subdocuments that are non-top-level
|
|
|
|
* content documents.
|
|
|
|
*/
|
|
|
|
bool MayHavePaintEventListenerInSubDocument();
|
|
|
|
|
2012-01-11 12:58:44 -08:00
|
|
|
protected:
|
2011-06-09 00:13:05 -07:00
|
|
|
void InvalidateThebesLayers();
|
2011-04-11 13:57:29 -07:00
|
|
|
void AppUnitsPerDevPixelChanged();
|
|
|
|
|
2008-11-25 15:22:38 -08:00
|
|
|
void HandleRebuildUserFontSet() {
|
2011-10-17 07:59:28 -07:00
|
|
|
mPostedFlushUserFontSet = false;
|
2008-11-25 15:22:38 -08:00
|
|
|
FlushUserFontSet();
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HavePendingInputEvent();
|
2009-04-21 16:53:52 -07:00
|
|
|
|
2008-12-29 07:07:36 -08:00
|
|
|
// Can't be inline because we can't include nsStyleSet.h.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasCachedStyleData();
|
2008-12-29 07:07:36 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsChromeSlow() const;
|
2010-04-10 11:03:40 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// IMPORTANT: The ownership implicit in the following member variables
|
|
|
|
// has been explicitly checked. If you add any members to this class,
|
|
|
|
// please make the ownership explicit (pinkerton, scc).
|
2012-07-29 21:29:33 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsPresContextType mType;
|
|
|
|
nsIPresShell* mShell; // [WEAK]
|
|
|
|
nsCOMPtr<nsIDocument> mDocument;
|
2012-07-29 21:36:32 -07:00
|
|
|
nsRefPtr<nsDeviceContext> mDeviceContext; // [STRONG] could be weak, but
|
|
|
|
// better safe than sorry.
|
|
|
|
// Cannot reintroduce cycles
|
|
|
|
// since there is no dependency
|
|
|
|
// from gfx back to layout.
|
2014-03-31 21:09:23 -07:00
|
|
|
nsRefPtr<mozilla::EventStateManager> mEventManager;
|
2009-12-23 11:10:30 -08:00
|
|
|
nsRefPtr<nsRefreshDriver> mRefreshDriver;
|
2009-12-23 11:10:31 -08:00
|
|
|
nsRefPtr<nsTransitionManager> mTransitionManager;
|
2011-04-11 23:18:44 -07:00
|
|
|
nsRefPtr<nsAnimationManager> mAnimationManager;
|
2013-07-20 12:14:24 -07:00
|
|
|
nsRefPtr<mozilla::RestyleManager> mRestyleManager;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* mMedium; // initialized by subclass ctors;
|
|
|
|
// weak pointer to static atom
|
2013-07-17 08:39:19 -07:00
|
|
|
nsCOMPtr<nsIAtom> mMediaEmulated;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsILinkHandler* mLinkHandler; // [WEAK]
|
2010-02-24 09:57:44 -08:00
|
|
|
|
|
|
|
// Formerly mLangGroup; moving from charset-oriented langGroup to
|
|
|
|
// maintaining actual language settings everywhere (see bug 524107).
|
|
|
|
// This may in fact hold a langGroup such as x-western rather than
|
|
|
|
// a specific language, however (e.g, if it is inferred from the
|
|
|
|
// charset rather than explicitly specified as a lang attribute).
|
2012-07-29 21:29:23 -07:00
|
|
|
nsCOMPtr<nsIAtom> mLanguage;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-24 17:21:28 -08:00
|
|
|
public:
|
|
|
|
// The following are public member variables so that we can use them
|
|
|
|
// with mozilla::AutoToggle or mozilla::AutoRestore.
|
|
|
|
|
2012-05-20 22:18:27 -07:00
|
|
|
// Should we disable font size inflation because we're inside of
|
|
|
|
// shrink-wrapping calculations on an inflation container?
|
|
|
|
bool mInflationDisabledForShrinkWrap;
|
|
|
|
|
2012-01-24 17:21:28 -08:00
|
|
|
protected:
|
2012-04-07 10:36:49 -07:00
|
|
|
|
2013-11-20 11:18:25 -08:00
|
|
|
mozilla::WeakPtr<nsDocShell> mContainer;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-21 20:17:31 -07:00
|
|
|
PRCList mDOMMediaQueryLists;
|
|
|
|
|
2014-02-25 11:07:47 -08:00
|
|
|
// Base minimum font size, independent of the language-specific global preference. Defaults to 0
|
|
|
|
int32_t mBaseMinFontSize;
|
2007-03-22 10:30:00 -07:00
|
|
|
float mTextZoom; // Text zoom, defaults to 1.0
|
2007-08-07 13:38:35 -07:00
|
|
|
float mFullZoom; // Page zoom, defaults to 1.0
|
2008-01-28 20:10:59 -08:00
|
|
|
|
2012-05-05 06:25:45 -07:00
|
|
|
float mLastFontInflationScreenWidth;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mCurAppUnitsPerDevPixel;
|
|
|
|
int32_t mAutoQualityMinFontSizePixelsPref;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsITheme> mTheme;
|
|
|
|
nsCOMPtr<nsILanguageAtomService> mLangService;
|
|
|
|
nsCOMPtr<nsIPrintSettings> mPrintSettings;
|
|
|
|
nsCOMPtr<nsITimer> mPrefChangedTimer;
|
|
|
|
|
2010-03-28 18:46:55 -07:00
|
|
|
FramePropertyTable mPropertyTable;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-10-18 21:50:34 -07:00
|
|
|
nsInvalidateRequestList mInvalidateRequestsSinceLastPaint;
|
|
|
|
nsInvalidateRequestList mUndeliveredInvalidateRequestsBeforeLastPaint;
|
2008-09-18 02:47:21 -07:00
|
|
|
|
2008-09-30 20:01:53 -07:00
|
|
|
// container for per-context fonts (downloadable, SVG, etc.)
|
2009-01-19 01:21:29 -08:00
|
|
|
nsUserFontSet* mUserFontSet;
|
2012-07-29 21:36:32 -07:00
|
|
|
|
2013-11-24 20:59:56 -08:00
|
|
|
// text performance metrics
|
|
|
|
nsAutoPtr<gfxTextPerfMetrics> mTextPerf;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRect mVisibleArea;
|
|
|
|
nsSize mPageSize;
|
|
|
|
float mPageScale;
|
|
|
|
float mPPScale;
|
|
|
|
|
|
|
|
nscolor mDefaultColor;
|
|
|
|
nscolor mBackgroundColor;
|
|
|
|
|
|
|
|
nscolor mLinkColor;
|
|
|
|
nscolor mActiveLinkColor;
|
|
|
|
nscolor mVisitedLinkColor;
|
|
|
|
|
|
|
|
nscolor mFocusBackgroundColor;
|
|
|
|
nscolor mFocusTextColor;
|
|
|
|
|
2011-06-01 04:43:31 -07:00
|
|
|
nscolor mBodyTextColor;
|
|
|
|
|
2013-08-23 13:20:07 -07:00
|
|
|
mozilla::ScrollbarStyles mViewportStyleOverflow;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mFocusRingWidth;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-12-11 13:12:43 -08:00
|
|
|
bool mExistThrottledUpdates;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t mImageAnimationMode;
|
|
|
|
uint16_t mImageAnimationModePref;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-25 15:52:26 -08:00
|
|
|
LangGroupFontPrefs mLangGroupFontPrefs;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nscoord mBorderWidthTable[3];
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mInterruptChecksToSkip;
|
2009-04-21 16:53:52 -07:00
|
|
|
|
2009-10-02 11:05:32 -07:00
|
|
|
mozilla::TimeStamp mReflowStartTime;
|
|
|
|
|
2013-10-22 05:14:41 -07:00
|
|
|
// last time animations styles were flushed to their primary frames
|
|
|
|
mozilla::TimeStamp mLastUpdateThrottledAnimationStyle;
|
|
|
|
// last time transition styles were flushed to their primary frames
|
|
|
|
mozilla::TimeStamp mLastUpdateThrottledTransitionStyle;
|
2012-12-11 13:12:43 -08:00
|
|
|
// last time we did a full style flush
|
|
|
|
mozilla::TimeStamp mLastStyleUpdateForAllAnimations;
|
|
|
|
|
2009-04-21 16:53:52 -07:00
|
|
|
unsigned mHasPendingInterrupt : 1;
|
|
|
|
unsigned mInterruptsEnabled : 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
unsigned mUseDocumentFonts : 1;
|
|
|
|
unsigned mUseDocumentColors : 1;
|
|
|
|
unsigned mUnderlineLinks : 1;
|
2011-01-24 16:23:08 -08:00
|
|
|
unsigned mSendAfterPaintToContent : 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
unsigned mUseFocusColors : 1;
|
|
|
|
unsigned mFocusRingOnAnything : 1;
|
2008-10-08 16:28:31 -07:00
|
|
|
unsigned mFocusRingStyle : 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
unsigned mDrawImageBackground : 1;
|
|
|
|
unsigned mDrawColorBackground : 1;
|
|
|
|
unsigned mNeverAnimate : 1;
|
|
|
|
unsigned mIsRenderingOnlySelection : 1;
|
|
|
|
unsigned mPaginated : 1;
|
|
|
|
unsigned mCanPaginatedScroll : 1;
|
|
|
|
unsigned mDoScaledTwips : 1;
|
|
|
|
unsigned mIsRootPaginatedDocument : 1;
|
|
|
|
unsigned mPrefBidiDirection : 1;
|
|
|
|
unsigned mPrefScrollbarSide : 2;
|
|
|
|
unsigned mPendingSysColorChanged : 1;
|
|
|
|
unsigned mPendingThemeChanged : 1;
|
2012-10-16 12:41:20 -07:00
|
|
|
unsigned mPendingUIResolutionChanged : 1;
|
2008-07-26 09:14:48 -07:00
|
|
|
unsigned mPendingMediaFeatureValuesChanged : 1;
|
2008-02-08 11:52:46 -08:00
|
|
|
unsigned mPrefChangePendingNeedsReflow : 1;
|
2013-07-17 08:39:19 -07:00
|
|
|
unsigned mIsEmulatingMedia : 1;
|
2012-10-18 21:50:34 -07:00
|
|
|
// True if the requests in mInvalidateRequestsSinceLastPaint cover the
|
|
|
|
// entire viewport
|
2012-08-28 22:48:44 -07:00
|
|
|
unsigned mAllInvalidated : 1;
|
2008-11-25 15:22:38 -08:00
|
|
|
|
2012-09-05 21:58:44 -07:00
|
|
|
// Are we currently drawing an SVG glyph?
|
|
|
|
unsigned mIsGlyph : 1;
|
|
|
|
|
2012-10-26 10:04:20 -07:00
|
|
|
// Does the associated document use root-em (rem) units?
|
|
|
|
unsigned mUsesRootEMUnits : 1;
|
|
|
|
// Does the associated document use viewport units (vw/vh/vmin/vmax)?
|
2012-10-19 16:21:06 -07:00
|
|
|
unsigned mUsesViewportUnits : 1;
|
|
|
|
|
|
|
|
// Has there been a change to the viewport's dimensions?
|
|
|
|
unsigned mPendingViewportChange : 1;
|
|
|
|
|
2008-11-25 15:22:38 -08:00
|
|
|
// Is the current mUserFontSet valid?
|
2008-11-25 15:22:38 -08:00
|
|
|
unsigned mUserFontSetDirty : 1;
|
2008-11-25 15:22:38 -08:00
|
|
|
// Has GetUserFontSet() been called?
|
|
|
|
unsigned mGetUserFontSetCalled : 1;
|
|
|
|
// Do we currently have an event posted to call FlushUserFontSet?
|
|
|
|
unsigned mPostedFlushUserFontSet : 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-13 05:19:50 -07:00
|
|
|
// resize reflow is suppressed when the only change has been to zoom
|
2008-01-28 20:10:59 -08:00
|
|
|
// the document rather than to change the document's dimensions
|
|
|
|
unsigned mSupressResizeReflow : 1;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
unsigned mIsVisual : 1;
|
|
|
|
|
2010-03-01 11:31:45 -08:00
|
|
|
unsigned mProcessingRestyles : 1;
|
2009-09-11 03:46:36 -07:00
|
|
|
unsigned mProcessingAnimationStyleChange : 1;
|
|
|
|
|
2011-01-15 01:40:33 -08:00
|
|
|
unsigned mFireAfterPaintEvents : 1;
|
2010-07-15 14:08:08 -07:00
|
|
|
|
2014-02-06 19:08:49 -08:00
|
|
|
unsigned mIsChrome : 1;
|
2014-03-06 20:02:59 -08:00
|
|
|
unsigned mIsChromeOriginImage : 1;
|
2010-04-10 11:03:40 -07:00
|
|
|
|
2013-07-22 08:51:38 -07:00
|
|
|
// Should we paint flash in this context? Do not use this variable directly.
|
|
|
|
// Use GetPaintFlashing() method instead.
|
|
|
|
mutable unsigned mPaintFlashing : 1;
|
|
|
|
mutable unsigned mPaintFlashingInitialized : 1;
|
|
|
|
|
2014-03-10 15:41:17 -07:00
|
|
|
unsigned mHasWarnedAboutPositionedTableParts : 1;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mInitialized;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2009-07-21 17:44:54 -07:00
|
|
|
virtual ~nsPresContext() NS_HIDDEN;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// these are private, use the list in nsFont.h if you want a public list
|
|
|
|
enum {
|
|
|
|
eDefaultFont_Variable,
|
|
|
|
eDefaultFont_Fixed,
|
|
|
|
eDefaultFont_Serif,
|
|
|
|
eDefaultFont_SansSerif,
|
|
|
|
eDefaultFont_Monospace,
|
|
|
|
eDefaultFont_Cursive,
|
|
|
|
eDefaultFont_Fantasy,
|
|
|
|
eDefaultFont_COUNT
|
|
|
|
};
|
|
|
|
|
2012-06-06 00:36:38 -07:00
|
|
|
nscolor MakeColorPref(const nsString& aColor);
|
|
|
|
|
2013-07-09 10:30:58 -07:00
|
|
|
void LastRelease();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
private:
|
|
|
|
friend struct nsAutoLayoutPhase;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mLayoutPhaseCount[eLayoutPhase_COUNT];
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t LayoutPhaseCount(nsLayoutPhase aPhase) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mLayoutPhaseCount[aPhase];
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-02-03 15:47:57 -08:00
|
|
|
class nsRootPresContext MOZ_FINAL : public nsPresContext {
|
2009-07-21 17:44:54 -07:00
|
|
|
public:
|
|
|
|
nsRootPresContext(nsIDocument* aDocument, nsPresContextType aType) NS_HIDDEN;
|
2009-07-21 17:45:00 -07:00
|
|
|
virtual ~nsRootPresContext();
|
2014-02-03 15:47:57 -08:00
|
|
|
virtual void Detach() MOZ_OVERRIDE;
|
2009-07-21 17:45:00 -07:00
|
|
|
|
2011-01-15 01:40:33 -08:00
|
|
|
/**
|
|
|
|
* Ensure that NotifyDidPaintForSubtree is eventually called on this
|
|
|
|
* object after a timeout.
|
|
|
|
*/
|
|
|
|
void EnsureEventualDidPaintEvent();
|
|
|
|
|
|
|
|
void CancelDidPaintTimer()
|
|
|
|
{
|
|
|
|
if (mNotifyDidPaintTimer) {
|
|
|
|
mNotifyDidPaintTimer->Cancel();
|
2012-07-30 07:20:58 -07:00
|
|
|
mNotifyDidPaintTimer = nullptr;
|
2011-01-15 01:40:33 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-21 17:45:00 -07:00
|
|
|
/**
|
|
|
|
* Registers a plugin to receive geometry updates (position and clip
|
|
|
|
* region) so it can update its widget.
|
|
|
|
* Callers must call UnregisterPluginForGeometryUpdates before
|
|
|
|
* the aPlugin frame is destroyed.
|
|
|
|
*/
|
2012-08-13 21:06:42 -07:00
|
|
|
void RegisterPluginForGeometryUpdates(nsIContent* aPlugin);
|
2009-07-21 17:45:00 -07:00
|
|
|
/**
|
|
|
|
* Stops a plugin receiving geometry updates (position and clip
|
|
|
|
* region). If the plugin was not already registered, this does
|
|
|
|
* nothing.
|
|
|
|
*/
|
2012-08-13 21:06:42 -07:00
|
|
|
void UnregisterPluginForGeometryUpdates(nsIContent* aPlugin);
|
2009-07-21 17:45:00 -07:00
|
|
|
|
2012-10-06 06:03:23 -07:00
|
|
|
bool NeedToComputePluginGeometryUpdates()
|
|
|
|
{
|
|
|
|
return mRegisteredPlugins.Count() > 0;
|
|
|
|
}
|
2009-07-21 17:45:00 -07:00
|
|
|
/**
|
2012-10-06 06:03:23 -07:00
|
|
|
* Compute geometry updates for each plugin given that aList is the display
|
|
|
|
* list for aFrame. The updates are not yet applied;
|
|
|
|
* ApplyPluginGeometryUpdates is responsible for that. In the meantime they
|
|
|
|
* are stored on each nsObjectFrame.
|
|
|
|
* This needs to be called even when aFrame is a popup, since although
|
|
|
|
* windowed plugins aren't allowed in popups, windowless plugins are
|
|
|
|
* and ComputePluginGeometryUpdates needs to be called for them.
|
2009-07-21 17:45:00 -07:00
|
|
|
*/
|
2012-10-06 06:03:23 -07:00
|
|
|
void ComputePluginGeometryUpdates(nsIFrame* aFrame,
|
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayList* aList);
|
2009-07-21 17:45:00 -07:00
|
|
|
|
2009-07-21 17:45:02 -07:00
|
|
|
/**
|
2012-10-06 06:03:23 -07:00
|
|
|
* Apply the stored plugin geometry updates. This should normally be called
|
|
|
|
* in DidPaint so the plugins are moved/clipped immediately after we've
|
|
|
|
* updated our window, so they look in sync with our window.
|
2009-07-21 17:45:02 -07:00
|
|
|
*/
|
2012-10-06 06:03:23 -07:00
|
|
|
void ApplyPluginGeometryUpdates();
|
2009-07-21 17:45:02 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual bool IsRoot() MOZ_OVERRIDE { return true; }
|
2010-01-26 05:10:12 -08:00
|
|
|
|
2010-09-17 12:09:08 -07:00
|
|
|
/**
|
|
|
|
* Increment DOM-modification generation counter to indicate that
|
|
|
|
* the DOM has changed in a way that might lead to style changes/
|
|
|
|
* reflows/frame creation and destruction.
|
|
|
|
*/
|
|
|
|
void IncrementDOMGeneration() { mDOMGeneration++; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current DOM generation counter.
|
2012-07-04 08:42:29 -07:00
|
|
|
*
|
|
|
|
* See nsFrameManagerBase::GetGlobalGenerationNumber() for a
|
|
|
|
* global generation number.
|
2010-09-17 12:09:08 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetDOMGeneration() { return mDOMGeneration; }
|
2010-09-17 12:09:08 -07:00
|
|
|
|
2011-10-25 21:14:31 -07:00
|
|
|
/**
|
|
|
|
* Add a runnable that will get called before the next paint. They will get
|
|
|
|
* run eventually even if painting doesn't happen. They might run well before
|
|
|
|
* painting happens.
|
|
|
|
*/
|
|
|
|
void AddWillPaintObserver(nsIRunnable* aRunnable);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run all runnables that need to get called before the next paint.
|
|
|
|
*/
|
|
|
|
void FlushWillPaintObservers();
|
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
|
2011-12-08 21:01:52 -08:00
|
|
|
|
2011-10-25 21:14:31 -07:00
|
|
|
protected:
|
2012-10-06 06:03:23 -07:00
|
|
|
/**
|
|
|
|
* Start a timer to ensure we eventually run ApplyPluginGeometryUpdates.
|
|
|
|
*/
|
|
|
|
void InitApplyPluginGeometryTimer();
|
|
|
|
/**
|
|
|
|
* Cancel the timer that ensures we eventually run ApplyPluginGeometryUpdates.
|
|
|
|
*/
|
|
|
|
void CancelApplyPluginGeometryTimer();
|
|
|
|
|
2011-10-25 21:14:31 -07:00
|
|
|
class RunWillPaintObservers : public nsRunnable {
|
|
|
|
public:
|
|
|
|
RunWillPaintObservers(nsRootPresContext* aPresContext) : mPresContext(aPresContext) {}
|
2012-07-30 07:20:58 -07:00
|
|
|
void Revoke() { mPresContext = nullptr; }
|
2013-05-29 12:37:49 -07:00
|
|
|
NS_IMETHOD Run() MOZ_OVERRIDE
|
2011-10-25 21:14:31 -07:00
|
|
|
{
|
|
|
|
if (mPresContext) {
|
|
|
|
mPresContext->FlushWillPaintObservers();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
nsRootPresContext* mPresContext;
|
|
|
|
};
|
|
|
|
|
2011-12-23 19:52:26 -08:00
|
|
|
friend class nsPresContext;
|
|
|
|
|
2011-01-15 01:40:33 -08:00
|
|
|
nsCOMPtr<nsITimer> mNotifyDidPaintTimer;
|
2012-10-06 06:03:23 -07:00
|
|
|
nsCOMPtr<nsITimer> mApplyPluginGeometryTimer;
|
2012-08-13 21:06:42 -07:00
|
|
|
nsTHashtable<nsRefPtrHashKey<nsIContent> > mRegisteredPlugins;
|
2011-10-25 21:14:31 -07:00
|
|
|
nsTArray<nsCOMPtr<nsIRunnable> > mWillPaintObservers;
|
|
|
|
nsRevocableEventPtr<RunWillPaintObservers> mWillPaintFallbackEvent;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mDOMGeneration;
|
2009-07-21 17:44:54 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef MOZ_REFLOW_PERF
|
|
|
|
|
|
|
|
#define DO_GLOBAL_REFLOW_COUNT(_name) \
|
2014-03-19 23:49:25 -07:00
|
|
|
aPresContext->CountReflows((_name), (nsIFrame*)this);
|
2007-03-22 10:30:00 -07:00
|
|
|
#else
|
|
|
|
#define DO_GLOBAL_REFLOW_COUNT(_name)
|
|
|
|
#endif // MOZ_REFLOW_PERF
|
|
|
|
|
|
|
|
#endif /* nsPresContext_h___ */
|