Exemplo n.º 1
0
nsresult
DOMWheelEvent::InitFromCtor(const nsAString& aType,
                            JSContext* aCx, JS::Value* aVal)
{
  mozilla::idl::WheelEventInit d;
  nsresult rv = d.Init(aCx, aVal);
  NS_ENSURE_SUCCESS(rv, rv);

  nsAutoString modifierList;
  GetModifierList(d.ctrlKey, d.shiftKey, d.altKey, d.metaKey, modifierList);

  rv = InitWheelEvent(aType, d.bubbles, d.cancelable,
                      d.view, d.detail, d.screenX, d.screenY,
                      d.clientX, d.clientY, d.button, d.relatedTarget,
                      modifierList, d.deltaX, d.deltaY, d.deltaZ, d.deltaMode);
  NS_ENSURE_SUCCESS(rv, rv);

  static_cast<widget::WheelEvent*>(mEvent)->buttons = d.buttons;

  return NS_OK;
}
already_AddRefed<DOMWheelEvent>
DOMWheelEvent::Constructor(const GlobalObject& aGlobal,
                           const nsAString& aType,
                           const WheelEventInit& aParam,
                           mozilla::ErrorResult& aRv)
{
  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.Get());
  nsRefPtr<DOMWheelEvent> e = new DOMWheelEvent(t, nullptr, nullptr);
  bool trusted = e->Init(t);
  nsAutoString modifierList;
  GetModifierList(aParam.mCtrlKey, aParam.mShiftKey,
                  aParam.mAltKey, aParam.mMetaKey,
                  modifierList);
  aRv = e->InitWheelEvent(aType, aParam.mBubbles, aParam.mCancelable,
                          aParam.mView, aParam.mDetail,
                          aParam.mScreenX, aParam.mScreenY,
                          aParam.mClientX, aParam.mClientY,
                          aParam.mButton, aParam.mRelatedTarget,
                          modifierList, aParam.mDeltaX,
                          aParam.mDeltaY, aParam.mDeltaZ, aParam.mDeltaMode);
  static_cast<widget::WheelEvent*>(e->mEvent)->buttons = aParam.mButtons;
  e->SetTrusted(trusted);
  return e.forget();
}