Merge inbound to m-c.

This commit is contained in:
Ryan VanderMeulen 2014-02-28 16:03:19 -05:00
commit a94a1ab0bc
144 changed files with 2589 additions and 1781 deletions

View File

@ -23,11 +23,11 @@
#include "nsEventStateManager.h"
#include "nsISelectionPrivate.h"
#include "nsISelectionController.h"
#include "mozilla/dom/TouchEvent.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/TouchEvents.h"
#include "nsView.h"
#include "nsGkAtoms.h"
#include "nsDOMTouchEvent.h"
#include "nsComponentManagerUtils.h"
@ -141,7 +141,7 @@ nsCoreUtils::DispatchTouchEvent(uint32_t aEventType, int32_t aX, int32_t aY,
nsIContent* aContent, nsIFrame* aFrame,
nsIPresShell* aPresShell, nsIWidget* aRootWidget)
{
if (!nsDOMTouchEvent::PrefEnabled())
if (!dom::TouchEvent::PrefEnabled())
return;
WidgetTouchEvent event(true, aEventType, aRootWidget);
@ -149,9 +149,8 @@ nsCoreUtils::DispatchTouchEvent(uint32_t aEventType, int32_t aX, int32_t aY,
event.time = PR_IntervalNow();
// XXX: Touch has an identifier of -1 to hint that it is synthesized.
nsRefPtr<mozilla::dom::Touch> t =
new mozilla::dom::Touch(-1, nsIntPoint(aX, aY),
nsIntPoint(1, 1), 0.0f, 1.0f);
nsRefPtr<dom::Touch> t = new dom::Touch(-1, nsIntPoint(aX, aY),
nsIntPoint(1, 1), 0.0f, 1.0f);
t->SetTarget(aContent);
event.touches.AppendElement(t);
nsEventStatus status = nsEventStatus_eIgnore;

View File

@ -933,7 +933,6 @@ Accessible::GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame)
if (canvasFrame) {
*aBoundingFrame = canvasFrame;
nsPresContext* presContext = mDoc->PresContext();
aTotalBounds = *hitRegionRect;
return;

View File

@ -1791,7 +1791,6 @@ HyperTextAccessible::GetSpellTextAttribute(nsINode* aNode,
return NS_OK;
int32_t startHTOffset = 0, endHTOffset = 0;
nsresult rv = NS_OK;
for (int32_t idx = 0; idx < rangeCount; idx++) {
nsRange* range = domSel->GetRangeAt(idx);
if (range->Collapsed())

View File

@ -533,7 +533,7 @@ class Automation(object):
# will otherwise lead to OOM conditions on the current test slaves.
if totalMemory <= 1024 * 1024 * 4:
self.log.info("INFO | automation.py | ASan running in low-memory configuration")
env["ASAN_OPTIONS"] = "quarantine_size=50331648"
env["ASAN_OPTIONS"] = "quarantine_size=50331648:malloc_context_size=5"
else:
self.log.info("INFO | automation.py | ASan running in default memory configuration")
except OSError,err:

View File

@ -479,7 +479,7 @@ def environment(xrePath, env=None, crashreporter=True, debugger=False, dmdPath=N
message = "INFO | runtests.py | ASan running in %s configuration"
if totalMemory <= 1024 * 1024 * 4:
message = message % 'low-memory'
env["ASAN_OPTIONS"] = "quarantine_size=50331648"
env["ASAN_OPTIONS"] = "quarantine_size=50331648:malloc_context_size=5"
else:
message = message % 'default memory'
except OSError,err:

View File

@ -32,7 +32,6 @@ class nsCSSStyleSheet;
class nsIDocShell;
class nsDocShell;
class nsDOMNavigationTiming;
class nsDOMTouchList;
class nsEventStates;
class nsFrameLoader;
class nsHTMLCSSStyleSheet;
@ -113,6 +112,7 @@ class NodeFilter;
class NodeIterator;
class ProcessingInstruction;
class Touch;
class TouchList;
class TreeWalker;
class UndoManager;
class XPathEvaluator;
@ -2200,11 +2200,11 @@ public:
int32_t aScreenX, int32_t aScreenY, int32_t aClientX,
int32_t aClientY, int32_t aRadiusX, int32_t aRadiusY,
float aRotationAngle, float aForce);
already_AddRefed<nsDOMTouchList> CreateTouchList();
already_AddRefed<nsDOMTouchList>
already_AddRefed<mozilla::dom::TouchList> CreateTouchList();
already_AddRefed<mozilla::dom::TouchList>
CreateTouchList(mozilla::dom::Touch& aTouch,
const mozilla::dom::Sequence<mozilla::dom::OwningNonNull<mozilla::dom::Touch> >& aTouches);
already_AddRefed<nsDOMTouchList>
already_AddRefed<mozilla::dom::TouchList>
CreateTouchList(const mozilla::dom::Sequence<mozilla::dom::OwningNonNull<mozilla::dom::Touch> >& aTouches);
void SetStyleSheetChangeEventsEnabled(bool aValue)

View File

@ -39,6 +39,7 @@
#include "mozilla/dom/HTMLTemplateElement.h"
#include "mozilla/dom/HTMLContentElement.h"
#include "mozilla/dom/TextDecoder.h"
#include "mozilla/dom/TouchEvent.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/InternalMutationEvent.h"
#include "mozilla/Likely.h"
@ -70,7 +71,6 @@
#include "mozilla/dom/DataTransfer.h"
#include "nsDOMJSUtils.h"
#include "nsDOMMutationObserver.h"
#include "nsDOMTouchEvent.h"
#include "nsError.h"
#include "nsEventDispatcher.h"
#include "nsEventListenerManager.h"

View File

@ -179,8 +179,8 @@
#include "mozilla/dom/HTMLElementBinding.h"
#include "mozilla/dom/SVGElementBinding.h"
#include "nsXULAppAPI.h"
#include "nsDOMTouchEvent.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/dom/TouchEvent.h"
#include "DictionaryHelpers.h"
#include "GeneratedEvents.h"
@ -10013,18 +10013,18 @@ nsIDocument::CreateTouch(nsIDOMWindow* aView,
return touch.forget();
}
already_AddRefed<nsDOMTouchList>
already_AddRefed<TouchList>
nsIDocument::CreateTouchList()
{
nsRefPtr<nsDOMTouchList> retval = new nsDOMTouchList(ToSupports(this));
nsRefPtr<TouchList> retval = new TouchList(ToSupports(this));
return retval.forget();
}
already_AddRefed<nsDOMTouchList>
already_AddRefed<TouchList>
nsIDocument::CreateTouchList(Touch& aTouch,
const Sequence<OwningNonNull<Touch> >& aTouches)
{
nsRefPtr<nsDOMTouchList> retval = new nsDOMTouchList(ToSupports(this));
nsRefPtr<TouchList> retval = new TouchList(ToSupports(this));
retval->Append(&aTouch);
for (uint32_t i = 0; i < aTouches.Length(); ++i) {
retval->Append(aTouches[i].get());
@ -10032,10 +10032,10 @@ nsIDocument::CreateTouchList(Touch& aTouch,
return retval.forget();
}
already_AddRefed<nsDOMTouchList>
already_AddRefed<TouchList>
nsIDocument::CreateTouchList(const Sequence<OwningNonNull<Touch> >& aTouches)
{
nsRefPtr<nsDOMTouchList> retval = new nsDOMTouchList(ToSupports(this));
nsRefPtr<TouchList> retval = new TouchList(ToSupports(this));
for (uint32_t i = 0; i < aTouches.Length(); ++i) {
retval->Append(aTouches[i].get());
}

View File

@ -97,9 +97,9 @@
#include "nsThreadUtils.h"
#include "nsTextFragment.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/TouchEvent.h"
#include "mozilla/ErrorResult.h"
#include "nsHTMLDocument.h"
#include "nsDOMTouchEvent.h"
#include "nsGlobalWindow.h"
#include "mozilla/dom/HTMLBodyElement.h"
#include "imgIContainer.h"
@ -1955,7 +1955,7 @@ nsGenericHTMLElement::SetUndoScopeInternal(bool aUndoScope)
bool
nsGenericHTMLElement::TouchEventsEnabled(JSContext* /* unused */, JSObject* /* unused */)
{
return nsDOMTouchEvent::PrefEnabled();
return TouchEvent::PrefEnabled();
}
//----------------------------------------------------------------------

View File

@ -268,8 +268,8 @@ protected:
TrackTicks aStart, TrackTicks aEnd)
{
NS_ASSERTION(aStart <= aEnd, "Endpoints inverted");
NS_ASSERTION(aStart >= 0 && aEnd <= aSource.mDuration,
"Slice out of range");
NS_WARN_IF_FALSE(aStart >= 0 && aEnd <= aSource.mDuration,
"Slice out of range");
mDuration += aEnd - aStart;
TrackTicks offset = 0;
for (uint32_t i = 0; i < aSource.mChunks.Length() && offset < aEnd; ++i) {

View File

@ -1239,9 +1239,9 @@ MediaStreamGraphImpl::RunThread()
} else {
ps->ProduceOutput(prevComputedTime, mStateComputedTime,
ProcessedMediaStream::ALLOW_FINISH);
NS_ASSERTION(stream->mBuffer.GetEnd() >=
GraphTimeToStreamTime(stream, mStateComputedTime),
"Stream did not produce enough data");
NS_WARN_IF_FALSE(stream->mBuffer.GetEnd() >=
GraphTimeToStreamTime(stream, mStateComputedTime),
"Stream did not produce enough data");
}
}
}

View File

@ -63,7 +63,7 @@ inline StreamTime TicksToTimeRound(TrackRate aRate, TrackTicks aTicks)
inline StreamTime TicksToTimeRoundDown(TrackRate aRate, TrackTicks aTicks)
{
NS_ASSERTION(0 < aRate && aRate <= TRACK_RATE_MAX, "Bad rate");
NS_ASSERTION(0 <= aTicks && aTicks <= TRACK_TICKS_MAX, "Bad samples");
NS_WARN_IF_FALSE(0 <= aTicks && aTicks <= TRACK_TICKS_MAX, "Bad samples");
return (aTicks << MEDIA_TIME_FRAC_BITS)/aRate;
}

View File

@ -249,8 +249,8 @@ protected:
StreamTime outputEnd = GraphTimeToStreamTime(interval.mEnd);
TrackTicks startTicks = outputTrack->GetEnd();
StreamTime outputStart = GraphTimeToStreamTime(interval.mStart);
NS_ASSERTION(startTicks == TimeToTicksRoundUp(rate, outputStart),
"Samples missing");
NS_WARN_IF_FALSE(startTicks == TimeToTicksRoundUp(rate, outputStart),
"Samples missing");
TrackTicks endTicks = TimeToTicksRoundUp(rate, outputEnd);
TrackTicks ticks = endTicks - startTicks;
StreamTime inputStart = source->GraphTimeToStreamTime(interval.mStart);

View File

@ -20,8 +20,8 @@ namespace dom {
SVGZoomEvent::SVGZoomEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetGUIEvent* aEvent)
: nsDOMUIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetGUIEvent(false, NS_SVG_ZOOM, 0))
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetGUIEvent(false, NS_SVG_ZOOM, 0))
, mPreviousScale(0)
, mNewScale(0)
{

View File

@ -6,11 +6,11 @@
#ifndef mozilla_dom_SVGZoomEvent_h
#define mozilla_dom_SVGZoomEvent_h
#include "nsAutoPtr.h"
#include "nsDOMUIEvent.h"
#include "DOMSVGPoint.h"
#include "mozilla/EventForwards.h"
#include "mozilla/dom/UIEvent.h"
#include "mozilla/dom/SVGZoomEventBinding.h"
#include "mozilla/EventForwards.h"
#include "nsAutoPtr.h"
class nsPresContext;
@ -20,14 +20,14 @@ class nsISVGPoint;
namespace dom {
class SVGZoomEvent MOZ_FINAL : public nsDOMUIEvent
class SVGZoomEvent MOZ_FINAL : public UIEvent
{
public:
SVGZoomEvent(EventTarget* aOwner, nsPresContext* aPresContext,
WidgetGUIEvent* aEvent);
// Forward to base class
NS_FORWARD_TO_NSDOMUIEVENT
NS_FORWARD_TO_UIEVENT
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE

View File

@ -136,7 +136,7 @@
#include "nsIEventListenerService.h"
#include "nsIMessageManager.h"
#include "nsDOMTouchEvent.h"
#include "mozilla/dom/TouchEvent.h"
#include "nsWrapperCacheInlines.h"
#include "mozilla/dom/HTMLCollectionBinding.h"
@ -868,7 +868,7 @@ nsDOMClassInfo::RegisterExternalClasses()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowPerformance) \
DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor) \
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver, \
nsDOMTouchEvent::PrefEnabled())
TouchEvent::PrefEnabled())
#else // !MOZ_B2G
#define DOM_CLASSINFO_WINDOW_MAP_ENTRIES \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow) \
@ -878,7 +878,7 @@ nsDOMClassInfo::RegisterExternalClasses()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowPerformance) \
DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor) \
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver, \
nsDOMTouchEvent::PrefEnabled())
TouchEvent::PrefEnabled())
#endif // MOZ_B2G
nsresult

View File

@ -64,7 +64,8 @@ DOMCI_CASTABLE_INTERFACE(nsSVGElement, nsIContent, 9, _extra) \
/* NOTE: When removing the casts below, remove the nsDOMEventBase class */ \
DOMCI_CASTABLE_NODECL_INTERFACE(mozilla::dom::MouseEvent, \
nsDOMEventBase, 10, _extra) \
DOMCI_CASTABLE_INTERFACE(nsDOMUIEvent, nsDOMEventBase, 11, _extra) \
DOMCI_CASTABLE_NODECL_INTERFACE(mozilla::dom::UIEvent, \
nsDOMEventBase, 11, _extra) \
DOMCI_CASTABLE_INTERFACE(nsGlobalWindow, nsIDOMEventTarget, 12, _extra)
// Make sure all classes mentioned in DOMCI_CASTABLE_INTERFACES
@ -79,6 +80,7 @@ namespace dom {
class Element;
class EventTarget;
class MouseEvent;
class UIEvent;
} // namespace dom
} // namespace mozilla

View File

@ -721,19 +721,8 @@ static const char js_werror_option_str[] = JS_OPTIONS_DOT_STR "werror";
static const char js_zeal_option_str[] = JS_OPTIONS_DOT_STR "gczeal";
static const char js_zeal_frequency_str[] = JS_OPTIONS_DOT_STR "gczeal.frequency";
#endif
static const char js_typeinfer_content_str[] = JS_OPTIONS_DOT_STR "typeinference.content";
static const char js_typeinfer_chrome_str[] = JS_OPTIONS_DOT_STR "typeinference.chrome";
static const char js_memlog_option_str[] = JS_OPTIONS_DOT_STR "mem.log";
static const char js_memnotify_option_str[] = JS_OPTIONS_DOT_STR "mem.notify";
static const char js_asmjs_content_str[] = JS_OPTIONS_DOT_STR "asmjs";
static const char js_baselinejit_content_str[] = JS_OPTIONS_DOT_STR "baselinejit.content";
static const char js_baselinejit_chrome_str[] = JS_OPTIONS_DOT_STR "baselinejit.chrome";
static const char js_baselinejit_eager_str[] = JS_OPTIONS_DOT_STR "baselinejit.unsafe_eager_compilation";
static const char js_ion_content_str[] = JS_OPTIONS_DOT_STR "ion.content";
static const char js_ion_chrome_str[] = JS_OPTIONS_DOT_STR "ion.chrome";
static const char js_ion_eager_str[] = JS_OPTIONS_DOT_STR "ion.unsafe_eager_compilation";
static const char js_parallel_parsing_str[] = JS_OPTIONS_DOT_STR "parallel_parsing";
static const char js_ion_parallel_compilation_str[] = JS_OPTIONS_DOT_STR "ion.parallel_compilation";
void
nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
@ -756,39 +745,6 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
nsCOMPtr<nsIDOMWindow> contentWindow(do_QueryInterface(global));
nsCOMPtr<nsIDOMChromeWindow> chromeWindow(do_QueryInterface(global));
bool useTypeInference = Preferences::GetBool((chromeWindow || !contentWindow) ?
js_typeinfer_chrome_str :
js_typeinfer_content_str);
bool useBaselineJIT = Preferences::GetBool((chromeWindow || !contentWindow) ?
js_baselinejit_chrome_str :
js_baselinejit_content_str);
bool useBaselineJITEager = Preferences::GetBool(js_baselinejit_eager_str);
bool useIon = Preferences::GetBool((chromeWindow || !contentWindow) ?
js_ion_chrome_str :
js_ion_content_str);
bool useIonEager = Preferences::GetBool(js_ion_eager_str);
bool useAsmJS = Preferences::GetBool(js_asmjs_content_str);
bool parallelParsing = Preferences::GetBool(js_parallel_parsing_str);
bool parallelIonCompilation = Preferences::GetBool(js_ion_parallel_compilation_str);
nsCOMPtr<nsIXULRuntime> xr = do_GetService(XULRUNTIME_SERVICE_CONTRACTID);
if (xr) {
bool safeMode = false;
xr->GetInSafeMode(&safeMode);
if (safeMode) {
useTypeInference = false;
useBaselineJIT = false;
useBaselineJITEager = false;
useIon = false;
useIonEager = false;
useAsmJS = false;
}
}
JS::ContextOptionsRef(cx).setTypeInference(useTypeInference)
.setBaseline(useBaselineJIT)
.setIon(useIon)
.setAsmJS(useAsmJS);
#ifdef DEBUG
// In debug builds, warnings are enabled in chrome context if
// javascript.options.strict.debug is true
@ -800,15 +756,6 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
JS::ContextOptionsRef(cx).setWerror(Preferences::GetBool(js_werror_option_str));
::JS_SetParallelParsingEnabled(context->mContext, parallelParsing);
::JS_SetParallelIonCompilationEnabled(context->mContext, parallelIonCompilation);
::JS_SetGlobalJitCompilerOption(context->mContext, JSJITCOMPILER_BASELINE_USECOUNT_TRIGGER,
(useBaselineJITEager ? 0 : -1));
::JS_SetGlobalJitCompilerOption(context->mContext, JSJITCOMPILER_ION_USECOUNT_TRIGGER,
(useIonEager ? 0 : -1));
#ifdef JS_GC_ZEAL
int32_t zeal = Preferences::GetInt(js_zeal_option_str, -1);
int32_t frequency = Preferences::GetInt(js_zeal_frequency_str, JS_DEFAULT_ZEAL_FREQ);

View File

@ -340,10 +340,11 @@ public:
// keep the same document active but create a new window.
bool HasActiveDocument()
{
MOZ_ASSERT(IsInnerWindow());
return IsCurrentInnerWindow() ||
(GetOuterWindow() &&
GetOuterWindow()->GetCurrentInnerWindow() &&
GetOuterWindow()->GetCurrentInnerWindow()->GetDoc() == mDoc);
(mOuterWindow &&
mOuterWindow->GetCurrentInnerWindow() &&
mOuterWindow->GetCurrentInnerWindow()->GetDoc() == mDoc);
}
bool IsOuterWindow() const

View File

@ -222,64 +222,6 @@ nsScreen::GetLockOrientationPermission() const
return doc->MozFullScreen() ? FULLSCREEN_LOCK_ALLOWED : LOCK_DENIED;
}
NS_IMETHODIMP
nsScreen::MozLockOrientation(JS::Handle<JS::Value> aOrientation, JSContext* aCx,
bool* aReturn)
{
if (aOrientation.isObject()) {
JS::Rooted<JSObject*> seq(aCx, &aOrientation.toObject());
if (IsArrayLike(aCx, seq)) {
uint32_t length;
// JS_GetArrayLength actually works on all objects
if (!JS_GetArrayLength(aCx, seq, &length)) {
return NS_ERROR_FAILURE;
}
Sequence<nsString> orientations;
if (!orientations.SetCapacity(length)) {
return NS_ERROR_OUT_OF_MEMORY;
}
for (uint32_t i = 0; i < length; ++i) {
JS::Rooted<JS::Value> temp(aCx);
if (!JS_GetElement(aCx, seq, i, &temp)) {
return NS_ERROR_FAILURE;
}
JS::Rooted<JSString*> jsString(aCx, JS::ToString(aCx, temp));
if (!jsString) {
return NS_ERROR_FAILURE;
}
nsDependentJSString str;
if (!str.init(aCx, jsString)) {
return NS_ERROR_FAILURE;
}
*orientations.AppendElement() = str;
}
ErrorResult rv;
*aReturn = MozLockOrientation(orientations, rv);
return rv.ErrorCode();
}
}
JS::Rooted<JSString*> jsString(aCx, JS::ToString(aCx, aOrientation));
if (!jsString) {
return NS_ERROR_FAILURE;
}
nsDependentJSString orientation;
if (!orientation.init(aCx, jsString)) {
return NS_ERROR_FAILURE;
}
ErrorResult rv;
*aReturn = MozLockOrientation(orientation, rv);
return rv.ErrorCode();
}
bool
nsScreen::MozLockOrientation(const nsAString& aOrientation, ErrorResult& aRv)
{
@ -365,13 +307,6 @@ nsScreen::MozUnlockOrientation()
hal::UnlockScreenOrientation();
}
NS_IMETHODIMP
nsScreen::SlowMozUnlockOrientation()
{
MozUnlockOrientation();
return NS_OK;
}
bool
nsScreen::IsDeviceSizePageSize()
{

View File

@ -263,12 +263,6 @@ IsNotDateOrRegExp(JSContext* cx, JS::Handle<JSObject*> obj)
return !JS_ObjectIsDate(cx, obj) && !JS_ObjectIsRegExp(cx, obj);
}
MOZ_ALWAYS_INLINE bool
IsArrayLike(JSContext* cx, JS::Handle<JSObject*> obj)
{
return IsNotDateOrRegExp(cx, obj);
}
MOZ_ALWAYS_INLINE bool
IsObjectValueConvertibleToDictionary(JSContext* cx,
JS::Handle<JS::Value> objVal)

View File

@ -97,10 +97,6 @@ DOMInterfaces = {
'concrete': False
},
'AnimationEvent': {
'nativeType': 'mozilla::dom::AnimationEvent',
},
'ArchiveReader': {
'nativeType': 'mozilla::dom::file::ArchiveReader',
},
@ -140,10 +136,6 @@ DOMInterfaces = {
'resultNotAddRefed': [ 'inputBuffer', 'outputBuffer' ],
},
'BeforeUnloadEvent': {
'nativeType': 'mozilla::dom::BeforeUnloadEvent',
},
'BarProp': {
'headerFile': 'mozilla/dom/BarProps.h',
},
@ -233,18 +225,6 @@ DOMInterfaces = {
'resultNotAddRefed': [ 'item' ]
},
'ClipboardEvent': {
'nativeType': 'mozilla::dom::ClipboardEvent',
},
'CommandEvent': {
'nativeType': 'mozilla::dom::CommandEvent',
},
'CompositionEvent': {
'nativeType': 'mozilla::dom::CompositionEvent',
},
'Console': {
'implicitJSContext': [ 'trace', 'time', 'timeEnd' ],
},
@ -303,10 +283,6 @@ DOMInterfaces = {
'nativeType': 'nsDOMDataChannel',
},
'DataContainerEvent': {
'nativeType': 'mozilla::dom::DataContainerEvent',
},
'DedicatedWorkerGlobalScope': {
'headerFile': 'mozilla/dom/WorkerScope.h',
'workers': True,
@ -852,14 +828,6 @@ DOMInterfaces = {
'resultNotAddRefed': [ 'item' ]
},
'NotifyPaintEvent': {
'nativeType': 'nsDOMNotifyPaintEvent',
},
'NotifyAudioAvailableEvent': {
'nativeType': 'nsDOMNotifyAudioAvailableEvent',
},
'OfflineAudioCompletionEvent': {
'resultNotAddRefed': [ 'renderedBuffer' ],
},
@ -958,10 +926,6 @@ DOMInterfaces = {
'nativeType': 'nsScreen',
},
'ScrollAreaEvent': {
'nativeType': 'nsDOMScrollAreaEvent',
},
'Selection': {
'nativeType': 'mozilla::Selection',
'resultNotAddRefed': [ 'anchorNode', 'focusNode', 'getRangeAt' ],
@ -1247,25 +1211,12 @@ DOMInterfaces = {
'nativeOwnership': 'owned',
},
'TimeEvent': {
'nativeType': 'nsDOMTimeEvent',
},
'TimeRanges': {
'wrapperCache': False
},
'TouchEvent': {
'nativeType': 'nsDOMTouchEvent',
},
'TouchList': {
'nativeType': 'nsDOMTouchList',
'headerFile': 'nsDOMTouchEvent.h',
},
'TransitionEvent': {
'nativeType': 'nsDOMTransitionEvent',
'headerFile': 'mozilla/dom/TouchEvent.h',
},
'TreeColumns': {
@ -1277,10 +1228,6 @@ DOMInterfaces = {
'resultNotAddRefed': [ 'root', 'currentNode' ],
},
'UIEvent': {
'nativeType': 'nsDOMUIEvent',
},
'UndoManager': {
'implicitJSContext' : [ 'undo', 'redo', 'transact' ],
},
@ -1478,10 +1425,6 @@ DOMInterfaces = {
'headerFile': 'WebSocket.h',
},
'WheelEvent': {
'nativeType': 'mozilla::dom::WheelEvent',
},
'Window': {
'nativeType': 'nsGlobalWindow',
# When turning on Window, remember to drop the "'register': False"
@ -1579,10 +1522,6 @@ DOMInterfaces = {
'headerFile': 'XULDocument.h'
},
'XULCommandEvent': {
'nativeType': 'nsDOMXULCommandEvent',
},
'XULElement': {
'nativeType': 'nsXULElement',
'resultNotAddRefed': [ 'controllers', 'style' ]

View File

@ -3105,31 +3105,35 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
arrayRef = "${declName}"
# NOTE: Keep this in sync with variadic conversions as needed
templateBody = ("""JS::Rooted<JSObject*> seq(cx, &${val}.toObject());\n
if (!IsArrayLike(cx, seq)) {
templateBody = ("""JS::ForOfIterator iter(cx);
if (!iter.init(${val}, JS::ForOfIterator::AllowNonIterable)) {
%s
}
uint32_t length;
// JS_GetArrayLength actually works on all objects
if (!JS_GetArrayLength(cx, seq, &length)) {
if (!iter.valueIsIterable()) {
%s
}
%s &arr = %s;
if (!arr.SetCapacity(length)) {
JS_ReportOutOfMemory(cx);
%s
}
for (uint32_t i = 0; i < length; ++i) {
JS::Rooted<JS::Value> temp(cx);
if (!JS_GetElement(cx, seq, i, &temp)) {
JS::Rooted<JS::Value> temp(cx);
while (true) {
bool done;
if (!iter.next(&temp, &done)) {
%s
}
%s& slot = *arr.AppendElement();
""" % (CGIndenter(CGGeneric(notSequence)).define(),
exceptionCodeIndented.define(),
if (done) {
break;
}
%s* slotPtr = arr.AppendElement();
if (!slotPtr) {
JS_ReportOutOfMemory(cx);
%s
}
%s& slot = *slotPtr;
""" % (exceptionCodeIndented.define(),
CGIndenter(CGGeneric(notSequence)).define(),
sequenceType,
arrayRef,
exceptionCodeIndented.define(),
CGIndenter(exceptionCodeIndented).define(),
elementInfo.declType.define(),
CGIndenter(exceptionCodeIndented).define(),
elementInfo.declType.define()))
@ -3196,12 +3200,7 @@ for (uint32_t i = 0; i < length; ++i) {
arrayObjectMemberTypes = filter(lambda t: t.isArray() or t.isSequence(), memberTypes)
if len(arrayObjectMemberTypes) > 0:
assert len(arrayObjectMemberTypes) == 1
memberType = arrayObjectMemberTypes[0]
name = memberType.name
arrayObject = CGGeneric("done = (failed = !%s.TrySetTo%s(cx, ${val}, ${mutableVal}, tryNext)) || !tryNext;" % (unionArgumentObj, name))
arrayObject = CGIfWrapper(arrayObject, "IsArrayLike(cx, argObj)")
names.append(name)
raise TypeError("Bug 767924: We don't support sequences in unions yet")
else:
arrayObject = None

View File

@ -36,7 +36,6 @@ using namespace mozilla::dom;
using namespace mozilla::idl;
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMCameraControl)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY(nsIDOMMediaStream)
NS_INTERFACE_MAP_END_INHERITING(DOMMediaStream)
@ -44,53 +43,25 @@ NS_INTERFACE_MAP_END_INHERITING(DOMMediaStream)
NS_IMPL_ADDREF_INHERITED(nsDOMCameraControl, DOMMediaStream)
NS_IMPL_RELEASE_INHERITED(nsDOMCameraControl, DOMMediaStream)
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMCameraControl)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMCameraControl, DOMMediaStream)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCapabilities)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGetCameraOnSuccessCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGetCameraOnErrorCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAutoFocusOnSuccessCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAutoFocusOnErrorCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTakePictureOnSuccessCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTakePictureOnErrorCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mStartRecordingOnSuccessCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mStartRecordingOnErrorCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mReleaseOnSuccessCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mReleaseOnErrorCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSetConfigurationOnSuccessCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSetConfigurationOnErrorCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOnShutterCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOnClosedCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOnRecorderStateChangeCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOnPreviewStateChangeCb)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMCameraControl, DOMMediaStream)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCapabilities)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGetCameraOnSuccessCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGetCameraOnErrorCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAutoFocusOnSuccessCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAutoFocusOnErrorCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTakePictureOnSuccessCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTakePictureOnErrorCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStartRecordingOnSuccessCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStartRecordingOnErrorCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mReleaseOnSuccessCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mReleaseOnErrorCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSetConfigurationOnSuccessCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSetConfigurationOnErrorCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOnShutterCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOnClosedCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOnRecorderStateChangeCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOnPreviewStateChangeCb)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsDOMCameraControl)
NS_IMPL_CYCLE_COLLECTION_INHERITED_18(nsDOMCameraControl, DOMMediaStream,
mCapabilities,
mWindow,
mGetCameraOnSuccessCb,
mGetCameraOnErrorCb,
mAutoFocusOnSuccessCb,
mAutoFocusOnErrorCb,
mTakePictureOnSuccessCb,
mTakePictureOnErrorCb,
mStartRecordingOnSuccessCb,
mStartRecordingOnErrorCb,
mReleaseOnSuccessCb,
mReleaseOnErrorCb,
mSetConfigurationOnSuccessCb,
mSetConfigurationOnErrorCb,
mOnShutterCb,
mOnClosedCb,
mOnRecorderStateChangeCb,
mOnPreviewStateChangeCb)
class mozilla::StartRecordingHelper : public nsIDOMEventListener
{

View File

@ -37,7 +37,7 @@ class StartRecordingHelper;
class nsDOMCameraControl MOZ_FINAL : public DOMMediaStream
{
public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsDOMCameraControl, DOMMediaStream)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMCameraControl, DOMMediaStream)
NS_DECL_ISUPPORTS_INHERITED
nsDOMCameraControl(uint32_t aCameraId,

View File

@ -681,12 +681,15 @@ var steps = [
req.onerror = onFailure;
},
function() {
ok(true, "Test setting array properties to scalar values")
ok(true, "Test that after setting array properties to scalar values the property os not a non-array")
const FIELDS = ["email","url","adr","tel","impp"];
createResult1 = new mozContact();
for (var prop of FIELDS) {
createResult1[prop] = {type: ["foo"]};
ok(Array.isArray(createResult1[prop]), prop + " is array");
try {
createResult1[prop] = {type: ["foo"]};
} catch (e) {}
ok(createResult1[prop] === null ||
Array.isArray(createResult1[prop]), prop + " is array");
}
next();
},

View File

@ -14,8 +14,8 @@ namespace dom {
CompositionEvent::CompositionEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetCompositionEvent* aEvent)
: nsDOMUIEvent(aOwner, aPresContext, aEvent ? aEvent :
new WidgetCompositionEvent(false, 0, nullptr))
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetCompositionEvent(false, 0, nullptr))
{
NS_ASSERTION(mEvent->eventStructType == NS_COMPOSITION_EVENT,
"event type mismatch");
@ -36,12 +36,12 @@ CompositionEvent::CompositionEvent(EventTarget* aOwner,
// TODO: Native event should have locale information.
}
NS_IMPL_ADDREF_INHERITED(CompositionEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(CompositionEvent, nsDOMUIEvent)
NS_IMPL_ADDREF_INHERITED(CompositionEvent, UIEvent)
NS_IMPL_RELEASE_INHERITED(CompositionEvent, UIEvent)
NS_INTERFACE_MAP_BEGIN(CompositionEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMCompositionEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
NS_IMETHODIMP
CompositionEvent::GetData(nsAString& aData)
@ -65,8 +65,7 @@ CompositionEvent::InitCompositionEvent(const nsAString& aType,
const nsAString& aData,
const nsAString& aLocale)
{
nsresult rv =
nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
nsresult rv = UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
NS_ENSURE_SUCCESS(rv, rv);
mData = aData;

View File

@ -7,15 +7,15 @@
#ifndef mozilla_dom_CompositionEvent_h_
#define mozilla_dom_CompositionEvent_h_
#include "nsDOMUIEvent.h"
#include "nsIDOMCompositionEvent.h"
#include "mozilla/dom/CompositionEventBinding.h"
#include "mozilla/dom/UIEvent.h"
#include "mozilla/EventForwards.h"
#include "nsIDOMCompositionEvent.h"
namespace mozilla {
namespace dom {
class CompositionEvent : public nsDOMUIEvent,
class CompositionEvent : public UIEvent,
public nsIDOMCompositionEvent
{
public:
@ -24,7 +24,7 @@ public:
WidgetCompositionEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
NS_FORWARD_TO_NSDOMUIEVENT
NS_FORWARD_TO_UIEVENT
NS_DECL_NSIDOMCOMPOSITIONEVENT
virtual JSObject* WrapObject(JSContext* aCx,

View File

@ -320,7 +320,7 @@ NS_IMETHODIMP
DataTransfer::GetFiles(nsIDOMFileList** aFileList)
{
ErrorResult rv;
*aFileList = GetFiles(rv);
NS_IF_ADDREF(*aFileList = GetFiles(rv));
return rv.ErrorCode();
}

View File

@ -87,7 +87,6 @@ DragEvent::InitDragEvent(const nsAString& aType,
nsIDOMDataTransfer* aDataTransfer)
{
nsCOMPtr<DataTransfer> dataTransfer = do_QueryInterface(aDataTransfer);
NS_ENSURE_ARG(dataTransfer);
nsresult rv =
MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,

View File

@ -10,14 +10,13 @@
namespace mozilla {
namespace dom {
NS_IMPL_ISUPPORTS_INHERITED1(FocusEvent, nsDOMUIEvent, nsIDOMFocusEvent)
NS_IMPL_ISUPPORTS_INHERITED1(FocusEvent, UIEvent, nsIDOMFocusEvent)
FocusEvent::FocusEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalFocusEvent* aEvent)
: nsDOMUIEvent(aOwner, aPresContext,
aEvent ? aEvent :
new InternalFocusEvent(false, NS_FOCUS_CONTENT))
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new InternalFocusEvent(false, NS_FOCUS_CONTENT))
{
if (aEvent) {
mEventIsInternal = false;
@ -50,7 +49,8 @@ FocusEvent::InitFocusEvent(const nsAString& aType,
int32_t aDetail,
EventTarget* aRelatedTarget)
{
nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
nsresult rv =
UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
NS_ENSURE_SUCCESS(rv, rv);
mEvent->AsFocusEvent()->relatedTarget = aRelatedTarget;
return NS_OK;

View File

@ -5,15 +5,15 @@
#ifndef mozilla_dom_FocusEvent_h_
#define mozilla_dom_FocusEvent_h_
#include "nsDOMUIEvent.h"
#include "nsIDOMFocusEvent.h"
#include "mozilla/EventForwards.h"
#include "mozilla/dom/FocusEventBinding.h"
#include "mozilla/dom/UIEvent.h"
#include "mozilla/EventForwards.h"
#include "nsIDOMFocusEvent.h"
namespace mozilla {
namespace dom {
class FocusEvent : public nsDOMUIEvent,
class FocusEvent : public UIEvent,
public nsIDOMFocusEvent
{
public:
@ -21,7 +21,7 @@ public:
NS_DECL_NSIDOMFOCUSEVENT
// Forward to base class
NS_FORWARD_TO_NSDOMUIEVENT
NS_FORWARD_TO_UIEVENT
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE

View File

@ -13,8 +13,8 @@ namespace dom {
KeyboardEvent::KeyboardEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetKeyboardEvent* aEvent)
: nsDOMUIEvent(aOwner, aPresContext, aEvent ? aEvent :
new WidgetKeyboardEvent(false, 0, nullptr))
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetKeyboardEvent(false, 0, nullptr))
{
NS_ASSERTION(mEvent->eventStructType == NS_KEY_EVENT, "event type mismatch");
@ -28,12 +28,12 @@ KeyboardEvent::KeyboardEvent(EventTarget* aOwner,
}
}
NS_IMPL_ADDREF_INHERITED(KeyboardEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(KeyboardEvent, nsDOMUIEvent)
NS_IMPL_ADDREF_INHERITED(KeyboardEvent, UIEvent)
NS_IMPL_RELEASE_INHERITED(KeyboardEvent, UIEvent)
NS_INTERFACE_MAP_BEGIN(KeyboardEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMKeyEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
bool
KeyboardEvent::AltKey()
@ -212,7 +212,7 @@ KeyboardEvent::InitKeyEvent(const nsAString& aType,
uint32_t aKeyCode,
uint32_t aCharCode)
{
nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
nsresult rv = UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
NS_ENSURE_SUCCESS(rv, rv);
WidgetKeyboardEvent* keyEvent = mEvent->AsKeyboardEvent();

View File

@ -6,15 +6,15 @@
#ifndef mozilla_dom_KeyboardEvent_h_
#define mozilla_dom_KeyboardEvent_h_
#include "nsIDOMKeyEvent.h"
#include "nsDOMUIEvent.h"
#include "mozilla/EventForwards.h"
#include "mozilla/dom/UIEvent.h"
#include "mozilla/dom/KeyboardEventBinding.h"
#include "mozilla/EventForwards.h"
#include "nsIDOMKeyEvent.h"
namespace mozilla {
namespace dom {
class KeyboardEvent : public nsDOMUIEvent,
class KeyboardEvent : public UIEvent,
public nsIDOMKeyEvent
{
public:
@ -28,7 +28,7 @@ public:
NS_DECL_NSIDOMKEYEVENT
// Forward to base class
NS_FORWARD_TO_NSDOMUIEVENT
NS_FORWARD_TO_UIEVENT
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE

View File

@ -15,9 +15,9 @@ namespace dom {
MouseEvent::MouseEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetMouseEventBase* aEvent)
: nsDOMUIEvent(aOwner, aPresContext, aEvent ? aEvent :
new WidgetMouseEvent(false, 0, nullptr,
WidgetMouseEvent::eReal))
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetMouseEvent(false, 0, nullptr,
WidgetMouseEvent::eReal))
{
// There's no way to make this class' ctor allocate an WidgetMouseScrollEvent.
// It's not that important, though, since a scroll event is not a real
@ -41,12 +41,12 @@ MouseEvent::MouseEvent(EventTarget* aOwner,
}
}
NS_IMPL_ADDREF_INHERITED(MouseEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(MouseEvent, nsDOMUIEvent)
NS_IMPL_ADDREF_INHERITED(MouseEvent, UIEvent)
NS_IMPL_RELEASE_INHERITED(MouseEvent, UIEvent)
NS_INTERFACE_MAP_BEGIN(MouseEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
NS_IMETHODIMP
MouseEvent::InitMouseEvent(const nsAString& aType,
@ -65,7 +65,8 @@ MouseEvent::InitMouseEvent(const nsAString& aType,
uint16_t aButton,
nsIDOMEventTarget* aRelatedTarget)
{
nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
nsresult rv =
UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
NS_ENSURE_SUCCESS(rv, rv);
switch(mEvent->eventStructType) {

View File

@ -6,15 +6,15 @@
#ifndef mozilla_dom_MouseEvent_h_
#define mozilla_dom_MouseEvent_h_
#include "nsIDOMMouseEvent.h"
#include "nsDOMUIEvent.h"
#include "mozilla/dom/UIEvent.h"
#include "mozilla/dom/MouseEventBinding.h"
#include "mozilla/EventForwards.h"
#include "nsIDOMMouseEvent.h"
namespace mozilla {
namespace dom {
class MouseEvent : public nsDOMUIEvent,
class MouseEvent : public UIEvent,
public nsIDOMMouseEvent
{
public:
@ -28,7 +28,7 @@ public:
NS_DECL_NSIDOMMOUSEEVENT
// Forward to base class
NS_FORWARD_TO_NSDOMUIEVENT
NS_FORWARD_TO_UIEVENT
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
@ -121,6 +121,6 @@ protected:
#define NS_FORWARD_TO_MOUSEEVENT \
NS_FORWARD_NSIDOMMOUSEEVENT(MouseEvent::) \
NS_FORWARD_TO_NSDOMUIEVENT
NS_FORWARD_TO_UIEVENT
#endif // mozilla_dom_MouseEvent_h_

View File

@ -0,0 +1,182 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#include "mozilla/dom/NotifyAudioAvailableEvent.h"
#include "mozilla/HoldDropJSObjects.h"
#include "nsError.h"
#include "jsfriendapi.h"
namespace mozilla {
namespace dom {
NotifyAudioAvailableEvent::NotifyAudioAvailableEvent(
EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
float* aFrameBuffer,
uint32_t aFrameBufferLength,
float aTime)
: nsDOMEvent(aOwner, aPresContext, aEvent)
, mFrameBuffer(aFrameBuffer)
, mFrameBufferLength(aFrameBufferLength)
, mTime(aTime)
, mCachedArray(nullptr)
, mAllowAudioData(false)
{
MOZ_COUNT_CTOR(NotifyAudioAvailableEvent);
if (mEvent) {
mEvent->message = aEventType;
}
}
NS_IMPL_ADDREF_INHERITED(NotifyAudioAvailableEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(NotifyAudioAvailableEvent, nsDOMEvent)
NS_IMPL_CYCLE_COLLECTION_CLASS(NotifyAudioAvailableEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(NotifyAudioAvailableEvent,
nsDOMEvent)
if (tmp->mCachedArray) {
tmp->mCachedArray = nullptr;
DropJSObjects(tmp);
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(NotifyAudioAvailableEvent,
nsDOMEvent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(NotifyAudioAvailableEvent,
nsDOMEvent)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mCachedArray)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(NotifyAudioAvailableEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMNotifyAudioAvailableEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NotifyAudioAvailableEvent::~NotifyAudioAvailableEvent()
{
MOZ_COUNT_DTOR(NotifyAudioAvailableEvent);
if (mCachedArray) {
mCachedArray = nullptr;
mozilla::DropJSObjects(this);
}
}
NS_IMETHODIMP
NotifyAudioAvailableEvent::GetFrameBuffer(JSContext* aCx,
JS::MutableHandle<JS::Value> aResult)
{
if (!mAllowAudioData) {
// Media is not same-origin, don't allow the data out.
return NS_ERROR_DOM_SECURITY_ERR;
}
if (mCachedArray) {
aResult.setObject(*mCachedArray);
return NS_OK;
}
// Cache this array so we don't recreate on next call.
mozilla::HoldJSObjects(this);
mCachedArray = JS_NewFloat32Array(aCx, mFrameBufferLength);
if (!mCachedArray) {
mozilla::DropJSObjects(this);
return NS_ERROR_FAILURE;
}
memcpy(JS_GetFloat32ArrayData(mCachedArray), mFrameBuffer.get(),
mFrameBufferLength * sizeof(float));
aResult.setObject(*mCachedArray);
return NS_OK;
}
NS_IMETHODIMP
NotifyAudioAvailableEvent::GetTime(float* aRetVal)
{
*aRetVal = Time();
return NS_OK;
}
NS_IMETHODIMP
NotifyAudioAvailableEvent::InitAudioAvailableEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
float* aFrameBuffer,
uint32_t aFrameBufferLength,
float aTime,
bool aAllowAudioData)
{
// Auto manage the memory which stores the frame buffer. This ensures
// that if we exit due to some error, the memory will be freed. Otherwise,
// the framebuffer's memory will be freed when this event is destroyed.
nsAutoArrayPtr<float> frameBuffer(aFrameBuffer);
nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS(rv, rv);
mFrameBuffer = frameBuffer.forget();
mFrameBufferLength = aFrameBufferLength;
mTime = aTime;
mAllowAudioData = aAllowAudioData;
mCachedArray = nullptr;
return NS_OK;
}
void
NotifyAudioAvailableEvent::InitAudioAvailableEvent(
const nsAString& aType,
bool aCanBubble,
bool aCancelable,
const Nullable<Sequence<float> >& aFrameBuffer,
uint32_t aFrameBufferLength,
float aTime,
bool aAllowAudioData,
ErrorResult& aRv)
{
if ((aFrameBuffer.IsNull() && aFrameBufferLength > 0) ||
(!aFrameBuffer.IsNull() &&
aFrameBuffer.Value().Length() < aFrameBufferLength)) {
aRv = NS_ERROR_UNEXPECTED;
return;
}
nsAutoArrayPtr<float> buffer;
if (!aFrameBuffer.IsNull()) {
buffer = new float[aFrameBufferLength];
memcpy(buffer.get(), aFrameBuffer.Value().Elements(),
aFrameBufferLength * sizeof(float));
}
aRv = InitAudioAvailableEvent(aType, aCanBubble, aCancelable,
buffer.forget(),
aFrameBufferLength,
aTime, aAllowAudioData);
}
} // namespace dom
} // namespace mozilla
using namespace mozilla;
using namespace mozilla::dom;
nsresult
NS_NewDOMAudioAvailableEvent(nsIDOMEvent** aInstancePtrResult,
EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
float* aFrameBuffer,
uint32_t aFrameBufferLength,
float aTime)
{
NotifyAudioAvailableEvent* it =
new NotifyAudioAvailableEvent(aOwner, aPresContext, aEvent, aEventType,
aFrameBuffer, aFrameBufferLength, aTime);
return CallQueryInterface(it, aInstancePtrResult);
}

View File

@ -0,0 +1,78 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#ifndef mozilla_dom_NotifyAudioAvailableEvent_h_
#define mozilla_dom_NotifyAudioAvailableEvent_h_
#include "nsIDOMNotifyAudioAvailableEvent.h"
#include "nsDOMEvent.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/dom/NotifyAudioAvailableEventBinding.h"
class nsPresContext;
namespace mozilla {
namespace dom {
class NotifyAudioAvailableEvent : public nsDOMEvent,
public nsIDOMNotifyAudioAvailableEvent
{
public:
NotifyAudioAvailableEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
float* aFrameBuffer,
uint32_t aFrameBufferLength,
float aTime);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
NotifyAudioAvailableEvent, nsDOMEvent)
NS_DECL_NSIDOMNOTIFYAUDIOAVAILABLEEVENT
NS_FORWARD_NSIDOMEVENT(nsDOMEvent::)
~NotifyAudioAvailableEvent();
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
{
return NotifyAudioAvailableEventBinding::Wrap(aCx, aScope, this);
}
JSObject* GetFrameBuffer(JSContext* aCx, ErrorResult& aRv)
{
JS::Rooted<JS::Value> dummy(aCx);
aRv = GetFrameBuffer(aCx, &dummy);
return mCachedArray;
}
float Time()
{
return mTime;
}
void InitAudioAvailableEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
const Nullable<Sequence<float> >& aFrameBuffer,
uint32_t aFrameBufferLength,
float aTime,
bool aAllowAudioData,
ErrorResult& aRv);
private:
nsAutoArrayPtr<float> mFrameBuffer;
uint32_t mFrameBufferLength;
float mTime;
JS::Heap<JSObject*> mCachedArray;
bool mAllowAudioData;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_NotifyAudioAvailableEvent_h_

View File

@ -5,20 +5,20 @@
#include "base/basictypes.h"
#include "ipc/IPCMessageUtils.h"
#include "mozilla/dom/DOMRect.h"
#include "mozilla/dom/NotifyPaintEvent.h"
#include "mozilla/GfxMessageUtils.h"
#include "nsDOMNotifyPaintEvent.h"
#include "nsContentUtils.h"
#include "nsPaintRequest.h"
#include "mozilla/dom/DOMRect.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
namespace dom {
nsDOMNotifyPaintEvent::nsDOMNotifyPaintEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
nsInvalidateRequestList* aInvalidateRequests)
NotifyPaintEvent::NotifyPaintEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
nsInvalidateRequestList* aInvalidateRequests)
: nsDOMEvent(aOwner, aPresContext, aEvent)
{
if (mEvent) {
@ -29,15 +29,15 @@ nsDOMNotifyPaintEvent::nsDOMNotifyPaintEvent(mozilla::dom::EventTarget* aOwner,
}
}
NS_INTERFACE_MAP_BEGIN(nsDOMNotifyPaintEvent)
NS_INTERFACE_MAP_BEGIN(NotifyPaintEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMNotifyPaintEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMPL_ADDREF_INHERITED(nsDOMNotifyPaintEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMNotifyPaintEvent, nsDOMEvent)
NS_IMPL_ADDREF_INHERITED(NotifyPaintEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(NotifyPaintEvent, nsDOMEvent)
nsRegion
nsDOMNotifyPaintEvent::GetRegion()
NotifyPaintEvent::GetRegion()
{
nsRegion r;
if (!nsContentUtils::IsCallerChrome()) {
@ -51,14 +51,14 @@ nsDOMNotifyPaintEvent::GetRegion()
}
NS_IMETHODIMP
nsDOMNotifyPaintEvent::GetBoundingClientRect(nsIDOMClientRect** aResult)
NotifyPaintEvent::GetBoundingClientRect(nsIDOMClientRect** aResult)
{
*aResult = BoundingClientRect().get();
return NS_OK;
}
already_AddRefed<DOMRect>
nsDOMNotifyPaintEvent::BoundingClientRect()
NotifyPaintEvent::BoundingClientRect()
{
nsRefPtr<DOMRect> rect = new DOMRect(ToSupports(this));
@ -70,14 +70,14 @@ nsDOMNotifyPaintEvent::BoundingClientRect()
}
NS_IMETHODIMP
nsDOMNotifyPaintEvent::GetClientRects(nsIDOMClientRectList** aResult)
NotifyPaintEvent::GetClientRects(nsIDOMClientRectList** aResult)
{
*aResult = ClientRects().get();
return NS_OK;
}
already_AddRefed<DOMRectList>
nsDOMNotifyPaintEvent::ClientRects()
NotifyPaintEvent::ClientRects()
{
nsISupports* parent = ToSupports(this);
nsRefPtr<DOMRectList> rectList = new DOMRectList(parent);
@ -95,7 +95,7 @@ nsDOMNotifyPaintEvent::ClientRects()
}
NS_IMETHODIMP
nsDOMNotifyPaintEvent::GetPaintRequests(nsISupports** aResult)
NotifyPaintEvent::GetPaintRequests(nsISupports** aResult)
{
nsRefPtr<nsPaintRequestList> requests = PaintRequests();
requests.forget(aResult);
@ -103,7 +103,7 @@ nsDOMNotifyPaintEvent::GetPaintRequests(nsISupports** aResult)
}
already_AddRefed<nsPaintRequestList>
nsDOMNotifyPaintEvent::PaintRequests()
NotifyPaintEvent::PaintRequests()
{
nsDOMEvent* parent = this;
nsRefPtr<nsPaintRequestList> requests = new nsPaintRequestList(parent);
@ -120,8 +120,8 @@ nsDOMNotifyPaintEvent::PaintRequests()
}
NS_IMETHODIMP_(void)
nsDOMNotifyPaintEvent::Serialize(IPC::Message* aMsg,
bool aSerializeInterfaceType)
NotifyPaintEvent::Serialize(IPC::Message* aMsg,
bool aSerializeInterfaceType)
{
if (aSerializeInterfaceType) {
IPC::WriteParam(aMsg, NS_LITERAL_STRING("notifypaintevent"));
@ -138,7 +138,7 @@ nsDOMNotifyPaintEvent::Serialize(IPC::Message* aMsg,
}
NS_IMETHODIMP_(bool)
nsDOMNotifyPaintEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
NotifyPaintEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
{
NS_ENSURE_TRUE(nsDOMEvent::Deserialize(aMsg, aIter), false);
@ -155,16 +155,21 @@ nsDOMNotifyPaintEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
return true;
}
nsresult NS_NewDOMNotifyPaintEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
nsInvalidateRequestList* aInvalidateRequests)
{
nsDOMNotifyPaintEvent* it =
new nsDOMNotifyPaintEvent(aOwner, aPresContext, aEvent, aEventType,
aInvalidateRequests);
} // namespace dom
} // namespace mozilla
using namespace mozilla;
using namespace mozilla::dom;
nsresult
NS_NewDOMNotifyPaintEvent(nsIDOMEvent** aInstancePtrResult,
EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
nsInvalidateRequestList* aInvalidateRequests)
{
NotifyPaintEvent* it = new NotifyPaintEvent(aOwner, aPresContext, aEvent,
aEventType, aInvalidateRequests);
return CallQueryInterface(it, aInstancePtrResult);
}

View File

@ -3,8 +3,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/. */
#ifndef nsDOMNotifyPaintEvent_h_
#define nsDOMNotifyPaintEvent_h_
#ifndef mozilla_dom_NotifyPaintEvent_h_
#define mozilla_dom_NotifyPaintEvent_h_
#include "mozilla/Attributes.h"
#include "nsIDOMNotifyPaintEvent.h"
@ -16,23 +16,20 @@ class nsPaintRequestList;
namespace mozilla {
namespace dom {
class DOMRect;
class DOMRectList;
}
}
class nsDOMNotifyPaintEvent : public nsDOMEvent,
public nsIDOMNotifyPaintEvent
class NotifyPaintEvent : public nsDOMEvent,
public nsIDOMNotifyPaintEvent
{
typedef mozilla::dom::DOMRect DOMRect;
typedef mozilla::dom::DOMRectList DOMRectList;
public:
nsDOMNotifyPaintEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetEvent* aEvent,
uint32_t aEventType,
nsInvalidateRequestList* aInvalidateRequests);
NotifyPaintEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
nsInvalidateRequestList* aInvalidateRequests);
NS_DECL_ISUPPORTS_INHERITED
@ -50,7 +47,7 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
{
return mozilla::dom::NotifyPaintEventBinding::Wrap(aCx, aScope, this);
return NotifyPaintEventBinding::Wrap(aCx, aScope, this);
}
already_AddRefed<DOMRectList> ClientRects();
@ -64,4 +61,7 @@ private:
nsTArray<nsInvalidateRequestList::Request> mInvalidateRequests;
};
#endif // nsDOMNotifyPaintEvent_h_
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_NotifyPaintEvent_h_

View File

@ -5,36 +5,36 @@
#include "base/basictypes.h"
#include "ipc/IPCMessageUtils.h"
#include "mozilla/dom/DOMRect.h"
#include "mozilla/dom/ScrollAreaEvent.h"
#include "mozilla/ContentEvents.h"
#include "nsDOMScrollAreaEvent.h"
#include "mozilla/dom/DOMRect.h"
namespace mozilla {
namespace dom {
using namespace mozilla;
nsDOMScrollAreaEvent::nsDOMScrollAreaEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext *aPresContext,
InternalScrollAreaEvent* aEvent)
: nsDOMUIEvent(aOwner, aPresContext, aEvent)
ScrollAreaEvent::ScrollAreaEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalScrollAreaEvent* aEvent)
: UIEvent(aOwner, aPresContext, aEvent)
, mClientArea(nullptr)
{
mClientArea.SetLayoutRect(aEvent ? aEvent->mArea : nsRect());
}
NS_IMPL_ADDREF_INHERITED(nsDOMScrollAreaEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMScrollAreaEvent, nsDOMUIEvent)
NS_IMPL_ADDREF_INHERITED(ScrollAreaEvent, UIEvent)
NS_IMPL_RELEASE_INHERITED(ScrollAreaEvent, UIEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMScrollAreaEvent)
NS_INTERFACE_MAP_BEGIN(ScrollAreaEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMScrollAreaEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
#define FORWARD_GETTER(_name) \
NS_IMETHODIMP \
nsDOMScrollAreaEvent::Get ## _name(float* aResult) \
{ \
*aResult = _name(); \
return NS_OK; \
#define FORWARD_GETTER(_name) \
NS_IMETHODIMP \
ScrollAreaEvent::Get ## _name(float* aResult) \
{ \
*aResult = _name(); \
return NS_OK; \
}
FORWARD_GETTER(X)
@ -43,15 +43,18 @@ FORWARD_GETTER(Width)
FORWARD_GETTER(Height)
NS_IMETHODIMP
nsDOMScrollAreaEvent::InitScrollAreaEvent(const nsAString &aEventType,
bool aCanBubble,
bool aCancelable,
nsIDOMWindow *aView,
int32_t aDetail,
float aX, float aY,
float aWidth, float aHeight)
ScrollAreaEvent::InitScrollAreaEvent(const nsAString& aEventType,
bool aCanBubble,
bool aCancelable,
nsIDOMWindow* aView,
int32_t aDetail,
float aX,
float aY,
float aWidth,
float aHeight)
{
nsresult rv = nsDOMUIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail);
nsresult rv =
UIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail);
NS_ENSURE_SUCCESS(rv, rv);
mClientArea.SetRect(aX, aY, aWidth, aHeight);
@ -60,8 +63,8 @@ nsDOMScrollAreaEvent::InitScrollAreaEvent(const nsAString &aEventType,
}
NS_IMETHODIMP_(void)
nsDOMScrollAreaEvent::Serialize(IPC::Message* aMsg,
bool aSerializeInterfaceType)
ScrollAreaEvent::Serialize(IPC::Message* aMsg,
bool aSerializeInterfaceType)
{
if (aSerializeInterfaceType) {
IPC::WriteParam(aMsg, NS_LITERAL_STRING("scrollareaevent"));
@ -76,7 +79,7 @@ nsDOMScrollAreaEvent::Serialize(IPC::Message* aMsg,
}
NS_IMETHODIMP_(bool)
nsDOMScrollAreaEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
{
NS_ENSURE_TRUE(nsDOMEvent::Deserialize(aMsg, aIter), false);
@ -90,13 +93,18 @@ nsDOMScrollAreaEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
return true;
}
} // namespace dom
} // namespace mozilla
using namespace mozilla;
using namespace mozilla::dom;
nsresult
NS_NewDOMScrollAreaEvent(nsIDOMEvent **aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext *aPresContext,
NS_NewDOMScrollAreaEvent(nsIDOMEvent** aInstancePtrResult,
EventTarget* aOwner,
nsPresContext* aPresContext,
InternalScrollAreaEvent* aEvent)
{
nsDOMScrollAreaEvent* ev =
new nsDOMScrollAreaEvent(aOwner, aPresContext, aEvent);
ScrollAreaEvent* ev = new ScrollAreaEvent(aOwner, aPresContext, aEvent);
return CallQueryInterface(ev, aInstancePtrResult);
}

View File

@ -3,32 +3,32 @@
* 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/. */
#ifndef nsDOMScrollAreaEvent_h__
#define nsDOMScrollAreaEvent_h__
#include "mozilla/Attributes.h"
#include "mozilla/EventForwards.h"
#include "nsIDOMScrollAreaEvent.h"
#include "nsDOMUIEvent.h"
#ifndef mozilla_dom_ScrollAreaEvent_h_
#define mozilla_dom_ScrollAreaEvent_h_
#include "mozilla/dom/DOMRect.h"
#include "mozilla/dom/ScrollAreaEventBinding.h"
#include "mozilla/dom/UIEvent.h"
#include "mozilla/Attributes.h"
#include "mozilla/EventForwards.h"
#include "nsIDOMScrollAreaEvent.h"
class nsDOMScrollAreaEvent : public nsDOMUIEvent,
public nsIDOMScrollAreaEvent
namespace mozilla {
namespace dom {
class ScrollAreaEvent : public UIEvent,
public nsIDOMScrollAreaEvent
{
typedef mozilla::dom::DOMRect DOMRect;
public:
nsDOMScrollAreaEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext *aPresContext,
mozilla::InternalScrollAreaEvent* aEvent);
ScrollAreaEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalScrollAreaEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSCROLLAREAEVENT
NS_FORWARD_NSIDOMUIEVENT(nsDOMUIEvent::)
NS_FORWARD_NSIDOMUIEVENT(UIEvent::)
NS_FORWARD_TO_NSDOMEVENT_NO_SERIALIZATION_NO_DUPLICATION
NS_IMETHOD DuplicatePrivateData()
@ -41,7 +41,7 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
{
return mozilla::dom::ScrollAreaEventBinding::Wrap(aCx, aScope, this);
return ScrollAreaEventBinding::Wrap(aCx, aScope, this);
}
float X() const
@ -71,7 +71,7 @@ public:
int32_t aDetail,
float aX, float aY,
float aWidth, float aHeight,
mozilla::ErrorResult& aRv)
ErrorResult& aRv)
{
aRv = InitScrollAreaEvent(aType, aCanBubble, aCancelable, aView,
aDetail, aX, aY, aWidth, aHeight);
@ -81,4 +81,7 @@ protected:
DOMRect mClientArea;
};
#endif // nsDOMScrollAreaEvent_h__
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_ScrollAreaEvent_h_

View File

@ -7,14 +7,14 @@
#include "mozilla/dom/EventTarget.h"
#include "mozilla/dom/TouchBinding.h"
#include "mozilla/dom/TouchEvent.h"
#include "nsContentUtils.h"
#include "nsDOMTouchEvent.h"
#include "nsIContent.h"
namespace mozilla {
namespace dom {
Touch::Touch(mozilla::dom::EventTarget* aTarget,
Touch::Touch(EventTarget* aTarget,
int32_t aIdentifier,
int32_t aPageX,
int32_t aPageY,
@ -71,10 +71,11 @@ Touch::~Touch()
{
}
/* static */ bool
// static
bool
Touch::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
{
return nsDOMTouchEvent::PrefEnabled(aCx, aGlobal);
return TouchEvent::PrefEnabled(aCx, aGlobal);
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(Touch, mTarget)
@ -117,7 +118,7 @@ Touch::InitializePoints(nsPresContext* aPresContext, WidgetEvent* aEvent)
}
void
Touch::SetTarget(mozilla::dom::EventTarget* aTarget)
Touch::SetTarget(EventTarget* aTarget)
{
mTarget = aTarget;
}
@ -132,7 +133,7 @@ Touch::Equals(Touch* aTouch)
mRadius.y == aTouch->RadiusY();
}
/* virtual */ JSObject*
JSObject*
Touch::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
return TouchBinding::Wrap(aCx, aScope, this);

View File

@ -3,8 +3,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/. */
#ifndef mozilla_dom_Touch_h
#define mozilla_dom_Touch_h
#ifndef mozilla_dom_Touch_h_
#define mozilla_dom_Touch_h_
#include "mozilla/Attributes.h"
#include "mozilla/EventForwards.h"
@ -27,7 +27,7 @@ class Touch MOZ_FINAL : public nsISupports
public:
static bool PrefEnabled(JSContext* aCx, JSObject* aGlobal);
Touch(mozilla::dom::EventTarget* aTarget,
Touch(EventTarget* aTarget,
int32_t aIdentifier,
int32_t aPageX,
int32_t aPageY,
@ -52,7 +52,7 @@ public:
void InitializePoints(nsPresContext* aPresContext, WidgetEvent* aEvent);
void SetTarget(mozilla::dom::EventTarget* aTarget);
void SetTarget(EventTarget* aTarget);
bool Equals(Touch* aTouch);
@ -92,4 +92,4 @@ protected:
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_Touch_h
#endif // mozilla_dom_Touch_h_

View File

@ -4,42 +4,52 @@
* 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 "nsDOMTouchEvent.h"
#include "nsContentUtils.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/TouchEvent.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/dom/TouchListBinding.h"
#include "mozilla/Preferences.h"
#include "mozilla/TouchEvents.h"
#include "nsContentUtils.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
// TouchList
#ifdef XP_WIN
namespace widget {
extern int32_t IsTouchDeviceSupportPresent();
} // namespace widget
#endif // #ifdef XP_WIN
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMTouchList)
namespace dom {
/******************************************************************************
* TouchList
*****************************************************************************/
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TouchList)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(nsDOMTouchList, mParent, mPoints)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(TouchList, mParent, mPoints)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMTouchList)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMTouchList)
NS_IMPL_CYCLE_COLLECTING_ADDREF(TouchList)
NS_IMPL_CYCLE_COLLECTING_RELEASE(TouchList)
/* virtual */ JSObject*
nsDOMTouchList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
JSObject*
TouchList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
return TouchListBinding::Wrap(aCx, aScope, this);
}
/* static */ bool
nsDOMTouchList::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
// static
bool
TouchList::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
{
return nsDOMTouchEvent::PrefEnabled(aCx, aGlobal);
return TouchEvent::PrefEnabled(aCx, aGlobal);
}
Touch*
nsDOMTouchList::IdentifiedTouch(int32_t aIdentifier) const
TouchList::IdentifiedTouch(int32_t aIdentifier) const
{
for (uint32_t i = 0; i < mPoints.Length(); ++i) {
Touch* point = mPoints[i];
@ -50,13 +60,15 @@ nsDOMTouchList::IdentifiedTouch(int32_t aIdentifier) const
return nullptr;
}
// TouchEvent
/******************************************************************************
* TouchEvent
*****************************************************************************/
nsDOMTouchEvent::nsDOMTouchEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetTouchEvent* aEvent)
: nsDOMUIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetTouchEvent(false, 0, nullptr))
TouchEvent::TouchEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetTouchEvent* aEvent)
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetTouchEvent(false, 0, nullptr))
{
if (aEvent) {
mEventIsInternal = false;
@ -71,38 +83,33 @@ nsDOMTouchEvent::nsDOMTouchEvent(mozilla::dom::EventTarget* aOwner,
}
}
NS_IMPL_CYCLE_COLLECTION_INHERITED_3(nsDOMTouchEvent, nsDOMUIEvent,
NS_IMPL_CYCLE_COLLECTION_INHERITED_3(TouchEvent, UIEvent,
mTouches,
mTargetTouches,
mChangedTouches)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMTouchEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
NS_IMPL_ADDREF_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TouchEvent)
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
NS_IMPL_ADDREF_INHERITED(TouchEvent, UIEvent)
NS_IMPL_RELEASE_INHERITED(TouchEvent, UIEvent)
void
nsDOMTouchEvent::InitTouchEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
nsIDOMWindow* aView,
int32_t aDetail,
bool aCtrlKey,
bool aAltKey,
bool aShiftKey,
bool aMetaKey,
nsDOMTouchList* aTouches,
nsDOMTouchList* aTargetTouches,
nsDOMTouchList* aChangedTouches,
mozilla::ErrorResult& aRv)
TouchEvent::InitTouchEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
nsIDOMWindow* aView,
int32_t aDetail,
bool aCtrlKey,
bool aAltKey,
bool aShiftKey,
bool aMetaKey,
TouchList* aTouches,
TouchList* aTargetTouches,
TouchList* aChangedTouches,
ErrorResult& aRv)
{
aRv = nsDOMUIEvent::InitUIEvent(aType,
aCanBubble,
aCancelable,
aView,
aDetail);
aRv = UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
if (aRv.Failed()) {
return;
}
@ -114,8 +121,8 @@ nsDOMTouchEvent::InitTouchEvent(const nsAString& aType,
mChangedTouches = aChangedTouches;
}
nsDOMTouchList*
nsDOMTouchEvent::Touches()
TouchList*
TouchEvent::Touches()
{
if (!mTouches) {
WidgetTouchEvent* touchEvent = mEvent->AsTouchEvent();
@ -128,16 +135,16 @@ nsDOMTouchEvent::Touches()
unchangedTouches.AppendElement(touches[i]);
}
}
mTouches = new nsDOMTouchList(ToSupports(this), unchangedTouches);
mTouches = new TouchList(ToSupports(this), unchangedTouches);
} else {
mTouches = new nsDOMTouchList(ToSupports(this), touchEvent->touches);
mTouches = new TouchList(ToSupports(this), touchEvent->touches);
}
}
return mTouches;
}
nsDOMTouchList*
nsDOMTouchEvent::TargetTouches()
TouchList*
TouchEvent::TargetTouches()
{
if (!mTargetTouches) {
nsTArray< nsRefPtr<Touch> > targetTouches;
@ -153,13 +160,13 @@ nsDOMTouchEvent::TargetTouches()
}
}
}
mTargetTouches = new nsDOMTouchList(ToSupports(this), targetTouches);
mTargetTouches = new TouchList(ToSupports(this), targetTouches);
}
return mTargetTouches;
}
nsDOMTouchList*
nsDOMTouchEvent::ChangedTouches()
TouchList*
TouchEvent::ChangedTouches()
{
if (!mChangedTouches) {
nsTArray< nsRefPtr<Touch> > changedTouches;
@ -170,20 +177,14 @@ nsDOMTouchEvent::ChangedTouches()
changedTouches.AppendElement(touches[i]);
}
}
mChangedTouches = new nsDOMTouchList(ToSupports(this), changedTouches);
mChangedTouches = new TouchList(ToSupports(this), changedTouches);
}
return mChangedTouches;
}
#ifdef XP_WIN
namespace mozilla {
namespace widget {
extern int32_t IsTouchDeviceSupportPresent();
} }
#endif
// static
bool
nsDOMTouchEvent::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
TouchEvent::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
{
bool prefValue = false;
int32_t flag = 0;
@ -196,7 +197,7 @@ nsDOMTouchEvent::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
// On Windows we auto-detect based on device support.
if (!sDidCheckTouchDeviceSupport) {
sDidCheckTouchDeviceSupport = true;
sIsTouchDeviceSupportPresent = mozilla::widget::IsTouchDeviceSupportPresent();
sIsTouchDeviceSupportPresent = widget::IsTouchDeviceSupportPresent();
}
prefValue = sIsTouchDeviceSupportPresent;
#else
@ -214,35 +215,41 @@ nsDOMTouchEvent::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
}
bool
nsDOMTouchEvent::AltKey()
TouchEvent::AltKey()
{
return mEvent->AsTouchEvent()->IsAlt();
}
bool
nsDOMTouchEvent::MetaKey()
TouchEvent::MetaKey()
{
return mEvent->AsTouchEvent()->IsMeta();
}
bool
nsDOMTouchEvent::CtrlKey()
TouchEvent::CtrlKey()
{
return mEvent->AsTouchEvent()->IsControl();
}
bool
nsDOMTouchEvent::ShiftKey()
TouchEvent::ShiftKey()
{
return mEvent->AsTouchEvent()->IsShift();
}
} // namespace dom
} // namespace mozilla
using namespace mozilla;
using namespace mozilla::dom;
nsresult
NS_NewDOMTouchEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetTouchEvent* aEvent)
{
nsDOMTouchEvent* it = new nsDOMTouchEvent(aOwner, aPresContext, aEvent);
TouchEvent* it = new TouchEvent(aOwner, aPresContext, aEvent);
return CallQueryInterface(it, aInstancePtrResult);
}

View File

@ -2,38 +2,38 @@
/* 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/. */
#ifndef nsDOMTouchEvent_h_
#define nsDOMTouchEvent_h_
#ifndef mozilla_dom_TouchEvent_h_
#define mozilla_dom_TouchEvent_h_
#include "nsDOMUIEvent.h"
#include "nsTArray.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/dom/TouchEventBinding.h"
#include "mozilla/dom/UIEvent.h"
#include "mozilla/Attributes.h"
#include "mozilla/EventForwards.h"
#include "nsJSEnvironment.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/dom/TouchEventBinding.h"
#include "nsTArray.h"
#include "nsWrapperCache.h"
class nsAString;
class nsDOMTouchList MOZ_FINAL : public nsISupports
, public nsWrapperCache
{
typedef mozilla::dom::Touch Touch;
namespace mozilla {
namespace dom {
class TouchList MOZ_FINAL : public nsISupports
, public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMTouchList)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TouchList)
nsDOMTouchList(nsISupports* aParent)
TouchList(nsISupports* aParent)
: mParent(aParent)
{
SetIsDOMBinding();
nsJSContext::LikelyShortLivingObjectCreated();
}
nsDOMTouchList(nsISupports* aParent,
const nsTArray< nsRefPtr<Touch> >& aTouches)
TouchList(nsISupports* aParent,
const nsTArray<nsRefPtr<Touch> >& aTouches)
: mParent(aParent)
, mPoints(aTouches)
{
@ -46,15 +46,16 @@ public:
mPoints.AppendElement(aPoint);
}
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
nsISupports* GetParentObject() const
{
return mParent;
}
static bool PrefEnabled(JSContext* aCx = nullptr, JSObject* aGlobal = nullptr);
static bool PrefEnabled(JSContext* aCx = nullptr,
JSObject* aGlobal = nullptr);
uint32_t Length() const
{
@ -76,28 +77,28 @@ public:
protected:
nsCOMPtr<nsISupports> mParent;
nsTArray< nsRefPtr<Touch> > mPoints;
nsTArray<nsRefPtr<Touch> > mPoints;
};
class nsDOMTouchEvent : public nsDOMUIEvent
class TouchEvent : public UIEvent
{
public:
nsDOMTouchEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetTouchEvent* aEvent);
TouchEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetTouchEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TouchEvent, UIEvent)
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
{
return mozilla::dom::TouchEventBinding::Wrap(aCx, aScope, this);
return TouchEventBinding::Wrap(aCx, aScope, this);
}
nsDOMTouchList* Touches();
nsDOMTouchList* TargetTouches();
nsDOMTouchList* ChangedTouches();
TouchList* Touches();
TouchList* TargetTouches();
TouchList* ChangedTouches();
bool AltKey();
bool MetaKey();
@ -113,16 +114,20 @@ public:
bool aAltKey,
bool aShiftKey,
bool aMetaKey,
nsDOMTouchList* aTouches,
nsDOMTouchList* aTargetTouches,
nsDOMTouchList* aChangedTouches,
mozilla::ErrorResult& aRv);
TouchList* aTouches,
TouchList* aTargetTouches,
TouchList* aChangedTouches,
ErrorResult& aRv);
static bool PrefEnabled(JSContext* aCx = nullptr, JSObject* aGlobal = nullptr);
static bool PrefEnabled(JSContext* aCx = nullptr,
JSObject* aGlobal = nullptr);
protected:
nsRefPtr<nsDOMTouchList> mTouches;
nsRefPtr<nsDOMTouchList> mTargetTouches;
nsRefPtr<nsDOMTouchList> mChangedTouches;
nsRefPtr<TouchList> mTouches;
nsRefPtr<TouchList> mTargetTouches;
nsRefPtr<TouchList> mChangedTouches;
};
#endif /* !defined(nsDOMTouchEvent_h_) */
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_TouchEvent_h_

View File

@ -3,15 +3,16 @@
* 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 "nsDOMTransitionEvent.h"
#include "prtime.h"
#include "mozilla/dom/TransitionEvent.h"
#include "mozilla/ContentEvents.h"
#include "prtime.h"
using namespace mozilla;
namespace mozilla {
namespace dom {
nsDOMTransitionEvent::nsDOMTransitionEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext *aPresContext,
InternalTransitionEvent* aEvent)
TransitionEvent::TransitionEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalTransitionEvent* aEvent)
: nsDOMEvent(aOwner, aPresContext,
aEvent ? aEvent : new InternalTransitionEvent(false, 0))
{
@ -24,22 +25,22 @@ nsDOMTransitionEvent::nsDOMTransitionEvent(mozilla::dom::EventTarget* aOwner,
}
}
NS_INTERFACE_MAP_BEGIN(nsDOMTransitionEvent)
NS_INTERFACE_MAP_BEGIN(TransitionEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMTransitionEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMPL_ADDREF_INHERITED(nsDOMTransitionEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMTransitionEvent, nsDOMEvent)
NS_IMPL_ADDREF_INHERITED(TransitionEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(TransitionEvent, nsDOMEvent)
//static
already_AddRefed<nsDOMTransitionEvent>
nsDOMTransitionEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
const nsAString& aType,
const mozilla::dom::TransitionEventInit& aParam,
mozilla::ErrorResult& aRv)
// static
already_AddRefed<TransitionEvent>
TransitionEvent::Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const TransitionEventInit& aParam,
ErrorResult& aRv)
{
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<nsDOMTransitionEvent> e = new nsDOMTransitionEvent(t, nullptr, nullptr);
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<TransitionEvent> e = new TransitionEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
@ -54,39 +55,44 @@ nsDOMTransitionEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
}
NS_IMETHODIMP
nsDOMTransitionEvent::GetPropertyName(nsAString & aPropertyName)
TransitionEvent::GetPropertyName(nsAString& aPropertyName)
{
aPropertyName = mEvent->AsTransitionEvent()->propertyName;
return NS_OK;
}
NS_IMETHODIMP
nsDOMTransitionEvent::GetElapsedTime(float *aElapsedTime)
TransitionEvent::GetElapsedTime(float* aElapsedTime)
{
*aElapsedTime = ElapsedTime();
return NS_OK;
}
float
nsDOMTransitionEvent::ElapsedTime()
TransitionEvent::ElapsedTime()
{
return mEvent->AsTransitionEvent()->elapsedTime;
}
NS_IMETHODIMP
nsDOMTransitionEvent::GetPseudoElement(nsAString& aPseudoElement)
TransitionEvent::GetPseudoElement(nsAString& aPseudoElement)
{
aPseudoElement = mEvent->AsTransitionEvent()->pseudoElement;
return NS_OK;
}
} // namespace dom
} // namespace mozilla
using namespace mozilla;
using namespace mozilla::dom;
nsresult
NS_NewDOMTransitionEvent(nsIDOMEvent **aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext *aPresContext,
NS_NewDOMTransitionEvent(nsIDOMEvent** aInstancePtrResult,
EventTarget* aOwner,
nsPresContext* aPresContext,
InternalTransitionEvent* aEvent)
{
nsDOMTransitionEvent *it =
new nsDOMTransitionEvent(aOwner, aPresContext, aEvent);
TransitionEvent *it = new TransitionEvent(aOwner, aPresContext, aEvent);
return CallQueryInterface(it, aInstancePtrResult);
}

View File

@ -2,8 +2,8 @@
/* 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/. */
#ifndef nsDOMTransitionEvent_h_
#define nsDOMTransitionEvent_h_
#ifndef mozilla_dom_TransitionEvent_h_
#define mozilla_dom_TransitionEvent_h_
#include "nsDOMEvent.h"
#include "nsIDOMTransitionEvent.h"
@ -12,28 +12,31 @@
class nsAString;
class nsDOMTransitionEvent : public nsDOMEvent,
public nsIDOMTransitionEvent
namespace mozilla {
namespace dom {
class TransitionEvent : public nsDOMEvent,
public nsIDOMTransitionEvent
{
public:
nsDOMTransitionEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext *aPresContext,
mozilla::InternalTransitionEvent* aEvent);
TransitionEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalTransitionEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
NS_FORWARD_TO_NSDOMEVENT
NS_DECL_NSIDOMTRANSITIONEVENT
static already_AddRefed<nsDOMTransitionEvent>
Constructor(const mozilla::dom::GlobalObject& aGlobal,
static already_AddRefed<TransitionEvent>
Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const mozilla::dom::TransitionEventInit& aParam,
mozilla::ErrorResult& aRv);
const TransitionEventInit& aParam,
ErrorResult& aRv);
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
{
return mozilla::dom::TransitionEventBinding::Wrap(aCx, aScope, this);
return TransitionEventBinding::Wrap(aCx, aScope, this);
}
// xpidl implementation
@ -43,4 +46,7 @@ public:
float ElapsedTime();
};
#endif /* !defined(nsDOMTransitionEvent_h_) */
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_TransitionEvent_h_

View File

@ -5,28 +5,33 @@
#include "base/basictypes.h"
#include "ipc/IPCMessageUtils.h"
#include "nsCOMPtr.h"
#include "nsDOMUIEvent.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDOMWindow.h"
#include "nsIDOMNode.h"
#include "nsIContent.h"
#include "nsContentUtils.h"
#include "nsEventStateManager.h"
#include "nsIFrame.h"
#include "mozilla/dom/UIEvent.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/TextEvents.h"
#include "nsCOMPtr.h"
#include "nsContentUtils.h"
#include "nsEventStateManager.h"
#include "nsIContent.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDOMWindow.h"
#include "nsIDOMNode.h"
#include "nsIFrame.h"
#include "prtime.h"
using namespace mozilla;
namespace mozilla {
namespace dom {
nsDOMUIEvent::nsDOMUIEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext, WidgetGUIEvent* aEvent)
UIEvent::UIEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetGUIEvent* aEvent)
: nsDOMEvent(aOwner, aPresContext,
aEvent ? aEvent : new InternalUIEvent(false, 0))
, mClientPoint(0, 0), mLayerPoint(0, 0), mPagePoint(0, 0), mMovementPoint(0, 0)
, mClientPoint(0, 0)
, mLayerPoint(0, 0)
, mPagePoint(0, 0)
, mMovementPoint(0, 0)
, mIsPointerLocked(nsEventStateManager::sIsPointerLocked)
, mLastClientPoint(nsEventStateManager::sLastClientPoint)
{
@ -73,15 +78,15 @@ nsDOMUIEvent::nsDOMUIEvent(mozilla::dom::EventTarget* aOwner,
}
}
//static
already_AddRefed<nsDOMUIEvent>
nsDOMUIEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
const nsAString& aType,
const mozilla::dom::UIEventInit& aParam,
mozilla::ErrorResult& aRv)
// static
already_AddRefed<UIEvent>
UIEvent::Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const UIEventInit& aParam,
ErrorResult& aRv)
{
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<nsDOMUIEvent> e = new nsDOMUIEvent(t, nullptr, nullptr);
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<UIEvent> e = new UIEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
aRv = e->InitUIEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,
aParam.mDetail);
@ -89,13 +94,13 @@ nsDOMUIEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
return e.forget();
}
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(nsDOMUIEvent, nsDOMEvent,
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(UIEvent, nsDOMEvent,
mView)
NS_IMPL_ADDREF_INHERITED(nsDOMUIEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMUIEvent, nsDOMEvent)
NS_IMPL_ADDREF_INHERITED(UIEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(UIEvent, nsDOMEvent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMUIEvent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(UIEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMUIEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
@ -108,7 +113,7 @@ DevPixelsToCSSPixels(const LayoutDeviceIntPoint& aPoint,
}
nsIntPoint
nsDOMUIEvent::GetMovementPoint()
UIEvent::GetMovementPoint()
{
if (mPrivateDataDuplicated) {
return mMovementPoint;
@ -132,7 +137,7 @@ nsDOMUIEvent::GetMovementPoint()
}
NS_IMETHODIMP
nsDOMUIEvent::GetView(nsIDOMWindow** aView)
UIEvent::GetView(nsIDOMWindow** aView)
{
*aView = mView;
NS_IF_ADDREF(*aView);
@ -140,18 +145,18 @@ nsDOMUIEvent::GetView(nsIDOMWindow** aView)
}
NS_IMETHODIMP
nsDOMUIEvent::GetDetail(int32_t* aDetail)
UIEvent::GetDetail(int32_t* aDetail)
{
*aDetail = mDetail;
return NS_OK;
}
NS_IMETHODIMP
nsDOMUIEvent::InitUIEvent(const nsAString& typeArg,
bool canBubbleArg,
bool cancelableArg,
nsIDOMWindow* viewArg,
int32_t detailArg)
UIEvent::InitUIEvent(const nsAString& typeArg,
bool canBubbleArg,
bool cancelableArg,
nsIDOMWindow* viewArg,
int32_t detailArg)
{
if (viewArg) {
nsCOMPtr<nsPIDOMWindow> view = do_QueryInterface(viewArg);
@ -166,9 +171,8 @@ nsDOMUIEvent::InitUIEvent(const nsAString& typeArg,
return NS_OK;
}
// ---- nsDOMNSUIEvent implementation -------------------
NS_IMETHODIMP
nsDOMUIEvent::GetPageX(int32_t* aPageX)
UIEvent::GetPageX(int32_t* aPageX)
{
NS_ENSURE_ARG_POINTER(aPageX);
*aPageX = PageX();
@ -176,7 +180,7 @@ nsDOMUIEvent::GetPageX(int32_t* aPageX)
}
int32_t
nsDOMUIEvent::PageX() const
UIEvent::PageX() const
{
if (mPrivateDataDuplicated) {
return mPagePoint.x;
@ -189,7 +193,7 @@ nsDOMUIEvent::PageX() const
}
NS_IMETHODIMP
nsDOMUIEvent::GetPageY(int32_t* aPageY)
UIEvent::GetPageY(int32_t* aPageY)
{
NS_ENSURE_ARG_POINTER(aPageY);
*aPageY = PageY();
@ -197,7 +201,7 @@ nsDOMUIEvent::GetPageY(int32_t* aPageY)
}
int32_t
nsDOMUIEvent::PageY() const
UIEvent::PageY() const
{
if (mPrivateDataDuplicated) {
return mPagePoint.y;
@ -210,7 +214,7 @@ nsDOMUIEvent::PageY() const
}
NS_IMETHODIMP
nsDOMUIEvent::GetWhich(uint32_t* aWhich)
UIEvent::GetWhich(uint32_t* aWhich)
{
NS_ENSURE_ARG_POINTER(aWhich);
*aWhich = Which();
@ -218,7 +222,7 @@ nsDOMUIEvent::GetWhich(uint32_t* aWhich)
}
already_AddRefed<nsINode>
nsDOMUIEvent::GetRangeParent()
UIEvent::GetRangeParent()
{
nsIFrame* targetFrame = nullptr;
@ -243,7 +247,7 @@ nsDOMUIEvent::GetRangeParent()
}
NS_IMETHODIMP
nsDOMUIEvent::GetRangeParent(nsIDOMNode** aRangeParent)
UIEvent::GetRangeParent(nsIDOMNode** aRangeParent)
{
NS_ENSURE_ARG_POINTER(aRangeParent);
*aRangeParent = nullptr;
@ -255,7 +259,7 @@ nsDOMUIEvent::GetRangeParent(nsIDOMNode** aRangeParent)
}
NS_IMETHODIMP
nsDOMUIEvent::GetRangeOffset(int32_t* aRangeOffset)
UIEvent::GetRangeOffset(int32_t* aRangeOffset)
{
NS_ENSURE_ARG_POINTER(aRangeOffset);
*aRangeOffset = RangeOffset();
@ -263,7 +267,7 @@ nsDOMUIEvent::GetRangeOffset(int32_t* aRangeOffset)
}
int32_t
nsDOMUIEvent::RangeOffset() const
UIEvent::RangeOffset() const
{
if (!mPresContext) {
return 0;
@ -280,7 +284,7 @@ nsDOMUIEvent::RangeOffset() const
}
NS_IMETHODIMP
nsDOMUIEvent::GetCancelBubble(bool* aCancelBubble)
UIEvent::GetCancelBubble(bool* aCancelBubble)
{
NS_ENSURE_ARG_POINTER(aCancelBubble);
*aCancelBubble = CancelBubble();
@ -288,14 +292,14 @@ nsDOMUIEvent::GetCancelBubble(bool* aCancelBubble)
}
NS_IMETHODIMP
nsDOMUIEvent::SetCancelBubble(bool aCancelBubble)
UIEvent::SetCancelBubble(bool aCancelBubble)
{
mEvent->mFlags.mPropagationStopped = aCancelBubble;
return NS_OK;
}
nsIntPoint
nsDOMUIEvent::GetLayerPoint() const
UIEvent::GetLayerPoint() const
{
if (!mEvent ||
(mEvent->eventStructType != NS_MOUSE_EVENT &&
@ -320,7 +324,7 @@ nsDOMUIEvent::GetLayerPoint() const
}
NS_IMETHODIMP
nsDOMUIEvent::GetLayerX(int32_t* aLayerX)
UIEvent::GetLayerX(int32_t* aLayerX)
{
NS_ENSURE_ARG_POINTER(aLayerX);
*aLayerX = GetLayerPoint().x;
@ -328,7 +332,7 @@ nsDOMUIEvent::GetLayerX(int32_t* aLayerX)
}
NS_IMETHODIMP
nsDOMUIEvent::GetLayerY(int32_t* aLayerY)
UIEvent::GetLayerY(int32_t* aLayerY)
{
NS_ENSURE_ARG_POINTER(aLayerY);
*aLayerY = GetLayerPoint().y;
@ -336,14 +340,14 @@ nsDOMUIEvent::GetLayerY(int32_t* aLayerY)
}
NS_IMETHODIMP
nsDOMUIEvent::GetIsChar(bool* aIsChar)
UIEvent::GetIsChar(bool* aIsChar)
{
*aIsChar = IsChar();
return NS_OK;
}
bool
nsDOMUIEvent::IsChar() const
UIEvent::IsChar() const
{
WidgetKeyboardEvent* keyEvent = mEvent->AsKeyboardEvent();
if (keyEvent) {
@ -354,7 +358,7 @@ nsDOMUIEvent::IsChar() const
}
NS_IMETHODIMP
nsDOMUIEvent::DuplicatePrivateData()
UIEvent::DuplicatePrivateData()
{
mClientPoint = nsDOMEvent::GetClientCoords(mPresContext,
mEvent,
@ -378,7 +382,7 @@ nsDOMUIEvent::DuplicatePrivateData()
}
NS_IMETHODIMP_(void)
nsDOMUIEvent::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType)
UIEvent::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType)
{
if (aSerializeInterfaceType) {
IPC::WriteParam(aMsg, NS_LITERAL_STRING("uievent"));
@ -392,7 +396,7 @@ nsDOMUIEvent::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType)
}
NS_IMETHODIMP_(bool)
nsDOMUIEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
UIEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
{
NS_ENSURE_TRUE(nsDOMEvent::Deserialize(aMsg, aIter), false);
NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &mDetail), false);
@ -400,14 +404,14 @@ nsDOMUIEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
}
// XXX Following struct and array are used only in
// nsDOMUIEvent::ComputeModifierState(), but if we define them in it,
// UIEvent::ComputeModifierState(), but if we define them in it,
// we fail to build on Mac at calling mozilla::ArrayLength().
struct nsModifierPair
struct ModifierPair
{
mozilla::Modifier modifier;
Modifier modifier;
const char* name;
};
static const nsModifierPair kPairs[] = {
static const ModifierPair kPairs[] = {
{ MODIFIER_ALT, NS_DOM_KEYNAME_ALT },
{ MODIFIER_ALTGRAPH, NS_DOM_KEYNAME_ALTGRAPH },
{ MODIFIER_CAPSLOCK, NS_DOM_KEYNAME_CAPSLOCK },
@ -421,9 +425,9 @@ static const nsModifierPair kPairs[] = {
{ MODIFIER_OS, NS_DOM_KEYNAME_OS }
};
/* static */
mozilla::Modifiers
nsDOMUIEvent::ComputeModifierState(const nsAString& aModifiersList)
// static
Modifiers
UIEvent::ComputeModifierState(const nsAString& aModifiersList)
{
if (aModifiersList.IsEmpty()) {
return 0;
@ -439,7 +443,7 @@ nsDOMUIEvent::ComputeModifierState(const nsAString& aModifiersList)
aModifiersList.BeginReading(listStart);
aModifiersList.EndReading(listEnd);
for (uint32_t i = 0; i < mozilla::ArrayLength(kPairs); i++) {
for (uint32_t i = 0; i < ArrayLength(kPairs); i++) {
nsAString::const_iterator start(listStart), end(listEnd);
if (!FindInReadable(NS_ConvertASCIItoUTF16(kPairs[i].name), start, end)) {
continue;
@ -456,7 +460,7 @@ nsDOMUIEvent::ComputeModifierState(const nsAString& aModifiersList)
}
bool
nsDOMUIEvent::GetModifierStateInternal(const nsAString& aKey)
UIEvent::GetModifierStateInternal(const nsAString& aKey)
{
WidgetInputEvent* inputEvent = mEvent->AsInputEvent();
MOZ_ASSERT(inputEvent, "mEvent must be WidgetInputEvent or derived class");
@ -499,12 +503,18 @@ nsDOMUIEvent::GetModifierStateInternal(const nsAString& aKey)
return false;
}
} // namespace dom
} // namespace mozilla
nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetGUIEvent* aEvent)
using namespace mozilla;
using namespace mozilla::dom;
nsresult
NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult,
EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetGUIEvent* aEvent)
{
nsDOMUIEvent* it = new nsDOMUIEvent(aOwner, aPresContext, aEvent);
UIEvent* it = new UIEvent(aOwner, aPresContext, aEvent);
return CallQueryInterface(it, aInstancePtrResult);
}

View File

@ -3,8 +3,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/. */
#ifndef nsDOMUIEvent_h
#define nsDOMUIEvent_h
#ifndef mozilla_dom_UIEvent_h_
#define mozilla_dom_UIEvent_h_
#include "mozilla/Attributes.h"
#include "nsIDOMUIEvent.h"
@ -16,30 +16,31 @@
class nsINode;
class nsDOMUIEvent : public nsDOMEvent,
public nsIDOMUIEvent
namespace mozilla {
namespace dom {
class UIEvent : public nsDOMEvent,
public nsIDOMUIEvent
{
typedef mozilla::CSSIntPoint CSSIntPoint;
public:
nsDOMUIEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetGUIEvent* aEvent);
UIEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetGUIEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMUIEvent, nsDOMEvent)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(UIEvent, nsDOMEvent)
// nsIDOMUIEvent Interface
NS_DECL_NSIDOMUIEVENT
// Forward to nsDOMEvent
NS_FORWARD_TO_NSDOMEVENT_NO_SERIALIZATION_NO_DUPLICATION
NS_IMETHOD DuplicatePrivateData() MOZ_OVERRIDE;
NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) MOZ_OVERRIDE;
NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter) MOZ_OVERRIDE;
static nsIntPoint
CalculateScreenPoint(nsPresContext* aPresContext,
mozilla::WidgetEvent* aEvent)
static nsIntPoint CalculateScreenPoint(nsPresContext* aPresContext,
WidgetEvent* aEvent)
{
if (!aEvent ||
(aEvent->eventStructType != NS_MOUSE_EVENT &&
@ -51,20 +52,21 @@ public:
return nsIntPoint(0, 0);
}
mozilla::WidgetGUIEvent* event = aEvent->AsGUIEvent();
WidgetGUIEvent* event = aEvent->AsGUIEvent();
if (!event->widget) {
return mozilla::LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint);
return LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint);
}
mozilla::LayoutDeviceIntPoint offset = aEvent->refPoint +
mozilla::LayoutDeviceIntPoint::FromUntyped(event->widget->WidgetToScreenOffset());
nscoord factor = aPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
LayoutDeviceIntPoint offset = aEvent->refPoint +
LayoutDeviceIntPoint::FromUntyped(event->widget->WidgetToScreenOffset());
nscoord factor =
aPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
}
static CSSIntPoint CalculateClientPoint(nsPresContext* aPresContext,
mozilla::WidgetEvent* aEvent,
WidgetEvent* aEvent,
CSSIntPoint* aDefaultClientPoint)
{
if (!aEvent ||
@ -95,15 +97,15 @@ public:
return CSSIntPoint::FromAppUnitsRounded(pt);
}
static already_AddRefed<nsDOMUIEvent> Constructor(const mozilla::dom::GlobalObject& aGlobal,
const nsAString& aType,
const mozilla::dom::UIEventInit& aParam,
mozilla::ErrorResult& aRv);
static already_AddRefed<UIEvent> Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const UIEventInit& aParam,
ErrorResult& aRv);
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
{
return mozilla::dom::UIEventBinding::Wrap(aCx, aScope, this);
return UIEventBinding::Wrap(aCx, aScope, this);
}
nsIDOMWindow* GetView() const
@ -164,27 +166,29 @@ protected:
bool mIsPointerLocked;
CSSIntPoint mLastClientPoint;
typedef mozilla::Modifiers Modifiers;
static Modifiers ComputeModifierState(const nsAString& aModifiersList);
bool GetModifierStateInternal(const nsAString& aKey);
};
#define NS_FORWARD_TO_NSDOMUIEVENT \
NS_FORWARD_NSIDOMUIEVENT(nsDOMUIEvent::) \
} // namespace dom
} // namespace mozilla
#define NS_FORWARD_TO_UIEVENT \
NS_FORWARD_NSIDOMUIEVENT(UIEvent::) \
NS_FORWARD_TO_NSDOMEVENT_NO_SERIALIZATION_NO_DUPLICATION \
NS_IMETHOD DuplicatePrivateData() \
{ \
return nsDOMUIEvent::DuplicatePrivateData(); \
return UIEvent::DuplicatePrivateData(); \
} \
NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, \
bool aSerializeInterfaceType) \
{ \
nsDOMUIEvent::Serialize(aMsg, aSerializeInterfaceType); \
UIEvent::Serialize(aMsg, aSerializeInterfaceType); \
} \
NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, \
void** aIter) \
{ \
return nsDOMUIEvent::Deserialize(aMsg, aIter); \
return UIEvent::Deserialize(aMsg, aIter); \
}
#endif // nsDOMUIEvent_h
#endif // mozilla_dom_UIEvent_h_

View File

@ -0,0 +1,139 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#include "mozilla/dom/XULCommandEvent.h"
#include "prtime.h"
namespace mozilla {
namespace dom {
XULCommandEvent::XULCommandEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetInputEvent* aEvent)
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetInputEvent(false, 0, nullptr))
{
if (aEvent) {
mEventIsInternal = false;
}
else {
mEventIsInternal = true;
mEvent->time = PR_Now();
}
}
NS_IMPL_ADDREF_INHERITED(XULCommandEvent, UIEvent)
NS_IMPL_RELEASE_INHERITED(XULCommandEvent, UIEvent)
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(XULCommandEvent, UIEvent,
mSourceEvent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(XULCommandEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMXULCommandEvent)
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
bool
XULCommandEvent::AltKey()
{
return mEvent->AsInputEvent()->IsAlt();
}
NS_IMETHODIMP
XULCommandEvent::GetAltKey(bool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = AltKey();
return NS_OK;
}
bool
XULCommandEvent::CtrlKey()
{
return mEvent->AsInputEvent()->IsControl();
}
NS_IMETHODIMP
XULCommandEvent::GetCtrlKey(bool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = CtrlKey();
return NS_OK;
}
bool
XULCommandEvent::ShiftKey()
{
return mEvent->AsInputEvent()->IsShift();
}
NS_IMETHODIMP
XULCommandEvent::GetShiftKey(bool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = ShiftKey();
return NS_OK;
}
bool
XULCommandEvent::MetaKey()
{
return mEvent->AsInputEvent()->IsMeta();
}
NS_IMETHODIMP
XULCommandEvent::GetMetaKey(bool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = MetaKey();
return NS_OK;
}
NS_IMETHODIMP
XULCommandEvent::GetSourceEvent(nsIDOMEvent** aSourceEvent)
{
NS_ENSURE_ARG_POINTER(aSourceEvent);
*aSourceEvent = GetSourceEvent().get();
return NS_OK;
}
NS_IMETHODIMP
XULCommandEvent::InitCommandEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
nsIDOMWindow* aView,
int32_t aDetail,
bool aCtrlKey,
bool aAltKey,
bool aShiftKey,
bool aMetaKey,
nsIDOMEvent* aSourceEvent)
{
nsresult rv = UIEvent::InitUIEvent(aType, aCanBubble, aCancelable,
aView, aDetail);
NS_ENSURE_SUCCESS(rv, rv);
mEvent->AsInputEvent()->InitBasicModifiers(aCtrlKey, aAltKey,
aShiftKey, aMetaKey);
mSourceEvent = aSourceEvent;
return NS_OK;
}
} // namespace dom
} // namespace mozilla
using namespace mozilla;
using namespace mozilla::dom;
nsresult
NS_NewDOMXULCommandEvent(nsIDOMEvent** aInstancePtrResult,
EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetInputEvent* aEvent)
{
XULCommandEvent* it = new XULCommandEvent(aOwner, aPresContext, aEvent);
return CallQueryInterface(it, aInstancePtrResult);
}

View File

@ -6,32 +6,35 @@
// This class implements a XUL "command" event. See nsIDOMXULCommandEvent.idl
#ifndef nsDOMXULCommandEvent_h_
#define nsDOMXULCommandEvent_h_
#ifndef mozilla_dom_XULCommandEvent_h_
#define mozilla_dom_XULCommandEvent_h_
#include "nsDOMUIEvent.h"
#include "nsIDOMXULCommandEvent.h"
#include "mozilla/dom/UIEvent.h"
#include "mozilla/dom/XULCommandEventBinding.h"
#include "nsIDOMXULCommandEvent.h"
class nsDOMXULCommandEvent : public nsDOMUIEvent,
public nsIDOMXULCommandEvent
namespace mozilla {
namespace dom {
class XULCommandEvent : public UIEvent,
public nsIDOMXULCommandEvent
{
public:
nsDOMXULCommandEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetInputEvent* aEvent);
XULCommandEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetInputEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULCommandEvent, UIEvent)
NS_DECL_NSIDOMXULCOMMANDEVENT
// Forward our inherited virtual methods to the base class
NS_FORWARD_TO_NSDOMUIEVENT
NS_FORWARD_TO_UIEVENT
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
{
return mozilla::dom::XULCommandEventBinding::Wrap(aCx, aScope, this);
return XULCommandEventBinding::Wrap(aCx, aScope, this);
}
bool AltKey();
@ -53,7 +56,7 @@ public:
bool aCtrlKey, bool aAltKey,
bool aShiftKey, bool aMetaKey,
nsDOMEvent* aSourceEvent,
mozilla::ErrorResult& aRv)
ErrorResult& aRv)
{
aRv = InitCommandEvent(aType, aCanBubble, aCancelable, aView, aDetail,
aCtrlKey, aAltKey, aShiftKey, aMetaKey,
@ -64,4 +67,7 @@ protected:
nsCOMPtr<nsIDOMEvent> mSourceEvent;
};
#endif // nsDOMXULCommandEvent_h_
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_XULCommandEvent_h_

View File

@ -18,8 +18,6 @@ EXPORTS += [
'nsDOMEvent.h',
'nsDOMEventTargetHelper.h',
'nsDOMKeyNameList.h',
'nsDOMTouchEvent.h',
'nsDOMUIEvent.h',
'nsEventDispatcher.h',
'nsEventListenerManager.h',
'nsEventNameList.h',
@ -52,10 +50,17 @@ EXPORTS.mozilla.dom += [
'MouseEvent.h',
'MouseScrollEvent.h',
'MutationEvent.h',
'NotifyAudioAvailableEvent.h',
'NotifyPaintEvent.h',
'PointerEvent.h',
'ScrollAreaEvent.h',
'SimpleGestureEvent.h',
'Touch.h',
'TouchEvent.h',
'TransitionEvent.h',
'UIEvent.h',
'WheelEvent.h',
'XULCommandEvent.h',
]
if CONFIG['MOZ_WEBSPEECH']:
@ -78,14 +83,11 @@ UNIFIED_SOURCES += [
'MouseEvent.cpp',
'MouseScrollEvent.cpp',
'MutationEvent.cpp',
'NotifyAudioAvailableEvent.cpp',
'nsAsyncDOMEvent.cpp',
'nsContentEventHandler.cpp',
'nsDOMEventTargetHelper.cpp',
'nsDOMNotifyAudioAvailableEvent.cpp',
'nsDOMTextEvent.cpp',
'nsDOMTouchEvent.cpp',
'nsDOMTransitionEvent.cpp',
'nsDOMXULCommandEvent.cpp',
'nsEventDispatcher.cpp',
'nsEventListenerService.cpp',
'nsIMEStateManager.cpp',
@ -96,28 +98,31 @@ UNIFIED_SOURCES += [
'SimpleGestureEvent.cpp',
'TextComposition.cpp',
'Touch.cpp',
'TouchEvent.cpp',
'TransitionEvent.cpp',
'WheelEvent.cpp',
'XULCommandEvent.cpp',
]
SOURCES += [
# nsDOMEvent.cpp should be built separately because it includes
# ipc/IPCMessageUtils.h, which on Windows includes windows.h.
'NotifyPaintEvent.cpp',
# nsDOMEvent.cpp should be built separately because it includes
# ipc/IPCMessageUtils.h, which on Windows includes windows.h.
'nsDOMEvent.cpp',
# nsDOMEvent.cpp should be built separately because it includes
# ipc/IPCMessageUtils.h, which on Windows includes windows.h.
'nsDOMNotifyPaintEvent.cpp',
# nsDOMEvent.cpp should be built separately because it includes
# ipc/IPCMessageUtils.h, which on Windows includes windows.h.
'nsDOMScrollAreaEvent.cpp',
# nsDOMEvent.cpp should be built separately because it includes
# ipc/IPCMessageUtils.h, which on Windows includes windows.h.
'nsDOMUIEvent.cpp',
# nsDOMEvent.cpp should be built separately because it includes
# mozilla/HalSensor.h, which includes ipc/IPCMessageUtils.h, which
# on Windows includes windows.h.
'nsEventListenerManager.cpp',
# nsEventStateManager.cpp should be built separately because of Mac OS X headers.
'nsEventStateManager.cpp',
# nsDOMEvent.cpp should be built separately because it includes
# ipc/IPCMessageUtils.h, which on Windows includes windows.h.
'ScrollAreaEvent.cpp',
# nsDOMEvent.cpp should be built separately because it includes
# ipc/IPCMessageUtils.h, which on Windows includes windows.h.
'UIEvent.cpp',
]
if CONFIG['MOZ_WEBSPEECH']:

View File

@ -1,169 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#include "nsDOMNotifyAudioAvailableEvent.h"
#include "nsError.h"
#include "mozilla/HoldDropJSObjects.h"
#include "jsfriendapi.h"
using namespace mozilla;
using namespace mozilla::dom;
nsDOMNotifyAudioAvailableEvent::nsDOMNotifyAudioAvailableEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
float* aFrameBuffer,
uint32_t aFrameBufferLength,
float aTime)
: nsDOMEvent(aOwner, aPresContext, aEvent),
mFrameBuffer(aFrameBuffer),
mFrameBufferLength(aFrameBufferLength),
mTime(aTime),
mCachedArray(nullptr),
mAllowAudioData(false)
{
MOZ_COUNT_CTOR(nsDOMNotifyAudioAvailableEvent);
if (mEvent) {
mEvent->message = aEventType;
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMNotifyAudioAvailableEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMNotifyAudioAvailableEvent, nsDOMEvent)
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMNotifyAudioAvailableEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMNotifyAudioAvailableEvent, nsDOMEvent)
if (tmp->mCachedArray) {
tmp->mCachedArray = nullptr;
mozilla::DropJSObjects(tmp);
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMNotifyAudioAvailableEvent, nsDOMEvent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsDOMNotifyAudioAvailableEvent, nsDOMEvent)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mCachedArray)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMNotifyAudioAvailableEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMNotifyAudioAvailableEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
nsDOMNotifyAudioAvailableEvent::~nsDOMNotifyAudioAvailableEvent()
{
MOZ_COUNT_DTOR(nsDOMNotifyAudioAvailableEvent);
if (mCachedArray) {
mCachedArray = nullptr;
mozilla::DropJSObjects(this);
}
}
NS_IMETHODIMP
nsDOMNotifyAudioAvailableEvent::GetFrameBuffer(JSContext* aCx, JS::MutableHandle<JS::Value> aResult)
{
if (!mAllowAudioData) {
// Media is not same-origin, don't allow the data out.
return NS_ERROR_DOM_SECURITY_ERR;
}
if (mCachedArray) {
aResult.setObject(*mCachedArray);
return NS_OK;
}
// Cache this array so we don't recreate on next call.
mozilla::HoldJSObjects(this);
mCachedArray = JS_NewFloat32Array(aCx, mFrameBufferLength);
if (!mCachedArray) {
mozilla::DropJSObjects(this);
return NS_ERROR_FAILURE;
}
memcpy(JS_GetFloat32ArrayData(mCachedArray), mFrameBuffer.get(), mFrameBufferLength * sizeof(float));
aResult.setObject(*mCachedArray);
return NS_OK;
}
NS_IMETHODIMP
nsDOMNotifyAudioAvailableEvent::GetTime(float *aRetVal)
{
*aRetVal = Time();
return NS_OK;
}
NS_IMETHODIMP
nsDOMNotifyAudioAvailableEvent::InitAudioAvailableEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
float* aFrameBuffer,
uint32_t aFrameBufferLength,
float aTime,
bool aAllowAudioData)
{
// Auto manage the memory which stores the frame buffer. This ensures
// that if we exit due to some error, the memory will be freed. Otherwise,
// the framebuffer's memory will be freed when this event is destroyed.
nsAutoArrayPtr<float> frameBuffer(aFrameBuffer);
nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS(rv, rv);
mFrameBuffer = frameBuffer.forget();
mFrameBufferLength = aFrameBufferLength;
mTime = aTime;
mAllowAudioData = aAllowAudioData;
mCachedArray = nullptr;
return NS_OK;
}
void
nsDOMNotifyAudioAvailableEvent::InitAudioAvailableEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
const Nullable<Sequence<float> >& aFrameBuffer,
uint32_t aFrameBufferLength,
float aTime,
bool aAllowAudioData,
ErrorResult& aRv)
{
if ((aFrameBuffer.IsNull() && aFrameBufferLength > 0) ||
(!aFrameBuffer.IsNull() &&
aFrameBuffer.Value().Length() < aFrameBufferLength)) {
aRv = NS_ERROR_UNEXPECTED;
return;
}
nsAutoArrayPtr<float> buffer;
if (!aFrameBuffer.IsNull()) {
buffer = new float[aFrameBufferLength];
memcpy(buffer.get(), aFrameBuffer.Value().Elements(),
aFrameBufferLength * sizeof(float));
}
aRv = InitAudioAvailableEvent(aType, aCanBubble, aCancelable,
buffer.forget(),
aFrameBufferLength,
aTime, aAllowAudioData);
}
nsresult NS_NewDOMAudioAvailableEvent(nsIDOMEvent** aInstancePtrResult,
EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent,
uint32_t aEventType,
float* aFrameBuffer,
uint32_t aFrameBufferLength,
float aTime)
{
nsDOMNotifyAudioAvailableEvent* it =
new nsDOMNotifyAudioAvailableEvent(aOwner, aPresContext, aEvent, aEventType,
aFrameBuffer, aFrameBufferLength, aTime);
return CallQueryInterface(it, aInstancePtrResult);
}

View File

@ -1,79 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#ifndef nsDOMNotifyAudioAvailableEvent_h_
#define nsDOMNotifyAudioAvailableEvent_h_
#include "nsIDOMNotifyAudioAvailableEvent.h"
#include "nsDOMEvent.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/dom/NotifyAudioAvailableEventBinding.h"
class nsPresContext;
class nsDOMNotifyAudioAvailableEvent : public nsDOMEvent,
public nsIDOMNotifyAudioAvailableEvent
{
public:
nsDOMNotifyAudioAvailableEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetEvent* aEvent,
uint32_t aEventType, float * aFrameBuffer,
uint32_t aFrameBufferLength, float aTime);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsDOMNotifyAudioAvailableEvent,
nsDOMEvent)
NS_DECL_NSIDOMNOTIFYAUDIOAVAILABLEEVENT
NS_FORWARD_NSIDOMEVENT(nsDOMEvent::)
nsresult NS_NewDOMAudioAvailableEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetEvent* aEvent,
uint32_t aEventType,
float * aFrameBuffer,
uint32_t aFrameBufferLength,
float aTime);
~nsDOMNotifyAudioAvailableEvent();
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
{
return mozilla::dom::NotifyAudioAvailableEventBinding::Wrap(aCx, aScope, this);
}
JSObject* GetFrameBuffer(JSContext* aCx, mozilla::ErrorResult& aRv)
{
JS::Rooted<JS::Value> dummy(aCx);
aRv = GetFrameBuffer(aCx, &dummy);
return mCachedArray;
}
float Time()
{
return mTime;
}
void InitAudioAvailableEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
const mozilla::dom::Nullable<mozilla::dom::Sequence<float> >& aFrameBuffer,
uint32_t aFrameBufferLength,
float aTime,
bool aAllowAudioData,
mozilla::ErrorResult& aRv);
private:
nsAutoArrayPtr<float> mFrameBuffer;
uint32_t mFrameBufferLength;
float mTime;
JS::Heap<JSObject*> mCachedArray;
bool mAllowAudioData;
};
#endif // nsDOMNotifyAudioAvailableEvent_h_

View File

@ -10,12 +10,13 @@
#include "mozilla/TextEvents.h"
using namespace mozilla;
using namespace mozilla::dom;
nsDOMTextEvent::nsDOMTextEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetTextEvent* aEvent)
: nsDOMUIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetTextEvent(false, 0, nullptr))
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetTextEvent(false, 0, nullptr))
{
NS_ASSERTION(mEvent->eventStructType == NS_TEXT_EVENT, "event type mismatch");
@ -53,12 +54,12 @@ nsDOMTextEvent::nsDOMTextEvent(mozilla::dom::EventTarget* aOwner,
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMTextEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMTextEvent, nsDOMUIEvent)
NS_IMPL_ADDREF_INHERITED(nsDOMTextEvent, UIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMTextEvent, UIEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMTextEvent)
NS_INTERFACE_MAP_ENTRY(nsIPrivateTextEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
NS_METHOD nsDOMTextEvent::GetText(nsString& aText)
{

View File

@ -6,15 +6,17 @@
#ifndef nsDOMTextEvent_h__
#define nsDOMTextEvent_h__
#include "mozilla/dom/UIEvent.h"
#include "mozilla/Attributes.h"
#include "mozilla/EventForwards.h"
#include "nsDOMUIEvent.h"
#include "nsIPrivateTextEvent.h"
#include "nsPrivateTextRange.h"
class nsDOMTextEvent : public nsDOMUIEvent,
class nsDOMTextEvent : public mozilla::dom::UIEvent,
public nsIPrivateTextEvent
{
typedef mozilla::dom::UIEvent UIEvent;
public:
nsDOMTextEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
@ -23,7 +25,7 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// Forward to base class
NS_FORWARD_TO_NSDOMUIEVENT
NS_FORWARD_TO_UIEVENT
// nsIPrivateTextEvent interface
NS_IMETHOD GetText(nsString& aText) MOZ_OVERRIDE;

View File

@ -1,130 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#include "nsDOMXULCommandEvent.h"
#include "prtime.h"
using namespace mozilla;
nsDOMXULCommandEvent::nsDOMXULCommandEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetInputEvent* aEvent)
: nsDOMUIEvent(aOwner, aPresContext,
aEvent ? aEvent : new WidgetInputEvent(false, 0, nullptr))
{
if (aEvent) {
mEventIsInternal = false;
}
else {
mEventIsInternal = true;
mEvent->time = PR_Now();
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(nsDOMXULCommandEvent, nsDOMUIEvent,
mSourceEvent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMXULCommandEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMXULCommandEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
bool
nsDOMXULCommandEvent::AltKey()
{
return mEvent->AsInputEvent()->IsAlt();
}
NS_IMETHODIMP
nsDOMXULCommandEvent::GetAltKey(bool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = AltKey();
return NS_OK;
}
bool
nsDOMXULCommandEvent::CtrlKey()
{
return mEvent->AsInputEvent()->IsControl();
}
NS_IMETHODIMP
nsDOMXULCommandEvent::GetCtrlKey(bool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = CtrlKey();
return NS_OK;
}
bool
nsDOMXULCommandEvent::ShiftKey()
{
return mEvent->AsInputEvent()->IsShift();
}
NS_IMETHODIMP
nsDOMXULCommandEvent::GetShiftKey(bool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = ShiftKey();
return NS_OK;
}
bool
nsDOMXULCommandEvent::MetaKey()
{
return mEvent->AsInputEvent()->IsMeta();
}
NS_IMETHODIMP
nsDOMXULCommandEvent::GetMetaKey(bool* aIsDown)
{
NS_ENSURE_ARG_POINTER(aIsDown);
*aIsDown = MetaKey();
return NS_OK;
}
NS_IMETHODIMP
nsDOMXULCommandEvent::GetSourceEvent(nsIDOMEvent** aSourceEvent)
{
NS_ENSURE_ARG_POINTER(aSourceEvent);
*aSourceEvent = GetSourceEvent().get();
return NS_OK;
}
NS_IMETHODIMP
nsDOMXULCommandEvent::InitCommandEvent(const nsAString& aType,
bool aCanBubble, bool aCancelable,
nsIDOMWindow* aView,
int32_t aDetail,
bool aCtrlKey, bool aAltKey,
bool aShiftKey, bool aMetaKey,
nsIDOMEvent* aSourceEvent)
{
nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable,
aView, aDetail);
NS_ENSURE_SUCCESS(rv, rv);
mEvent->AsInputEvent()->InitBasicModifiers(aCtrlKey, aAltKey,
aShiftKey, aMetaKey);
mSourceEvent = aSourceEvent;
return NS_OK;
}
nsresult NS_NewDOMXULCommandEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetInputEvent* aEvent)
{
nsDOMXULCommandEvent* it =
new nsDOMXULCommandEvent(aOwner, aPresContext, aEvent);
return CallQueryInterface(it, aInstancePtrResult);
}

View File

@ -14,11 +14,11 @@
#include "nsIDocument.h"
#include "nsINode.h"
#include "nsPIDOMWindow.h"
#include "nsDOMTouchEvent.h"
#include "GeckoProfiler.h"
#include "GeneratedEvents.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/dom/EventTarget.h"
#include "mozilla/dom/TouchEvent.h"
#include "mozilla/InternalMutationEvent.h"
#include "mozilla/MiscEvents.h"
#include "mozilla/MouseEvents.h"
@ -818,7 +818,7 @@ nsEventDispatcher::CreateEvent(mozilla::dom::EventTarget* aOwner,
if (aEventType.LowerCaseEqualsLiteral("closeevent"))
return NS_NewDOMCloseEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("touchevent") &&
nsDOMTouchEvent::PrefEnabled())
TouchEvent::PrefEnabled())
return NS_NewDOMTouchEvent(aDOMEvent, aOwner, aPresContext, nullptr);
if (aEventType.LowerCaseEqualsLiteral("hashchangeevent"))
return NS_NewDOMHashChangeEvent(aDOMEvent, aOwner, aPresContext, nullptr);

View File

@ -11,6 +11,7 @@
#include "mozilla/TextEvents.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/dom/TabParent.h"
#include "mozilla/dom/UIEvent.h"
#include "nsCOMPtr.h"
#include "nsEventStateManager.h"
@ -50,7 +51,6 @@
#include "nsIDOMWheelEvent.h"
#include "nsIDOMDragEvent.h"
#include "nsIDOMUIEvent.h"
#include "nsDOMUIEvent.h"
#include "nsIMozBrowserFrame.h"
#include "nsSubDocumentFrame.h"
@ -1030,9 +1030,9 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
aEvent->eventStructType == NS_WHEEL_EVENT) &&
!sIsPointerLocked) {
sLastScreenPoint =
nsDOMUIEvent::CalculateScreenPoint(aPresContext, aEvent);
UIEvent::CalculateScreenPoint(aPresContext, aEvent);
sLastClientPoint =
nsDOMUIEvent::CalculateClientPoint(aPresContext, aEvent, nullptr);
UIEvent::CalculateClientPoint(aPresContext, aEvent, nullptr);
}
// Do not take account NS_MOUSE_ENTER/EXIT so that loading a page
@ -2337,9 +2337,9 @@ nsEventStateManager::DoDefaultDragStart(nsPresContext* aPresContext,
// target of the mouse event. If one wasn't set in the
// aDataTransfer during the event handler, just use the original
// target instead.
nsCOMPtr<Element> dragTarget = aDataTransfer->GetDragTarget();
nsCOMPtr<nsIContent> dragTarget = aDataTransfer->GetDragTarget();
if (!dragTarget) {
dragTarget = do_QueryInterface(aDragTarget);
dragTarget = aDragTarget;
if (!dragTarget)
return false;
}
@ -4332,7 +4332,7 @@ nsEventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent,
// Returns the center point of the window's inner content area.
// This is in widget coordinates, i.e. relative to the widget's top
// left corner, not in screen coordinates, the same units that
// nsDOMUIEvent::refPoint is in.
// UIEvent::refPoint is in.
//
// XXX Hack alert: XXX
// However, we do the computation in integer CSS pixels, NOT device pix,
@ -4386,7 +4386,7 @@ nsEventStateManager::GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent)
case NS_MOUSE_MOVE:
{
// Mouse movement is reported on the MouseEvent.movement{X,Y} fields.
// Movement is calculated in nsDOMUIEvent::GetMovementPoint() as:
// Movement is calculated in UIEvent::GetMovementPoint() as:
// previous_mousemove_refPoint - current_mousemove_refPoint.
if (sIsPointerLocked && aMouseEvent->widget) {
// The pointer is locked. If the pointer is not located at the center of

View File

@ -198,6 +198,7 @@ function testOnPointerProperty()
iframeBody.onpointerover = function (e) { gOnPointerPropHandled["pointerover"] = true; }
iframeBody.onpointerenter = function (e) { gOnPointerPropHandled["pointerenter"] = true; }
iframeBody.onpointerleave = function (e) { gOnPointerPropHandled["pointerleave"] = true; }
iframeBody.onpointercancel = function (e) { gOnPointerPropHandled["pointercancel"] = true; }
iframeBody.dispatchEvent(getDefaultArgEvent("pointerdown"));
is(gOnPointerPropHandled['pointerdown'], true, "pointerdown property is performed");
@ -220,6 +221,9 @@ function testOnPointerProperty()
iframeBody.dispatchEvent(getDefaultArgEvent("pointerleave"));
is(gOnPointerPropHandled['pointerleave'], true, "pointerleave property is performed");
iframeBody.dispatchEvent(getDefaultArgEvent("pointercancel"));
is(gOnPointerPropHandled['pointercancel'], true, "pointercancel property is performed");
nextTest();
}

View File

@ -166,7 +166,7 @@ function penter(evt) {
is(evt.target.id, t, "Wrong event target!");
}
is(evt.bubbles, false, evt.type + " should not bubble!");
is(evt.cancelable, true, evt.type + " is cancelable!");
is(evt.cancelable, false, evt.type + " is cancelable!");
is(evt.target, evt.currentTarget, "Wrong event target!");
ok(!evt.relatedTarget || evt.target.ownerDocument == evt.relatedTarget.ownerDocument,
"Leaking nodes to another document?");
@ -183,7 +183,7 @@ function pleave(evt) {
is(evt.target.id, t, "Wrong event target!");
}
is(evt.bubbles, false, evt.type + " should not bubble!");
is(evt.cancelable, true, evt.type + " is cancelable!");
is(evt.cancelable, false, evt.type + " is cancelable!");
is(evt.target, evt.currentTarget, "Wrong event target!");
ok(!evt.relatedTarget || evt.target.ownerDocument == evt.relatedTarget.ownerDocument,
"Leaking nodes to another document?");

View File

@ -5,7 +5,7 @@
#include "nsIDOMEventTarget.idl"
[scriptable, builtinclass, uuid(bcdf4ce4-9785-4e31-a851-1d51ea16da20)]
[scriptable, builtinclass, uuid(e732649a-4f78-4ded-abe1-dbdc36fd59d3)]
interface nsIDOMScreen : nsIDOMEventTarget
{
readonly attribute long top;
@ -26,36 +26,4 @@ interface nsIDOMScreen : nsIDOMEventTarget
*/
[binaryname(SlowMozOrientation)]
readonly attribute DOMString mozOrientation;
/**
* Lock the screen to the specified orientations(s). This method returns true
* if the lock was acquired successfully, and false otherwise.
*
* The parameter can be a DOMString or an Array of DOMStrings. If you pass a
* string, we lock the screen to that one orientation. If you pass an Array,
* we ensure that the screen is always in one of the given orientations.
*
* Valid orientations are "portrait", "portrait-primary",
* "portrait-secondary", "landscape", "landscape-primary", and
* "landscape-secondary".
* These tokens are case-sensitive.
*
* If you pass a string that's not one of the valid orientations, or if you
* pass an array of orientations and any of the orientations in the array is
* not valid, we reject the lock and return false.
*
* The "-primary" orientations correspond to holding the device right-side up,
* while the "-secondary" orientations correspond to holding the device
* upside-down. Locking the orientation in "portrait" is the same as locking
* the orientation in ['portrait-primary', 'portrait-secondary'], and the
* "landscape" orientation similarly corresponds to the set
* ['landscape-primary', 'landscape-secondary'].
*/
[implicit_jscontext] boolean mozLockOrientation(in jsval orientation);
/**
* Unlock the screen orientation.
*/
[binaryname(SlowMozUnlockOrientation)]
void mozUnlockOrientation();
};

View File

@ -3,16 +3,17 @@
* 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 "nsDOMTimeEvent.h"
#include "nsPresContext.h"
#include "nsIInterfaceRequestorUtils.h"
#include "mozilla/dom/TimeEvent.h"
#include "mozilla/BasicEvents.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsPresContext.h"
using namespace mozilla;
namespace mozilla {
namespace dom {
nsDOMTimeEvent::nsDOMTimeEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent)
TimeEvent::TimeEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent)
: nsDOMEvent(aOwner, aPresContext,
aEvent ? aEvent : new InternalUIEvent(false, 0)),
mDetail(0)
@ -43,18 +44,18 @@ nsDOMTimeEvent::nsDOMTimeEvent(mozilla::dom::EventTarget* aOwner,
}
}
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(nsDOMTimeEvent, nsDOMEvent,
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(TimeEvent, nsDOMEvent,
mView)
NS_IMPL_ADDREF_INHERITED(nsDOMTimeEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMTimeEvent, nsDOMEvent)
NS_IMPL_ADDREF_INHERITED(TimeEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(TimeEvent, nsDOMEvent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMTimeEvent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TimeEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMTimeEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMETHODIMP
nsDOMTimeEvent::GetView(nsIDOMWindow** aView)
TimeEvent::GetView(nsIDOMWindow** aView)
{
*aView = mView;
NS_IF_ADDREF(*aView);
@ -62,16 +63,16 @@ nsDOMTimeEvent::GetView(nsIDOMWindow** aView)
}
NS_IMETHODIMP
nsDOMTimeEvent::GetDetail(int32_t* aDetail)
TimeEvent::GetDetail(int32_t* aDetail)
{
*aDetail = mDetail;
return NS_OK;
}
NS_IMETHODIMP
nsDOMTimeEvent::InitTimeEvent(const nsAString& aTypeArg,
nsIDOMWindow* aViewArg,
int32_t aDetailArg)
TimeEvent::InitTimeEvent(const nsAString& aTypeArg,
nsIDOMWindow* aViewArg,
int32_t aDetailArg)
{
nsresult rv = nsDOMEvent::InitEvent(aTypeArg, false /*doesn't bubble*/,
false /*can't cancel*/);
@ -83,11 +84,18 @@ nsDOMTimeEvent::InitTimeEvent(const nsAString& aTypeArg,
return NS_OK;
}
nsresult NS_NewDOMTimeEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent)
} // namespace dom
} // namespace mozilla
using namespace mozilla;
using namespace mozilla::dom;
nsresult
NS_NewDOMTimeEvent(nsIDOMEvent** aInstancePtrResult,
EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent)
{
nsDOMTimeEvent* it = new nsDOMTimeEvent(aOwner, aPresContext, aEvent);
TimeEvent* it = new TimeEvent(aOwner, aPresContext, aEvent);
return CallQueryInterface(it, aInstancePtrResult);
}

View File

@ -3,24 +3,27 @@
* 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/. */
#ifndef NS_DOMTIMEEVENT_H_
#define NS_DOMTIMEEVENT_H_
#ifndef mozilla_dom_TimeEvent_h_
#define mozilla_dom_TimeEvent_h_
#include "nsIDOMTimeEvent.h"
#include "nsDOMEvent.h"
#include "mozilla/dom/TimeEventBinding.h"
class nsDOMTimeEvent MOZ_FINAL : public nsDOMEvent,
public nsIDOMTimeEvent
namespace mozilla {
namespace dom {
class TimeEvent MOZ_FINAL : public nsDOMEvent,
public nsIDOMTimeEvent
{
public:
nsDOMTimeEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetEvent* aEvent);
TimeEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetEvent* aEvent);
// nsISupports interface:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMTimeEvent, nsDOMEvent)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TimeEvent, nsDOMEvent)
// nsIDOMTimeEvent interface:
NS_DECL_NSIDOMTIMEEVENT
@ -31,7 +34,7 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
{
return mozilla::dom::TimeEventBinding::Wrap(aCx, aScope, this);
return TimeEventBinding::Wrap(aCx, aScope, this);
}
int32_t Detail() const
@ -45,7 +48,7 @@ public:
}
void InitTimeEvent(const nsAString& aType, nsIDOMWindow* aView,
int32_t aDetail, mozilla::ErrorResult& aRv)
int32_t aDetail, ErrorResult& aRv)
{
aRv = InitTimeEvent(aType, aView, aDetail);
}
@ -55,4 +58,7 @@ private:
int32_t mDetail;
};
#endif // NS_DOMTIMEEVENT_H_
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_TimeEvent_h_

View File

@ -7,7 +7,6 @@
TEST_TOOL_DIRS += ['test']
EXPORTS += [
'nsDOMTimeEvent.h',
'nsISMILAttr.h',
'nsISMILType.h',
'nsSMILAnimationController.h',
@ -32,8 +31,11 @@ EXPORTS += [
'nsSMILValue.h',
]
EXPORTS.mozilla.dom += [
'TimeEvent.h',
]
UNIFIED_SOURCES += [
'nsDOMTimeEvent.cpp',
'nsSMILAnimationController.cpp',
'nsSMILAnimationFunction.cpp',
'nsSMILCompositor.cpp',
@ -57,6 +59,7 @@ UNIFIED_SOURCES += [
'SMILEnumType.cpp',
'SMILIntegerType.cpp',
'SMILStringType.cpp',
'TimeEvent.cpp',
]
FAIL_ON_WARNINGS = True

View File

@ -90,6 +90,8 @@ interface GlobalEventHandlers {
// Pointer events handlers
[Pref="dom.w3c_pointer_events.enabled"]
attribute EventHandler onpointercancel;
[Pref="dom.w3c_pointer_events.enabled"]
attribute EventHandler onpointerdown;
[Pref="dom.w3c_pointer_events.enabled"]
attribute EventHandler onpointerup;

View File

@ -6,7 +6,7 @@
interface WindowProxy;
[Func="nsDOMTouchEvent::PrefEnabled"]
[Func="mozilla::dom::TouchEvent::PrefEnabled"]
interface TouchEvent : UIEvent {
readonly attribute TouchList touches;
readonly attribute TouchList targetTouches;

View File

@ -10,7 +10,7 @@
* liability, trademark and document use rules apply.
*/
[Func="nsDOMTouchList::PrefEnabled"]
[Func="mozilla::dom::TouchList::PrefEnabled"]
interface TouchList {
[Pure]
readonly attribute unsigned long length;

View File

@ -148,7 +148,7 @@ namespace {
const uint32_t kNoIndex = uint32_t(-1);
const JS::ContextOptions kRequiredJSContextOptions =
const JS::ContextOptions kRequiredContextOptions =
JS::ContextOptions().setDontReportUncaught(true)
.setNoScriptRval(true);
@ -300,7 +300,7 @@ GenerateSharedWorkerKey(const nsACString& aScriptSpec, const nsACString& aName,
}
void
LoadJSContextOptions(const char* aPrefName, void* /* aClosure */)
LoadRuntimeAndContextOptions(const char* aPrefName, void* /* aClosure */)
{
AssertIsOnMainThread();
@ -330,51 +330,47 @@ LoadJSContextOptions(const char* aPrefName, void* /* aClosure */)
}
#endif
// Runtime options.
JS::RuntimeOptions runtimeOptions;
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("asmjs"))) {
runtimeOptions.setAsmJS(true);
}
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("typeinference"))) {
runtimeOptions.setTypeInference(true);
}
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("baselinejit"))) {
runtimeOptions.setBaseline(true);
}
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("ion"))) {
runtimeOptions.setIon(true);
}
// Common options.
JS::ContextOptions commonOptions = kRequiredJSContextOptions;
JS::ContextOptions commonContextOptions = kRequiredContextOptions;
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict"))) {
commonOptions.setExtraWarnings(true);
commonContextOptions.setExtraWarnings(true);
}
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("werror"))) {
commonOptions.setWerror(true);
}
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("asmjs"))) {
commonOptions.setAsmJS(true);
commonContextOptions.setWerror(true);
}
// Content options.
JS::ContextOptions contentOptions = commonOptions;
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("baselinejit.content"))) {
contentOptions.setBaseline(true);
}
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("ion.content"))) {
contentOptions.setIon(true);
}
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("typeinference.content"))) {
contentOptions.setTypeInference(true);
}
JS::ContextOptions contentContextOptions = commonContextOptions;
// Chrome options.
JS::ContextOptions chromeOptions = commonOptions;
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("baselinejit.chrome"))) {
chromeOptions.setBaseline(true);
}
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("ion.chrome"))) {
chromeOptions.setIon(true);
}
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("typeinference.chrome"))) {
chromeOptions.setTypeInference(true);
}
JS::ContextOptions chromeContextOptions = commonContextOptions;
#ifdef DEBUG
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict.debug"))) {
chromeOptions.setExtraWarnings(true);
chromeContextOptions.setExtraWarnings(true);
}
#endif
RuntimeService::SetDefaultJSContextOptions(contentOptions, chromeOptions);
RuntimeService::SetDefaultRuntimeAndContextOptions(runtimeOptions,
contentContextOptions,
chromeContextOptions);
if (rts) {
rts->UpdateAllWorkerJSContextOptions();
rts->UpdateAllWorkerRuntimeAndContextOptions();
}
}
@ -771,6 +767,8 @@ CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate, JSRuntime* aRuntime)
JSSettings settings;
aWorkerPrivate->CopyJSSettings(settings);
JS::RuntimeOptionsRef(aRuntime) = settings.runtimeOptions;
JSSettings::JSGCSettingsArray& gcSettings = settings.gcSettings;
// This is the real place where we set the max memory for the runtime.
@ -1614,10 +1612,11 @@ RuntimeService::Init()
// Initialize JSSettings.
if (!sDefaultJSSettings.gcSettings[0].IsSet()) {
sDefaultJSSettings.chrome.contextOptions = kRequiredJSContextOptions;
sDefaultJSSettings.runtimeOptions = JS::RuntimeOptions();
sDefaultJSSettings.chrome.contextOptions = kRequiredContextOptions;
sDefaultJSSettings.chrome.maxScriptRuntime = -1;
sDefaultJSSettings.chrome.compartmentOptions.setVersion(JSVERSION_LATEST);
sDefaultJSSettings.content.contextOptions = kRequiredJSContextOptions;
sDefaultJSSettings.content.contextOptions = kRequiredContextOptions;
sDefaultJSSettings.content.maxScriptRuntime = MAX_SCRIPT_RUN_TIME_SEC;
#ifdef JS_GC_ZEAL
sDefaultJSSettings.gcZealFrequency = JS_DEFAULT_ZEAL_FREQ;
@ -1692,13 +1691,13 @@ RuntimeService::Init()
PREF_DOM_WINDOW_DUMP_ENABLED,
reinterpret_cast<void *>(WORKERPREF_DUMP))) ||
#endif
NS_FAILED(Preferences::RegisterCallback(LoadJSContextOptions,
NS_FAILED(Preferences::RegisterCallback(LoadRuntimeAndContextOptions,
PREF_JS_OPTIONS_PREFIX,
nullptr)) ||
NS_FAILED(Preferences::RegisterCallbackAndCall(
LoadJSContextOptions,
PREF_WORKERS_OPTIONS_PREFIX,
nullptr)) ||
LoadRuntimeAndContextOptions,
PREF_WORKERS_OPTIONS_PREFIX,
nullptr)) ||
NS_FAILED(Preferences::RegisterCallbackAndCall(
JSVersionChanged,
PREF_WORKERS_LATEST_JS_VERSION,
@ -1845,10 +1844,10 @@ RuntimeService::Cleanup()
if (NS_FAILED(Preferences::UnregisterCallback(JSVersionChanged,
PREF_WORKERS_LATEST_JS_VERSION,
nullptr)) ||
NS_FAILED(Preferences::UnregisterCallback(LoadJSContextOptions,
NS_FAILED(Preferences::UnregisterCallback(LoadRuntimeAndContextOptions,
PREF_JS_OPTIONS_PREFIX,
nullptr)) ||
NS_FAILED(Preferences::UnregisterCallback(LoadJSContextOptions,
NS_FAILED(Preferences::UnregisterCallback(LoadRuntimeAndContextOptions,
PREF_WORKERS_OPTIONS_PREFIX,
nullptr)) ||
#if DUMP_CONTROLLED_BY_PREF
@ -2230,9 +2229,10 @@ RuntimeService::NoteIdleThread(WorkerThread* aThread)
}
void
RuntimeService::UpdateAllWorkerJSContextOptions()
RuntimeService::UpdateAllWorkerRuntimeAndContextOptions()
{
BROADCAST_ALL_WORKERS(UpdateJSContextOptions,
BROADCAST_ALL_WORKERS(UpdateRuntimeAndContextOptions,
sDefaultJSSettings.runtimeOptions,
sDefaultJSSettings.content.contextOptions,
sDefaultJSSettings.chrome.contextOptions);
}

View File

@ -174,16 +174,19 @@ public:
}
static void
SetDefaultJSContextOptions(const JS::ContextOptions& aContentOptions,
const JS::ContextOptions& aChromeOptions)
SetDefaultRuntimeAndContextOptions(
const JS::RuntimeOptions& aRuntimeOptions,
const JS::ContextOptions& aContentCxOptions,
const JS::ContextOptions& aChromeCxOptions)
{
AssertIsOnMainThread();
sDefaultJSSettings.content.contextOptions = aContentOptions;
sDefaultJSSettings.chrome.contextOptions = aChromeOptions;
sDefaultJSSettings.runtimeOptions = aRuntimeOptions;
sDefaultJSSettings.content.contextOptions = aContentCxOptions;
sDefaultJSSettings.chrome.contextOptions = aChromeCxOptions;
}
void
UpdateAllWorkerJSContextOptions();
UpdateAllWorkerRuntimeAndContextOptions();
void
UpdateAllWorkerPreference(WorkerPreference aPref, bool aValue);

View File

@ -1515,25 +1515,32 @@ private:
}
};
class UpdateJSContextOptionsRunnable MOZ_FINAL : public WorkerControlRunnable
class UpdateRuntimeAndContextOptionsRunnable MOZ_FINAL : public WorkerControlRunnable
{
JS::ContextOptions mContentOptions;
JS::ContextOptions mChromeOptions;
JS::RuntimeOptions mRuntimeOptions;
JS::ContextOptions mContentCxOptions;
JS::ContextOptions mChromeCxOptions;
public:
UpdateJSContextOptionsRunnable(WorkerPrivate* aWorkerPrivate,
const JS::ContextOptions& aContentOptions,
const JS::ContextOptions& aChromeOptions)
UpdateRuntimeAndContextOptionsRunnable(
WorkerPrivate* aWorkerPrivate,
const JS::RuntimeOptions& aRuntimeOptions,
const JS::ContextOptions& aContentCxOptions,
const JS::ContextOptions& aChromeCxOptions)
: WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount),
mContentOptions(aContentOptions), mChromeOptions(aChromeOptions)
mRuntimeOptions(aRuntimeOptions),
mContentCxOptions(aContentCxOptions),
mChromeCxOptions(aChromeCxOptions)
{ }
private:
virtual bool
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) MOZ_OVERRIDE
{
aWorkerPrivate->UpdateJSContextOptionsInternal(aCx, mContentOptions,
mChromeOptions);
aWorkerPrivate->UpdateRuntimeAndContextOptionsInternal(aCx,
mRuntimeOptions,
mContentCxOptions,
mChromeCxOptions);
return true;
}
};
@ -2835,22 +2842,26 @@ WorkerPrivateParent<Derived>::GetInnerWindowId()
template <class Derived>
void
WorkerPrivateParent<Derived>::UpdateJSContextOptions(
JSContext* aCx,
const JS::ContextOptions& aContentOptions,
const JS::ContextOptions& aChromeOptions)
WorkerPrivateParent<Derived>::UpdateRuntimeAndContextOptions(
JSContext* aCx,
const JS::RuntimeOptions& aRuntimeOptions,
const JS::ContextOptions& aContentCxOptions,
const JS::ContextOptions& aChromeCxOptions)
{
AssertIsOnParentThread();
{
MutexAutoLock lock(mMutex);
mJSSettings.content.contextOptions = aContentOptions;
mJSSettings.chrome.contextOptions = aChromeOptions;
mJSSettings.runtimeOptions = aRuntimeOptions;
mJSSettings.content.contextOptions = aContentCxOptions;
mJSSettings.chrome.contextOptions = aChromeCxOptions;
}
nsRefPtr<UpdateJSContextOptionsRunnable> runnable =
new UpdateJSContextOptionsRunnable(ParentAsWorkerPrivate(), aContentOptions,
aChromeOptions);
nsRefPtr<UpdateRuntimeAndContextOptionsRunnable> runnable =
new UpdateRuntimeAndContextOptionsRunnable(ParentAsWorkerPrivate(),
aRuntimeOptions,
aContentCxOptions,
aChromeCxOptions);
if (!runnable->Dispatch(aCx)) {
NS_WARNING("Failed to update worker context options!");
JS_ClearPendingException(aCx);
@ -5488,17 +5499,21 @@ WorkerPrivate::RescheduleTimeoutTimer(JSContext* aCx)
}
void
WorkerPrivate::UpdateJSContextOptionsInternal(JSContext* aCx,
const JS::ContextOptions& aContentOptions,
const JS::ContextOptions& aChromeOptions)
WorkerPrivate::UpdateRuntimeAndContextOptionsInternal(
JSContext* aCx,
const JS::RuntimeOptions& aRuntimeOptions,
const JS::ContextOptions& aContentCxOptions,
const JS::ContextOptions& aChromeCxOptions)
{
AssertIsOnWorkerThread();
JS::ContextOptionsRef(aCx) = IsChromeWorker() ? aChromeOptions : aContentOptions;
JS::RuntimeOptionsRef(aCx) = aRuntimeOptions;
JS::ContextOptionsRef(aCx) = IsChromeWorker() ? aChromeCxOptions : aContentCxOptions;
for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
mChildWorkers[index]->UpdateJSContextOptions(aCx, aContentOptions,
aChromeOptions);
mChildWorkers[index]->UpdateRuntimeAndContextOptions(aCx, aRuntimeOptions,
aContentCxOptions,
aChromeCxOptions);
}
}

View File

@ -389,8 +389,10 @@ public:
GetInnerWindowId();
void
UpdateJSContextOptions(JSContext* aCx, const JS::ContextOptions& aChromeOptions,
const JS::ContextOptions& aContentOptions);
UpdateRuntimeAndContextOptions(JSContext* aCx,
const JS::RuntimeOptions& aRuntimeOptions,
const JS::ContextOptions& aContentCxOptions,
const JS::ContextOptions& aChromeCxOptions);
void
UpdatePreference(JSContext* aCx, WorkerPreference aPref, bool aValue);
@ -906,8 +908,11 @@ public:
}
void
UpdateJSContextOptionsInternal(JSContext* aCx, const JS::ContextOptions& aContentOptions,
const JS::ContextOptions& aChromeOptions);
UpdateRuntimeAndContextOptionsInternal(
JSContext* aCx,
const JS::RuntimeOptions& aRuntimeOptions,
const JS::ContextOptions& aContentCxOptions,
const JS::ContextOptions& aChromeCxOptions);
void
UpdatePreferenceInternal(JSContext* aCx, WorkerPreference aPref, bool aValue);

View File

@ -107,6 +107,7 @@ struct JSSettings
JSContentChromeSettings chrome;
JSContentChromeSettings content;
JSGCSettingsArray gcSettings;
JS::RuntimeOptions runtimeOptions;
#ifdef JS_GC_ZEAL
uint8_t gcZeal;

View File

@ -3,6 +3,7 @@
* 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 <initguid.h>
#include "DrawTargetD2D.h"
#include "SourceSurfaceD2D.h"
#include "SourceSurfaceD2DTarget.h"

View File

@ -1655,11 +1655,7 @@ jsdContext::GetJSContext(JSContext **_rval)
#define JSOPTION_DONT_REPORT_UNCAUGHT JS_BIT(8)
#define JSOPTION_NO_DEFAULT_COMPARTMENT_OBJECT JS_BIT(11)
#define JSOPTION_NO_SCRIPT_RVAL JS_BIT(12)
#define JSOPTION_BASELINE JS_BIT(14)
#define JSOPTION_TYPE_INFERENCE JS_BIT(16)
#define JSOPTION_STRICT_MODE JS_BIT(17)
#define JSOPTION_ION JS_BIT(18)
#define JSOPTION_ASMJS JS_BIT(19)
#define JSOPTION_MASK JS_BITMASK(20)
NS_IMETHODIMP
@ -1673,11 +1669,7 @@ jsdContext::GetOptions(uint32_t *_rval)
| (JS::ContextOptionsRef(mJSCx).dontReportUncaught() ? JSOPTION_DONT_REPORT_UNCAUGHT : 0)
| (JS::ContextOptionsRef(mJSCx).noDefaultCompartmentObject() ? JSOPTION_NO_DEFAULT_COMPARTMENT_OBJECT : 0)
| (JS::ContextOptionsRef(mJSCx).noScriptRval() ? JSOPTION_NO_SCRIPT_RVAL : 0)
| (JS::ContextOptionsRef(mJSCx).strictMode() ? JSOPTION_STRICT_MODE : 0)
| (JS::ContextOptionsRef(mJSCx).baseline() ? JSOPTION_BASELINE : 0)
| (JS::ContextOptionsRef(mJSCx).typeInference() ? JSOPTION_TYPE_INFERENCE : 0)
| (JS::ContextOptionsRef(mJSCx).ion() ? JSOPTION_ION : 0)
| (JS::ContextOptionsRef(mJSCx).asmJS() ? JSOPTION_ASMJS : 0);
| (JS::ContextOptionsRef(mJSCx).strictMode() ? JSOPTION_STRICT_MODE : 0);
return NS_OK;
}
@ -1698,11 +1690,7 @@ jsdContext::SetOptions(uint32_t options)
.setDontReportUncaught(options & JSOPTION_DONT_REPORT_UNCAUGHT)
.setNoDefaultCompartmentObject(options & JSOPTION_NO_DEFAULT_COMPARTMENT_OBJECT)
.setNoScriptRval(options & JSOPTION_NO_SCRIPT_RVAL)
.setStrictMode(options & JSOPTION_STRICT_MODE)
.setBaseline(options & JSOPTION_BASELINE)
.setTypeInference(options & JSOPTION_TYPE_INFERENCE)
.setIon(options & JSOPTION_ION)
.setAsmJS(options & JSOPTION_ASMJS);
.setStrictMode(options & JSOPTION_STRICT_MODE);
return NS_OK;
}

View File

@ -1160,7 +1160,7 @@ SetJitCompilerOption(JSContext *cx, unsigned argc, jsval *vp)
if (number < 0)
number = -1;
JS_SetGlobalJitCompilerOption(cx, opt, uint32_t(number));
JS_SetGlobalJitCompilerOption(cx->runtime(), opt, uint32_t(number));
args.rval().setUndefined();
return true;
@ -1175,10 +1175,10 @@ GetJitCompilerOptions(JSContext *cx, unsigned argc, jsval *vp)
RootedValue value(cx);
#define JIT_COMPILER_MATCH(key, string) \
opt = JSJITCOMPILER_ ## key; \
value.setInt32(JS_GetGlobalJitCompilerOption(cx, opt)); \
if (!JS_SetProperty(cx, info, string, value)) \
#define JIT_COMPILER_MATCH(key, string) \
opt = JSJITCOMPILER_ ## key; \
value.setInt32(JS_GetGlobalJitCompilerOption(cx->runtime(), opt)); \
if (!JS_SetProperty(cx, info, string, value)) \
return false;
JSJitCompilerOption opt = JSJITCOMPILER_NOT_AN_OPTION;

View File

@ -894,8 +894,12 @@ StructMetaTypeDescr::layout(JSContext *cx,
// fieldTypes : { string: Type, ... }
RootedObject fieldOffsets(cx);
fieldOffsets = NewObjectWithProto<JSObject>(cx, nullptr, nullptr, TenuredObject);
if (!fieldOffsets)
return false;
RootedObject fieldTypes(cx);
fieldTypes = NewObjectWithProto<JSObject>(cx, nullptr, nullptr, TenuredObject);
if (!fieldTypes)
return false;
for (size_t i = 0; i < typeRepr->fieldCount(); i++) {
const StructField &field = typeRepr->field(i);
RootedId fieldId(cx, NameToId(field.propertyName));

View File

@ -880,6 +880,29 @@ IsTypedObjectClass(const Class *class_)
class_ == &OpaqueTypedObject::class_;
}
inline bool
IsSimpleTypeDescrClass(const Class* clasp)
{
return clasp == &ScalarTypeDescr::class_ ||
clasp == &ReferenceTypeDescr::class_;
}
inline bool
IsSizedTypeDescrClass(const Class* clasp)
{
return IsSimpleTypeDescrClass(clasp) ||
clasp == &StructTypeDescr::class_ ||
clasp == &SizedArrayTypeDescr::class_ ||
clasp == &X4TypeDescr::class_;
}
inline bool
IsTypeDescrClass(const Class* clasp)
{
return IsSizedTypeDescrClass(clasp) ||
clasp == &UnsizedArrayTypeDescr::class_;
}
} // namespace js
JSObject *
@ -889,26 +912,21 @@ template <>
inline bool
JSObject::is<js::SimpleTypeDescr>() const
{
return is<js::ScalarTypeDescr>() ||
is<js::ReferenceTypeDescr>();
return IsSimpleTypeDescrClass(getClass());
}
template <>
inline bool
JSObject::is<js::SizedTypeDescr>() const
{
return is<js::SimpleTypeDescr>() ||
is<js::StructTypeDescr>() ||
is<js::SizedArrayTypeDescr>() ||
is<js::X4TypeDescr>();
return IsSizedTypeDescrClass(getClass());
}
template <>
inline bool
JSObject::is<js::TypeDescr>() const
{
return is<js::SizedTypeDescr>() ||
is<js::UnsizedArrayTypeDescr>();
return IsTypeDescrClass(getClass());
}
template <>
@ -919,4 +937,3 @@ JSObject::is<js::TypedObject>() const
}
#endif /* builtin_TypedObject_h */

View File

@ -1447,7 +1447,7 @@ struct ConvertImpl<uint64_t, double> {
// round-trip. In fact, on some platforms, including SPARC, there are pairs of
// values, a uint64_t and a double, such that neither value is exactly
// representable in the other type, but they cast to each other.
#ifdef SPARC
#if defined(SPARC) || defined(__powerpc__)
// Simulate x86 overflow behavior
template<>
struct ConvertImpl<uint64_t, double> {

View File

@ -0,0 +1,38 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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/. */
/* Used to verify that the JIT resolves the ObjectIsTypeDescr tests
* internal to Type.toSource().
*
* In this case the argument type is always a type descriptor object
* (though not a unique one), so ObjectIsTypeDescr resolves to true
* and there should be no exceptions.
*
* Load this into the js shell with IONFLAGS=logs, then exit and run
* iongraph. You're looking for a smallish function within the
* "self-hosted" domain. Look for a call to ObjectIsTypeDescr far
* down in the graph for pass00, with a call to DescrToSource in a
* subsequent block (all of this is at the mercy of the way the code
* is currently written).
*/
var T = TypedObject;
var ST1 = new T.StructType({x:T.int32});
var ST2 = new T.StructType({x:T.float64});
function check(v) {
return v.toSource();
}
function test() {
var a = [ ST1, ST2 ];
for ( var i=0 ; i < 1000 ; i++ )
check(a[i%2]);
return check(a[0]);
}
print(test());

View File

@ -0,0 +1,36 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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/. */
/* Used to verify that the JIT resolves the ObjectIsTypeDescr tests
* internal to Type.toSource().
*
* In this case the argument type is never a type descriptor object,
* so ObjectIsTypeDescr resolves to false (and we have to catch
* exceptions).
*
* Load this into the js shell with IONFLAGS=logs, then exit and run
* iongraph. You're looking for a smallish function within the
* "self-hosted" domain. Look for a call to ObjectIsTypeDescr far
* down in the graph for pass00, with a call to DescrToSource in a
* subsequent block (all of this is at the mercy of the way the code
* is currently written).
*/
var T = TypedObject;
var ST = new T.StructType({x:T.int32});
function check(v) {
return v.toSource();
}
function test() {
var fake = { toSource: ST.toSource };
var a = [ ST, fake ];
for ( var i=0 ; i < 1000 ; i++ )
try { check(a[i%2]); } catch (e) {}
try { return check(a[0]); } catch (e) { return "Thrown" }
}
print(test());

View File

@ -0,0 +1,38 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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/. */
/* Used to verify that the JIT resolves the ObjectIsTypeDescr tests
* internal to Type.toSource().
*
* In this case the argument type is never a type descriptor object
* (though not a unique non-type-descriptor), so ObjectIsTypeDescr
* resolves to false (and we have to catch exceptions).
*
* Load this into the js shell with IONFLAGS=logs, then exit and run
* iongraph. You're looking for a smallish function within the
* "self-hosted" domain. Look for a call to ObjectIsTypeDescr far
* down in the graph for pass00, with a call to DescrToSource in a
* subsequent block (all of this is at the mercy of the way the code
* is currently written).
*/
var T = TypedObject;
var ST = new T.StructType({x:T.int32});
function check(v) {
return v.toSource();
}
function test() {
var fake1 = { toSource: ST.toSource };
var fake2 = []; fake2.toSource = ST.toSource;
var a = [ fake1, fake2 ];
for ( var i=0 ; i < 1000 ; i++ )
try { check(a[i%2]); } catch (e) {}
try { return check(a[0]); } catch (e) { return "Thrown" }
}
print(test());

View File

@ -0,0 +1,36 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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/. */
/* Used to verify that the JIT resolves the ObjectIsTypeDescr tests
* internal to Type.toSource().
*
* In this case the argument type is never a type descriptor object,
* so ObjectIsTypeDescr resolves to false (and we have to catch
* exceptions).
*
* Load this into the js shell with IONFLAGS=logs, then exit and run
* iongraph. You're looking for a smallish function within the
* "self-hosted" domain. Look for a call to ObjectIsTypeDescr far
* down in the graph for pass00, with a call to DescrToSource in a
* subsequent block (all of this is at the mercy of the way the code
* is currently written).
*/
var T = TypedObject;
var ST = new T.StructType({x:T.int32});
function check(v) {
return v.toSource();
}
function test() {
var fake = { toSource: ST.toSource };
for ( var i=0 ; i < 1000 ; i++ )
try { check(fake); } catch (e) {}
try { return check(fake); } catch (e) { return "Thrown" }
}
print(test());

View File

@ -0,0 +1,36 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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/. */
/* Used to verify that the JIT resolves the ObjectIsTypeDescr tests
* internal to Type.toSource().
*
* In this case the argument type is always a type descriptor object,
* so ObjectIsTypeDescr resolves to true and there should be no
* exceptions.
*
* Load this into the js shell with IONFLAGS=logs, then exit and run
* iongraph. You're looking for a smallish function within the
* "self-hosted" domain. Look for a call to ObjectIsTypeDescr far
* down in the graph for pass00, with a call to DescrToSource in a
* subsequent block (all of this is at the mercy of the way the code
* is currently written).
*/
var T = TypedObject;
var ST = new T.StructType({x:T.int32});
function check(v) {
return v.toSource();
}
function test() {
for ( var i=0 ; i < 1000 ; i++ )
check(ST);
return check(ST);
}
print(test());

View File

@ -230,6 +230,45 @@ function testFloorDouble() {
test(setupFloor, testFloor);
test(setupFloorDouble, testFloorDouble);
function setupRound() {
f32[0] = -5.5;
f32[1] = -0.6;
f32[2] = 1.5;
f32[3] = 1;
}
function setupRoundDouble() {
f32[4] = NaN;
f32[5] = -0.49; // rounded to -0
f32[6] = Infinity;
f32[7] = -Infinity;
f32[8] = Math.pow(2,31); // too big to fit into a int
f32[9] = -0;
}
function testRound() {
for (var i = 0; i < 4; ++i) {
var r32 = Math.round(f32[i]);
assertFloat32(r32, false); // r32 is an int32
var r64 = Math.round(-0 + f32[i]);
assertFloat32(r64, false);
assertEq(r32, r64);
}
}
function testRoundDouble() {
for (var i = 4; i < 10; ++i) {
var r32 = Math.fround(Math.round(f32[i]));
assertFloat32(r32, true);
var r64 = Math.round(-0 + f32[i]);
assertFloat32(r64, false);
assertEq(r32, r64);
}
}
test(setupRound, testRound);
test(setupRoundDouble, testRoundDouble);
function setupCeil() {
f32[0] = -5.5;
f32[1] = -1.5;

View File

@ -0,0 +1,3 @@
// No result, just mustn't crash.
Array.prototype.push(0);
Array.prototype.indexOf();

View File

@ -6952,7 +6952,7 @@ js::IsAsmJSCompilationAvailable(JSContext *cx, unsigned argc, Value *vp)
cx->signalHandlersInstalled() &&
cx->gcSystemPageSize() == AsmJSPageSize &&
!cx->compartment()->debugMode() &&
cx->compartment()->options().asmJS(cx);
cx->runtime()->options().asmJS();
args.rval().set(BooleanValue(available));
return true;

View File

@ -312,7 +312,7 @@ struct BaselineScript
inline bool
IsBaselineEnabled(JSContext *cx)
{
return cx->compartment()->options().baseline(cx);
return cx->runtime()->options().baseline();
}
MethodStatus

View File

@ -4305,8 +4305,9 @@ CodeGenerator::visitMathFunctionF(LMathFunctionF *ins)
void *funptr = nullptr;
switch (ins->mir()->function()) {
case MMathFunction::Floor: funptr = JS_FUNC_TO_DATA_PTR(void *, floorf); break;
case MMathFunction::Ceil: funptr = JS_FUNC_TO_DATA_PTR(void *, ceilf); break;
case MMathFunction::Floor: funptr = JS_FUNC_TO_DATA_PTR(void *, floorf); break;
case MMathFunction::Round: funptr = JS_FUNC_TO_DATA_PTR(void *, math_roundf_impl); break;
case MMathFunction::Ceil: funptr = JS_FUNC_TO_DATA_PTR(void *, ceilf); break;
default:
MOZ_ASSUME_UNREACHABLE("Unknown or unsupported float32 math function");
}

View File

@ -159,8 +159,8 @@ void StopAllOffThreadCompilations(JSCompartment *comp);
static inline bool
IsIonEnabled(JSContext *cx)
{
return cx->compartment()->options().ion(cx) &&
cx->compartment()->options().baseline(cx) &&
return cx->runtime()->options().ion() &&
cx->runtime()->options().baseline() &&
cx->typeInferenceEnabled();
}

View File

@ -677,6 +677,9 @@ class IonBuilder : public MIRGenerator
// ForkJoin intrinsics
InliningStatus inlineForkJoinGetSlice(CallInfo &callInfo);
// TypedObject intrinsics.
InliningStatus inlineObjectIsTypeDescr(CallInfo &callInfo);
// Utility intrinsics.
InliningStatus inlineIsCallable(CallInfo &callInfo);
InliningStatus inlineHaveSameClass(CallInfo &callInfo);

View File

@ -4738,7 +4738,7 @@ class LFloorF : public LInstructionHelper<1, 1, 0>
}
};
// Round a number. Implements Math.round().
// Round a double precision number. Implements Math.round().
class LRound : public LInstructionHelper<1, 1, 1>
{
public:
@ -4757,6 +4757,25 @@ class LRound : public LInstructionHelper<1, 1, 1>
}
};
// Round a single precision number. Implements Math.round().
class LRoundF : public LInstructionHelper<1, 1, 1>
{
public:
LIR_HEADER(RoundF)
LRoundF(const LAllocation &num, const LDefinition &temp) {
setOperand(0, num);
setTemp(0, temp);
}
const LDefinition *temp() {
return getTemp(0);
}
MRound *mir() const {
return mir_->toRound();
}
};
// Load a function's call environment.
class LFunctionEnvironment : public LInstructionHelper<1, 1, 0>
{

View File

@ -261,6 +261,7 @@
_(Floor) \
_(FloorF) \
_(Round) \
_(RoundF) \
_(In) \
_(InArray) \
_(InstanceOfO) \

View File

@ -1179,8 +1179,17 @@ LIRGenerator::visitFloor(MFloor *ins)
bool
LIRGenerator::visitRound(MRound *ins)
{
JS_ASSERT(ins->num()->type() == MIRType_Double);
LRound *lir = new(alloc()) LRound(useRegister(ins->num()), tempDouble());
MIRType type = ins->num()->type();
JS_ASSERT(IsFloatingPointType(type));
if (type == MIRType_Double) {
LRound *lir = new (alloc()) LRound(useRegister(ins->num()), tempDouble());
if (!assignSnapshot(lir))
return false;
return define(lir, ins);
}
LRoundF *lir = new (alloc()) LRoundF(useRegister(ins->num()), tempDouble());
if (!assignSnapshot(lir))
return false;
return define(lir, ins);

View File

@ -162,6 +162,8 @@ IonBuilder::inlineNativeCall(CallInfo &callInfo, JSNative native)
return inlineHasClass(callInfo, &TransparentTypedObject::class_);
if (native == intrinsic_ObjectIsOpaqueTypedObject)
return inlineHasClass(callInfo, &OpaqueTypedObject::class_);
if (native == intrinsic_ObjectIsTypeDescr)
return inlineObjectIsTypeDescr(callInfo);
// Testing Functions
if (native == testingFunc_inParallelSection)
@ -673,7 +675,7 @@ IonBuilder::inlineMathRound(CallInfo &callInfo)
return InliningStatus_Inlined;
}
if (argType == MIRType_Double && returnType == MIRType_Int32) {
if (IsFloatingPointType(argType) && returnType == MIRType_Int32) {
callInfo.setImplicitlyUsedUnchecked();
MRound *ins = MRound::New(alloc(), callInfo.getArg(0));
current->add(ins);
@ -681,7 +683,7 @@ IonBuilder::inlineMathRound(CallInfo &callInfo)
return InliningStatus_Inlined;
}
if (argType == MIRType_Double && returnType == MIRType_Double) {
if (IsFloatingPointType(argType) && returnType == MIRType_Double) {
callInfo.setImplicitlyUsedUnchecked();
MMathFunction *ins = MMathFunction::New(alloc(), callInfo.getArg(0), MMathFunction::Round, nullptr);
current->add(ins);
@ -1508,6 +1510,43 @@ IonBuilder::inlineHasClass(CallInfo &callInfo, const Class *clasp)
return InliningStatus_Inlined;
}
IonBuilder::InliningStatus
IonBuilder::inlineObjectIsTypeDescr(CallInfo &callInfo)
{
if (callInfo.constructing() || callInfo.argc() != 1)
return InliningStatus_NotInlined;
if (callInfo.getArg(0)->type() != MIRType_Object)
return InliningStatus_NotInlined;
if (getInlineReturnType() != MIRType_Boolean)
return InliningStatus_NotInlined;
// The test is elaborate: in-line only if there is exact
// information.
types::TemporaryTypeSet *types = callInfo.getArg(0)->resultTypeSet();
if (!types)
return InliningStatus_NotInlined;
bool result = false;
switch (types->forAllClasses(IsTypeDescrClass)) {
case types::TemporaryTypeSet::ForAllResult::ALL_FALSE:
case types::TemporaryTypeSet::ForAllResult::EMPTY:
result = false;
break;
case types::TemporaryTypeSet::ForAllResult::ALL_TRUE:
result = true;
break;
case types::TemporaryTypeSet::ForAllResult::MIXED:
return InliningStatus_NotInlined;
}
pushConstant(BooleanValue(result));
callInfo.setImplicitlyUsedUnchecked();
return InliningStatus_Inlined;
}
IonBuilder::InliningStatus
IonBuilder::inlineUnsafeSetReservedSlot(CallInfo &callInfo)
{

View File

@ -810,6 +810,22 @@ MFloor::trySpecializeFloat32(TempAllocator &alloc)
setPolicyType(MIRType_Float32);
}
void
MRound::trySpecializeFloat32(TempAllocator &alloc)
{
// No need to look at the output, as it's an integer (unique way to have
// this instruction in IonBuilder::inlineMathRound)
JS_ASSERT(type() == MIRType_Int32);
if (!input()->canProduceFloat32()) {
if (input()->type() == MIRType_Float32)
ConvertDefinitionToDouble<0>(alloc, input(), this);
return;
}
setPolicyType(MIRType_Float32);
}
MTest *
MTest::New(TempAllocator &alloc, MDefinition *ins, MBasicBlock *ifTrue, MBasicBlock *ifFalse)
{

View File

@ -3930,7 +3930,7 @@ class MMathFunction
static const char *FunctionName(Function function);
bool isFloat32Commutative() const {
return function_ == Floor || function_ == Ceil;
return function_ == Floor || function_ == Ceil || function_ == Round;
}
void trySpecializeFloat32(TempAllocator &alloc);
void computeRange(TempAllocator &alloc);
@ -8283,12 +8283,13 @@ class MFloor
// Inlined version of Math.round().
class MRound
: public MUnaryInstruction,
public DoublePolicy<0>
public FloatingPointPolicy<0>
{
MRound(MDefinition *num)
: MUnaryInstruction(num)
{
setResultType(MIRType_Int32);
setPolicyType(MIRType_Double);
setMovable();
}
@ -8308,6 +8309,16 @@ class MRound
TypePolicy *typePolicy() {
return this;
}
bool isFloat32Commutative() const {
return true;
}
void trySpecializeFloat32(TempAllocator &alloc);
#ifdef DEBUG
bool isConsistentFloat32Use(MUse *use) const {
return true;
}
#endif
};
class MIteratorStart

View File

@ -1244,6 +1244,21 @@ CodeGeneratorARM::visitRound(LRound *lir)
return true;
}
bool
CodeGeneratorARM::visitRoundF(LRoundF *lir)
{
FloatRegister input = ToFloatRegister(lir->input());
Register output = ToRegister(lir->output());
FloatRegister tmp = ToFloatRegister(lir->temp());
Label bail;
// Output is either correct, or clamped. All -0 cases have been translated to a clamped
// case.a
masm.roundf(input, output, &bail, tmp);
if (!bailoutFrom(&bail, lir->snapshot()))
return false;
return true;
}
void
CodeGeneratorARM::emitRoundDouble(const FloatRegister &src, const Register &dest, Label *fail)
{

View File

@ -112,6 +112,7 @@ class CodeGeneratorARM : public CodeGeneratorShared
virtual bool visitFloor(LFloor *lir);
virtual bool visitFloorF(LFloorF *lir);
virtual bool visitRound(LRound *lir);
virtual bool visitRoundF(LRoundF *lir);
virtual bool visitTruncateDToInt32(LTruncateDToInt32 *ins);
virtual bool visitTruncateFToInt32(LTruncateFToInt32 *ins);

Some files were not shown because too many files have changed in this diff Show More