mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 09:49:14 +00:00
Bug 816421. Make Document.visibilityState a WebIDL enum. r=peterv
A lot of the changes here are just so I can actually build after including DocumentBinding.h in nsIDocument.h
This commit is contained in:
parent
3b7f2fb148
commit
a3b4bd9774
@ -24,6 +24,7 @@
|
||||
#include "nsPropertyTable.h" // for member
|
||||
#include "nsTHashtable.h" // for member
|
||||
#include "mozilla/dom/DirectionalityUtils.h"
|
||||
#include "mozilla/dom/DocumentBinding.h"
|
||||
|
||||
class imgIRequest;
|
||||
class nsAString;
|
||||
@ -1888,15 +1889,22 @@ public:
|
||||
}
|
||||
bool Hidden() const
|
||||
{
|
||||
return mVisibilityState != eVisible;
|
||||
return mVisibilityState != mozilla::dom::VisibilityStateValues::Visible;
|
||||
}
|
||||
bool MozHidden() // Not const because of WarnOnceAbout
|
||||
{
|
||||
WarnOnceAbout(ePrefixedVisibilityAPI);
|
||||
return Hidden();
|
||||
}
|
||||
void GetVisibilityState(nsAString& aState);
|
||||
void GetMozVisibilityState(nsAString& aState);
|
||||
mozilla::dom::VisibilityState VisibilityState()
|
||||
{
|
||||
return mVisibilityState;
|
||||
}
|
||||
mozilla::dom::VisibilityState MozVisibilityState()
|
||||
{
|
||||
WarnOnceAbout(ePrefixedVisibilityAPI);
|
||||
return VisibilityState();
|
||||
}
|
||||
virtual nsIDOMStyleSheetList* StyleSheets() = 0;
|
||||
void GetSelectedStyleSheetSet(nsAString& aSheetSet);
|
||||
virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) = 0;
|
||||
@ -1988,14 +1996,6 @@ protected:
|
||||
mDirectionality = aDir;
|
||||
}
|
||||
|
||||
// This needs to stay in sync with the list in GetVisibilityState.
|
||||
// XXXbz visibilityState needs to be an IDL enum.
|
||||
enum VisibilityState {
|
||||
eHidden = 0,
|
||||
eVisible,
|
||||
eVisibilityStateCount
|
||||
};
|
||||
|
||||
nsCString mReferrer;
|
||||
nsString mLastModified;
|
||||
|
||||
@ -2047,7 +2047,7 @@ protected:
|
||||
ReadyState mReadyState;
|
||||
|
||||
// Our visibility state
|
||||
VisibilityState mVisibilityState;
|
||||
mozilla::dom::VisibilityState mVisibilityState;
|
||||
|
||||
// True if BIDI is enabled.
|
||||
bool mBidiEnabled;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "nsGkAtoms.h"
|
||||
#include "mozilla/dom/HTMLCollectionBinding.h"
|
||||
#include "mozilla/dom/NodeListBinding.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
|
||||
|
@ -1298,7 +1298,7 @@ nsIDocument::nsIDocument()
|
||||
mCharacterSet(NS_LITERAL_CSTRING("ISO-8859-1")),
|
||||
mNodeInfoManager(nullptr),
|
||||
mCompatMode(eCompatibility_FullStandards),
|
||||
mVisibilityState(eHidden),
|
||||
mVisibilityState(VisibilityStateValues::Hidden),
|
||||
mIsInitialDocumentInWindow(false),
|
||||
mMayStartLayout(true),
|
||||
mVisible(true),
|
||||
@ -9934,7 +9934,7 @@ nsIDocument::GetMozPointerLockElement()
|
||||
void
|
||||
nsDocument::UpdateVisibilityState()
|
||||
{
|
||||
VisibilityState oldState = mVisibilityState;
|
||||
dom::VisibilityState oldState = mVisibilityState;
|
||||
mVisibilityState = GetVisibilityState();
|
||||
if (oldState != mVisibilityState) {
|
||||
nsContentUtils::DispatchTrustedEvent(this, static_cast<nsIDocument*>(this),
|
||||
@ -9950,7 +9950,7 @@ nsDocument::UpdateVisibilityState()
|
||||
}
|
||||
}
|
||||
|
||||
nsDocument::VisibilityState
|
||||
VisibilityState
|
||||
nsDocument::GetVisibilityState() const
|
||||
{
|
||||
// We have to check a few pieces of information here:
|
||||
@ -9962,10 +9962,10 @@ nsDocument::GetVisibilityState() const
|
||||
// Otherwise, we're visible.
|
||||
if (!IsVisible() || !mWindow || !mWindow->GetOuterWindow() ||
|
||||
mWindow->GetOuterWindow()->IsBackground()) {
|
||||
return eHidden;
|
||||
return VisibilityStateValues::Hidden;
|
||||
}
|
||||
|
||||
return eVisible;
|
||||
return VisibilityStateValues::Visible;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
@ -9992,13 +9992,6 @@ nsDocument::GetHidden(bool* aHidden)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetMozVisibilityState(nsAString& aState)
|
||||
{
|
||||
nsIDocument::GetMozVisibilityState(aState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsIDocument::GetMozVisibilityState(nsAString& aState)
|
||||
{
|
||||
WarnOnceAbout(ePrefixedVisibilityAPI);
|
||||
return GetVisibilityState(aState);
|
||||
@ -10007,22 +10000,11 @@ nsIDocument::GetMozVisibilityState(nsAString& aState)
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetVisibilityState(nsAString& aState)
|
||||
{
|
||||
nsIDocument::GetVisibilityState(aState);
|
||||
const EnumEntry& entry = VisibilityStateValues::strings[mVisibilityState];
|
||||
aState.AssignASCII(entry.value, entry.length);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsIDocument::GetVisibilityState(nsAString& aState)
|
||||
{
|
||||
// This needs to stay in sync with the VisibilityState enum.
|
||||
static const char states[][8] = {
|
||||
"hidden",
|
||||
"visible"
|
||||
};
|
||||
PR_STATIC_ASSERT(NS_ARRAY_LENGTH(states) == eVisibilityStateCount);
|
||||
aState.AssignASCII(states[mVisibilityState]);
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
nsIDocument::DocSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
|
||||
{
|
||||
|
@ -1253,7 +1253,7 @@ protected:
|
||||
private:
|
||||
friend class nsUnblockOnloadEvent;
|
||||
// Recomputes the visibility state but doesn't set the new value.
|
||||
VisibilityState GetVisibilityState() const;
|
||||
mozilla::dom::VisibilityState GetVisibilityState() const;
|
||||
|
||||
void PostUnblockOnloadEvent();
|
||||
void DoUnblockOnload();
|
||||
|
@ -52,6 +52,7 @@
|
||||
|
||||
#include "nsIDOMHTMLButtonElement.h"
|
||||
#include "mozilla/dom/HTMLCollectionBinding.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "nsIHTMLCollection.h"
|
||||
#include "nsHTMLStyleSheet.h"
|
||||
#include "mozilla/dom/HTMLCollectionBinding.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
40
dom/bindings/BindingDeclarations.h
Normal file
40
dom/bindings/BindingDeclarations.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
||||
/* vim: set ts=2 sw=2 et tw=79: */
|
||||
/* 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/. */
|
||||
|
||||
/**
|
||||
* A header for declaring various things that binding implementation headers
|
||||
* might need. The idea is to make binding implementation headers safe to
|
||||
* include anywhere without running into include hell like we do with
|
||||
* BindingUtils.h
|
||||
*/
|
||||
#ifndef mozilla_dom_BindingDeclarations_h__
|
||||
#define mozilla_dom_BindingDeclarations_h__
|
||||
|
||||
#include "nsStringGlue.h"
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
struct MainThreadDictionaryBase
|
||||
{
|
||||
protected:
|
||||
JSContext* ParseJSON(const nsAString& aJSON,
|
||||
mozilla::Maybe<JSAutoRequest>& aAr,
|
||||
mozilla::Maybe<JSAutoCompartment>& aAc,
|
||||
JS::Value& aVal);
|
||||
};
|
||||
|
||||
struct EnumEntry {
|
||||
const char* value;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_BindingDeclarations_h__
|
@ -13,7 +13,6 @@
|
||||
#include "mozilla/dom/workers/Workers.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jswrapper.h"
|
||||
|
||||
@ -23,6 +22,7 @@
|
||||
#include "nsTraceRefcnt.h"
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
|
||||
// nsGlobalWindow implements nsWrapperCache, but doesn't always use it. Don't
|
||||
// try to use it without fixing that first.
|
||||
@ -692,11 +692,6 @@ HandleNewBindingWrappingFailure(JSContext* cx, JSObject* scope,
|
||||
return HandleNewBindingWrappingFailure(cx, scope, value.get(), vp);
|
||||
}
|
||||
|
||||
struct EnumEntry {
|
||||
const char* value;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
template<bool Fatal>
|
||||
inline bool
|
||||
EnumValueNotFound(JSContext* cx, const jschar* chars, size_t length,
|
||||
@ -1652,15 +1647,6 @@ MustInheritFromNonRefcountedDOMObject(NonRefcountedDOMObject*)
|
||||
JSObject* GetXrayExpandoChain(JSObject *obj);
|
||||
void SetXrayExpandoChain(JSObject *obj, JSObject *chain);
|
||||
|
||||
struct MainThreadDictionaryBase
|
||||
{
|
||||
protected:
|
||||
JSContext* ParseJSON(const nsAString& aJSON,
|
||||
mozilla::Maybe<JSAutoRequest>& aAr,
|
||||
mozilla::Maybe<JSAutoCompartment>& aAc,
|
||||
JS::Value& aVal);
|
||||
};
|
||||
|
||||
/**
|
||||
* This creates a JSString containing the value that the toString function for
|
||||
* obj should create according to the WebIDL specification, ignoring any
|
||||
|
@ -530,6 +530,8 @@ class CGHeaders(CGWrapper):
|
||||
if len(callbacks) != 0:
|
||||
# We need CallbackFunction to serve as our parent class
|
||||
declareIncludes.add("mozilla/dom/CallbackFunction.h")
|
||||
# And we need BindingUtils.h so we can wrap "this" objects
|
||||
declareIncludes.add("mozilla/dom/BindingUtils.h")
|
||||
|
||||
# Let the machinery do its thing.
|
||||
def _includeString(includes):
|
||||
@ -6920,10 +6922,12 @@ class CGBindingRoot(CGThing):
|
||||
curr = CGHeaders(descriptors,
|
||||
dictionaries,
|
||||
callbacks,
|
||||
['mozilla/dom/BindingUtils.h',
|
||||
['mozilla/dom/BindingDeclarations.h',
|
||||
'mozilla/ErrorResult.h',
|
||||
'mozilla/dom/DOMJSClass.h',
|
||||
'mozilla/dom/DOMJSProxyHandler.h'],
|
||||
['mozilla/dom/NonRefcountedDOMObject.h',
|
||||
['mozilla/dom/BindingUtils.h',
|
||||
'mozilla/dom/NonRefcountedDOMObject.h',
|
||||
'mozilla/dom/Nullable.h',
|
||||
'PrimitiveConversions.h',
|
||||
'XPCQuickStubs.h',
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsproxy.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "mozilla/Likely.h"
|
||||
|
||||
#define DOM_PROXY_OBJECT_SLOT js::JSSLOT_PROXY_PRIVATE
|
||||
|
@ -57,6 +57,7 @@ EXPORTS_mozilla = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS_$(binding_include_path) = \
|
||||
BindingDeclarations.h \
|
||||
BindingUtils.h \
|
||||
CallbackFunction.h \
|
||||
DOMJSClass.h \
|
||||
|
@ -29,6 +29,8 @@ interface TreeWalker;
|
||||
interface WindowProxy;
|
||||
interface nsISupports;
|
||||
|
||||
enum VisibilityState { "hidden", "visible" };
|
||||
|
||||
/* http://dom.spec.whatwg.org/#interface-document */
|
||||
[Constructor]
|
||||
interface Document : Node {
|
||||
@ -352,9 +354,8 @@ partial interface Document {
|
||||
*/
|
||||
readonly attribute boolean hidden;
|
||||
readonly attribute boolean mozHidden;
|
||||
readonly attribute DOMString visibilityState;
|
||||
readonly attribute DOMString mozVisibilityState;
|
||||
// "hidden", "visible", "prerender", "unloaded"
|
||||
readonly attribute VisibilityState visibilityState;
|
||||
readonly attribute VisibilityState mozVisibilityState;
|
||||
/*
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user