author Nathan Froyd <froydnj@gmail.com>
Fri, 12 Aug 2016 22:43:49 -0400
changeset 400339 e3608df9fe09f509a8fe62be0cd6743151e4f7a3
parent 386757 c010bad64aedd2b8d2f0a47d894b640c6f476255
child 460653 e42fd81cdc352421fe5cee9753a5e787e454b7f5
child 463670 78cb74f1129ca4a029de5557d01c065aed0be841
child 468945 50b45aa104405b40dd4a3c97120253b6a3ad3d78
permissions -rw-r--r--
Bug 1294537 - introduce a non-null-checking placement operator new; r=sunfish,nbp The default placement operator new is defined to always require that its result be null-checked. A sufficiently smart compiler can remove this check, but not all compilers are sufficiently smart. Better to have a custom placement operator new that will remove null checks in a way defined by the standard.

/* -*- Mode: C++; tab-width: 4; 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 EditorEventListener_h
#define EditorEventListener_h

#include "nsCOMPtr.h"
#include "nsError.h"
#include "nsIDOMEventListener.h"
#include "nsISupportsImpl.h"
#include "nscore.h"

class nsCaret;
class nsIContent;
class nsIDOMDragEvent;
class nsIDOMEvent;
class nsIDOMKeyEvent;
class nsIDOMMouseEvent;
class nsIPresShell;
class nsPresContext;

// X.h defines KeyPress
#ifdef KeyPress
#undef KeyPress

#ifdef XP_WIN
// On Windows, we support switching the text direction by pressing Ctrl+Shift

namespace mozilla {

class EditorBase;

class EditorEventListener : public nsIDOMEventListener

  virtual nsresult Connect(EditorBase* aEditorBase);

  void Disconnect();


  void SpellCheckIfNeeded();

  virtual ~EditorEventListener();

  nsresult InstallToEditor();
  void UninstallFromEditor();

  nsresult KeyDown(nsIDOMKeyEvent* aKeyEvent);
  nsresult KeyUp(nsIDOMKeyEvent* aKeyEvent);
  nsresult KeyPress(nsIDOMKeyEvent* aKeyEvent);
  nsresult HandleText(nsIDOMEvent* aTextEvent);
  nsresult HandleStartComposition(nsIDOMEvent* aCompositionEvent);
  void HandleEndComposition(nsIDOMEvent* aCompositionEvent);
  virtual nsresult MouseDown(nsIDOMMouseEvent* aMouseEvent);
  virtual nsresult MouseUp(nsIDOMMouseEvent* aMouseEvent) { return NS_OK; }
  virtual nsresult MouseClick(nsIDOMMouseEvent* aMouseEvent);
  nsresult Focus(nsIDOMEvent* aEvent);
  nsresult Blur(nsIDOMEvent* aEvent);
  nsresult DragEnter(nsIDOMDragEvent* aDragEvent);
  nsresult DragOver(nsIDOMDragEvent* aDragEvent);
  nsresult DragExit(nsIDOMDragEvent* aDragEvent);
  nsresult Drop(nsIDOMDragEvent* aDragEvent);

  bool CanDrop(nsIDOMDragEvent* aEvent);
  void CleanupDragDropCaret();
  already_AddRefed<nsIPresShell> GetPresShell();
  nsPresContext* GetPresContext();
  nsIContent* GetFocusedRootContent();
  // Returns true if IME consumes the mouse event.
  bool NotifyIMEOfMouseButtonEvent(nsIDOMMouseEvent* aMouseEvent);
  bool EditorHasFocus();
  bool IsFileControlTextBox();
  bool ShouldHandleNativeKeyBindings(nsIDOMKeyEvent* aKeyEvent);
  nsresult HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent);

  EditorBase* mEditorBase; // weak
  RefPtr<nsCaret> mCaret;
  bool mCommitText;
  bool mInTransaction;
  bool mMouseDownOrUpConsumedByIME;
  bool mHaveBidiKeyboards;
  bool mShouldSwitchTextDirection;
  bool mSwitchToRTL;

} // namespace mozilla

#endif // #ifndef EditorEventListener_h