2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2008-12-15 12:56:29 -08:00
|
|
|
* Thomas K. Dyas <tdyas@zecador.org>
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef nsChildView_h_
|
|
|
|
#define nsChildView_h_
|
|
|
|
|
|
|
|
// formal protocols
|
|
|
|
#include "mozView.h"
|
|
|
|
#ifdef ACCESSIBILITY
|
2010-05-11 23:47:35 -07:00
|
|
|
#include "nsAccessible.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "mozAccessibleProtocol.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsBaseWidget.h"
|
2008-04-23 15:56:40 -07:00
|
|
|
#include "nsIPluginInstanceOwner.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIPluginWidget.h"
|
|
|
|
#include "nsWeakPtr.h"
|
2011-05-08 03:19:15 -07:00
|
|
|
#include "TextInputHandler.h"
|
2009-09-30 19:52:50 -07:00
|
|
|
#include "nsCocoaUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIDragService.h"
|
|
|
|
|
2009-08-31 18:00:13 -07:00
|
|
|
#include "npapi.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-04-05 17:26:53 -07:00
|
|
|
#import <Carbon/Carbon.h>
|
2007-03-22 10:30:00 -07:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2010-04-27 15:29:29 -07:00
|
|
|
#import <AppKit/NSOpenGL.h>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-11 00:12:58 -07:00
|
|
|
// The header files QuickdrawAPI.h and QDOffscreen.h are missing on OS X 10.7
|
|
|
|
// and up (though the QuickDraw APIs defined in them are still present) -- so
|
|
|
|
// we need to supply the relevant parts of their contents here. It's likely
|
|
|
|
// that Apple will eventually remove the APIs themselves (probably in OS X
|
|
|
|
// 10.8), so we need to make them weak imports, and test for their presence
|
|
|
|
// before using them.
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
#if !defined(__QUICKDRAWAPI__)
|
|
|
|
|
|
|
|
extern void SetPort(GrafPtr port)
|
|
|
|
__attribute__((weak_import));
|
|
|
|
extern void SetOrigin(short h, short v)
|
|
|
|
__attribute__((weak_import));
|
|
|
|
extern RgnHandle NewRgn(void)
|
|
|
|
__attribute__((weak_import));
|
|
|
|
extern void DisposeRgn(RgnHandle rgn)
|
|
|
|
__attribute__((weak_import));
|
|
|
|
extern void RectRgn(RgnHandle rgn, const Rect * r)
|
|
|
|
__attribute__((weak_import));
|
|
|
|
extern GDHandle GetMainDevice(void)
|
|
|
|
__attribute__((weak_import));
|
|
|
|
extern Boolean IsPortOffscreen(CGrafPtr port)
|
|
|
|
__attribute__((weak_import));
|
|
|
|
extern void SetPortVisibleRegion(CGrafPtr port, RgnHandle visRgn)
|
|
|
|
__attribute__((weak_import));
|
|
|
|
extern void SetPortClipRegion(CGrafPtr port, RgnHandle clipRgn)
|
|
|
|
__attribute__((weak_import));
|
|
|
|
extern CGrafPtr GetQDGlobalsThePort(void)
|
|
|
|
__attribute__((weak_import));
|
|
|
|
|
|
|
|
#endif /* __QUICKDRAWAPI__ */
|
|
|
|
|
|
|
|
#if !defined(__QDOFFSCREEN__)
|
|
|
|
|
|
|
|
extern void GetGWorld(CGrafPtr * port, GDHandle * gdh)
|
|
|
|
__attribute__((weak_import));
|
|
|
|
extern void SetGWorld(CGrafPtr port, GDHandle gdh)
|
|
|
|
__attribute__((weak_import));
|
|
|
|
|
|
|
|
#endif /* __QDOFFSCREEN__ */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-04-05 17:26:53 -07:00
|
|
|
class gfxASurface;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsChildView;
|
2009-08-13 15:06:49 -07:00
|
|
|
class nsCocoaWindow;
|
2007-04-05 17:26:53 -07:00
|
|
|
union nsPluginPort;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-02-19 14:23:02 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
class TextureImage;
|
|
|
|
}
|
2012-01-19 06:45:37 -08:00
|
|
|
|
|
|
|
namespace layers {
|
|
|
|
class LayerManagerOGL;
|
|
|
|
}
|
2011-02-19 14:23:02 -08:00
|
|
|
}
|
|
|
|
|
2010-03-20 08:05:47 -07:00
|
|
|
#ifndef NP_NO_CARBON
|
2008-06-30 09:30:22 -07:00
|
|
|
enum {
|
|
|
|
// Currently focused ChildView (while this TSM document is active).
|
|
|
|
// Transient (only set while TSMProcessRawKeyEvent() is processing a key
|
|
|
|
// event), and the ChildView will be retained and released around the call
|
|
|
|
// to TSMProcessRawKeyEvent() -- so it can be weak.
|
|
|
|
kFocusedChildViewTSMDocPropertyTag = 'GKFV', // type ChildView* [WEAK]
|
|
|
|
};
|
|
|
|
|
|
|
|
// Undocumented HIToolbox function used by WebKit to allow Carbon-based IME
|
|
|
|
// to work in a Cocoa-based browser (like Safari or Cocoa-widgets Firefox).
|
|
|
|
// (Recent WebKit versions actually use a thin wrapper around this function
|
|
|
|
// called WKSendKeyEventToTSM().)
|
|
|
|
//
|
|
|
|
// Calling TSMProcessRawKeyEvent() from ChildView's keyDown: and keyUp:
|
|
|
|
// methods (when the ChildView is a plugin view) bypasses Cocoa's IME
|
|
|
|
// infrastructure and (instead) causes Carbon TSM events to be sent on each
|
|
|
|
// NSKeyDown event. We install a Carbon event handler
|
|
|
|
// (PluginKeyEventsHandler()) to catch these events and pass them to Gecko
|
|
|
|
// (which in turn passes them to the plugin).
|
|
|
|
extern "C" long TSMProcessRawKeyEvent(EventRef carbonEvent);
|
2010-03-20 08:05:47 -07:00
|
|
|
#endif // NP_NO_CARBON
|
2008-06-30 09:30:22 -07:00
|
|
|
|
|
|
|
@interface NSEvent (Undocumented)
|
|
|
|
|
|
|
|
// Return Cocoa event's corresponding Carbon event. Not initialized (on
|
|
|
|
// synthetic events) until the OS actually "sends" the event. This method
|
|
|
|
// has been present in the same form since at least OS X 10.2.8.
|
|
|
|
- (EventRef)_eventRef;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2008-09-17 04:27:19 -07:00
|
|
|
// Support for pixel scroll deltas, not part of NSEvent.h
|
|
|
|
// See http://lists.apple.com/archives/cocoa-dev/2007/Feb/msg00050.html
|
|
|
|
@interface NSEvent (DeviceDelta)
|
2010-04-19 07:10:02 -07:00
|
|
|
- (CGFloat)deviceDeltaX;
|
|
|
|
- (CGFloat)deviceDeltaY;
|
2008-09-17 04:27:19 -07:00
|
|
|
@end
|
|
|
|
|
2010-11-05 09:04:28 -07:00
|
|
|
// Undocumented scrollPhase flag that lets us discern between real scrolls and
|
|
|
|
// automatically firing momentum scroll events.
|
|
|
|
@interface NSEvent (ScrollPhase)
|
|
|
|
- (long long)_scrollPhase;
|
|
|
|
@end
|
|
|
|
|
2011-08-11 10:42:23 -07:00
|
|
|
// The following section, required to support fluid swipe tracking on OS X 10.7
|
|
|
|
// and up, contains defines/declarations that are only available on 10.7 and up.
|
|
|
|
// [NSEvent trackSwipeEventWithOptions:...] also requires that the compiler
|
|
|
|
// support "blocks"
|
|
|
|
// (http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html)
|
|
|
|
// -- which it does on 10.6 and up (using the 10.6 SDK or higher).
|
2011-08-12 09:48:29 -07:00
|
|
|
//
|
|
|
|
// MAC_OS_X_VERSION_MAX_ALLOWED "controls which OS functionality, if used,
|
|
|
|
// will result in a compiler error because that functionality is not
|
|
|
|
// available" (quoting from AvailabilityMacros.h). The compiler initializes
|
|
|
|
// it to the version of the SDK being used. Its value does *not* prevent the
|
|
|
|
// binary from running on higher OS versions. MAC_OS_X_VERSION_10_7 and
|
|
|
|
// friends are defined (in AvailabilityMacros.h) as decimal numbers (not
|
|
|
|
// hexadecimal numbers).
|
|
|
|
#if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
2011-08-11 10:42:23 -07:00
|
|
|
#ifdef __LP64__
|
|
|
|
enum {
|
|
|
|
NSEventPhaseNone = 0,
|
|
|
|
NSEventPhaseBegan = 0x1 << 0,
|
|
|
|
NSEventPhaseStationary = 0x1 << 1,
|
|
|
|
NSEventPhaseChanged = 0x1 << 2,
|
|
|
|
NSEventPhaseEnded = 0x1 << 3,
|
|
|
|
NSEventPhaseCancelled = 0x1 << 4,
|
|
|
|
};
|
|
|
|
typedef NSUInteger NSEventPhase;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
NSEventSwipeTrackingLockDirection = 0x1 << 0,
|
|
|
|
NSEventSwipeTrackingClampGestureAmount = 0x1 << 1
|
|
|
|
};
|
|
|
|
typedef NSUInteger NSEventSwipeTrackingOptions;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
NSEventGestureAxisNone = 0,
|
|
|
|
NSEventGestureAxisHorizontal,
|
|
|
|
NSEventGestureAxisVertical
|
|
|
|
};
|
|
|
|
typedef NSInteger NSEventGestureAxis;
|
|
|
|
|
|
|
|
@interface NSEvent (FluidSwipeTracking)
|
|
|
|
+ (BOOL)isSwipeTrackingFromScrollEventsEnabled;
|
|
|
|
- (BOOL)hasPreciseScrollingDeltas;
|
|
|
|
- (CGFloat)scrollingDeltaX;
|
|
|
|
- (CGFloat)scrollingDeltaY;
|
|
|
|
- (NSEventPhase)phase;
|
|
|
|
- (void)trackSwipeEventWithOptions:(NSEventSwipeTrackingOptions)options
|
|
|
|
dampenAmountThresholdMin:(CGFloat)minDampenThreshold
|
|
|
|
max:(CGFloat)maxDampenThreshold
|
|
|
|
usingHandler:(void (^)(CGFloat gestureAmount, NSEventPhase phase, BOOL isComplete, BOOL *stop))trackingHandler;
|
|
|
|
@end
|
|
|
|
#endif // #ifdef __LP64__
|
2011-08-12 09:48:29 -07:00
|
|
|
#endif // #if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
2011-08-11 10:42:23 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
@interface ChildView : NSView<
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
mozAccessible,
|
|
|
|
#endif
|
|
|
|
mozView, NSTextInput>
|
|
|
|
{
|
|
|
|
@private
|
|
|
|
// the nsChildView that created the view. It retains this NSView, so
|
|
|
|
// the link back to it must be weak.
|
|
|
|
nsChildView* mGeckoChild;
|
2009-08-26 17:29:47 -07:00
|
|
|
|
2011-05-08 03:19:23 -07:00
|
|
|
// Text input handler for mGeckoChild and us. Note that this is a weak
|
|
|
|
// reference. Ideally, this should be a strong reference but a ChildView
|
|
|
|
// object can live longer than the mGeckoChild that owns it. And if
|
|
|
|
// mTextInputHandler were a strong reference, this would make it difficult
|
|
|
|
// for Gecko's leak detector to detect leaked TextInputHandler objects.
|
|
|
|
// This is initialized by [mozView installTextInputHandler:aHandler] and
|
|
|
|
// cleared by [mozView uninstallTextInputHandler].
|
|
|
|
mozilla::widget::TextInputHandler* mTextInputHandler; // [WEAK]
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
BOOL mIsPluginView;
|
2009-08-31 18:00:13 -07:00
|
|
|
NPEventModel mPluginEventModel;
|
2010-09-17 10:55:39 -07:00
|
|
|
NPDrawingModel mPluginDrawingModel;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-04-06 16:52:05 -07:00
|
|
|
// when mouseDown: is called, we store its event here (strong)
|
|
|
|
NSEvent* mLastMouseDownEvent;
|
2010-07-16 05:48:02 -07:00
|
|
|
|
|
|
|
// Whether the last mouse down event was blocked from Gecko.
|
|
|
|
BOOL mBlockedLastMouseDown;
|
|
|
|
|
|
|
|
// when acceptsFirstMouse: is called, we store the event here (strong)
|
|
|
|
NSEvent* mClickThroughMouseDownEvent;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// rects that were invalidated during a draw, so have pending drawing
|
|
|
|
NSMutableArray* mPendingDirtyRects;
|
|
|
|
BOOL mPendingFullDisplay;
|
2010-06-08 21:11:42 -07:00
|
|
|
BOOL mPendingDisplay;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Holds our drag service across multiple drag calls. The reference to the
|
|
|
|
// service is obtained when the mouse enters the view and is released when
|
|
|
|
// the mouse exits or there is a drop. This prevents us from having to
|
|
|
|
// re-establish the connection to the service manager many times per second
|
|
|
|
// when handling |draggingUpdated:| messages.
|
|
|
|
nsIDragService* mDragService;
|
2010-03-20 08:05:47 -07:00
|
|
|
|
2010-06-18 02:22:01 -07:00
|
|
|
NSOpenGLContext *mGLContext;
|
2010-04-27 15:29:29 -07:00
|
|
|
|
2008-10-23 13:15:20 -07:00
|
|
|
// Simple gestures support
|
|
|
|
//
|
|
|
|
// mGestureState is used to detect when Cocoa has called both
|
|
|
|
// magnifyWithEvent and rotateWithEvent within the same
|
|
|
|
// beginGestureWithEvent and endGestureWithEvent sequence. We
|
|
|
|
// discard the spurious gesture event so as not to confuse Gecko.
|
|
|
|
//
|
|
|
|
// mCumulativeMagnification keeps track of the total amount of
|
|
|
|
// magnification peformed during a magnify gesture so that we can
|
|
|
|
// send that value with the final MozMagnifyGesture event.
|
|
|
|
//
|
|
|
|
// mCumulativeRotation keeps track of the total amount of rotation
|
|
|
|
// performed during a rotate gesture so we can send that value with
|
|
|
|
// the final MozRotateGesture event.
|
|
|
|
enum {
|
|
|
|
eGestureState_None,
|
|
|
|
eGestureState_StartGesture,
|
|
|
|
eGestureState_MagnifyGesture,
|
|
|
|
eGestureState_RotateGesture
|
|
|
|
} mGestureState;
|
|
|
|
float mCumulativeMagnification;
|
|
|
|
float mCumulativeRotation;
|
2011-02-03 13:12:33 -08:00
|
|
|
|
|
|
|
BOOL mDidForceRefreshOpenGL;
|
2011-08-11 10:42:23 -07:00
|
|
|
|
|
|
|
// Support for fluid swipe tracking.
|
|
|
|
#ifdef __LP64__
|
|
|
|
BOOL *mSwipeAnimationCancelled;
|
|
|
|
#endif
|
2012-01-19 06:45:37 -08:00
|
|
|
|
|
|
|
// Whether this uses off-main-thread compositing.
|
|
|
|
BOOL mUsingOMTCompositor;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-12-15 12:56:29 -08:00
|
|
|
// class initialization
|
|
|
|
+ (void)initialize;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// these are sent to the first responder when the window key status changes
|
|
|
|
- (void)viewsWindowDidBecomeKey;
|
|
|
|
- (void)viewsWindowDidResignKey;
|
2007-05-30 11:25:44 -07:00
|
|
|
|
|
|
|
// Stop NSView hierarchy being changed during [ChildView drawRect:]
|
|
|
|
- (void)delayedTearDown;
|
2008-01-17 08:58:29 -08:00
|
|
|
|
|
|
|
- (void)sendFocusEvent:(PRUint32)eventType;
|
2008-06-30 09:30:22 -07:00
|
|
|
|
2009-09-22 19:31:37 -07:00
|
|
|
- (void)handleMouseMoved:(NSEvent*)aEvent;
|
|
|
|
|
2010-10-15 03:34:29 -07:00
|
|
|
- (void)drawRect:(NSRect)aRect inTitlebarContext:(CGContextRef)aContext;
|
2009-10-21 00:05:39 -07:00
|
|
|
|
2009-09-22 19:31:37 -07:00
|
|
|
- (void)sendMouseEnterOrExitEvent:(NSEvent*)aEvent
|
|
|
|
enter:(BOOL)aEnter
|
|
|
|
type:(nsMouseEvent::exitType)aType;
|
|
|
|
|
2010-04-27 15:29:29 -07:00
|
|
|
- (void)update;
|
|
|
|
- (void)lockFocus;
|
|
|
|
- (void) _surfaceNeedsUpdate:(NSNotification*)notification;
|
|
|
|
|
2010-08-16 20:26:17 -07:00
|
|
|
- (BOOL)isPluginView;
|
|
|
|
|
2010-11-15 13:12:50 -08:00
|
|
|
// Are we processing an NSLeftMouseDown event that will fail to click through?
|
|
|
|
// If so, we shouldn't focus or unfocus a plugin.
|
|
|
|
- (BOOL)isInFailingLeftClickThrough;
|
|
|
|
|
2012-01-19 06:45:37 -08:00
|
|
|
- (void)setGLContext:(NSOpenGLContext *)aGLContext;
|
|
|
|
|
2008-10-23 13:15:20 -07:00
|
|
|
// Simple gestures support
|
|
|
|
//
|
|
|
|
// XXX - The swipeWithEvent, beginGestureWithEvent, magnifyWithEvent,
|
|
|
|
// rotateWithEvent, and endGestureWithEvent methods are part of a
|
|
|
|
// PRIVATE interface exported by nsResponder and reverse-engineering
|
|
|
|
// was necessary to obtain the methods' prototypes. Thus, Apple may
|
|
|
|
// change the interface in the future without notice.
|
|
|
|
//
|
|
|
|
// The prototypes were obtained from the following link:
|
|
|
|
// http://cocoadex.com/2008/02/nsevent-modifications-swipe-ro.html
|
|
|
|
- (void)swipeWithEvent:(NSEvent *)anEvent;
|
|
|
|
- (void)beginGestureWithEvent:(NSEvent *)anEvent;
|
|
|
|
- (void)magnifyWithEvent:(NSEvent *)anEvent;
|
|
|
|
- (void)rotateWithEvent:(NSEvent *)anEvent;
|
|
|
|
- (void)endGestureWithEvent:(NSEvent *)anEvent;
|
2011-08-11 10:42:23 -07:00
|
|
|
|
|
|
|
// Support for fluid swipe tracking.
|
|
|
|
#ifdef __LP64__
|
|
|
|
- (void)maybeTrackScrollEventAsSwipe:(NSEvent *)anEvent
|
|
|
|
scrollOverflow:(PRInt32)overflow;
|
|
|
|
#endif
|
2012-01-19 06:45:37 -08:00
|
|
|
|
|
|
|
- (void)setUsingOMTCompositor:(BOOL)aUseOMTC;
|
2007-03-22 10:30:00 -07:00
|
|
|
@end
|
|
|
|
|
2009-09-22 19:31:37 -07:00
|
|
|
class ChildViewMouseTracker {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static void MouseMoved(NSEvent* aEvent);
|
2011-08-17 15:30:52 -07:00
|
|
|
static void MouseScrolled(NSEvent* aEvent);
|
2009-09-22 19:31:37 -07:00
|
|
|
static void OnDestroyView(ChildView* aView);
|
2011-08-08 07:43:13 -07:00
|
|
|
static void OnDestroyWindow(NSWindow* aWindow);
|
2010-07-16 05:48:02 -07:00
|
|
|
static BOOL WindowAcceptsEvent(NSWindow* aWindow, NSEvent* aEvent,
|
|
|
|
ChildView* aView, BOOL isClickThrough = NO);
|
2011-08-08 07:43:13 -07:00
|
|
|
static void MouseExitedWindow(NSEvent* aEvent);
|
|
|
|
static void MouseEnteredWindow(NSEvent* aEvent);
|
2009-12-11 13:56:59 -08:00
|
|
|
static void ReEvaluateMouseEnterState(NSEvent* aEvent = nil);
|
2011-08-13 07:25:39 -07:00
|
|
|
static void ResendLastMouseMoveEvent();
|
2010-01-22 12:57:04 -08:00
|
|
|
static ChildView* ViewForEvent(NSEvent* aEvent);
|
2009-09-22 19:31:37 -07:00
|
|
|
|
|
|
|
static ChildView* sLastMouseEventView;
|
2011-08-13 07:25:39 -07:00
|
|
|
static NSEvent* sLastMouseMoveEvent;
|
2011-08-08 07:43:13 -07:00
|
|
|
static NSWindow* sWindowUnderMouse;
|
2011-08-17 15:30:52 -07:00
|
|
|
static NSPoint sLastScrollEventScreenLocation;
|
2009-09-22 19:31:37 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsChildView
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsChildView : public nsBaseWidget,
|
2008-07-13 19:56:18 -07:00
|
|
|
public nsIPluginWidget
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
typedef nsBaseWidget Inherited;
|
|
|
|
|
|
|
|
public:
|
|
|
|
nsChildView();
|
|
|
|
virtual ~nsChildView();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// nsIWidget interface
|
|
|
|
NS_IMETHOD Create(nsIWidget *aParent,
|
2009-09-23 23:18:10 -07:00
|
|
|
nsNativeWidget aNativeParent,
|
2009-01-14 19:27:09 -08:00
|
|
|
const nsIntRect &aRect,
|
2007-03-22 10:30:00 -07:00
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
2011-04-16 18:22:44 -07:00
|
|
|
nsDeviceContext *aContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsWidgetInitData *aInitData = nsnull);
|
|
|
|
|
|
|
|
NS_IMETHOD Destroy();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD Show(bool aState);
|
|
|
|
NS_IMETHOD IsVisible(bool& outState);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-10-28 22:19:42 -07:00
|
|
|
NS_IMETHOD SetParent(nsIWidget* aNewParent);
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual nsIWidget* GetParent(void);
|
2010-08-13 02:57:55 -07:00
|
|
|
virtual float GetDPI();
|
2008-02-19 23:40:04 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
|
2007-03-22 10:30:00 -07:00
|
|
|
PRInt32 *aX, PRInt32 *aY);
|
|
|
|
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD Resize(PRInt32 aWidth,PRInt32 aHeight, bool aRepaint);
|
|
|
|
NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY,PRInt32 aWidth,PRInt32 aHeight, bool aRepaint);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD Enable(bool aState);
|
|
|
|
NS_IMETHOD IsEnabled(bool *aState);
|
|
|
|
NS_IMETHOD SetFocus(bool aRaise);
|
2009-01-14 19:27:09 -08:00
|
|
|
NS_IMETHOD GetBounds(nsIntRect &aRect);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-12-23 19:52:21 -08:00
|
|
|
NS_IMETHOD Invalidate(const nsIntRect &aRect);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual void* GetNativeData(PRUint32 aDataType);
|
2009-07-21 17:44:55 -07:00
|
|
|
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations);
|
2009-02-18 16:11:49 -08:00
|
|
|
virtual nsIntPoint WidgetToScreenOffset();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool ConvertStatus(nsEventStatus aStatus)
|
2007-03-22 10:30:00 -07:00
|
|
|
{ return aStatus == nsEventStatus_eConsumeNoDefault; }
|
|
|
|
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool GetShouldAccelerate();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor);
|
|
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor, PRUint32 aHotspotX, PRUint32 aHotspotY);
|
2012-01-19 06:45:37 -08:00
|
|
|
|
2011-11-08 11:59:07 -08:00
|
|
|
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, bool aDoCapture, bool aConsumeRollupEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD SetTitle(const nsAString& title);
|
|
|
|
|
|
|
|
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool HasPendingInputEvent();
|
2009-04-21 16:53:52 -07:00
|
|
|
|
2008-07-27 21:46:33 -07:00
|
|
|
NS_IMETHOD ActivateNativeMenuItemAt(const nsAString& indexString);
|
2008-10-29 22:36:01 -07:00
|
|
|
NS_IMETHOD ForceUpdateNativeMenuAt(const nsAString& indexString);
|
2008-06-28 00:55:30 -07:00
|
|
|
|
2008-07-13 19:56:18 -07:00
|
|
|
NS_IMETHOD ResetInputState();
|
2011-11-27 03:51:52 -08:00
|
|
|
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
|
|
|
const InputContextAction& aAction);
|
|
|
|
NS_IMETHOD_(InputContext) GetInputContext();
|
2008-07-13 19:56:18 -07:00
|
|
|
NS_IMETHOD CancelIMEComposition();
|
|
|
|
NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aLEDState);
|
|
|
|
NS_IMETHOD OnIMEFocusChange(bool aFocus);
|
2008-07-13 19:56:18 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIPluginWidget
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD GetPluginClipRect(nsIntRect& outClipRect, nsIntPoint& outOrigin, bool& outWidgetVisible);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD StartDrawPlugin();
|
|
|
|
NS_IMETHOD EndDrawPlugin();
|
2008-04-23 15:56:40 -07:00
|
|
|
NS_IMETHOD SetPluginInstanceOwner(nsIPluginInstanceOwner* aInstanceOwner);
|
2009-08-26 17:29:47 -07:00
|
|
|
|
|
|
|
NS_IMETHOD SetPluginEventModel(int inEventModel);
|
|
|
|
NS_IMETHOD GetPluginEventModel(int* outEventModel);
|
2010-09-17 10:55:39 -07:00
|
|
|
NS_IMETHOD SetPluginDrawingModel(int inDrawingModel);
|
2009-08-26 17:29:47 -07:00
|
|
|
|
2010-06-09 17:56:17 -07:00
|
|
|
NS_IMETHOD StartComplexTextInputForCurrentEvent();
|
|
|
|
|
2008-08-12 17:44:14 -07:00
|
|
|
virtual nsTransparencyMode GetTransparencyMode();
|
|
|
|
virtual void SetTransparencyMode(nsTransparencyMode aMode);
|
2009-09-22 19:31:37 -07:00
|
|
|
|
|
|
|
virtual nsresult SynthesizeNativeKeyEvent(PRInt32 aNativeKeyboardLayout,
|
|
|
|
PRInt32 aNativeKeyCode,
|
|
|
|
PRUint32 aModifierFlags,
|
|
|
|
const nsAString& aCharacters,
|
|
|
|
const nsAString& aUnmodifiedCharacters);
|
|
|
|
|
|
|
|
virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint,
|
|
|
|
PRUint32 aNativeMessage,
|
|
|
|
PRUint32 aModifierFlags);
|
2007-12-19 11:40:18 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Mac specific methods
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool DispatchWindowEvent(nsGUIEvent& event);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2010-05-11 23:47:35 -07:00
|
|
|
already_AddRefed<nsAccessible> GetDocumentAccessible();
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2012-01-19 06:45:37 -08:00
|
|
|
virtual void CreateCompositor();
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual gfxASurface* GetThebesSurface();
|
2012-01-21 18:01:17 -08:00
|
|
|
virtual void DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-01-11 05:03:16 -08:00
|
|
|
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries);
|
|
|
|
|
2007-09-27 09:01:32 -07:00
|
|
|
NS_IMETHOD BeginSecureKeyboardInput();
|
|
|
|
NS_IMETHOD EndSecureKeyboardInput();
|
|
|
|
|
2008-04-23 15:56:40 -07:00
|
|
|
void HidePlugin();
|
2009-07-22 01:57:39 -07:00
|
|
|
void UpdatePluginPort();
|
2008-04-23 15:56:40 -07:00
|
|
|
|
2009-04-23 08:54:50 -07:00
|
|
|
void ResetParent();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool DoHasPendingInputEvent();
|
2009-04-21 16:53:52 -07:00
|
|
|
static PRUint32 GetCurrentInputEventCount();
|
|
|
|
static void UpdateCurrentInputEventCount();
|
2009-07-21 17:44:55 -07:00
|
|
|
|
2009-09-30 19:52:50 -07:00
|
|
|
NSView<mozView>* GetEditorView();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsPluginView() { return (mWindowType == eWindowType_plugin); }
|
2010-09-07 10:20:03 -07:00
|
|
|
|
2010-09-17 10:58:26 -07:00
|
|
|
void PaintQD();
|
|
|
|
|
2010-11-15 13:12:50 -08:00
|
|
|
nsCocoaWindow* GetXULWindowWidget();
|
|
|
|
|
2010-09-18 04:28:50 -07:00
|
|
|
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);
|
2011-02-23 20:48:12 -08:00
|
|
|
|
|
|
|
mozilla::widget::TextInputHandler* GetTextInputHandler()
|
|
|
|
{
|
|
|
|
return mTextInputHandler;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ReportDestroyEvent();
|
|
|
|
bool ReportMoveEvent();
|
|
|
|
bool ReportSizeEvent();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// override to create different kinds of child views. Autoreleases, so
|
|
|
|
// caller must retain.
|
|
|
|
virtual NSView* CreateCocoaView(NSRect inFrame);
|
|
|
|
void TearDownView();
|
|
|
|
|
2010-08-20 12:29:02 -07:00
|
|
|
virtual already_AddRefed<nsIWidget>
|
|
|
|
AllocateChildPopupWidget()
|
|
|
|
{
|
|
|
|
static NS_DEFINE_IID(kCPopUpCID, NS_POPUP_CID);
|
|
|
|
nsCOMPtr<nsIWidget> widget = do_CreateInstance(kCPopUpCID);
|
|
|
|
return widget.forget();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
|
|
|
|
NSView<mozView>* mView; // my parallel cocoa view (ChildView or NativeScrollbarView), [STRONG]
|
2011-05-08 03:19:23 -07:00
|
|
|
nsRefPtr<mozilla::widget::TextInputHandler> mTextInputHandler;
|
2011-11-27 03:51:52 -08:00
|
|
|
InputContext mInputContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NSView<mozView>* mParentView;
|
|
|
|
nsIWidget* mParentWidget;
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
// weak ref to this childview's associated mozAccessible for speed reasons
|
|
|
|
// (we get queried for it *a lot* but don't want to own it)
|
|
|
|
nsWeakPtr mAccessible;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsRefPtr<gfxASurface> mTempThebesSurface;
|
2011-02-19 14:23:02 -08:00
|
|
|
nsRefPtr<mozilla::gl::TextureImage> mResizerImage;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mVisible;
|
|
|
|
bool mDrawing;
|
|
|
|
bool mPluginDrawing;
|
|
|
|
bool mIsDispatchPaint; // Is a paint event being dispatched
|
2008-01-15 15:11:55 -08:00
|
|
|
|
2009-09-16 18:30:26 -07:00
|
|
|
NP_CGContext mPluginCGContext;
|
2010-06-15 12:34:32 -07:00
|
|
|
#ifndef NP_NO_QUICKDRAW
|
2009-09-16 18:30:26 -07:00
|
|
|
NP_Port mPluginQDPort;
|
2010-06-15 12:34:32 -07:00
|
|
|
#endif
|
2008-04-23 15:56:40 -07:00
|
|
|
nsIPluginInstanceOwner* mPluginInstanceOwner; // [WEAK]
|
2009-04-21 16:53:52 -07:00
|
|
|
|
|
|
|
static PRUint32 sLastInputEventCount;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2008-06-30 09:30:22 -07:00
|
|
|
void NS_InstallPluginKeyEventsHandler();
|
|
|
|
void NS_RemovePluginKeyEventsHandler();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#endif // nsChildView_h_
|