mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 893004 part 3. Remove the unused-from-C++ bits of nsIDOMNavigator, except the ones that share implementation with WebIDL anyway. r=smaug
Note that I believe we could remove all these remaining attributes too; it's just some tedious work.
This commit is contained in:
parent
9af6d565fa
commit
0e992ed848
@ -453,14 +453,6 @@ Navigator::GetProductSub(nsAString& aProductSub)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::GetMimeTypes(nsISupports** aMimeTypes)
|
||||
{
|
||||
ErrorResult rv;
|
||||
NS_IF_ADDREF(*aMimeTypes = GetMimeTypes(rv));
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
nsMimeTypeArray*
|
||||
Navigator::GetMimeTypes(ErrorResult& aRv)
|
||||
{
|
||||
@ -476,14 +468,6 @@ Navigator::GetMimeTypes(ErrorResult& aRv)
|
||||
return mMimeTypes;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::GetPlugins(nsISupports** aPlugins)
|
||||
{
|
||||
ErrorResult rv;
|
||||
NS_IF_ADDREF(*aPlugins = static_cast<nsIObserver*>(GetPlugins(rv)));
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
nsPluginArray*
|
||||
Navigator::GetPlugins(ErrorResult& aRv)
|
||||
{
|
||||
@ -504,13 +488,6 @@ Navigator::GetPlugins(ErrorResult& aRv)
|
||||
// nsCookieService.cpp.
|
||||
#define COOKIE_BEHAVIOR_REJECT 2
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::GetCookieEnabled(bool* aCookieEnabled)
|
||||
{
|
||||
*aCookieEnabled = CookieEnabled();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
Navigator::CookieEnabled()
|
||||
{
|
||||
@ -555,15 +532,6 @@ Navigator::CookieEnabled()
|
||||
return cookieEnabled;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::GetOnLine(bool* aOnline)
|
||||
{
|
||||
NS_PRECONDITION(aOnline, "Null out param");
|
||||
|
||||
*aOnline = OnLine();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
Navigator::OnLine()
|
||||
{
|
||||
@ -612,14 +580,6 @@ Navigator::GetDoNotTrack(nsAString &aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::JavaEnabled(bool* aReturn)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aReturn = JavaEnabled(rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
bool
|
||||
Navigator::JavaEnabled(ErrorResult& aRv)
|
||||
{
|
||||
@ -643,13 +603,6 @@ Navigator::JavaEnabled(ErrorResult& aRv)
|
||||
return mimeType && mimeType->GetEnabledPlugin();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::TaintEnabled(bool *aReturn)
|
||||
{
|
||||
*aReturn = TaintEnabled();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
Navigator::RefreshMIMEArray()
|
||||
{
|
||||
@ -732,52 +685,8 @@ VibrateWindowListener::RemoveListener()
|
||||
true /* use capture */);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a JS::Value into a vibration duration, checking that the duration is in
|
||||
* bounds (non-negative and not larger than sMaxVibrateMS).
|
||||
*
|
||||
* Returns true on success, false on failure.
|
||||
*/
|
||||
bool
|
||||
GetVibrationDurationFromJsval(const JS::Value& aJSVal, JSContext* cx,
|
||||
int32_t* aOut)
|
||||
{
|
||||
return JS_ValueToInt32(cx, aJSVal, aOut) &&
|
||||
*aOut >= 0 && static_cast<uint32_t>(*aOut) <= sMaxVibrateMS;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::AddIdleObserver(nsIIdleObserver* aIdleObserver)
|
||||
{
|
||||
NS_ENSURE_STATE(mWindow);
|
||||
|
||||
if (!nsContentUtils::IsIdleObserverAPIEnabled()) {
|
||||
NS_WARNING("The IdleObserver API has been disabled.");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aIdleObserver);
|
||||
|
||||
if (!CheckPermission("idle")) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
AddIdleObserver(*aIdleObserver);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
Navigator::AddIdleObserver(nsIIdleObserver& aIdleObserver)
|
||||
{
|
||||
// Callers (either the XPCOM method or the WebIDL binding) are responsible for
|
||||
// the permission check here.
|
||||
if (NS_FAILED(mWindow->RegisterIdleObserver(&aIdleObserver))) {
|
||||
NS_WARNING("Failed to add idle observer.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Navigator::AddIdleObserver(MozIdleObserver& aIdleObserver, ErrorResult& aRv)
|
||||
{
|
||||
@ -787,32 +696,8 @@ Navigator::AddIdleObserver(MozIdleObserver& aIdleObserver, ErrorResult& aRv)
|
||||
}
|
||||
CallbackObjectHolder<MozIdleObserver, nsIIdleObserver> holder(&aIdleObserver);
|
||||
nsCOMPtr<nsIIdleObserver> obs = holder.ToXPCOMCallback();
|
||||
return AddIdleObserver(*obs);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::RemoveIdleObserver(nsIIdleObserver* aIdleObserver)
|
||||
{
|
||||
NS_ENSURE_STATE(mWindow);
|
||||
|
||||
if (!nsContentUtils::IsIdleObserverAPIEnabled()) {
|
||||
NS_WARNING("The IdleObserver API has been disabled");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aIdleObserver);
|
||||
|
||||
RemoveIdleObserver(*aIdleObserver);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
Navigator::RemoveIdleObserver(nsIIdleObserver& aIdleObserver)
|
||||
{
|
||||
// Callers (either the XPCOM method or the WebIDL binding) are responsible for
|
||||
// the permission check here.
|
||||
if (NS_FAILED(mWindow->UnregisterIdleObserver(&aIdleObserver))) {
|
||||
NS_WARNING("Failed to remove idle observer.");
|
||||
if (NS_FAILED(mWindow->RegisterIdleObserver(obs))) {
|
||||
NS_WARNING("Failed to add idle observer.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -825,52 +710,9 @@ Navigator::RemoveIdleObserver(MozIdleObserver& aIdleObserver, ErrorResult& aRv)
|
||||
}
|
||||
CallbackObjectHolder<MozIdleObserver, nsIIdleObserver> holder(&aIdleObserver);
|
||||
nsCOMPtr<nsIIdleObserver> obs = holder.ToXPCOMCallback();
|
||||
return RemoveIdleObserver(*obs);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::Vibrate(const JS::Value& aPattern, JSContext* cx)
|
||||
{
|
||||
nsAutoTArray<uint32_t, 8> pattern;
|
||||
|
||||
// null or undefined pattern is an error.
|
||||
if (JSVAL_IS_NULL(aPattern) || JSVAL_IS_VOID(aPattern)) {
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
if (NS_FAILED(mWindow->UnregisterIdleObserver(obs))) {
|
||||
NS_WARNING("Failed to remove idle observer.");
|
||||
}
|
||||
|
||||
if (JSVAL_IS_PRIMITIVE(aPattern)) {
|
||||
int32_t p;
|
||||
if (GetVibrationDurationFromJsval(aPattern, cx, &p)) {
|
||||
pattern.AppendElement(p);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS::Rooted<JSObject*> obj(cx, aPattern.toObjectOrNull());
|
||||
uint32_t length;
|
||||
if (!JS_GetArrayLength(cx, obj, &length) || length > sMaxVibrateListLen) {
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
}
|
||||
pattern.SetLength(length);
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
int32_t pv;
|
||||
if (JS_GetElement(cx, obj, i, v.address()) &&
|
||||
GetVibrationDurationFromJsval(v, cx, &pv)) {
|
||||
pattern[i] = pv;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ErrorResult rv;
|
||||
Vibrate(pattern, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
@ -1235,23 +1077,9 @@ Navigator::GetBattery(ErrorResult& aRv)
|
||||
return mBatteryManager;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::GetMozPower(nsIDOMMozPowerManager** aPower)
|
||||
{
|
||||
if (!PowerManager::CheckPermission(mWindow)) {
|
||||
*aPower = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
ErrorResult rv;
|
||||
NS_IF_ADDREF(*aPower = GetMozPower(rv));
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
nsIDOMMozPowerManager*
|
||||
Navigator::GetMozPower(ErrorResult& aRv)
|
||||
{
|
||||
// Callers (either the XPCOM method or the WebIDL binding) are responsible for
|
||||
// the permission check here.
|
||||
if (!mPowerManager) {
|
||||
if (!mWindow) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
@ -1267,14 +1095,6 @@ Navigator::GetMozPower(ErrorResult& aRv)
|
||||
return mPowerManager;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::RequestWakeLock(const nsAString &aTopic, nsIDOMMozWakeLock **aWakeLock)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aWakeLock = RequestWakeLock(aTopic, rv).get();
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMMozWakeLock>
|
||||
Navigator::RequestWakeLock(const nsAString &aTopic, ErrorResult& aRv)
|
||||
{
|
||||
|
@ -300,11 +300,6 @@ private:
|
||||
// any, else null.
|
||||
static already_AddRefed<nsPIDOMWindow> GetWindowFromGlobal(JSObject* aGlobal);
|
||||
|
||||
// Methods to common up the XPCOM and WebIDL implementations of
|
||||
// Add/RemoveIdleObserver.
|
||||
void AddIdleObserver(nsIIdleObserver& aIdleObserver);
|
||||
void RemoveIdleObserver(nsIIdleObserver& aIdleObserver);
|
||||
|
||||
nsRefPtr<nsMimeTypeArray> mMimeTypes;
|
||||
nsRefPtr<nsPluginArray> mPlugins;
|
||||
nsRefPtr<Geolocation> mGeolocation;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "nsPluginArray.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsIMIMEInfo.h"
|
||||
#include "Navigator.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -196,12 +197,12 @@ nsMimeTypeArray::EnsureMimeTypes()
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> pluginsSupports;
|
||||
navigator->GetPlugins(getter_AddRefs(pluginsSupports));
|
||||
nsCOMPtr<nsIObserver> pluginsObserver(do_QueryInterface(pluginsSupports));
|
||||
|
||||
ErrorResult rv;
|
||||
nsPluginArray *pluginArray =
|
||||
static_cast<nsPluginArray*>(pluginsObserver.get());
|
||||
static_cast<Navigator*>(navigator.get())->GetPlugins(rv);
|
||||
if (!pluginArray) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsTArray<nsRefPtr<nsPluginElement> > plugins;
|
||||
pluginArray->GetPlugins(plugins);
|
||||
|
@ -7,116 +7,20 @@
|
||||
|
||||
interface nsIIdleObserver;
|
||||
|
||||
[scriptable, uuid(be8930d7-7543-45bd-8ba3-5678450c543a)]
|
||||
[uuid(f1101fbb-d119-4cb8-845b-6bbae8a151c7)]
|
||||
interface nsIDOMNavigator : nsISupports
|
||||
{
|
||||
readonly attribute DOMString appCodeName;
|
||||
readonly attribute DOMString appName;
|
||||
readonly attribute DOMString appVersion;
|
||||
readonly attribute DOMString language;
|
||||
readonly attribute nsISupports mimeTypes;
|
||||
readonly attribute DOMString platform;
|
||||
readonly attribute DOMString oscpu;
|
||||
readonly attribute DOMString vendor;
|
||||
readonly attribute DOMString vendorSub;
|
||||
readonly attribute DOMString product;
|
||||
readonly attribute DOMString productSub;
|
||||
readonly attribute nsISupports plugins;
|
||||
readonly attribute DOMString userAgent;
|
||||
readonly attribute boolean cookieEnabled;
|
||||
readonly attribute boolean onLine;
|
||||
readonly attribute DOMString buildID;
|
||||
readonly attribute DOMString doNotTrack;
|
||||
readonly attribute nsIDOMMozPowerManager mozPower;
|
||||
|
||||
boolean javaEnabled();
|
||||
boolean taintEnabled();
|
||||
|
||||
/**
|
||||
* Pulse the device's vibrator, if it has one. If the device does not have a
|
||||
* vibrator, this function does nothing. If the window is hidden, this
|
||||
* function does nothing.
|
||||
*
|
||||
* vibrate takes one argument, which specifies either how long to vibrate for
|
||||
* or gives a pattern of vibrator-on/vibrator-off timings.
|
||||
*
|
||||
* If a vibration pattern is in effect when this function is called, this
|
||||
* call will overwrite the existing pattern, if this call successfully
|
||||
* completes.
|
||||
*
|
||||
* We handle the argument to vibrate as follows.
|
||||
*
|
||||
* - If the argument is undefined or null, we throw
|
||||
* NS_ERROR_DOM_NOT_SUPPORTED_ERR.
|
||||
*
|
||||
* - If the argument is 0, the empty list, or a list containing entirely 0s,
|
||||
* we cancel any outstanding vibration pattern; that is, we stop the device
|
||||
* from vibrating.
|
||||
*
|
||||
* - Otherwise, if the argument X is not a list, we treat it as though it's
|
||||
* the singleton list [X] and then proceed as below.
|
||||
*
|
||||
* - If the argument is a list (or if we wrapped it as a list above), then we
|
||||
* try to convert each element in the list to an integer, by first
|
||||
* converting it to a number and then rounding. If there is some element
|
||||
* that we can't convert to an integer, or if any of the integers are
|
||||
* negative, we throw NS_ERROR_DOM_NOT_SUPPORTED_ERR.
|
||||
*
|
||||
* This list of integers specifies a vibration pattern. Given a list of
|
||||
* numbers
|
||||
*
|
||||
* [a_1, b_1, a_2, b_2, ..., a_n]
|
||||
*
|
||||
* the device will vibrate for a_1 milliseconds, then be still for b_1
|
||||
* milliseconds, then vibrate for a_2 milliseconds, and so on.
|
||||
*
|
||||
* The list may contain an even or an odd number of elements, but if you
|
||||
* pass an even number of elements (that is, if your list ends with b_n
|
||||
* instead of a_n), the final element doesn't specify anything meaningful.
|
||||
*
|
||||
* We may throw NS_ERROR_DOM_NOT_SUPPORTED_ERR if the vibration pattern is
|
||||
* too long, or if any of its elements is too large.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
void vibrate(in jsval aPattern);
|
||||
|
||||
/**
|
||||
* Navigator requests to add an idle observer to the existing window.
|
||||
*/
|
||||
void addIdleObserver(in nsIIdleObserver aIdleObserver);
|
||||
|
||||
/**
|
||||
* Navigator requests to remove an idle observer from the existing window.
|
||||
*/
|
||||
void removeIdleObserver(in nsIIdleObserver aIdleObserver);
|
||||
|
||||
/**
|
||||
* Request a wake lock for a resource.
|
||||
*
|
||||
* A page holds a wake lock to request that a resource not be turned
|
||||
* off (or otherwise made unavailable).
|
||||
*
|
||||
* The topic is the name of a resource that might be made unavailable for
|
||||
* various reasons. For example, on a mobile device the power manager might
|
||||
* decide to turn off the screen after a period of idle time to save power.
|
||||
*
|
||||
* The resource manager checks the lock state of a topic before turning off
|
||||
* the associated resource. For example, a page could hold a lock on the
|
||||
* "screen" topic to prevent the screensaver from appearing or the screen
|
||||
* from turning off.
|
||||
*
|
||||
* The resource manager defines what each topic means and sets policy. For
|
||||
* example, the resource manager might decide to ignore 'screen' wake locks
|
||||
* held by pages which are not visible.
|
||||
*
|
||||
* One topic can be locked multiple times; it is considered released only when
|
||||
* all locks on the topic have been released.
|
||||
*
|
||||
* The returned nsIDOMMozWakeLock object is a token of the lock. You can
|
||||
* unlock the lock via the object's |unlock| method. The lock is released
|
||||
* automatically when its associated window is unloaded.
|
||||
*
|
||||
* @param aTopic resource name
|
||||
*/
|
||||
nsIDOMMozWakeLock requestWakeLock(in DOMString aTopic);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user