Bug 952890 part 2. Remove the IsArrayLike method, since it no longer matches any spec concept. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 14 Feb 2014 10:46:09 -0500
changeset 171501 584e7a00ac79c9506a1e031fb237f0cb93aef272
parent 171500 d0b0dca8f79266b3c759e69d807f1c7913df2e05
child 171502 21771134f63c16d670ffecb038162651d3e790a8
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerspeterv
bugs952890
milestone30.0a1
Bug 952890 part 2. Remove the IsArrayLike method, since it no longer matches any spec concept. r=peterv
dom/base/nsScreen.cpp
dom/bindings/BindingUtils.h
dom/interfaces/base/nsIDOMScreen.idl
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -217,74 +217,16 @@ nsScreen::GetLockOrientationPermission()
         nsIPrincipal::APP_STATUS_INSTALLED) {
     return LOCK_ALLOWED;
   }
 
   // Other content must be full-screen in order to lock orientation.
   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)
 {
   nsString orientation(aOrientation);
   Sequence<nsString> orientations;
   if (!orientations.AppendElement(orientation)) {
     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return false;
@@ -360,23 +302,16 @@ nsScreen::MozLockOrientation(const Seque
 }
 
 void
 nsScreen::MozUnlockOrientation()
 {
   hal::UnlockScreenOrientation();
 }
 
-NS_IMETHODIMP
-nsScreen::SlowMozUnlockOrientation()
-{
-  MozUnlockOrientation();
-  return NS_OK;
-}
-
 bool
 nsScreen::IsDeviceSizePageSize()
 {
   nsPIDOMWindow* owner = GetOwner();
   if (owner) {
     nsIDocShell* docShell = owner->GetDocShell();
     if (docShell) {
       return docShell->GetDeviceSizeIsPageSize();
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -259,22 +259,16 @@ UnwrapObject(JSObject* obj, U& value)
 inline bool
 IsNotDateOrRegExp(JSContext* cx, JS::Handle<JSObject*> obj)
 {
   MOZ_ASSERT(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)
 {
   JS::Rooted<JSObject*> obj(cx, &objVal.toObject());
   return IsNotDateOrRegExp(cx, obj);
 }
 
 MOZ_ALWAYS_INLINE bool
--- a/dom/interfaces/base/nsIDOMScreen.idl
+++ b/dom/interfaces/base/nsIDOMScreen.idl
@@ -1,16 +1,16 @@
 /* -*- Mode: IDL; tab-width: 2; 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/. */
 
 #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;
   readonly attribute long             left;
   readonly attribute long             width;
   readonly attribute long             height;
   readonly attribute long             pixelDepth;
   readonly attribute long             colorDepth;
@@ -21,41 +21,9 @@ interface nsIDOMScreen : nsIDOMEventTarg
 
   /**
    * Returns the current screen orientation.
    * Can be: landscape-primary, landscape-secondary,
    *         portrait-primary or portrait-secondary.
    */
   [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();
 };