mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 875784 - Move MozTimeManager to WebIDL; r=smaug
This commit is contained in:
parent
d98902ff9a
commit
68ea30a57e
@ -1480,7 +1480,7 @@ Navigator::MozSetMessageHandler(const nsAString& aType,
|
||||
//*****************************************************************************
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
NS_IMETHODIMP
|
||||
Navigator::GetMozTime(nsIDOMMozTimeManager** aTime)
|
||||
Navigator::GetMozTime(nsISupports** aTime)
|
||||
{
|
||||
*aTime = nullptr;
|
||||
|
||||
@ -1489,7 +1489,7 @@ Navigator::GetMozTime(nsIDOMMozTimeManager** aTime)
|
||||
}
|
||||
|
||||
if (!mTimeManager) {
|
||||
mTimeManager = new time::TimeManager();
|
||||
mTimeManager = new time::TimeManager(GetWindow());
|
||||
}
|
||||
|
||||
NS_ADDREF(*aTime = mTimeManager);
|
||||
|
@ -797,11 +797,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSFontFeatureValuesRule, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
NS_DEFINE_CLASSINFO_DATA(MozTimeManager, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
#endif
|
||||
};
|
||||
|
||||
#define NS_DEFINE_CONTRACT_CTOR(_class, _contract_id) \
|
||||
@ -1925,12 +1920,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFeatureValuesRule)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozTimeManager, nsIDOMMozTimeManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozTimeManager)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
#endif
|
||||
|
||||
MOZ_STATIC_ASSERT(MOZ_ARRAY_LENGTH(sClassInfoData) == eDOMClassInfoIDCount,
|
||||
"The number of items in sClassInfoData doesn't match the "
|
||||
"number of nsIDOMClassInfo ID's, this is bad! Fix it!");
|
||||
|
@ -191,10 +191,3 @@ DOMCI_CLASS(AsyncScrollEventDetail)
|
||||
DOMCI_CLASS(LockedFile)
|
||||
|
||||
DOMCI_CLASS(CSSFontFeatureValuesRule)
|
||||
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
DOMCI_CLASS(MozTimeManager)
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WEBRTC
|
||||
#endif
|
||||
|
@ -652,6 +652,14 @@ DOMInterfaces = {
|
||||
'workers': True,
|
||||
}],
|
||||
|
||||
'MozNamedAttrMap': {
|
||||
'nativeType': 'nsDOMAttributeMap',
|
||||
},
|
||||
|
||||
'MozTimeManager': {
|
||||
'nativeType': 'mozilla::dom::time::TimeManager',
|
||||
},
|
||||
|
||||
'MozStkCommandEvent' : {
|
||||
'nativeType': 'mozilla::dom::icc::StkCommandEvent',
|
||||
'headerFile': 'StkCommandEvent.h',
|
||||
@ -672,10 +680,6 @@ DOMInterfaces = {
|
||||
'previousSibling', 'nextSibling' ]
|
||||
},
|
||||
|
||||
'MozNamedAttrMap': {
|
||||
'nativeType': 'nsDOMAttributeMap',
|
||||
},
|
||||
|
||||
'Node': {
|
||||
'nativeType': 'nsINode',
|
||||
'concrete': False,
|
||||
|
@ -20,7 +20,7 @@ var gData = [
|
||||
{
|
||||
perm: ["time"],
|
||||
obj: "mozTime",
|
||||
idl: "nsIDOMMozTimeManager",
|
||||
webidl: "MozTimeManager",
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
@ -2,56 +2,46 @@
|
||||
* 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/. */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsITimeService.h"
|
||||
#include "TimeManager.h"
|
||||
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
DOMCI_DATA(MozTimeManager, mozilla::dom::time::TimeManager)
|
||||
#endif
|
||||
#include "mozilla/dom/MozTimeManagerBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsITimeService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace time {
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(TimeManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMozTimeManager)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TimeManager)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozTimeManager)
|
||||
#endif
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(TimeManager)
|
||||
NS_IMPL_RELEASE(TimeManager)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(TimeManager)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(TimeManager)
|
||||
|
||||
nsresult
|
||||
TimeManager::Set(const JS::Value& date, JSContext* ctx) {
|
||||
double dateMSec;
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(TimeManager, mWindow)
|
||||
|
||||
if (date.isObject()) {
|
||||
JS::Rooted<JSObject*> dateObj(ctx, date.toObjectOrNull());
|
||||
JSObject*
|
||||
TimeManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
return MozTimeManagerBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
if (JS_ObjectIsDate(ctx, dateObj) && js_DateIsValid(dateObj)) {
|
||||
dateMSec = js_DateGetMsecSinceEpoch(dateObj);
|
||||
}
|
||||
else {
|
||||
NS_WARN_IF_FALSE(JS_ObjectIsDate(ctx, dateObj), "This is not a Date object");
|
||||
NS_WARN_IF_FALSE(js_DateIsValid(dateObj), "Date is not valid");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
} else if (date.isNumber()) {
|
||||
dateMSec = date.toNumber();
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
void
|
||||
TimeManager::Set(Date& aDate)
|
||||
{
|
||||
Set(aDate.TimeStamp());
|
||||
}
|
||||
|
||||
void
|
||||
TimeManager::Set(double aTime)
|
||||
{
|
||||
nsCOMPtr<nsITimeService> timeService = do_GetService(TIMESERVICE_CONTRACTID);
|
||||
if (timeService) {
|
||||
return timeService->Set(dateMSec);
|
||||
timeService->Set(aTime);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace time
|
||||
|
@ -5,18 +5,51 @@
|
||||
#ifndef mozilla_dom_time_TimeManager_h
|
||||
#define mozilla_dom_time_TimeManager_h
|
||||
|
||||
#include "nsIDOMTimeManager.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Date;
|
||||
|
||||
namespace time {
|
||||
|
||||
class TimeManager MOZ_FINAL : public nsIDOMMozTimeManager
|
||||
class TimeManager MOZ_FINAL : public nsISupports
|
||||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMMOZTIMEMANAGER
|
||||
static bool PrefEnabled()
|
||||
{
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TimeManager)
|
||||
|
||||
explicit TimeManager(nsPIDOMWindow* aWindow)
|
||||
: mWindow(aWindow)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
nsPIDOMWindow* GetParentObject() const
|
||||
{
|
||||
return mWindow;
|
||||
}
|
||||
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope);
|
||||
|
||||
void Set(Date& aDate);
|
||||
void Set(double aTime);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
};
|
||||
|
||||
} // namespace time
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMNavigatorTime.idl',
|
||||
'nsIDOMTimeManager.idl',
|
||||
'nsITimeService.idl',
|
||||
]
|
||||
|
||||
@ -17,6 +16,7 @@ MODULE = 'dom'
|
||||
EXPORTS.mozilla.dom.time += [
|
||||
'DateCacheCleaner.h',
|
||||
'TimeChangeObserver.h',
|
||||
'TimeManager.h',
|
||||
'TimeService.h',
|
||||
]
|
||||
|
||||
|
@ -4,10 +4,8 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMMozTimeManager;
|
||||
|
||||
[scriptable, uuid(befc186d-c249-4acb-8e70-8080f7b45e5c)]
|
||||
[scriptable, uuid(88df63f0-814d-4424-b1f9-9184149639e5)]
|
||||
interface nsIDOMMozNavigatorTime : nsISupports
|
||||
{
|
||||
readonly attribute nsIDOMMozTimeManager mozTime;
|
||||
readonly attribute nsISupports /* MozTimeManager */ mozTime;
|
||||
};
|
||||
|
@ -2,11 +2,8 @@
|
||||
* 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/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, builtinclass, uuid(d29beaaa-bd54-4fd5-9f18-e0eedb1dc96d)]
|
||||
interface nsIDOMMozTimeManager : nsISupports
|
||||
{
|
||||
[PrefControlled]
|
||||
interface MozTimeManager {
|
||||
/* Set the system time.
|
||||
*
|
||||
* The |time| argument can be either a Date object or a number.
|
||||
@ -16,5 +13,6 @@ interface nsIDOMMozTimeManager : nsISupports
|
||||
* - If |time| is a Date object, |set(time)| is equivalent to
|
||||
* |set(time.getTime())|.
|
||||
*/
|
||||
[implicit_jscontext] void set(in jsval time);
|
||||
void set(Date time);
|
||||
void set(double time);
|
||||
};
|
@ -181,6 +181,7 @@ webidl_files = \
|
||||
MozActivity.webidl \
|
||||
MozMmsMessage.webidl \
|
||||
MozNamedAttrMap.webidl \
|
||||
MozTimeManager.webidl \
|
||||
MutationEvent.webidl \
|
||||
MutationObserver.webidl \
|
||||
NetDashboard.webidl \
|
||||
|
Loading…
Reference in New Issue
Block a user