コード例 #1
0
js::DOMProxyShadowsResult
DOMProxyShadows(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id)
{
  JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
  JS::Value v = js::GetProxyExtra(proxy, JSPROXYSLOT_EXPANDO);
  bool isOverrideBuiltins = !v.isObject() && !v.isUndefined();
  if (expando) {
    bool hasOwn;
    if (!JS_AlreadyHasOwnPropertyById(cx, expando, id, &hasOwn))
      return js::ShadowCheckFailed;

    if (hasOwn) {
      return isOverrideBuiltins ?
        js::ShadowsViaIndirectExpando : js::ShadowsViaDirectExpando;
    }
  }

  if (!isOverrideBuiltins) {
    // Our expando, if any, didn't shadow, so we're not shadowing at all.
    return js::DoesntShadow;
  }

  bool hasOwn;
  if (!GetProxyHandler(proxy)->hasOwn(cx, proxy, id, &hasOwn))
    return js::ShadowCheckFailed;

  return hasOwn ? js::Shadows : js::DoesntShadowUnique;
}
コード例 #2
0
bool
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy,
                         JS::Handle<jsid> id, JS::ObjectOpResult &result) const
{
  JS::Rooted<JSObject*> expando(cx);
  if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
    return JS_DeletePropertyById(cx, expando, id, result);
  }

  return result.succeed();
}
コード例 #3
0
bool
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy,
                         JS::Handle<jsid> id, bool* bp)
{
    JS::Rooted<JSObject*> expando(cx);
    if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
        return JS_DeletePropertyById2(cx, expando, id, bp);
    }

    *bp = true;
    return true;
}
コード例 #4
0
ファイル: alarmview.cpp プロジェクト: Camelek/qtmoko
void AlarmView::init()
{
    /* Create stuff! */
    QFormLayout *mainL = new QFormLayout();
    mainL->setSpacing(2);
    mainL->setMargin(2);

    mAlarmList = new QWrapListView();
    mAlarmList->setSelectionMode(QListView::SingleSelection);
    mAlarmList->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    //mAlarmList->setUniformItemSizes(true);
    mAlarmList->setAlternatingRowColors(true);
    mAlarmList->setItemDelegate(new TwoLevelDelegate(mAlarmList));
    mAlarmList->setResizeMode(QListView::Adjust);
    mAlarmList->setLayoutMode(QListView::Batched);
    QSizePolicy expando(QSizePolicy::Expanding, QSizePolicy::Expanding);
    expando.setVerticalStretch(1);
    mAlarmList->setSizePolicy(expando);

    mainL->addRow(mAlarmList);

    mSnoozeButton = new QPushButton(tr("Snooze"));
    mainL->addRow(mSnoozeButton);

    mSnoozeChoices = new QComboBox();

    mSnoozeChoices->clear();
    mSnoozeChoices->addItem(tr("5 minutes"));
    mSnoozeChoices->addItem(tr("10 minutes"));
    mSnoozeChoices->addItem(tr("15 minutes"));
    mSnoozeChoices->addItem(tr("30 minutes"));
    mSnoozeChoices->addItem(tr("1 hour"));
    mSnoozeChoices->addItem(tr("1 day"));
    mSnoozeChoices->addItem(tr("1 week"));
    mSnoozeChoices->addItem(tr("1 month"));

    mainL->addRow(tr("Snooze delay:"), mSnoozeChoices);
    setLayout(mainL);

    mStandardModel = new QStandardItemModel(this);
    mAlarmList->setModel(mStandardModel);
    connect(mAlarmList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
            this, SLOT(currentAlarmChanged(QModelIndex)));
    connect(mAlarmList, SIGNAL(activated(QModelIndex)), this, SLOT(alarmSelected(QModelIndex)));

    connect(mSnoozeButton, SIGNAL(clicked()), this, SLOT(snoozeClicked()));
}
コード例 #5
0
// static
JSObject*
DOMProxyHandler::EnsureExpandoObject(JSContext* cx, JS::Handle<JSObject*> obj)
{
    NS_ASSERTION(IsDOMProxy(obj), "expected a DOM proxy object");
    JS::Value v = js::GetProxyExtra(obj, JSPROXYSLOT_EXPANDO);
    if (v.isObject()) {
        return &v.toObject();
    }

    js::ExpandoAndGeneration* expandoAndGeneration;
    if (!v.isUndefined()) {
        expandoAndGeneration = static_cast<js::ExpandoAndGeneration*>(v.toPrivate());
        if (expandoAndGeneration->expando.isObject()) {
            return &expandoAndGeneration->expando.toObject();
        }
    } else {
        expandoAndGeneration = nullptr;
    }

    JS::Rooted<JSObject*> expando(cx,
                                  JS_NewObjectWithGivenProto(cx, nullptr, nullptr, js::GetObjectParent(obj)));
    if (!expando) {
        return nullptr;
    }

    nsISupports* native = UnwrapDOMObject<nsISupports>(obj);
    nsWrapperCache* cache;
    CallQueryInterface(native, &cache);
    if (expandoAndGeneration) {
        cache->PreserveWrapper(native);
        expandoAndGeneration->expando.setObject(*expando);

        return expando;
    }

    XPCWrappedNativeScope* scope = xpc::GetObjectScope(obj);
    if (!scope->RegisterDOMExpandoObject(obj)) {
        return nullptr;
    }

    cache->SetPreservingWrapper(true);
    js::SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(*expando));

    return expando;
}
コード例 #6
0
bool
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy,
                         JS::Handle<jsid> id, bool* bp)
{
  JSBool b = true;

  JS::Rooted<JSObject*> expando(cx);
  if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
    JS::Rooted<Value> v(cx);
    if (!JS_DeletePropertyById2(cx, expando, id, v.address()) ||
        !JS_ValueToBoolean(cx, v, &b)) {
      return false;
    }
  }

  *bp = !!b;
  return true;
}
コード例 #7
0
// static
JSObject* DOMProxyHandler::EnsureExpandoObject(JSContext* cx,
                                               JS::Handle<JSObject*> obj) {
  CheckDOMProxy(obj);

  JS::Value v = js::GetProxyPrivate(obj);
  if (v.isObject()) {
    CheckExpandoObject(obj, v);
    return &v.toObject();
  }

  js::ExpandoAndGeneration* expandoAndGeneration;
  if (!v.isUndefined()) {
    expandoAndGeneration =
        static_cast<js::ExpandoAndGeneration*>(v.toPrivate());
    CheckExpandoAndGeneration(obj, expandoAndGeneration);
    if (expandoAndGeneration->expando.isObject()) {
      return &expandoAndGeneration->expando.toObject();
    }
  } else {
    expandoAndGeneration = nullptr;
  }

  JS::Rooted<JSObject*> expando(
      cx, JS_NewObjectWithGivenProto(cx, nullptr, nullptr));
  if (!expando) {
    return nullptr;
  }

  nsISupports* native = UnwrapDOMObject<nsISupports>(obj);
  nsWrapperCache* cache;
  CallQueryInterface(native, &cache);
  cache->PreserveWrapper(native);

  if (expandoAndGeneration) {
    expandoAndGeneration->expando.setObject(*expando);
    return expando;
  }

  js::SetProxyPrivate(obj, ObjectValue(*expando));

  return expando;
}
コード例 #8
0
bool
DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
                                Handle<PropertyDescriptor> desc,
                                JS::ObjectOpResult &result, bool *defined) const
{
  if (xpc::WrapperFactory::IsXrayWrapper(proxy)) {
    return result.succeed();
  }

  JS::Rooted<JSObject*> expando(cx, EnsureExpandoObject(cx, proxy));
  if (!expando) {
    return false;
  }

  if (!JS_DefinePropertyById(cx, expando, id, desc, result)) {
    return false;
  }
  *defined = true;
  return true;
}