Bug 1505601 - Turn nsIDocShell XPIDL const lists into cenums; r=bzbarsky

Turn all const lists and related attributes into cenums, to provide a
vague sense of type safety.

Depends on D11715

Differential Revision: https://phabricator.services.mozilla.com/D11716
This commit is contained in:
Kyle Machulis
2018-11-28 03:30:56 +00:00
parent 41c3435c93
commit f293508546
15 changed files with 215 additions and 206 deletions

View File

@@ -102,7 +102,7 @@ LogDocShellState(nsIDocument* aDocumentNode)
nsAutoCString docShellBusy; nsAutoCString docShellBusy;
nsCOMPtr<nsIDocShell> docShell = aDocumentNode->GetDocShell(); nsCOMPtr<nsIDocShell> docShell = aDocumentNode->GetDocShell();
uint32_t busyFlags = nsIDocShell::BUSY_FLAGS_NONE; nsIDocShell::BusyFlags busyFlags = nsIDocShell::BUSY_FLAGS_NONE;
docShell->GetBusyFlags(&busyFlags); docShell->GetBusyFlags(&busyFlags);
if (busyFlags == nsIDocShell::BUSY_FLAGS_NONE) { if (busyFlags == nsIDocShell::BUSY_FLAGS_NONE) {
printf("'none'"); printf("'none'");

View File

@@ -791,9 +791,9 @@ void
nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState) nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState)
{ {
// First, verify if this is a subframe. // First, verify if this is a subframe.
nsCOMPtr<nsIDocShellTreeItem> parentAsItem; nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
GetSameTypeParent(getter_AddRefs(parentAsItem)); GetSameTypeParent(getter_AddRefs(parentAsItem));
nsCOMPtr<nsIDocShell> parentDS(do_QueryInterface(parentAsItem)); nsCOMPtr<nsIDocShell> parentDS(do_QueryInterface(parentAsItem));
if (!parentDS || parentDS == static_cast<nsIDocShell*>(this)) { if (!parentDS || parentDS == static_cast<nsIDocShell*>(this)) {
// This is the root docshell. If we got here while // This is the root docshell. If we got here while
@@ -813,58 +813,57 @@ nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState)
* back/forward. If the parent was loaded through any other loadType, set the * back/forward. If the parent was loaded through any other loadType, set the
* child's loadType too accordingly, so that session history does not get * child's loadType too accordingly, so that session history does not get
* confused. * confused.
*/ */
// Get the parent's load type // Get the parent's load type
uint32_t parentLoadType; uint32_t parentLoadType;
parentDS->GetLoadType(&parentLoadType); parentDS->GetLoadType(&parentLoadType);
// Get the ShEntry for the child from the parent // Get the ShEntry for the child from the parent
nsCOMPtr<nsISHEntry> currentSH; nsCOMPtr<nsISHEntry> currentSH;
bool oshe = false; bool oshe = false;
parentDS->GetCurrentSHEntry(getter_AddRefs(currentSH), &oshe); parentDS->GetCurrentSHEntry(getter_AddRefs(currentSH), &oshe);
bool dynamicallyAddedChild = mDynamicallyCreated; bool dynamicallyAddedChild = mDynamicallyCreated;
if (!dynamicallyAddedChild && !oshe && currentSH) { if (!dynamicallyAddedChild && !oshe && currentSH) {
currentSH->HasDynamicallyAddedChild(&dynamicallyAddedChild); currentSH->HasDynamicallyAddedChild(&dynamicallyAddedChild);
} }
if (!dynamicallyAddedChild) { if (!dynamicallyAddedChild) {
// Only use the old SHEntry, if we're sure enough that // Only use the old SHEntry, if we're sure enough that
// it wasn't originally for some other frame. // it wasn't originally for some other frame.
nsCOMPtr<nsISHEntry> shEntry; nsCOMPtr<nsISHEntry> shEntry;
parentDS->GetChildSHEntry(mChildOffset, getter_AddRefs(shEntry)); parentDS->GetChildSHEntry(mChildOffset, getter_AddRefs(shEntry));
aLoadState->SetSHEntry(shEntry); aLoadState->SetSHEntry(shEntry);
} }
// Make some decisions on the child frame's loadType based on the // Make some decisions on the child frame's loadType based on the
// parent's loadType, if the subframe hasn't loaded anything into it. // parent's loadType, if the subframe hasn't loaded anything into it.
// //
// In some cases privileged scripts may try to get the DOMWindow // In some cases privileged scripts may try to get the DOMWindow
// reference of this docshell before the loading starts, causing the // reference of this docshell before the loading starts, causing the
// initial about:blank content viewer being created and mCurrentURI being // initial about:blank content viewer being created and mCurrentURI being
// set. To handle this case we check if mCurrentURI is about:blank and // set. To handle this case we check if mCurrentURI is about:blank and
// currentSHEntry is null. // currentSHEntry is null.
nsCOMPtr<nsISHEntry> currentChildEntry; nsCOMPtr<nsISHEntry> currentChildEntry;
GetCurrentSHEntry(getter_AddRefs(currentChildEntry), &oshe); GetCurrentSHEntry(getter_AddRefs(currentChildEntry), &oshe);
if (mCurrentURI && (!NS_IsAboutBlank(mCurrentURI) || currentChildEntry)) { if (mCurrentURI && (!NS_IsAboutBlank(mCurrentURI) || currentChildEntry)) {
// This is a pre-existing subframe. If // This is a pre-existing subframe. If
// 1. The load of this frame was not originally initiated by session // 1. The load of this frame was not originally initiated by session
// history directly (i.e. (!shEntry) condition succeeded, but it can // history directly (i.e. (!shEntry) condition succeeded, but it can
// still be a history load on parent which causes this frame being // still be a history load on parent which causes this frame being
// loaded), which we checked with the above assert, and // loaded), which we checked with the above assert, and
// 2. mCurrentURI is not null, nor the initial about:blank, // 2. mCurrentURI is not null, nor the initial about:blank,
// it is possible that a parent's onLoadHandler or even self's // it is possible that a parent's onLoadHandler or even self's
// onLoadHandler is loading a new page in this child. Check parent's and // onLoadHandler is loading a new page in this child. Check parent's and
// self's busy flag and if it is set, we don't want this onLoadHandler // self's busy flag and if it is set, we don't want this onLoadHandler
// load to get in to session history. // load to get in to session history.
uint32_t parentBusy = BUSY_FLAGS_NONE; BusyFlags parentBusy = parentDS->GetBusyFlags();
uint32_t selfBusy = BUSY_FLAGS_NONE; BusyFlags selfBusy = GetBusyFlags();
parentDS->GetBusyFlags(&parentBusy);
GetBusyFlags(&selfBusy); if (parentBusy & BUSY_FLAGS_BUSY ||
if (parentBusy & BUSY_FLAGS_BUSY || selfBusy & BUSY_FLAGS_BUSY) {
selfBusy & BUSY_FLAGS_BUSY) {
aLoadState->SetLoadType(LOAD_NORMAL_REPLACE); aLoadState->SetLoadType(LOAD_NORMAL_REPLACE);
aLoadState->SetSHEntry(nullptr); aLoadState->SetSHEntry(nullptr);
} }
@@ -882,9 +881,9 @@ nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState)
// in the onLoadHandler. We don't want this url to get into session // in the onLoadHandler. We don't want this url to get into session
// history. Clear off shEntry, and set load type to // history. Clear off shEntry, and set load type to
// LOAD_BYPASS_HISTORY. // LOAD_BYPASS_HISTORY.
bool inOnLoadHandler = false; bool inOnLoadHandler = false;
parentDS->GetIsExecutingOnLoadHandler(&inOnLoadHandler); parentDS->GetIsExecutingOnLoadHandler(&inOnLoadHandler);
if (inOnLoadHandler) { if (inOnLoadHandler) {
aLoadState->SetLoadType(LOAD_NORMAL_REPLACE); aLoadState->SetLoadType(LOAD_NORMAL_REPLACE);
aLoadState->SetSHEntry(nullptr); aLoadState->SetSHEntry(nullptr);
} }
@@ -2010,7 +2009,7 @@ nsDocShell::GetMayEnableCharacterEncodingMenu(
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::GetDocShellEnumerator(int32_t aItemType, int32_t aDirection, nsDocShell::GetDocShellEnumerator(int32_t aItemType, DocShellEnumeratorDirection aDirection,
nsISimpleEnumerator** aResult) nsISimpleEnumerator** aResult)
{ {
NS_ENSURE_ARG_POINTER(aResult); NS_ENSURE_ARG_POINTER(aResult);
@@ -2045,14 +2044,14 @@ nsDocShell::GetDocShellEnumerator(int32_t aItemType, int32_t aDirection,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::GetAppType(uint32_t* aAppType) nsDocShell::GetAppType(AppType* aAppType)
{ {
*aAppType = mAppType; *aAppType = mAppType;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::SetAppType(uint32_t aAppType) nsDocShell::SetAppType(AppType aAppType)
{ {
mAppType = aAppType; mAppType = aAppType;
return NS_OK; return NS_OK;
@@ -2119,7 +2118,7 @@ nsDocShell::SetMarginHeight(int32_t aHeight)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::GetBusyFlags(uint32_t* aBusyFlags) nsDocShell::GetBusyFlags(BusyFlags* aBusyFlags)
{ {
NS_ENSURE_ARG_POINTER(aBusyFlags); NS_ENSURE_ARG_POINTER(aBusyFlags);
@@ -2521,18 +2520,20 @@ nsDocShell::SetCustomUserAgent(const nsAString& aCustomUserAgent)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::GetTouchEventsOverride(uint32_t* aTouchEventsOverride) nsDocShell::GetTouchEventsOverride(TouchEventsOverride* aTouchEventsOverride)
{ {
*aTouchEventsOverride = mTouchEventsOverride; *aTouchEventsOverride = mTouchEventsOverride;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::SetTouchEventsOverride(uint32_t aTouchEventsOverride) nsDocShell::SetTouchEventsOverride(TouchEventsOverride aTouchEventsOverride)
{ {
if (!(aTouchEventsOverride == nsIDocShell::TOUCHEVENTS_OVERRIDE_NONE || // We don't have a way to verify this coming from Javascript, so this check is
aTouchEventsOverride == nsIDocShell::TOUCHEVENTS_OVERRIDE_ENABLED || // still needed.
aTouchEventsOverride == nsIDocShell::TOUCHEVENTS_OVERRIDE_DISABLED)) { if (!(aTouchEventsOverride == TOUCHEVENTS_OVERRIDE_NONE ||
aTouchEventsOverride == TOUCHEVENTS_OVERRIDE_ENABLED ||
aTouchEventsOverride == TOUCHEVENTS_OVERRIDE_DISABLED)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@@ -2549,7 +2550,7 @@ nsDocShell::SetTouchEventsOverride(uint32_t aTouchEventsOverride)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::GetMetaViewportOverride(uint32_t* aMetaViewportOverride) nsDocShell::GetMetaViewportOverride(MetaViewportOverride* aMetaViewportOverride)
{ {
NS_ENSURE_ARG_POINTER(aMetaViewportOverride); NS_ENSURE_ARG_POINTER(aMetaViewportOverride);
@@ -2558,11 +2559,13 @@ nsDocShell::GetMetaViewportOverride(uint32_t* aMetaViewportOverride)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::SetMetaViewportOverride(uint32_t aMetaViewportOverride) nsDocShell::SetMetaViewportOverride(MetaViewportOverride aMetaViewportOverride)
{ {
if (!(aMetaViewportOverride == nsIDocShell::META_VIEWPORT_OVERRIDE_NONE || // We don't have a way to verify this coming from Javascript, so this check is
aMetaViewportOverride == nsIDocShell::META_VIEWPORT_OVERRIDE_ENABLED || // still needed.
aMetaViewportOverride == nsIDocShell::META_VIEWPORT_OVERRIDE_DISABLED)) { if (!(aMetaViewportOverride == META_VIEWPORT_OVERRIDE_NONE ||
aMetaViewportOverride == META_VIEWPORT_OVERRIDE_ENABLED ||
aMetaViewportOverride == META_VIEWPORT_OVERRIDE_DISABLED)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@@ -2827,10 +2830,9 @@ nsDocShell::SetDocLoaderParent(nsDocLoader* aParent)
if (NS_SUCCEEDED(parentAsDocShell->GetDefaultLoadFlags(&flags))) { if (NS_SUCCEEDED(parentAsDocShell->GetDefaultLoadFlags(&flags))) {
SetDefaultLoadFlags(flags); SetDefaultLoadFlags(flags);
} }
uint32_t touchEventsOverride;
if (NS_SUCCEEDED(parentAsDocShell->GetTouchEventsOverride(&touchEventsOverride))) { SetTouchEventsOverride(parentAsDocShell->GetTouchEventsOverride());
SetTouchEventsOverride(touchEventsOverride);
}
// We don't need to inherit metaViewportOverride, because the viewport // We don't need to inherit metaViewportOverride, because the viewport
// is only relevant for the outermost nsDocShell, not for any iframes // is only relevant for the outermost nsDocShell, not for any iframes
// like this that might be embedded within it. // like this that might be embedded within it.
@@ -6114,8 +6116,7 @@ nsDocShell::RefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal,
nsCOMPtr<nsITimerCallback> refreshTimer = nsCOMPtr<nsITimerCallback> refreshTimer =
new nsRefreshTimer(this, aURI, aPrincipal, aDelay, aRepeat, aMetaRefresh); new nsRefreshTimer(this, aURI, aPrincipal, aDelay, aRepeat, aMetaRefresh);
uint32_t busyFlags = 0; BusyFlags busyFlags = GetBusyFlags();
GetBusyFlags(&busyFlags);
if (!mRefreshURIList) { if (!mRefreshURIList) {
mRefreshURIList = nsArray::Create(); mRefreshURIList = nsArray::Create();
@@ -6798,7 +6799,7 @@ nsDocShell::OnStateChange(nsIWebProgress* aProgress, nsIRequest* aRequest,
} }
} }
// Page has begun to load // Page has begun to load
mBusyFlags = BUSY_FLAGS_BUSY | BUSY_FLAGS_BEFORE_PAGE_LOAD; mBusyFlags = (BusyFlags)(BUSY_FLAGS_BUSY | BUSY_FLAGS_BEFORE_PAGE_LOAD);
if ((aStateFlags & STATE_RESTORING) == 0) { if ((aStateFlags & STATE_RESTORING) == 0) {
// Show the progress cursor if the pref is set // Show the progress cursor if the pref is set
@@ -6812,7 +6813,7 @@ nsDocShell::OnStateChange(nsIWebProgress* aProgress, nsIRequest* aRequest,
} }
} else if ((~aStateFlags & (STATE_TRANSFERRING | STATE_IS_DOCUMENT)) == 0) { } else if ((~aStateFlags & (STATE_TRANSFERRING | STATE_IS_DOCUMENT)) == 0) {
// Page is loading // Page is loading
mBusyFlags = BUSY_FLAGS_BUSY | BUSY_FLAGS_PAGE_LOADING; mBusyFlags = (BusyFlags)(BUSY_FLAGS_BUSY | BUSY_FLAGS_PAGE_LOADING);
} else if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_NETWORK)) { } else if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_NETWORK)) {
// Page has finished loading // Page has finished loading
mBusyFlags = BUSY_FLAGS_NONE; mBusyFlags = BUSY_FLAGS_NONE;
@@ -13574,14 +13575,14 @@ nsDocShell::GetCanExecuteScripts(bool* aResult)
} }
/* [infallible] */ NS_IMETHODIMP /* [infallible] */ NS_IMETHODIMP
nsDocShell::SetFrameType(uint32_t aFrameType) nsDocShell::SetFrameType(FrameType aFrameType)
{ {
mFrameType = aFrameType; mFrameType = aFrameType;
return NS_OK; return NS_OK;
} }
/* [infallible] */ NS_IMETHODIMP /* [infallible] */ NS_IMETHODIMP
nsDocShell::GetFrameType(uint32_t* aFrameType) nsDocShell::GetFrameType(FrameType* aFrameType)
{ {
*aFrameType = mFrameType; *aFrameType = mFrameType;
return NS_OK; return NS_OK;
@@ -14064,15 +14065,17 @@ nsIDocShell::SetHTMLEditor(HTMLEditor* aHTMLEditor)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::GetDisplayMode(uint32_t* aDisplayMode) nsDocShell::GetDisplayMode(DisplayMode* aDisplayMode)
{ {
*aDisplayMode = mDisplayMode; *aDisplayMode = mDisplayMode;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::SetDisplayMode(uint32_t aDisplayMode) nsDocShell::SetDisplayMode(DisplayMode aDisplayMode)
{ {
// We don't have a way to verify this coming from Javascript, so this check is
// still needed.
if (!(aDisplayMode == nsIDocShell::DISPLAY_MODE_BROWSER || if (!(aDisplayMode == nsIDocShell::DISPLAY_MODE_BROWSER ||
aDisplayMode == nsIDocShell::DISPLAY_MODE_STANDALONE || aDisplayMode == nsIDocShell::DISPLAY_MODE_STANDALONE ||
aDisplayMode == nsIDocShell::DISPLAY_MODE_FULLSCREEN || aDisplayMode == nsIDocShell::DISPLAY_MODE_FULLSCREEN ||

View File

@@ -133,38 +133,38 @@ class nsDocShell final
{ {
public: public:
enum InternalLoad : uint32_t { enum InternalLoad : uint32_t {
INTERNAL_LOAD_FLAGS_NONE = 0x0, INTERNAL_LOAD_FLAGS_NONE = 0x0,
INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL = 0x1, INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL = 0x1,
INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 0x2, INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 0x2,
INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x4, INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x4,
// This flag marks the first load in this object // This flag marks the first load in this object
// @see nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD // @see nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD
INTERNAL_LOAD_FLAGS_FIRST_LOAD = 0x8, INTERNAL_LOAD_FLAGS_FIRST_LOAD = 0x8,
// The set of flags that should not be set before calling into // The set of flags that should not be set before calling into
// nsDocShell::LoadURI and other nsDocShell loading functions. // nsDocShell::LoadURI and other nsDocShell loading functions.
INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS = 0xf, INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS = 0xf,
INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER = 0x10, INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER = 0x10,
INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES = 0x20, INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES = 0x20,
// Whether the load should be treated as srcdoc load, rather than a URI one. // Whether the load should be treated as srcdoc load, rather than a URI one.
INTERNAL_LOAD_FLAGS_IS_SRCDOC = 0x40, INTERNAL_LOAD_FLAGS_IS_SRCDOC = 0x40,
// Whether this is the load of a frame's original src attribute // Whether this is the load of a frame's original src attribute
INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC = 0x80, INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC = 0x80,
INTERNAL_LOAD_FLAGS_NO_OPENER = 0x100, INTERNAL_LOAD_FLAGS_NO_OPENER = 0x100,
// Whether a top-level data URI navigation is allowed for that load // Whether a top-level data URI navigation is allowed for that load
INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x200, INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x200,
// Whether the load was triggered by user interaction. // Whether the load was triggered by user interaction.
INTERNAL_LOAD_FLAGS_IS_USER_TRIGGERED = 0x1000, INTERNAL_LOAD_FLAGS_IS_USER_TRIGGERED = 0x1000,
}; };
// Event type dispatched by RestorePresentation // Event type dispatched by RestorePresentation
class RestorePresentationEvent : public mozilla::Runnable class RestorePresentationEvent : public mozilla::Runnable
@@ -1089,15 +1089,15 @@ private: // data members
int32_t mChildOffset; int32_t mChildOffset;
uint32_t mSandboxFlags; uint32_t mSandboxFlags;
uint32_t mBusyFlags; BusyFlags mBusyFlags;
uint32_t mAppType; AppType mAppType;
uint32_t mLoadType; uint32_t mLoadType;
uint32_t mDefaultLoadFlags; uint32_t mDefaultLoadFlags;
uint32_t mReferrerPolicy; uint32_t mReferrerPolicy;
uint32_t mFailedLoadType; uint32_t mFailedLoadType;
// Are we a regular frame, a browser frame, or an app frame? // Are we a regular frame, a browser frame, or an app frame?
uint32_t mFrameType; FrameType mFrameType;
// This represents the state of private browsing in the docshell. // This represents the state of private browsing in the docshell.
// Currently treated as a binary value: 1 - in private mode, 0 - not private mode // Currently treated as a binary value: 1 - in private mode, 0 - not private mode
@@ -1106,17 +1106,9 @@ private: // data members
// origin attribute set. // origin attribute set.
uint32_t mPrivateBrowsingId; uint32_t mPrivateBrowsingId;
// This represents the CSS display-mode we are currently using. // This represents the CSS display-mode we are currently using. This is mostly
// It can be any of the following values from nsIDocShell.idl: // used for media queries.
// DisplayMode mDisplayMode;
// DISPLAY_MODE_BROWSER = 0
// DISPLAY_MODE_MINIMAL_UI = 1
// DISPLAY_MODE_STANDALONE = 2
// DISPLAY_MODE_FULLSCREEN = 3
//
// This is mostly used for media queries. The integer values above
// match those used in nsStyleConsts.h
uint32_t mDisplayMode;
// A depth count of how many times NotifyRunToCompletionStart // A depth count of how many times NotifyRunToCompletionStart
// has been called without a matching NotifyRunToCompletionStop. // has been called without a matching NotifyRunToCompletionStop.
@@ -1124,11 +1116,11 @@ private: // data members
// Whether or not touch events are overridden. Possible values are defined // Whether or not touch events are overridden. Possible values are defined
// as constants in the nsIDocShell.idl file. // as constants in the nsIDocShell.idl file.
uint32_t mTouchEventsOverride; TouchEventsOverride mTouchEventsOverride;
// Whether or not handling of the <meta name="viewport"> tag is overridden. // Whether or not handling of the <meta name="viewport"> tag is overridden.
// Possible values are defined as constants in nsIDocShell.idl. // Possible values are defined as constants in nsIDocShell.idl.
uint32_t mMetaViewportOverride; MetaViewportOverride mMetaViewportOverride;
// mFullscreenAllowed stores how we determine whether fullscreen is allowed // mFullscreenAllowed stores how we determine whether fullscreen is allowed
// when GetFullscreenAllowed() is called. Fullscreen is allowed in a // when GetFullscreenAllowed() is called. Fullscreen is allowed in a

View File

@@ -323,20 +323,29 @@ interface nsIDocShell : nsIDocShellTreeItem
* @param aDirection - Whether to enumerate forwards or backwards. * @param aDirection - Whether to enumerate forwards or backwards.
*/ */
const long ENUMERATE_FORWARDS = 0; cenum DocShellEnumeratorDirection : 8 {
const long ENUMERATE_BACKWARDS = 1; ENUMERATE_FORWARDS = 0,
ENUMERATE_BACKWARDS = 1
};
nsISimpleEnumerator getDocShellEnumerator(in long aItemType, nsISimpleEnumerator getDocShellEnumerator(in long aItemType,
in long aDirection); in nsIDocShell_DocShellEnumeratorDirection aDirection);
/** /**
* The type of application that created this window * The type of application that created this window.
*
* DO NOT DELETE, see bug 176166. For firefox, this value will always be
* UNKNOWN. However, it is used heavily in Thunderbird/comm-central and we
* don't really have a great replacement at the moment, so we'll just leave it
* here.
*/ */
const unsigned long APP_TYPE_UNKNOWN = 0; cenum AppType : 8 {
const unsigned long APP_TYPE_MAIL = 1; APP_TYPE_UNKNOWN = 0,
const unsigned long APP_TYPE_EDITOR = 2; APP_TYPE_MAIL = 1,
APP_TYPE_EDITOR = 2
};
attribute unsigned long appType; [infallible] attribute nsIDocShell_AppType appType;
/** /**
* certain dochshells (like the message pane) * certain dochshells (like the message pane)
@@ -384,25 +393,30 @@ interface nsIDocShell : nsIDocShellTreeItem
/** /**
* Current busy state for DocShell * Current busy state for DocShell
*/ */
const unsigned long BUSY_FLAGS_NONE = 0; cenum BusyFlags : 8 {
const unsigned long BUSY_FLAGS_BUSY = 1; BUSY_FLAGS_NONE = 0,
const unsigned long BUSY_FLAGS_BEFORE_PAGE_LOAD = 2; BUSY_FLAGS_BUSY = 1,
const unsigned long BUSY_FLAGS_PAGE_LOADING = 4; BUSY_FLAGS_BEFORE_PAGE_LOAD = 2,
BUSY_FLAGS_PAGE_LOADING = 4,
};
[infallible] readonly attribute nsIDocShell_BusyFlags busyFlags;
/** /**
* Load commands for the document * Load commands for the document
*/ */
const unsigned long LOAD_CMD_NORMAL = 0x1; // Normal load cenum LoadCommand : 8 {
const unsigned long LOAD_CMD_RELOAD = 0x2; // Reload LOAD_CMD_NORMAL = 0x1, // Normal load
const unsigned long LOAD_CMD_HISTORY = 0x4; // Load from history LOAD_CMD_RELOAD = 0x2, // Reload
const unsigned long LOAD_CMD_PUSHSTATE = 0x8; // History.pushState() LOAD_CMD_HISTORY = 0x4, // Load from history
LOAD_CMD_PUSHSTATE = 0x8, // History.pushState()
readonly attribute unsigned long busyFlags; };
/* /*
* attribute to access the loadtype for the document * Attribute to access the loadtype for the document. LoadType Enum is
* defined in nsDocShellLoadTypes.h
*/ */
attribute unsigned long loadType; [infallible] attribute unsigned long loadType;
/* /*
* Default load flags (as defined in nsIRequest) that will be set on all * Default load flags (as defined in nsIRequest) that will be set on all
@@ -787,10 +801,11 @@ interface nsIDocShell : nsIDocShellTreeItem
/** /**
* The type of iframe that this docshell lives. * The type of iframe that this docshell lives.
*/ */
const unsigned long FRAME_TYPE_REGULAR = 0; cenum FrameType : 8 {
const unsigned long FRAME_TYPE_BROWSER = 1; FRAME_TYPE_REGULAR = 0,
FRAME_TYPE_BROWSER = 1,
[infallible] attribute unsigned long frameType; };
[infallible] attribute nsIDocShell_FrameType frameType;
/** /**
* Returns true if this docshell corresponds to an <iframe mozbrowser>. * Returns true if this docshell corresponds to an <iframe mozbrowser>.
@@ -1099,45 +1114,51 @@ interface nsIDocShell : nsIDocShellTreeItem
[noscript,nostdcall,notxpcom] nsICommandManager GetCommandManager(); [noscript,nostdcall,notxpcom] nsICommandManager GetCommandManager();
cenum TouchEventsOverride: 8 {
/**
* Override platform/pref default behaviour and force-disable touch events.
*/
TOUCHEVENTS_OVERRIDE_DISABLED = 0,
/**
* Override platform/pref default behaviour and force-enable touch events.
*/
TOUCHEVENTS_OVERRIDE_ENABLED = 1,
/**
* Don't override the platform/pref default behaviour for touch events.
*/
TOUCHEVENTS_OVERRIDE_NONE = 2,
};
/** /**
* This allows chrome to override the default choice of whether touch events * This allows chrome to override the default choice of whether touch events
* are available on a specific docshell. Possible values are listed below. * are available on a specific docshell. Possible values are listed below.
*/ */
[infallible] attribute unsigned long touchEventsOverride; [infallible] attribute nsIDocShell_TouchEventsOverride touchEventsOverride;
/**
* Override platform/pref default behaviour and force-disable touch events. cenum MetaViewportOverride: 8 {
*/ /**
const unsigned long TOUCHEVENTS_OVERRIDE_DISABLED = 0; * Override platform/pref default behaviour and force-disable support for
/** * <meta name="viewport">.
* Override platform/pref default behaviour and force-enable touch events. */
*/ META_VIEWPORT_OVERRIDE_DISABLED = 0,
const unsigned long TOUCHEVENTS_OVERRIDE_ENABLED = 1; /**
/** * Override platform/pref default behaviour and force-enable support for
* Don't override the platform/pref default behaviour for touch events. * <meta name="viewport">.
*/ */
const unsigned long TOUCHEVENTS_OVERRIDE_NONE = 2; META_VIEWPORT_OVERRIDE_ENABLED = 1,
/**
* Don't override the platform/pref default behaviour for support for
* <meta name="viewport">.
*/
META_VIEWPORT_OVERRIDE_NONE = 2,
};
/**
* Override platform/pref default behaviour and force-disable support for
* <meta name="viewport">.
*/
const unsigned long META_VIEWPORT_OVERRIDE_DISABLED = 0;
/**
* Override platform/pref default behaviour and force-enable support for
* <meta name="viewport">.
*/
const unsigned long META_VIEWPORT_OVERRIDE_ENABLED = 1;
/**
* Don't override the platform/pref default behaviour for support for
* <meta name="viewport">.
*/
const unsigned long META_VIEWPORT_OVERRIDE_NONE = 2;
/** /**
* This allows chrome to override the default choice of whether the * This allows chrome to override the default choice of whether the
* <meta name="viewport"> tag is respected in a specific docshell. * <meta name="viewport"> tag is respected in a specific docshell.
* Possible values are listed above. * Possible values are listed above.
*/ */
attribute unsigned long metaViewportOverride; [infallible] attribute nsIDocShell_MetaViewportOverride metaViewportOverride;
/** /**
* This value is `true` if its corresponding unit of related browsing contexts * This value is `true` if its corresponding unit of related browsing contexts
@@ -1208,18 +1229,20 @@ interface nsIDocShell : nsIDocShellTreeItem
/** /**
* Allowed CSS display modes. This needs to be kept in * Allowed CSS display modes. This needs to be kept in
* sync with similar values in nsStyleConsts.h * sync with similar values in ServoStyleConsts.h
*/ */
const unsigned long DISPLAY_MODE_BROWSER = 0; cenum DisplayMode: 8 {
const unsigned long DISPLAY_MODE_MINIMAL_UI = 1; DISPLAY_MODE_BROWSER = 0,
const unsigned long DISPLAY_MODE_STANDALONE = 2; DISPLAY_MODE_MINIMAL_UI = 1,
const unsigned long DISPLAY_MODE_FULLSCREEN = 3; DISPLAY_MODE_STANDALONE = 2,
DISPLAY_MODE_FULLSCREEN = 3,
};
/** /**
* Display mode for this docshell. Defaults to DISPLAY_MODE_BROWSER. * Display mode for this docshell. Defaults to DISPLAY_MODE_BROWSER.
* Media queries only look at the value in the top-most docshell. * Media queries only look at the value in the top-most docshell.
*/ */
[infallible] attribute unsigned long displayMode; [infallible] attribute nsIDocShell_DisplayMode displayMode;
/** /**
* The message manager for this docshell. This does not throw, but * The message manager for this docshell. This does not throw, but

View File

@@ -3443,7 +3443,7 @@ nsContentUtils::CanLoadImage(nsIURI* aURI, nsINode* aNode,
nsresult rv; nsresult rv;
uint32_t appType = nsIDocShell::APP_TYPE_UNKNOWN; auto appType = nsIDocShell::APP_TYPE_UNKNOWN;
{ {
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem = aLoadingDocument->GetDocShell(); nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem = aLoadingDocument->GetDocShell();
@@ -3453,8 +3453,8 @@ nsContentUtils::CanLoadImage(nsIURI* aURI, nsINode* aNode,
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(root)); nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(root));
if (!docShell || NS_FAILED(docShell->GetAppType(&appType))) { if (docShell) {
appType = nsIDocShell::APP_TYPE_UNKNOWN; appType = docShell->GetAppType();
} }
} }
} }
@@ -7669,9 +7669,8 @@ nsContentUtils::PrefetchPreloadEnabled(nsIDocShell* aDocShell)
nsCOMPtr<nsIDocShellTreeItem> parentItem; nsCOMPtr<nsIDocShellTreeItem> parentItem;
do { do {
uint32_t appType = 0; auto appType = docshell->GetAppType();
nsresult rv = docshell->GetAppType(&appType); if (appType == nsIDocShell::APP_TYPE_MAIL) {
if (NS_FAILED(rv) || appType == nsIDocShell::APP_TYPE_MAIL) {
return false; // do not prefetch, preload, preconnect from mailnews return false; // do not prefetch, preload, preconnect from mailnews
} }

View File

@@ -3036,9 +3036,8 @@ nsGlobalWindowOuter::GetSanitizedOpener(nsPIDOMWindowOuter* aOpener)
openerDocShell->GetRootTreeItem(getter_AddRefs(openerRootItem)); openerDocShell->GetRootTreeItem(getter_AddRefs(openerRootItem));
nsCOMPtr<nsIDocShell> openerRootDocShell(do_QueryInterface(openerRootItem)); nsCOMPtr<nsIDocShell> openerRootDocShell(do_QueryInterface(openerRootItem));
if (openerRootDocShell) { if (openerRootDocShell) {
uint32_t appType; nsIDocShell::AppType appType = openerRootDocShell->GetAppType();
nsresult rv = openerRootDocShell->GetAppType(&appType); if (appType != nsIDocShell::APP_TYPE_MAIL) {
if (NS_SUCCEEDED(rv) && appType != nsIDocShell::APP_TYPE_MAIL) {
return aOpener; return aOpener;
} }
} }

View File

@@ -3885,13 +3885,12 @@ EventStateManager::UpdateCursor(nsPresContext* aPresContext,
// Check whether or not to show the busy cursor // Check whether or not to show the busy cursor
nsCOMPtr<nsIDocShell> docShell(aPresContext->GetDocShell()); nsCOMPtr<nsIDocShell> docShell(aPresContext->GetDocShell());
if (!docShell) return; if (!docShell) return;
uint32_t busyFlags = nsIDocShell::BUSY_FLAGS_NONE; auto busyFlags = docShell->GetBusyFlags();
docShell->GetBusyFlags(&busyFlags);
// Show busy cursor everywhere before page loads // Show busy cursor everywhere before page loads
// and just replace the arrow cursor after page starts loading // and just replace the arrow cursor after page starts loading
if (busyFlags & nsIDocShell::BUSY_FLAGS_BUSY && if (busyFlags & nsIDocShell::BUSY_FLAGS_BUSY &&
(cursor == NS_STYLE_CURSOR_AUTO || cursor == NS_STYLE_CURSOR_DEFAULT)) (cursor == NS_STYLE_CURSOR_AUTO || cursor == NS_STYLE_CURSOR_DEFAULT))
{ {
cursor = NS_STYLE_CURSOR_SPINNING; cursor = NS_STYLE_CURSOR_SPINNING;
container = nullptr; container = nullptr;

View File

@@ -253,9 +253,9 @@ TouchEvent::PrefEnabled(nsIDocShell* aDocShell)
static bool sPrefCached = false; static bool sPrefCached = false;
static int32_t sPrefCacheValue = 0; static int32_t sPrefCacheValue = 0;
uint32_t touchEventsOverride = nsIDocShell::TOUCHEVENTS_OVERRIDE_NONE; auto touchEventsOverride = nsIDocShell::TOUCHEVENTS_OVERRIDE_NONE;
if (aDocShell) { if (aDocShell) {
aDocShell->GetTouchEventsOverride(&touchEventsOverride); touchEventsOverride = aDocShell->GetTouchEventsOverride();
} }
if (!sPrefCached) { if (!sPrefCached) {

View File

@@ -179,11 +179,7 @@ PresentationResponderLoadingCallback::Init(nsIDocShell* aDocShell)
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
uint32_t busyFlags = nsIDocShell::BUSY_FLAGS_NONE; auto busyFlags = aDocShell->GetBusyFlags();
nsresult rv = aDocShell->GetBusyFlags(&busyFlags);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if ((busyFlags == nsIDocShell::BUSY_FLAGS_NONE) || if ((busyFlags == nsIDocShell::BUSY_FLAGS_NONE) ||
(busyFlags & nsIDocShell::BUSY_FLAGS_PAGE_LOADING)) { (busyFlags & nsIDocShell::BUSY_FLAGS_PAGE_LOADING)) {

View File

@@ -270,7 +270,7 @@ static bool IsImageLoadInEditorAppType(nsILoadInfo* aLoadInfo)
return false; return false;
} }
uint32_t appType = nsIDocShell::APP_TYPE_UNKNOWN; auto appType = nsIDocShell::APP_TYPE_UNKNOWN;
nsINode* node = aLoadInfo->LoadingNode(); nsINode* node = aLoadInfo->LoadingNode();
if (!node) { if (!node) {
return false; return false;
@@ -288,8 +288,8 @@ static bool IsImageLoadInEditorAppType(nsILoadInfo* aLoadInfo)
nsCOMPtr<nsIDocShellTreeItem> root; nsCOMPtr<nsIDocShellTreeItem> root;
docShellTreeItem->GetRootTreeItem(getter_AddRefs(root)); docShellTreeItem->GetRootTreeItem(getter_AddRefs(root));
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(root)); nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(root));
if (!docShell || NS_FAILED(docShell->GetAppType(&appType))) { if (docShell) {
appType = nsIDocShell::APP_TYPE_UNKNOWN; appType = docShell->GetAppType();
} }
return appType == nsIDocShell::APP_TYPE_EDITOR; return appType == nsIDocShell::APP_TYPE_EDITOR;

View File

@@ -488,10 +488,9 @@ TextEditor::IsSafeToInsertData(nsIDocument* aSourceDoc)
dsti->GetRootTreeItem(getter_AddRefs(root)); dsti->GetRootTreeItem(getter_AddRefs(root));
} }
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(root); nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(root);
uint32_t appType;
if (docShell && NS_SUCCEEDED(docShell->GetAppType(&appType))) { isSafe = docShell && docShell->GetAppType() == nsIDocShell::APP_TYPE_EDITOR;
isSafe = appType == nsIDocShell::APP_TYPE_EDITOR;
}
if (!isSafe && aSourceDoc) { if (!isSafe && aSourceDoc) {
nsIPrincipal* srcPrincipal = aSourceDoc->NodePrincipal(); nsIPrincipal* srcPrincipal = aSourceDoc->NodePrincipal();
nsIPrincipal* destPrincipal = destdoc->NodePrincipal(); nsIPrincipal* destPrincipal = destdoc->NodePrincipal();

View File

@@ -3830,9 +3830,8 @@ nsDocumentViewer::Print(nsIPrintSettings* aPrintSettings,
// Check to see if this document is still busy // Check to see if this document is still busy
// If it is busy and we aren't already "queued" up to print then // If it is busy and we aren't already "queued" up to print then
// Indicate there is a print pending and cache the args for later // Indicate there is a print pending and cache the args for later
uint32_t busyFlags = nsIDocShell::BUSY_FLAGS_NONE; auto busyFlags = docShell->GetBusyFlags();
if ((NS_FAILED(docShell->GetBusyFlags(&busyFlags)) || if (busyFlags != nsIDocShell::BUSY_FLAGS_NONE && busyFlags & nsIDocShell::BUSY_FLAGS_PAGE_LOADING &&
(busyFlags != nsIDocShell::BUSY_FLAGS_NONE && busyFlags & nsIDocShell::BUSY_FLAGS_PAGE_LOADING)) &&
!mPrintDocIsFullyLoaded) { !mPrintDocIsFullyLoaded) {
if (!mPrintIsPending) { if (!mPrintIsPending) {
mCachedPrintSettings = aPrintSettings; mCachedPrintSettings = aPrintSettings;

View File

@@ -10347,10 +10347,10 @@ nsLayoutUtils::ComputeSystemFont(nsFont* aSystemFont, LookAndFeel::FontID aFontI
/* static */ bool /* static */ bool
nsLayoutUtils::ShouldHandleMetaViewport(nsIDocument* aDocument) nsLayoutUtils::ShouldHandleMetaViewport(nsIDocument* aDocument)
{ {
uint32_t metaViewportOverride = nsIDocShell::META_VIEWPORT_OVERRIDE_NONE; auto metaViewportOverride = nsIDocShell::META_VIEWPORT_OVERRIDE_NONE;
if (aDocument) { if (aDocument) {
if (nsIDocShell* docShell = aDocument->GetDocShell()) { if (nsIDocShell* docShell = aDocument->GetDocShell()) {
docShell->GetMetaViewportOverride(&metaViewportOverride); metaViewportOverride = docShell->GetMetaViewportOverride();
} }
} }
switch (metaViewportOverride) { switch (metaViewportOverride) {

View File

@@ -1049,9 +1049,8 @@ nsPrintJob::PrintPreview(nsIPrintSettings* aPrintSettings,
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mContainer)); nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mContainer));
NS_ENSURE_STATE(docShell); NS_ENSURE_STATE(docShell);
uint32_t busyFlags = nsIDocShell::BUSY_FLAGS_NONE; auto busyFlags = docShell->GetBusyFlags();
if (NS_FAILED(docShell->GetBusyFlags(&busyFlags)) || if (busyFlags != nsIDocShell::BUSY_FLAGS_NONE) {
busyFlags != nsIDocShell::BUSY_FLAGS_NONE) {
CloseProgressDialog(aWebProgressListener); CloseProgressDialog(aWebProgressListener);
FirePrintingErrorEvent(NS_ERROR_GFX_PRINTER_DOC_IS_BUSY); FirePrintingErrorEvent(NS_ERROR_GFX_PRINTER_DOC_IS_BUSY);
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

View File

@@ -127,8 +127,9 @@ nsWebBrowserFind::FindNext(bool* aResult)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
int32_t enumDirection = mFindBackwards ? nsIDocShell::ENUMERATE_BACKWARDS : auto enumDirection =
nsIDocShell::ENUMERATE_FORWARDS; mFindBackwards ? nsIDocShell::ENUMERATE_BACKWARDS :
nsIDocShell::ENUMERATE_FORWARDS;
nsCOMPtr<nsISimpleEnumerator> docShellEnumerator; nsCOMPtr<nsISimpleEnumerator> docShellEnumerator;
rv = rootDocShell->GetDocShellEnumerator(nsIDocShellTreeItem::typeAll, rv = rootDocShell->GetDocShellEnumerator(nsIDocShellTreeItem::typeAll,