dom/plugins/ipc/PluginInterposeOSX.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 // vim:set ts=2 sts=2 sw=2 et cin:
michael@0 2 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
michael@0 3 //
michael@0 4 // Redistribution and use in source and binary forms, with or without
michael@0 5 // modification, are permitted provided that the following conditions are
michael@0 6 // met:
michael@0 7 //
michael@0 8 // * Redistributions of source code must retain the above copyright
michael@0 9 // notice, this list of conditions and the following disclaimer.
michael@0 10 // * Redistributions in binary form must reproduce the above
michael@0 11 // copyright notice, this list of conditions and the following disclaimer
michael@0 12 // in the documentation and/or other materials provided with the
michael@0 13 // distribution.
michael@0 14 // * Neither the name of Google Inc. nor the names of its
michael@0 15 // contributors may be used to endorse or promote products derived from
michael@0 16 // this software without specific prior written permission.
michael@0 17 //
michael@0 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 29
michael@0 30 #ifndef DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H
michael@0 31 #define DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H
michael@0 32
michael@0 33 #include "base/basictypes.h"
michael@0 34 #include "nsPoint.h"
michael@0 35 #include "npapi.h"
michael@0 36
michael@0 37 // Make this includable from non-Objective-C code.
michael@0 38 #ifndef __OBJC__
michael@0 39 class NSCursor;
michael@0 40 #else
michael@0 41 #import <Cocoa/Cocoa.h>
michael@0 42 #endif
michael@0 43
michael@0 44 // The header file QuickdrawAPI.h is missing on OS X 10.7 and up (though the
michael@0 45 // QuickDraw APIs defined in it are still present) -- so we need to supply the
michael@0 46 // relevant parts of its contents here. It's likely that Apple will eventually
michael@0 47 // remove the APIs themselves (probably in OS X 10.8), so we need to make them
michael@0 48 // weak imports, and test for their presence before using them.
michael@0 49 #if !defined(__QUICKDRAWAPI__)
michael@0 50
michael@0 51 typedef short Bits16[16];
michael@0 52 struct Cursor {
michael@0 53 Bits16 data;
michael@0 54 Bits16 mask;
michael@0 55 Point hotSpot;
michael@0 56 };
michael@0 57 typedef struct Cursor Cursor;
michael@0 58
michael@0 59 #endif /* __QUICKDRAWAPI__ */
michael@0 60
michael@0 61 namespace mac_plugin_interposing {
michael@0 62
michael@0 63 // Class used to serialize NSCursor objects over IPC between processes.
michael@0 64 class NSCursorInfo {
michael@0 65 public:
michael@0 66 enum Type {
michael@0 67 TypeCustom,
michael@0 68 TypeArrow,
michael@0 69 TypeClosedHand,
michael@0 70 TypeContextualMenu, // Only supported on OS X 10.6 and up
michael@0 71 TypeCrosshair,
michael@0 72 TypeDisappearingItem,
michael@0 73 TypeDragCopy, // Only supported on OS X 10.6 and up
michael@0 74 TypeDragLink, // Only supported on OS X 10.6 and up
michael@0 75 TypeIBeam,
michael@0 76 TypeNotAllowed, // Only supported on OS X 10.6 and up
michael@0 77 TypeOpenHand,
michael@0 78 TypePointingHand,
michael@0 79 TypeResizeDown,
michael@0 80 TypeResizeLeft,
michael@0 81 TypeResizeLeftRight,
michael@0 82 TypeResizeRight,
michael@0 83 TypeResizeUp,
michael@0 84 TypeResizeUpDown,
michael@0 85 TypeTransparent // Special type
michael@0 86 };
michael@0 87
michael@0 88 NSCursorInfo();
michael@0 89 NSCursorInfo(NSCursor* aCursor);
michael@0 90 NSCursorInfo(const Cursor* aCursor);
michael@0 91 ~NSCursorInfo();
michael@0 92
michael@0 93 NSCursor* GetNSCursor() const;
michael@0 94 Type GetType() const;
michael@0 95 const char* GetTypeName() const;
michael@0 96 nsPoint GetHotSpot() const;
michael@0 97 uint8_t* GetCustomImageData() const;
michael@0 98 uint32_t GetCustomImageDataLength() const;
michael@0 99
michael@0 100 void SetType(Type aType);
michael@0 101 void SetHotSpot(nsPoint aHotSpot);
michael@0 102 void SetCustomImageData(uint8_t* aData, uint32_t aDataLength);
michael@0 103
michael@0 104 static bool GetNativeCursorsSupported();
michael@0 105
michael@0 106 private:
michael@0 107 NSCursor* GetTransparentCursor() const;
michael@0 108
michael@0 109 Type mType;
michael@0 110 // The hot spot's coordinate system is the cursor's coordinate system, and
michael@0 111 // has an upper-left origin (in both Cocoa and pre-Cocoa systems).
michael@0 112 nsPoint mHotSpot;
michael@0 113 uint8_t* mCustomImageData;
michael@0 114 uint32_t mCustomImageDataLength;
michael@0 115 static int32_t mNativeCursorsSupported;
michael@0 116 };
michael@0 117
michael@0 118 namespace parent {
michael@0 119
michael@0 120 void OnPluginShowWindow(uint32_t window_id, CGRect window_bounds, bool modal);
michael@0 121 void OnPluginHideWindow(uint32_t window_id, pid_t aPluginPid);
michael@0 122 void OnSetCursor(const NSCursorInfo& cursorInfo);
michael@0 123 void OnShowCursor(bool show);
michael@0 124 void OnPushCursor(const NSCursorInfo& cursorInfo);
michael@0 125 void OnPopCursor();
michael@0 126
michael@0 127 }
michael@0 128
michael@0 129 namespace child {
michael@0 130
michael@0 131 void SetUpCocoaInterposing();
michael@0 132
michael@0 133 }
michael@0 134
michael@0 135 }
michael@0 136
michael@0 137 #endif /* DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H */

mercurial