1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/cocoa/nsChildView.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,737 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsChildView_h_ 1.10 +#define nsChildView_h_ 1.11 + 1.12 +// formal protocols 1.13 +#include "mozView.h" 1.14 +#ifdef ACCESSIBILITY 1.15 +#include "mozilla/a11y/Accessible.h" 1.16 +#include "mozAccessibleProtocol.h" 1.17 +#endif 1.18 + 1.19 +#include "nsAutoPtr.h" 1.20 +#include "nsISupports.h" 1.21 +#include "nsBaseWidget.h" 1.22 +#include "nsIPluginInstanceOwner.h" 1.23 +#include "nsIPluginWidget.h" 1.24 +#include "nsWeakPtr.h" 1.25 +#include "TextInputHandler.h" 1.26 +#include "nsCocoaUtils.h" 1.27 +#include "gfxQuartzSurface.h" 1.28 +#include "GLContextTypes.h" 1.29 +#include "mozilla/Mutex.h" 1.30 +#include "nsRegion.h" 1.31 +#include "mozilla/MouseEvents.h" 1.32 + 1.33 +#include "nsString.h" 1.34 +#include "nsIDragService.h" 1.35 + 1.36 +#include "npapi.h" 1.37 + 1.38 +#import <Carbon/Carbon.h> 1.39 +#import <Cocoa/Cocoa.h> 1.40 +#import <AppKit/NSOpenGL.h> 1.41 + 1.42 +// The header files QuickdrawAPI.h and QDOffscreen.h are missing on OS X 10.7 1.43 +// and up (though the QuickDraw APIs defined in them are still present) -- so 1.44 +// we need to supply the relevant parts of their contents here. It's likely 1.45 +// that Apple will eventually remove the APIs themselves (probably in OS X 1.46 +// 10.8), so we need to make them weak imports, and test for their presence 1.47 +// before using them. 1.48 +#ifdef __cplusplus 1.49 +extern "C" { 1.50 +#endif 1.51 + #if !defined(__QUICKDRAWAPI__) 1.52 + 1.53 + extern void SetPort(GrafPtr port) 1.54 + __attribute__((weak_import)); 1.55 + extern void SetOrigin(short h, short v) 1.56 + __attribute__((weak_import)); 1.57 + extern RgnHandle NewRgn(void) 1.58 + __attribute__((weak_import)); 1.59 + extern void DisposeRgn(RgnHandle rgn) 1.60 + __attribute__((weak_import)); 1.61 + extern void RectRgn(RgnHandle rgn, const Rect * r) 1.62 + __attribute__((weak_import)); 1.63 + extern GDHandle GetMainDevice(void) 1.64 + __attribute__((weak_import)); 1.65 + extern Boolean IsPortOffscreen(CGrafPtr port) 1.66 + __attribute__((weak_import)); 1.67 + extern void SetPortVisibleRegion(CGrafPtr port, RgnHandle visRgn) 1.68 + __attribute__((weak_import)); 1.69 + extern void SetPortClipRegion(CGrafPtr port, RgnHandle clipRgn) 1.70 + __attribute__((weak_import)); 1.71 + extern CGrafPtr GetQDGlobalsThePort(void) 1.72 + __attribute__((weak_import)); 1.73 + 1.74 + #endif /* __QUICKDRAWAPI__ */ 1.75 + 1.76 + #if !defined(__QDOFFSCREEN__) 1.77 + 1.78 + extern void GetGWorld(CGrafPtr * port, GDHandle * gdh) 1.79 + __attribute__((weak_import)); 1.80 + extern void SetGWorld(CGrafPtr port, GDHandle gdh) 1.81 + __attribute__((weak_import)); 1.82 + 1.83 + #endif /* __QDOFFSCREEN__ */ 1.84 +#ifdef __cplusplus 1.85 +} 1.86 +#endif 1.87 + 1.88 +class gfxASurface; 1.89 +class nsChildView; 1.90 +class nsCocoaWindow; 1.91 +union nsPluginPort; 1.92 + 1.93 +namespace { 1.94 +class GLPresenter; 1.95 +class RectTextureImage; 1.96 +} 1.97 + 1.98 +namespace mozilla { 1.99 +namespace layers { 1.100 +class GLManager; 1.101 +} 1.102 +} 1.103 + 1.104 +@interface NSEvent (Undocumented) 1.105 + 1.106 +// Return Cocoa event's corresponding Carbon event. Not initialized (on 1.107 +// synthetic events) until the OS actually "sends" the event. This method 1.108 +// has been present in the same form since at least OS X 10.2.8. 1.109 +- (EventRef)_eventRef; 1.110 + 1.111 +@end 1.112 + 1.113 +@interface NSView (Undocumented) 1.114 + 1.115 +// Draws the title string of a window. 1.116 +// Present on NSThemeFrame since at least 10.6. 1.117 +// _drawTitleBar is somewhat complex, and has changed over the years 1.118 +// since OS X 10.6. But in that time it's never done anything that 1.119 +// would break when called outside of -[NSView drawRect:] (which we 1.120 +// sometimes do), or whose output can't be redirected to a 1.121 +// CGContextRef object (which we also sometimes do). This is likely 1.122 +// to remain true for the indefinite future. However we should 1.123 +// check _drawTitleBar in each new major version of OS X. For more 1.124 +// information see bug 877767. 1.125 +- (void)_drawTitleBar:(NSRect)aRect; 1.126 + 1.127 +// Returns an NSRect that is the bounding box for all an NSView's dirty 1.128 +// rectangles (ones that need to be redrawn). The full list of dirty 1.129 +// rectangles can be obtained by calling -[NSView _dirtyRegion] and then 1.130 +// calling -[NSRegion getRects:count:] on what it returns. Both these 1.131 +// methods have been present in the same form since at least OS X 10.5. 1.132 +// Unlike -[NSView getRectsBeingDrawn:count:], these methods can be called 1.133 +// outside a call to -[NSView drawRect:]. 1.134 +- (NSRect)_dirtyRect; 1.135 + 1.136 +// Undocumented method of one or more of NSFrameView's subclasses. Called 1.137 +// when one or more of the titlebar buttons needs to be repositioned, to 1.138 +// disappear, or to reappear (say if the window's style changes). If 1.139 +// 'redisplay' is true, the entire titlebar (the window's top 22 pixels) is 1.140 +// marked as needing redisplay. This method has been present in the same 1.141 +// format since at least OS X 10.5. 1.142 +- (void)_tileTitlebarAndRedisplay:(BOOL)redisplay; 1.143 + 1.144 +@end 1.145 + 1.146 +// Support for pixel scroll deltas, not part of NSEvent.h 1.147 +// See http://lists.apple.com/archives/cocoa-dev/2007/Feb/msg00050.html 1.148 +@interface NSEvent (DeviceDelta) 1.149 +// Leopard and SnowLeopard 1.150 +- (CGFloat)deviceDeltaX; 1.151 +- (CGFloat)deviceDeltaY; 1.152 +// Lion and above 1.153 +- (CGFloat)scrollingDeltaX; 1.154 +- (CGFloat)scrollingDeltaY; 1.155 +- (BOOL)hasPreciseScrollingDeltas; 1.156 +@end 1.157 + 1.158 +#if !defined(MAC_OS_X_VERSION_10_6) || \ 1.159 +MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 1.160 +@interface NSEvent (SnowLeopardEventFeatures) 1.161 ++ (NSUInteger)pressedMouseButtons; 1.162 ++ (NSUInteger)modifierFlags; 1.163 +@end 1.164 +#endif 1.165 + 1.166 +// The following section, required to support fluid swipe tracking on OS X 10.7 1.167 +// and up, contains defines/declarations that are only available on 10.7 and up. 1.168 +// [NSEvent trackSwipeEventWithOptions:...] also requires that the compiler 1.169 +// support "blocks" 1.170 +// (http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html) 1.171 +// -- which it does on 10.6 and up (using the 10.6 SDK or higher). 1.172 +// 1.173 +// MAC_OS_X_VERSION_MAX_ALLOWED "controls which OS functionality, if used, 1.174 +// will result in a compiler error because that functionality is not 1.175 +// available" (quoting from AvailabilityMacros.h). The compiler initializes 1.176 +// it to the version of the SDK being used. Its value does *not* prevent the 1.177 +// binary from running on higher OS versions. MAC_OS_X_VERSION_10_7 and 1.178 +// friends are defined (in AvailabilityMacros.h) as decimal numbers (not 1.179 +// hexadecimal numbers). 1.180 +#if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 1.181 +enum { 1.182 + NSEventPhaseNone = 0, 1.183 + NSEventPhaseBegan = 0x1 << 0, 1.184 + NSEventPhaseStationary = 0x1 << 1, 1.185 + NSEventPhaseChanged = 0x1 << 2, 1.186 + NSEventPhaseEnded = 0x1 << 3, 1.187 + NSEventPhaseCancelled = 0x1 << 4, 1.188 +}; 1.189 +typedef NSUInteger NSEventPhase; 1.190 + 1.191 +enum { 1.192 + NSFullScreenWindowMask = 1 << 14 1.193 +}; 1.194 + 1.195 +@interface NSWindow (LionWindowFeatures) 1.196 +- (NSRect)convertRectToScreen:(NSRect)aRect; 1.197 +@end 1.198 + 1.199 +#ifdef __LP64__ 1.200 +enum { 1.201 + NSEventSwipeTrackingLockDirection = 0x1 << 0, 1.202 + NSEventSwipeTrackingClampGestureAmount = 0x1 << 1 1.203 +}; 1.204 +typedef NSUInteger NSEventSwipeTrackingOptions; 1.205 + 1.206 +enum { 1.207 + NSEventGestureAxisNone = 0, 1.208 + NSEventGestureAxisHorizontal, 1.209 + NSEventGestureAxisVertical 1.210 +}; 1.211 +typedef NSInteger NSEventGestureAxis; 1.212 + 1.213 +@interface NSEvent (FluidSwipeTracking) 1.214 ++ (BOOL)isSwipeTrackingFromScrollEventsEnabled; 1.215 +- (BOOL)hasPreciseScrollingDeltas; 1.216 +- (CGFloat)scrollingDeltaX; 1.217 +- (CGFloat)scrollingDeltaY; 1.218 +- (NSEventPhase)phase; 1.219 +- (void)trackSwipeEventWithOptions:(NSEventSwipeTrackingOptions)options 1.220 + dampenAmountThresholdMin:(CGFloat)minDampenThreshold 1.221 + max:(CGFloat)maxDampenThreshold 1.222 + usingHandler:(void (^)(CGFloat gestureAmount, NSEventPhase phase, BOOL isComplete, BOOL *stop))trackingHandler; 1.223 +@end 1.224 +#endif // #ifdef __LP64__ 1.225 +#endif // #if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 1.226 + 1.227 +#if !defined(MAC_OS_X_VERSION_10_8) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8 1.228 +enum { 1.229 + NSEventPhaseMayBegin = 0x1 << 5 1.230 +}; 1.231 +#endif // #if !defined(MAC_OS_X_VERSION_10_8) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8 1.232 + 1.233 +// Undocumented scrollPhase flag that lets us discern between real scrolls and 1.234 +// automatically firing momentum scroll events. 1.235 +@interface NSEvent (ScrollPhase) 1.236 +// Leopard and SnowLeopard 1.237 +- (long long)_scrollPhase; 1.238 +// Lion and above 1.239 +- (NSEventPhase)momentumPhase; 1.240 +@end 1.241 + 1.242 +@interface ChildView : NSView< 1.243 +#ifdef ACCESSIBILITY 1.244 + mozAccessible, 1.245 +#endif 1.246 + mozView, NSTextInput, NSTextInputClient> 1.247 +{ 1.248 +@private 1.249 + // the nsChildView that created the view. It retains this NSView, so 1.250 + // the link back to it must be weak. 1.251 + nsChildView* mGeckoChild; 1.252 + 1.253 + // Text input handler for mGeckoChild and us. Note that this is a weak 1.254 + // reference. Ideally, this should be a strong reference but a ChildView 1.255 + // object can live longer than the mGeckoChild that owns it. And if 1.256 + // mTextInputHandler were a strong reference, this would make it difficult 1.257 + // for Gecko's leak detector to detect leaked TextInputHandler objects. 1.258 + // This is initialized by [mozView installTextInputHandler:aHandler] and 1.259 + // cleared by [mozView uninstallTextInputHandler]. 1.260 + mozilla::widget::TextInputHandler* mTextInputHandler; // [WEAK] 1.261 + 1.262 + BOOL mIsPluginView; 1.263 + NPEventModel mPluginEventModel; 1.264 + NPDrawingModel mPluginDrawingModel; 1.265 + 1.266 + // when mouseDown: is called, we store its event here (strong) 1.267 + NSEvent* mLastMouseDownEvent; 1.268 + 1.269 + // Whether the last mouse down event was blocked from Gecko. 1.270 + BOOL mBlockedLastMouseDown; 1.271 + 1.272 + // when acceptsFirstMouse: is called, we store the event here (strong) 1.273 + NSEvent* mClickThroughMouseDownEvent; 1.274 + 1.275 + // rects that were invalidated during a draw, so have pending drawing 1.276 + NSMutableArray* mPendingDirtyRects; 1.277 + BOOL mPendingFullDisplay; 1.278 + BOOL mPendingDisplay; 1.279 + 1.280 + // WheelStart/Stop events should always come in pairs. This BOOL records the 1.281 + // last received event so that, when we receive one of the events, we make sure 1.282 + // to send its pair event first, in case we didn't yet for any reason. 1.283 + BOOL mExpectingWheelStop; 1.284 + 1.285 + // Holds our drag service across multiple drag calls. The reference to the 1.286 + // service is obtained when the mouse enters the view and is released when 1.287 + // the mouse exits or there is a drop. This prevents us from having to 1.288 + // re-establish the connection to the service manager many times per second 1.289 + // when handling |draggingUpdated:| messages. 1.290 + nsIDragService* mDragService; 1.291 + 1.292 + NSOpenGLContext *mGLContext; 1.293 + 1.294 + // Simple gestures support 1.295 + // 1.296 + // mGestureState is used to detect when Cocoa has called both 1.297 + // magnifyWithEvent and rotateWithEvent within the same 1.298 + // beginGestureWithEvent and endGestureWithEvent sequence. We 1.299 + // discard the spurious gesture event so as not to confuse Gecko. 1.300 + // 1.301 + // mCumulativeMagnification keeps track of the total amount of 1.302 + // magnification peformed during a magnify gesture so that we can 1.303 + // send that value with the final MozMagnifyGesture event. 1.304 + // 1.305 + // mCumulativeRotation keeps track of the total amount of rotation 1.306 + // performed during a rotate gesture so we can send that value with 1.307 + // the final MozRotateGesture event. 1.308 + enum { 1.309 + eGestureState_None, 1.310 + eGestureState_StartGesture, 1.311 + eGestureState_MagnifyGesture, 1.312 + eGestureState_RotateGesture 1.313 + } mGestureState; 1.314 + float mCumulativeMagnification; 1.315 + float mCumulativeRotation; 1.316 + 1.317 + BOOL mDidForceRefreshOpenGL; 1.318 + BOOL mWaitingForPaint; 1.319 + 1.320 +#ifdef __LP64__ 1.321 + // Support for fluid swipe tracking. 1.322 + BOOL* mCancelSwipeAnimation; 1.323 + uint32_t mCurrentSwipeDir; 1.324 +#endif 1.325 + 1.326 + // Whether this uses off-main-thread compositing. 1.327 + BOOL mUsingOMTCompositor; 1.328 + 1.329 + // The mask image that's used when painting into the titlebar using basic 1.330 + // CGContext painting (i.e. non-accelerated). 1.331 + CGImageRef mTopLeftCornerMask; 1.332 +} 1.333 + 1.334 +// class initialization 1.335 ++ (void)initialize; 1.336 + 1.337 ++ (void)registerViewForDraggedTypes:(NSView*)aView; 1.338 + 1.339 +// these are sent to the first responder when the window key status changes 1.340 +- (void)viewsWindowDidBecomeKey; 1.341 +- (void)viewsWindowDidResignKey; 1.342 + 1.343 +// Stop NSView hierarchy being changed during [ChildView drawRect:] 1.344 +- (void)delayedTearDown; 1.345 + 1.346 +- (void)sendFocusEvent:(uint32_t)eventType; 1.347 + 1.348 +- (void)handleMouseMoved:(NSEvent*)aEvent; 1.349 + 1.350 +- (void)updateWindowDraggableStateOnMouseMove:(NSEvent*)theEvent; 1.351 + 1.352 +- (void)sendMouseEnterOrExitEvent:(NSEvent*)aEvent 1.353 + enter:(BOOL)aEnter 1.354 + type:(mozilla::WidgetMouseEvent::exitType)aType; 1.355 + 1.356 +- (void)updateGLContext; 1.357 +- (void)_surfaceNeedsUpdate:(NSNotification*)notification; 1.358 + 1.359 +- (BOOL)isPluginView; 1.360 + 1.361 +// Are we processing an NSLeftMouseDown event that will fail to click through? 1.362 +// If so, we shouldn't focus or unfocus a plugin. 1.363 +- (BOOL)isInFailingLeftClickThrough; 1.364 + 1.365 +- (void)setGLContext:(NSOpenGLContext *)aGLContext; 1.366 +- (bool)preRender:(NSOpenGLContext *)aGLContext; 1.367 +- (void)postRender:(NSOpenGLContext *)aGLContext; 1.368 + 1.369 +- (BOOL)isCoveringTitlebar; 1.370 + 1.371 +// Simple gestures support 1.372 +// 1.373 +// XXX - The swipeWithEvent, beginGestureWithEvent, magnifyWithEvent, 1.374 +// rotateWithEvent, and endGestureWithEvent methods are part of a 1.375 +// PRIVATE interface exported by nsResponder and reverse-engineering 1.376 +// was necessary to obtain the methods' prototypes. Thus, Apple may 1.377 +// change the interface in the future without notice. 1.378 +// 1.379 +// The prototypes were obtained from the following link: 1.380 +// http://cocoadex.com/2008/02/nsevent-modifications-swipe-ro.html 1.381 +- (void)swipeWithEvent:(NSEvent *)anEvent; 1.382 +- (void)beginGestureWithEvent:(NSEvent *)anEvent; 1.383 +- (void)magnifyWithEvent:(NSEvent *)anEvent; 1.384 +- (void)smartMagnifyWithEvent:(NSEvent *)anEvent; 1.385 +- (void)rotateWithEvent:(NSEvent *)anEvent; 1.386 +- (void)endGestureWithEvent:(NSEvent *)anEvent; 1.387 + 1.388 +- (void)scrollWheel:(NSEvent *)anEvent; 1.389 + 1.390 +// Helper function for Lion smart magnify events 1.391 ++ (BOOL)isLionSmartMagnifyEvent:(NSEvent*)anEvent; 1.392 + 1.393 +// Support for fluid swipe tracking. 1.394 +#ifdef __LP64__ 1.395 +- (void)maybeTrackScrollEventAsSwipe:(NSEvent *)anEvent 1.396 + scrollOverflowX:(double)anOverflowX 1.397 + scrollOverflowY:(double)anOverflowY 1.398 + viewPortIsOverscrolled:(BOOL)aViewPortIsOverscrolled; 1.399 +#endif 1.400 + 1.401 +- (void)setUsingOMTCompositor:(BOOL)aUseOMTC; 1.402 +@end 1.403 + 1.404 +class ChildViewMouseTracker { 1.405 + 1.406 +public: 1.407 + 1.408 + static void MouseMoved(NSEvent* aEvent); 1.409 + static void MouseScrolled(NSEvent* aEvent); 1.410 + static void OnDestroyView(ChildView* aView); 1.411 + static void OnDestroyWindow(NSWindow* aWindow); 1.412 + static BOOL WindowAcceptsEvent(NSWindow* aWindow, NSEvent* aEvent, 1.413 + ChildView* aView, BOOL isClickThrough = NO); 1.414 + static void MouseExitedWindow(NSEvent* aEvent); 1.415 + static void MouseEnteredWindow(NSEvent* aEvent); 1.416 + static void ReEvaluateMouseEnterState(NSEvent* aEvent = nil, ChildView* aOldView = nil); 1.417 + static void ResendLastMouseMoveEvent(); 1.418 + static ChildView* ViewForEvent(NSEvent* aEvent); 1.419 + static void AttachPluginEvent(mozilla::WidgetMouseEventBase& aMouseEvent, 1.420 + ChildView* aView, 1.421 + NSEvent* aNativeMouseEvent, 1.422 + int aPluginEventType, 1.423 + void* aPluginEventHolder); 1.424 + 1.425 + static ChildView* sLastMouseEventView; 1.426 + static NSEvent* sLastMouseMoveEvent; 1.427 + static NSWindow* sWindowUnderMouse; 1.428 + static NSPoint sLastScrollEventScreenLocation; 1.429 +}; 1.430 + 1.431 +//------------------------------------------------------------------------- 1.432 +// 1.433 +// nsChildView 1.434 +// 1.435 +//------------------------------------------------------------------------- 1.436 + 1.437 +class nsChildView : public nsBaseWidget, 1.438 + public nsIPluginWidget 1.439 +{ 1.440 +private: 1.441 + typedef nsBaseWidget Inherited; 1.442 + 1.443 +public: 1.444 + nsChildView(); 1.445 + virtual ~nsChildView(); 1.446 + 1.447 + NS_DECL_ISUPPORTS_INHERITED 1.448 + 1.449 + // nsIWidget interface 1.450 + NS_IMETHOD Create(nsIWidget *aParent, 1.451 + nsNativeWidget aNativeParent, 1.452 + const nsIntRect &aRect, 1.453 + nsDeviceContext *aContext, 1.454 + nsWidgetInitData *aInitData = nullptr); 1.455 + 1.456 + NS_IMETHOD Destroy(); 1.457 + 1.458 + NS_IMETHOD Show(bool aState); 1.459 + virtual bool IsVisible() const; 1.460 + 1.461 + NS_IMETHOD SetParent(nsIWidget* aNewParent); 1.462 + virtual nsIWidget* GetParent(void); 1.463 + virtual float GetDPI(); 1.464 + 1.465 + NS_IMETHOD ConstrainPosition(bool aAllowSlop, 1.466 + int32_t *aX, int32_t *aY); 1.467 + NS_IMETHOD Move(double aX, double aY); 1.468 + NS_IMETHOD Resize(double aWidth, double aHeight, bool aRepaint); 1.469 + NS_IMETHOD Resize(double aX, double aY, 1.470 + double aWidth, double aHeight, bool aRepaint); 1.471 + 1.472 + NS_IMETHOD Enable(bool aState); 1.473 + virtual bool IsEnabled() const; 1.474 + NS_IMETHOD SetFocus(bool aRaise); 1.475 + NS_IMETHOD GetBounds(nsIntRect &aRect); 1.476 + NS_IMETHOD GetClientBounds(nsIntRect &aRect); 1.477 + NS_IMETHOD GetScreenBounds(nsIntRect &aRect); 1.478 + 1.479 + // Returns the "backing scale factor" of the view's window, which is the 1.480 + // ratio of pixels in the window's backing store to Cocoa points. Prior to 1.481 + // HiDPI support in OS X 10.7, this was always 1.0, but in HiDPI mode it 1.482 + // will be 2.0 (and might potentially other values as screen resolutions 1.483 + // evolve). This gives the relationship between what Gecko calls "device 1.484 + // pixels" and the Cocoa "points" coordinate system. 1.485 + CGFloat BackingScaleFactor(); 1.486 + 1.487 + // Call if the window's backing scale factor changes - i.e., it is moved 1.488 + // between HiDPI and non-HiDPI screens 1.489 + void BackingScaleFactorChanged(); 1.490 + 1.491 + virtual double GetDefaultScaleInternal(); 1.492 + 1.493 + virtual int32_t RoundsWidgetCoordinatesTo() MOZ_OVERRIDE; 1.494 + 1.495 + NS_IMETHOD Invalidate(const nsIntRect &aRect); 1.496 + 1.497 + virtual void* GetNativeData(uint32_t aDataType); 1.498 + virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations); 1.499 + virtual nsIntPoint WidgetToScreenOffset(); 1.500 + virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect); 1.501 + 1.502 + static bool ConvertStatus(nsEventStatus aStatus) 1.503 + { return aStatus == nsEventStatus_eConsumeNoDefault; } 1.504 + NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent, 1.505 + nsEventStatus& aStatus); 1.506 + 1.507 + virtual bool ComputeShouldAccelerate(bool aDefault); 1.508 + virtual bool ShouldUseOffMainThreadCompositing() MOZ_OVERRIDE; 1.509 + 1.510 + NS_IMETHOD SetCursor(nsCursor aCursor); 1.511 + NS_IMETHOD SetCursor(imgIContainer* aCursor, uint32_t aHotspotX, uint32_t aHotspotY); 1.512 + 1.513 + NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, bool aDoCapture); 1.514 + NS_IMETHOD SetTitle(const nsAString& title); 1.515 + 1.516 + NS_IMETHOD GetAttention(int32_t aCycleCount); 1.517 + 1.518 + virtual bool HasPendingInputEvent(); 1.519 + 1.520 + NS_IMETHOD ActivateNativeMenuItemAt(const nsAString& indexString); 1.521 + NS_IMETHOD ForceUpdateNativeMenuAt(const nsAString& indexString); 1.522 + 1.523 + NS_IMETHOD NotifyIME(const IMENotification& aIMENotification) MOZ_OVERRIDE; 1.524 + NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, 1.525 + const InputContextAction& aAction); 1.526 + NS_IMETHOD_(InputContext) GetInputContext(); 1.527 + NS_IMETHOD AttachNativeKeyEvent(mozilla::WidgetKeyboardEvent& aEvent); 1.528 + NS_IMETHOD_(bool) ExecuteNativeKeyBinding( 1.529 + NativeKeyBindingsType aType, 1.530 + const mozilla::WidgetKeyboardEvent& aEvent, 1.531 + DoCommandCallback aCallback, 1.532 + void* aCallbackData) MOZ_OVERRIDE; 1.533 + virtual nsIMEUpdatePreference GetIMEUpdatePreference() MOZ_OVERRIDE; 1.534 + NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, 1.535 + bool* aLEDState); 1.536 + 1.537 + // nsIPluginWidget 1.538 + // outClipRect and outOrigin are in display pixels (not device pixels) 1.539 + NS_IMETHOD GetPluginClipRect(nsIntRect& outClipRect, nsIntPoint& outOrigin, bool& outWidgetVisible); 1.540 + NS_IMETHOD StartDrawPlugin(); 1.541 + NS_IMETHOD EndDrawPlugin(); 1.542 + NS_IMETHOD SetPluginInstanceOwner(nsIPluginInstanceOwner* aInstanceOwner); 1.543 + 1.544 + NS_IMETHOD SetPluginEventModel(int inEventModel); 1.545 + NS_IMETHOD GetPluginEventModel(int* outEventModel); 1.546 + NS_IMETHOD SetPluginDrawingModel(int inDrawingModel); 1.547 + 1.548 + NS_IMETHOD StartComplexTextInputForCurrentEvent(); 1.549 + 1.550 + virtual nsTransparencyMode GetTransparencyMode(); 1.551 + virtual void SetTransparencyMode(nsTransparencyMode aMode); 1.552 + 1.553 + virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout, 1.554 + int32_t aNativeKeyCode, 1.555 + uint32_t aModifierFlags, 1.556 + const nsAString& aCharacters, 1.557 + const nsAString& aUnmodifiedCharacters); 1.558 + 1.559 + virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint, 1.560 + uint32_t aNativeMessage, 1.561 + uint32_t aModifierFlags); 1.562 + 1.563 + virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint) 1.564 + { return SynthesizeNativeMouseEvent(aPoint, NSMouseMoved, 0); } 1.565 + 1.566 + // Mac specific methods 1.567 + 1.568 + virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent& event); 1.569 + 1.570 + void WillPaintWindow(); 1.571 + bool PaintWindow(nsIntRegion aRegion); 1.572 + 1.573 +#ifdef ACCESSIBILITY 1.574 + already_AddRefed<mozilla::a11y::Accessible> GetDocumentAccessible(); 1.575 +#endif 1.576 + 1.577 + virtual void CreateCompositor(); 1.578 + virtual gfxASurface* GetThebesSurface(); 1.579 + virtual void PrepareWindowEffects() MOZ_OVERRIDE; 1.580 + virtual void CleanupWindowEffects() MOZ_OVERRIDE; 1.581 + virtual bool PreRender(LayerManagerComposite* aManager) MOZ_OVERRIDE; 1.582 + virtual void PostRender(LayerManagerComposite* aManager) MOZ_OVERRIDE; 1.583 + virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect) MOZ_OVERRIDE; 1.584 + 1.585 + virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries); 1.586 + 1.587 + void HidePlugin(); 1.588 + void UpdatePluginPort(); 1.589 + 1.590 + void ResetParent(); 1.591 + 1.592 + static bool DoHasPendingInputEvent(); 1.593 + static uint32_t GetCurrentInputEventCount(); 1.594 + static void UpdateCurrentInputEventCount(); 1.595 + 1.596 + NSView<mozView>* GetEditorView(); 1.597 + 1.598 + bool IsPluginView() { return (mWindowType == eWindowType_plugin); } 1.599 + 1.600 + nsCocoaWindow* GetXULWindowWidget(); 1.601 + 1.602 + NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent); 1.603 + 1.604 + mozilla::widget::TextInputHandler* GetTextInputHandler() 1.605 + { 1.606 + return mTextInputHandler; 1.607 + } 1.608 + 1.609 + void NotifyDirtyRegion(const nsIntRegion& aDirtyRegion); 1.610 + 1.611 + // unit conversion convenience functions 1.612 + int32_t CocoaPointsToDevPixels(CGFloat aPts) { 1.613 + return nsCocoaUtils::CocoaPointsToDevPixels(aPts, BackingScaleFactor()); 1.614 + } 1.615 + nsIntPoint CocoaPointsToDevPixels(const NSPoint& aPt) { 1.616 + return nsCocoaUtils::CocoaPointsToDevPixels(aPt, BackingScaleFactor()); 1.617 + } 1.618 + nsIntRect CocoaPointsToDevPixels(const NSRect& aRect) { 1.619 + return nsCocoaUtils::CocoaPointsToDevPixels(aRect, BackingScaleFactor()); 1.620 + } 1.621 + CGFloat DevPixelsToCocoaPoints(int32_t aPixels) { 1.622 + return nsCocoaUtils::DevPixelsToCocoaPoints(aPixels, BackingScaleFactor()); 1.623 + } 1.624 + NSRect DevPixelsToCocoaPoints(const nsIntRect& aRect) { 1.625 + return nsCocoaUtils::DevPixelsToCocoaPoints(aRect, BackingScaleFactor()); 1.626 + } 1.627 + 1.628 + mozilla::TemporaryRef<mozilla::gfx::DrawTarget> StartRemoteDrawing() MOZ_OVERRIDE; 1.629 + void EndRemoteDrawing() MOZ_OVERRIDE; 1.630 + void CleanupRemoteDrawing() MOZ_OVERRIDE; 1.631 + 1.632 +protected: 1.633 + 1.634 + void ReportMoveEvent(); 1.635 + void ReportSizeEvent(); 1.636 + 1.637 + // override to create different kinds of child views. Autoreleases, so 1.638 + // caller must retain. 1.639 + virtual NSView* CreateCocoaView(NSRect inFrame); 1.640 + void TearDownView(); 1.641 + 1.642 + virtual already_AddRefed<nsIWidget> 1.643 + AllocateChildPopupWidget() 1.644 + { 1.645 + static NS_DEFINE_IID(kCPopUpCID, NS_POPUP_CID); 1.646 + nsCOMPtr<nsIWidget> widget = do_CreateInstance(kCPopUpCID); 1.647 + return widget.forget(); 1.648 + } 1.649 + 1.650 + void DoRemoteComposition(const nsIntRect& aRenderRect); 1.651 + 1.652 + // Overlay drawing functions for OpenGL drawing 1.653 + void DrawWindowOverlay(mozilla::layers::GLManager* aManager, nsIntRect aRect); 1.654 + void MaybeDrawResizeIndicator(mozilla::layers::GLManager* aManager, const nsIntRect& aRect); 1.655 + void MaybeDrawRoundedCorners(mozilla::layers::GLManager* aManager, const nsIntRect& aRect); 1.656 + void MaybeDrawTitlebar(mozilla::layers::GLManager* aManager, const nsIntRect& aRect); 1.657 + 1.658 + // Redraw the contents of mTitlebarCGContext on the main thread, as 1.659 + // determined by mDirtyTitlebarRegion. 1.660 + void UpdateTitlebarCGContext(); 1.661 + 1.662 + nsIntRect RectContainingTitlebarControls(); 1.663 + 1.664 + nsIWidget* GetWidgetForListenerEvents(); 1.665 + 1.666 +protected: 1.667 + 1.668 + NSView<mozView>* mView; // my parallel cocoa view (ChildView or NativeScrollbarView), [STRONG] 1.669 + nsRefPtr<mozilla::widget::TextInputHandler> mTextInputHandler; 1.670 + InputContext mInputContext; 1.671 + 1.672 + NSView<mozView>* mParentView; 1.673 + nsIWidget* mParentWidget; 1.674 + 1.675 +#ifdef ACCESSIBILITY 1.676 + // weak ref to this childview's associated mozAccessible for speed reasons 1.677 + // (we get queried for it *a lot* but don't want to own it) 1.678 + nsWeakPtr mAccessible; 1.679 +#endif 1.680 + 1.681 + nsRefPtr<gfxASurface> mTempThebesSurface; 1.682 + 1.683 + // Protects the view from being teared down while a composition is in 1.684 + // progress on the compositor thread. 1.685 + mozilla::Mutex mViewTearDownLock; 1.686 + 1.687 + mozilla::Mutex mEffectsLock; 1.688 + 1.689 + // May be accessed from any thread, protected 1.690 + // by mEffectsLock. 1.691 + bool mShowsResizeIndicator; 1.692 + nsIntRect mResizeIndicatorRect; 1.693 + bool mHasRoundedBottomCorners; 1.694 + int mDevPixelCornerRadius; 1.695 + bool mIsCoveringTitlebar; 1.696 + bool mIsFullscreen; 1.697 + nsIntRect mTitlebarRect; 1.698 + 1.699 + // The area of mTitlebarCGContext that needs to be redrawn during the next 1.700 + // transaction. Accessed from any thread, protected by mEffectsLock. 1.701 + nsIntRegion mUpdatedTitlebarRegion; 1.702 + CGContextRef mTitlebarCGContext; 1.703 + 1.704 + // Compositor thread only 1.705 + nsAutoPtr<RectTextureImage> mResizerImage; 1.706 + nsAutoPtr<RectTextureImage> mCornerMaskImage; 1.707 + nsAutoPtr<RectTextureImage> mTitlebarImage; 1.708 + nsAutoPtr<RectTextureImage> mBasicCompositorImage; 1.709 + 1.710 + // The area of mTitlebarCGContext that has changed and needs to be 1.711 + // uploaded to to mTitlebarImage. Main thread only. 1.712 + nsIntRegion mDirtyTitlebarRegion; 1.713 + 1.714 + // Cached value of [mView backingScaleFactor], to avoid sending two obj-c 1.715 + // messages (respondsToSelector, backingScaleFactor) every time we need to 1.716 + // use it. 1.717 + // ** We'll need to reinitialize this if the backing resolution changes. ** 1.718 + CGFloat mBackingScaleFactor; 1.719 + 1.720 + bool mVisible; 1.721 + bool mDrawing; 1.722 + bool mPluginDrawing; 1.723 + bool mIsDispatchPaint; // Is a paint event being dispatched 1.724 + 1.725 + NP_CGContext mPluginCGContext; 1.726 + nsIPluginInstanceOwner* mPluginInstanceOwner; // [WEAK] 1.727 + 1.728 + // Used in OMTC BasicLayers mode. Presents the BasicCompositor result 1.729 + // surface to the screen using an OpenGL context. 1.730 + nsAutoPtr<GLPresenter> mGLPresenter; 1.731 + 1.732 + static uint32_t sLastInputEventCount; 1.733 + 1.734 + void ReleaseTitlebarCGContext(); 1.735 +}; 1.736 + 1.737 +void NS_InstallPluginKeyEventsHandler(); 1.738 +void NS_RemovePluginKeyEventsHandler(); 1.739 + 1.740 +#endif // nsChildView_h_