dom/plugins/ipc/PluginInterposeOSX.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/ipc/PluginInterposeOSX.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,137 @@
     1.4 +// vim:set ts=2 sts=2 sw=2 et cin:
     1.5 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
     1.6 +//
     1.7 +// Redistribution and use in source and binary forms, with or without
     1.8 +// modification, are permitted provided that the following conditions are
     1.9 +// met:
    1.10 +//
    1.11 +//    * Redistributions of source code must retain the above copyright
    1.12 +// notice, this list of conditions and the following disclaimer.
    1.13 +//    * Redistributions in binary form must reproduce the above
    1.14 +// copyright notice, this list of conditions and the following disclaimer
    1.15 +// in the documentation and/or other materials provided with the
    1.16 +// distribution.
    1.17 +//    * Neither the name of Google Inc. nor the names of its
    1.18 +// contributors may be used to endorse or promote products derived from
    1.19 +// this software without specific prior written permission.
    1.20 +//
    1.21 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.22 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.23 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.24 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    1.25 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.26 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.27 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.28 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    1.29 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    1.30 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    1.31 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.32 +
    1.33 +#ifndef DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H
    1.34 +#define DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H
    1.35 +
    1.36 +#include "base/basictypes.h"
    1.37 +#include "nsPoint.h"
    1.38 +#include "npapi.h"
    1.39 +
    1.40 +// Make this includable from non-Objective-C code.
    1.41 +#ifndef __OBJC__
    1.42 +class NSCursor;
    1.43 +#else
    1.44 +#import <Cocoa/Cocoa.h>
    1.45 +#endif
    1.46 +
    1.47 +// The header file QuickdrawAPI.h is missing on OS X 10.7 and up (though the
    1.48 +// QuickDraw APIs defined in it are still present) -- so we need to supply the
    1.49 +// relevant parts of its contents here.  It's likely that Apple will eventually
    1.50 +// remove the APIs themselves (probably in OS X 10.8), so we need to make them
    1.51 +// weak imports, and test for their presence before using them.
    1.52 +#if !defined(__QUICKDRAWAPI__)
    1.53 +
    1.54 +typedef short Bits16[16];
    1.55 +struct Cursor {
    1.56 +  Bits16  data;
    1.57 +  Bits16  mask;
    1.58 +  Point   hotSpot;
    1.59 +};
    1.60 +typedef struct Cursor Cursor;
    1.61 +
    1.62 +#endif /* __QUICKDRAWAPI__ */
    1.63 +
    1.64 +namespace mac_plugin_interposing {
    1.65 +
    1.66 +// Class used to serialize NSCursor objects over IPC between processes.
    1.67 +class NSCursorInfo {
    1.68 +public:
    1.69 +  enum Type {
    1.70 +    TypeCustom,
    1.71 +    TypeArrow,
    1.72 +    TypeClosedHand,
    1.73 +    TypeContextualMenu,   // Only supported on OS X 10.6 and up
    1.74 +    TypeCrosshair,
    1.75 +    TypeDisappearingItem,
    1.76 +    TypeDragCopy,         // Only supported on OS X 10.6 and up
    1.77 +    TypeDragLink,         // Only supported on OS X 10.6 and up
    1.78 +    TypeIBeam,
    1.79 +    TypeNotAllowed,       // Only supported on OS X 10.6 and up
    1.80 +    TypeOpenHand,
    1.81 +    TypePointingHand,
    1.82 +    TypeResizeDown,
    1.83 +    TypeResizeLeft,
    1.84 +    TypeResizeLeftRight,
    1.85 +    TypeResizeRight,
    1.86 +    TypeResizeUp,
    1.87 +    TypeResizeUpDown,
    1.88 +    TypeTransparent       // Special type
    1.89 +  };
    1.90 +
    1.91 +  NSCursorInfo();
    1.92 +  NSCursorInfo(NSCursor* aCursor);
    1.93 +  NSCursorInfo(const Cursor* aCursor);
    1.94 +  ~NSCursorInfo();
    1.95 +
    1.96 +  NSCursor* GetNSCursor() const;
    1.97 +  Type GetType() const;
    1.98 +  const char* GetTypeName() const;
    1.99 +  nsPoint GetHotSpot() const;
   1.100 +  uint8_t* GetCustomImageData() const;
   1.101 +  uint32_t GetCustomImageDataLength() const;
   1.102 +
   1.103 +  void SetType(Type aType);
   1.104 +  void SetHotSpot(nsPoint aHotSpot);
   1.105 +  void SetCustomImageData(uint8_t* aData, uint32_t aDataLength);
   1.106 +
   1.107 +  static bool GetNativeCursorsSupported();
   1.108 +
   1.109 +private:
   1.110 +  NSCursor* GetTransparentCursor() const;
   1.111 +
   1.112 +  Type mType;
   1.113 +  // The hot spot's coordinate system is the cursor's coordinate system, and
   1.114 +  // has an upper-left origin (in both Cocoa and pre-Cocoa systems).
   1.115 +  nsPoint mHotSpot;
   1.116 +  uint8_t* mCustomImageData;
   1.117 +  uint32_t mCustomImageDataLength;
   1.118 +  static int32_t mNativeCursorsSupported;
   1.119 +};
   1.120 +
   1.121 +namespace parent {
   1.122 +
   1.123 +void OnPluginShowWindow(uint32_t window_id, CGRect window_bounds, bool modal);
   1.124 +void OnPluginHideWindow(uint32_t window_id, pid_t aPluginPid);
   1.125 +void OnSetCursor(const NSCursorInfo& cursorInfo);
   1.126 +void OnShowCursor(bool show);
   1.127 +void OnPushCursor(const NSCursorInfo& cursorInfo);
   1.128 +void OnPopCursor();
   1.129 +
   1.130 +}
   1.131 +
   1.132 +namespace child {
   1.133 +
   1.134 +void SetUpCocoaInterposing();
   1.135 +
   1.136 +}
   1.137 +
   1.138 +}
   1.139 +
   1.140 +#endif /* DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H */

mercurial