mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Back out bug 952890, since the dependencies aren't fixed yet.
This commit is contained in:
parent
80ea81c519
commit
5aacab2d55
@ -222,6 +222,64 @@ 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)
|
||||
{
|
||||
@ -307,6 +365,13 @@ nsScreen::MozUnlockOrientation()
|
||||
hal::UnlockScreenOrientation();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreen::SlowMozUnlockOrientation()
|
||||
{
|
||||
MozUnlockOrientation();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsScreen::IsDeviceSizePageSize()
|
||||
{
|
||||
|
@ -264,6 +264,12 @@ 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)
|
||||
|
@ -3094,35 +3094,31 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||
arrayRef = "${declName}"
|
||||
|
||||
# NOTE: Keep this in sync with variadic conversions as needed
|
||||
templateBody = ("""JS::ForOfIterator iter(cx);
|
||||
if (!iter.init(${val}, JS::ForOfIterator::AllowNonIterable)) {
|
||||
templateBody = ("""JS::Rooted<JSObject*> seq(cx, &${val}.toObject());\n
|
||||
if (!IsArrayLike(cx, seq)) {
|
||||
%s
|
||||
}
|
||||
if (!iter.valueIsIterable()) {
|
||||
uint32_t length;
|
||||
// JS_GetArrayLength actually works on all objects
|
||||
if (!JS_GetArrayLength(cx, seq, &length)) {
|
||||
%s
|
||||
}
|
||||
%s &arr = %s;
|
||||
JS::Rooted<JS::Value> temp(cx);
|
||||
while (true) {
|
||||
bool done;
|
||||
if (!iter.next(&temp, &done)) {
|
||||
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)) {
|
||||
%s
|
||||
}
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
%s* slotPtr = arr.AppendElement();
|
||||
if (!slotPtr) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
%s
|
||||
}
|
||||
%s& slot = *slotPtr;
|
||||
""" % (exceptionCodeIndented.define(),
|
||||
CGIndenter(CGGeneric(notSequence)).define(),
|
||||
%s& slot = *arr.AppendElement();
|
||||
""" % (CGIndenter(CGGeneric(notSequence)).define(),
|
||||
exceptionCodeIndented.define(),
|
||||
sequenceType,
|
||||
arrayRef,
|
||||
CGIndenter(exceptionCodeIndented).define(),
|
||||
elementInfo.declType.define(),
|
||||
exceptionCodeIndented.define(),
|
||||
CGIndenter(exceptionCodeIndented).define(),
|
||||
elementInfo.declType.define()))
|
||||
|
||||
@ -3189,7 +3185,12 @@ while (true) {
|
||||
|
||||
arrayObjectMemberTypes = filter(lambda t: t.isArray() or t.isSequence(), memberTypes)
|
||||
if len(arrayObjectMemberTypes) > 0:
|
||||
raise TypeError("Bug 767924: We don't support sequences in unions yet")
|
||||
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)
|
||||
else:
|
||||
arrayObject = None
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "nsIDOMEventTarget.idl"
|
||||
|
||||
[scriptable, builtinclass, uuid(e732649a-4f78-4ded-abe1-dbdc36fd59d3)]
|
||||
[scriptable, builtinclass, uuid(bcdf4ce4-9785-4e31-a851-1d51ea16da20)]
|
||||
interface nsIDOMScreen : nsIDOMEventTarget
|
||||
{
|
||||
readonly attribute long top;
|
||||
@ -26,4 +26,36 @@ 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();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user