author Mike Hommey <mh+mozilla@glandium.org>
Fri, 11 Jan 2019 16:01:15 +0000
changeset 453570 daf50f25895db073e44d50fecf2e4f6fe873865d
parent 448947 6f3709b3878117466168c40affa7bca0b60cf75b
permissions -rw-r--r--
Bug 1519307 - Add a new project to build useful parts of breakpad independently. r=froydnj With `ac_add_options --enable-project=tools/crashreporter` in a mozconfig, `./mach build` builds minidump_stackwalk, dump_syms and fileid. One caveat is that due to limitation in how the build system works currently, it's cumbersome to keep dump_syms as a host program for Gecko, and to make it a target program for this project. For now, keep it as a host program. We're not going to use it on automation, but it's still convenient to have for quick local builds (I've had to resort to awful hacks downstream). Differential Revision: https://phabricator.services.mozilla.com/D16299

/* -*- Mode: C++; 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/. */

#ifndef mozilla_MiscEvents_h__
#define mozilla_MiscEvents_h__

#include <stdint.h>

#include "mozilla/BasicEvents.h"
#include "nsCOMPtr.h"
#include "nsAtom.h"
#include "nsGkAtoms.h"
#include "nsITransferable.h"

namespace mozilla {

namespace dom {
class PBrowserParent;
class PBrowserChild;
}  // namespace dom

 * mozilla::WidgetContentCommandEvent

class WidgetContentCommandEvent : public WidgetGUIEvent {
  virtual WidgetContentCommandEvent* AsContentCommandEvent() override {
    return this;

  WidgetContentCommandEvent(bool aIsTrusted, EventMessage aMessage,
                            nsIWidget* aWidget, bool aOnlyEnabledCheck = false)
      : WidgetGUIEvent(aIsTrusted, aMessage, aWidget,
        mIsEnabled(false) {}

  virtual WidgetEvent* Duplicate() const override {
    // This event isn't an internal event of any DOM event.
                 "WidgetQueryContentEvent needs to support Duplicate()");
    MOZ_CRASH("WidgetQueryContentEvent doesn't support Duplicate()");
    return nullptr;

  // eContentCommandPasteTransferable
  nsCOMPtr<nsITransferable> mTransferable;  // [in]

  // eContentCommandScroll
  // for mScroll.mUnit
  enum { eCmdScrollUnit_Line, eCmdScrollUnit_Page, eCmdScrollUnit_Whole };

  struct ScrollInfo {
        : mAmount(0), mUnit(eCmdScrollUnit_Line), mIsHorizontal(false) {}

    int32_t mAmount;     // [in]
    uint8_t mUnit;       // [in]
    bool mIsHorizontal;  // [in]
  } mScroll;

  bool mOnlyEnabledCheck;  // [in]

  bool mSucceeded;  // [out]
  bool mIsEnabled;  // [out]

  void AssignContentCommandEventData(const WidgetContentCommandEvent& aEvent,
                                     bool aCopyTargets) {
    AssignGUIEventData(aEvent, aCopyTargets);

    mScroll = aEvent.mScroll;
    mOnlyEnabledCheck = aEvent.mOnlyEnabledCheck;
    mSucceeded = aEvent.mSucceeded;
    mIsEnabled = aEvent.mIsEnabled;

 * mozilla::WidgetCommandEvent
 * This sends a command to chrome.  If you want to request what is performed
 * in focused content, you should use WidgetContentCommandEvent instead.
 * XXX Should be |WidgetChromeCommandEvent|?

class WidgetCommandEvent : public WidgetGUIEvent {
  virtual WidgetCommandEvent* AsCommandEvent() override { return this; }

  WidgetCommandEvent(bool aIsTrusted, nsAtom* aEventType, nsAtom* aCommand,
                     nsIWidget* aWidget)
      : WidgetGUIEvent(aIsTrusted, eUnidentifiedEvent, aWidget,
        mCommand(aCommand) {
    mSpecifiedEventType = aEventType;

   * Constructor to initialize an app command.  This is the only case to
   * initialize this class as a command in C++ stack.
  WidgetCommandEvent(bool aIsTrusted, nsAtom* aCommand, nsIWidget* aWidget)
      : WidgetCommandEvent(aIsTrusted, nsGkAtoms::onAppCommand, aCommand,
                           aWidget) {}

   * Constructor to initialize as internal event of dom::CommandEvent.
  WidgetCommandEvent() : WidgetCommandEvent(false, nullptr, nullptr, nullptr) {}

  virtual WidgetEvent* Duplicate() const override {
    MOZ_ASSERT(mClass == eCommandEventClass,
               "Duplicate() must be overridden by sub class");
    // Not copying widget, it is a weak reference.
    WidgetCommandEvent* result =
        new WidgetCommandEvent(false, mSpecifiedEventType, mCommand, nullptr);
    result->AssignCommandEventData(*this, true);
    result->mFlags = mFlags;
    return result;

  RefPtr<nsAtom> mCommand;

  // XXX Not tested by test_assign_event_data.html
  void AssignCommandEventData(const WidgetCommandEvent& aEvent,
                              bool aCopyTargets) {
    AssignGUIEventData(aEvent, aCopyTargets);

    // mCommand must have been initialized with the constructor.

 * mozilla::WidgetPluginEvent
 * This event delivers only a native event to focused plugin.

class WidgetPluginEvent : public WidgetGUIEvent {
  friend class dom::PBrowserParent;
  friend class dom::PBrowserChild;

  virtual WidgetPluginEvent* AsPluginEvent() override { return this; }

  WidgetPluginEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
      : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, ePluginEventClass),
        mRetargetToFocusedDocument(false) {}

  virtual WidgetEvent* Duplicate() const override {
    // NOTE: PluginEvent has to be dispatched to nsIFrame::HandleEvent().
    //       So, this event needs to support Duplicate().
    MOZ_ASSERT(mClass == ePluginEventClass,
               "Duplicate() must be overridden by sub class");
    // Not copying widget, it is a weak reference.
    WidgetPluginEvent* result = new WidgetPluginEvent(false, mMessage, nullptr);
    result->AssignPluginEventData(*this, true);
    result->mFlags = mFlags;
    return result;

  // If true, this event needs to be retargeted to focused document.
  // Otherwise, never retargeted. Defaults to false.
  bool mRetargetToFocusedDocument;

  void AssignPluginEventData(const WidgetPluginEvent& aEvent,
                             bool aCopyTargets) {
    AssignGUIEventData(aEvent, aCopyTargets);

    mRetargetToFocusedDocument = aEvent.mRetargetToFocusedDocument;

  WidgetPluginEvent() : mRetargetToFocusedDocument(false) {}

}  // namespace mozilla

#endif  // mozilla_MiscEvents_h__