2015-06-12 15:49:57 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#import <UIKit/UIEvent.h>
|
|
|
|
#import <UIKit/UIGraphics.h>
|
|
|
|
#import <UIKit/UIInterface.h>
|
|
|
|
#import <UIKit/UIScreen.h>
|
|
|
|
#import <UIKit/UITapGestureRecognizer.h>
|
|
|
|
#import <UIKit/UITouch.h>
|
|
|
|
#import <UIKit/UIView.h>
|
|
|
|
#import <UIKit/UIViewController.h>
|
|
|
|
#import <UIKit/UIWindow.h>
|
|
|
|
#import <QuartzCore/QuartzCore.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "nsWindow.h"
|
|
|
|
#include "nsScreenManager.h"
|
|
|
|
#include "nsAppShell.h"
|
|
|
|
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsGfxCIID.h"
|
|
|
|
|
|
|
|
#include "gfxQuartzSurface.h"
|
|
|
|
#include "gfxUtils.h"
|
|
|
|
#include "gfxImageSurface.h"
|
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "nsRegion.h"
|
|
|
|
#include "Layers.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
|
|
|
|
#include "mozilla/BasicEvents.h"
|
|
|
|
#include "mozilla/TouchEvents.h"
|
|
|
|
#include "mozilla/unused.h"
|
|
|
|
|
|
|
|
#include "GeckoProfiler.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
using namespace mozilla::layers;
|
|
|
|
|
|
|
|
#define ALOG(args...) fprintf(stderr, args); fprintf(stderr, "\n")
|
|
|
|
|
|
|
|
static LayoutDeviceIntPoint
|
|
|
|
UIKitPointsToDevPixels(CGPoint aPoint, CGFloat aBackingScale)
|
|
|
|
{
|
|
|
|
return LayoutDeviceIntPoint(NSToIntRound(aPoint.x * aBackingScale),
|
|
|
|
NSToIntRound(aPoint.y * aBackingScale));
|
|
|
|
}
|
|
|
|
|
|
|
|
static CGRect
|
2015-11-23 07:32:29 +03:00
|
|
|
DevPixelsToUIKitPoints(const LayoutDeviceIntRect& aRect, CGFloat aBackingScale)
|
2015-06-12 15:49:57 +03:00
|
|
|
{
|
|
|
|
return CGRectMake((CGFloat)aRect.x / aBackingScale,
|
|
|
|
(CGFloat)aRect.y / aBackingScale,
|
|
|
|
(CGFloat)aRect.width / aBackingScale,
|
|
|
|
(CGFloat)aRect.height / aBackingScale);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used to retain a Cocoa object for the remainder of a method's execution.
|
|
|
|
class nsAutoRetainUIKitObject {
|
|
|
|
public:
|
|
|
|
nsAutoRetainUIKitObject(id anObject)
|
|
|
|
{
|
|
|
|
mObject = [anObject retain];
|
|
|
|
}
|
|
|
|
~nsAutoRetainUIKitObject()
|
|
|
|
{
|
|
|
|
[mObject release];
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
id mObject; // [STRONG]
|
|
|
|
};
|
|
|
|
|
|
|
|
@interface ChildView : UIView
|
|
|
|
{
|
|
|
|
@public
|
|
|
|
nsWindow* mGeckoChild; // weak ref
|
|
|
|
BOOL mWaitingForPaint;
|
|
|
|
CFMutableDictionaryRef mTouches;
|
|
|
|
int mNextTouchID;
|
|
|
|
}
|
|
|
|
// sets up our view, attaching it to its owning gecko view
|
|
|
|
- (id)initWithFrame:(CGRect)inFrame geckoChild:(nsWindow*)inChild;
|
|
|
|
// Our Gecko child was Destroy()ed
|
|
|
|
- (void)widgetDestroyed;
|
|
|
|
// Tear down this ChildView
|
|
|
|
- (void)delayedTearDown;
|
2015-09-22 16:33:51 +03:00
|
|
|
- (void)sendMouseEvent:(EventMessage) aType point:(LayoutDeviceIntPoint)aPoint widget:(nsWindow*)aWindow;
|
2015-06-12 15:49:57 +03:00
|
|
|
- (void)handleTap:(UITapGestureRecognizer *)sender;
|
|
|
|
- (BOOL)isUsingMainThreadOpenGL;
|
|
|
|
- (void)drawUsingOpenGL;
|
|
|
|
- (void)drawUsingOpenGLCallback;
|
2015-09-22 16:33:51 +03:00
|
|
|
- (void)sendTouchEvent:(EventMessage) aType touches:(NSSet*)aTouches widget:(nsWindow*)aWindow;
|
2015-06-12 15:49:57 +03:00
|
|
|
// Event handling (UIResponder)
|
|
|
|
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
|
|
|
|
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
|
|
|
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
|
|
|
|
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation ChildView
|
|
|
|
+ (Class)layerClass {
|
|
|
|
return [CAEAGLLayer class];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)initWithFrame:(CGRect)inFrame geckoChild:(nsWindow*)inChild
|
|
|
|
{
|
|
|
|
self.multipleTouchEnabled = YES;
|
|
|
|
if ((self = [super initWithFrame:inFrame])) {
|
|
|
|
mGeckoChild = inChild;
|
|
|
|
}
|
|
|
|
ALOG("[ChildView[%p] initWithFrame:] (mGeckoChild = %p)", (void*)self, (void*)mGeckoChild);
|
|
|
|
self.opaque = YES;
|
|
|
|
self.alpha = 1.0;
|
|
|
|
|
|
|
|
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc]
|
|
|
|
initWithTarget:self action:@selector(handleTap:)];
|
|
|
|
tapRecognizer.numberOfTapsRequired = 1;
|
|
|
|
[self addGestureRecognizer:tapRecognizer];
|
|
|
|
|
|
|
|
mTouches = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, nullptr, nullptr);
|
|
|
|
mNextTouchID = 0;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)widgetDestroyed
|
|
|
|
{
|
|
|
|
mGeckoChild = nullptr;
|
|
|
|
CFRelease(mTouches);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)delayedTearDown
|
|
|
|
{
|
|
|
|
[self removeFromSuperview];
|
|
|
|
[self release];
|
|
|
|
}
|
|
|
|
|
2015-09-22 16:33:51 +03:00
|
|
|
- (void)sendMouseEvent:(EventMessage) aType point:(LayoutDeviceIntPoint)aPoint widget:(nsWindow*)aWindow
|
2015-06-12 15:49:57 +03:00
|
|
|
{
|
|
|
|
WidgetMouseEvent event(true, aType, aWindow,
|
|
|
|
WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
|
|
|
|
|
2016-04-18 17:09:02 +03:00
|
|
|
event.mRefPoint = aPoint;
|
2016-05-10 17:29:14 +03:00
|
|
|
event.mClickCount = 1;
|
2015-06-12 15:49:57 +03:00
|
|
|
event.button = WidgetMouseEvent::eLeftButton;
|
2016-03-28 07:29:42 +03:00
|
|
|
event.mTime = PR_IntervalNow();
|
2015-06-12 15:49:57 +03:00
|
|
|
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
|
|
|
|
|
|
|
|
nsEventStatus status;
|
|
|
|
aWindow->DispatchEvent(&event, status);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)handleTap:(UITapGestureRecognizer *)sender
|
|
|
|
{
|
|
|
|
if (sender.state == UIGestureRecognizerStateEnded) {
|
|
|
|
ALOG("[ChildView[%p] handleTap]", self);
|
|
|
|
LayoutDeviceIntPoint lp = UIKitPointsToDevPixels([sender locationInView:self], [self contentScaleFactor]);
|
2015-08-29 02:58:29 +03:00
|
|
|
[self sendMouseEvent:eMouseMove point:lp widget:mGeckoChild];
|
2015-08-29 02:58:30 +03:00
|
|
|
[self sendMouseEvent:eMouseDown point:lp widget:mGeckoChild];
|
2015-08-29 02:58:30 +03:00
|
|
|
[self sendMouseEvent:eMouseUp point:lp widget:mGeckoChild];
|
2015-06-12 15:49:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-22 16:33:51 +03:00
|
|
|
- (void)sendTouchEvent:(EventMessage) aType touches:(NSSet*)aTouches widget:(nsWindow*)aWindow
|
2015-06-12 15:49:57 +03:00
|
|
|
{
|
|
|
|
WidgetTouchEvent event(true, aType, aWindow);
|
|
|
|
//XXX: I think nativeEvent.timestamp * 1000 is probably usable here but
|
|
|
|
// I don't care that much right now.
|
2016-03-28 07:29:42 +03:00
|
|
|
event.mTime = PR_IntervalNow();
|
2016-03-30 12:44:28 +03:00
|
|
|
event.mTouches.SetCapacity(aTouches.count);
|
2015-06-12 15:49:57 +03:00
|
|
|
for (UITouch* touch in aTouches) {
|
|
|
|
LayoutDeviceIntPoint loc = UIKitPointsToDevPixels([touch locationInView:self], [self contentScaleFactor]);
|
2015-11-10 08:37:31 +03:00
|
|
|
LayoutDeviceIntPoint radius = UIKitPointsToDevPixels([touch majorRadius], [touch majorRadius]);
|
2015-06-12 15:49:57 +03:00
|
|
|
void* value;
|
|
|
|
if (!CFDictionaryGetValueIfPresent(mTouches, touch, (const void**)&value)) {
|
|
|
|
// This shouldn't happen.
|
|
|
|
NS_ASSERTION(false, "Got a touch that we didn't know about");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int id = reinterpret_cast<int>(value);
|
2015-11-10 08:37:31 +03:00
|
|
|
RefPtr<Touch> t = new Touch(id, loc, radius, 0.0f, 1.0f);
|
2016-04-18 17:09:02 +03:00
|
|
|
event.mRefPoint = loc;
|
2016-03-30 12:44:28 +03:00
|
|
|
event.mTouches.AppendElement(t);
|
2015-06-12 15:49:57 +03:00
|
|
|
}
|
2016-03-11 02:25:48 +03:00
|
|
|
aWindow->DispatchInputEvent(&event);
|
2015-06-12 15:49:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
|
|
|
{
|
|
|
|
ALOG("[ChildView[%p] touchesBegan", self);
|
|
|
|
if (!mGeckoChild)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (UITouch* touch : touches) {
|
|
|
|
CFDictionaryAddValue(mTouches, touch, (void*)mNextTouchID);
|
|
|
|
mNextTouchID++;
|
|
|
|
}
|
2015-09-14 18:14:34 +03:00
|
|
|
[self sendTouchEvent:eTouchStart
|
|
|
|
touches:[event allTouches]
|
|
|
|
widget:mGeckoChild];
|
2015-06-12 15:49:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
|
|
|
{
|
|
|
|
ALOG("[ChildView[%p] touchesCancelled", self);
|
2015-09-14 18:14:35 +03:00
|
|
|
[self sendTouchEvent:eTouchCancel touches:touches widget:mGeckoChild];
|
2015-06-12 15:49:57 +03:00
|
|
|
for (UITouch* touch : touches) {
|
|
|
|
CFDictionaryRemoveValue(mTouches, touch);
|
|
|
|
}
|
|
|
|
if (CFDictionaryGetCount(mTouches) == 0) {
|
|
|
|
mNextTouchID = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
|
|
|
{
|
|
|
|
ALOG("[ChildView[%p] touchesEnded", self);
|
|
|
|
if (!mGeckoChild)
|
|
|
|
return;
|
|
|
|
|
2015-09-14 18:14:35 +03:00
|
|
|
[self sendTouchEvent:eTouchEnd touches:touches widget:mGeckoChild];
|
2015-06-12 15:49:57 +03:00
|
|
|
for (UITouch* touch : touches) {
|
|
|
|
CFDictionaryRemoveValue(mTouches, touch);
|
|
|
|
}
|
|
|
|
if (CFDictionaryGetCount(mTouches) == 0) {
|
|
|
|
mNextTouchID = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
|
|
|
{
|
|
|
|
ALOG("[ChildView[%p] touchesMoved", self);
|
|
|
|
if (!mGeckoChild)
|
|
|
|
return;
|
|
|
|
|
2015-09-14 18:14:35 +03:00
|
|
|
[self sendTouchEvent:eTouchMove
|
|
|
|
touches:[event allTouches]
|
|
|
|
widget:mGeckoChild];
|
2015-06-12 15:49:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setNeedsDisplayInRect:(CGRect)aRect
|
|
|
|
{
|
|
|
|
if ([self isUsingMainThreadOpenGL]) {
|
|
|
|
// Draw without calling drawRect. This prevent us from
|
|
|
|
// needing to access the normal window buffer surface unnecessarily, so we
|
|
|
|
// waste less time synchronizing the two surfaces.
|
|
|
|
if (!mWaitingForPaint) {
|
|
|
|
mWaitingForPaint = YES;
|
|
|
|
// Use NSRunLoopCommonModes instead of the default NSDefaultRunLoopMode
|
|
|
|
// so that the timer also fires while a native menu is open.
|
|
|
|
[self performSelector:@selector(drawUsingOpenGLCallback)
|
|
|
|
withObject:nil
|
|
|
|
afterDelay:0
|
|
|
|
inModes:[NSArray arrayWithObject:NSRunLoopCommonModes]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isUsingMainThreadOpenGL
|
|
|
|
{
|
|
|
|
if (!mGeckoChild || ![self window])
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
return mGeckoChild->GetLayerManager(nullptr)->GetBackendType() == mozilla::layers::LayersBackend::LAYERS_OPENGL;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)drawUsingOpenGL
|
|
|
|
{
|
|
|
|
ALOG("drawUsingOpenGL");
|
|
|
|
PROFILER_LABEL("ChildView", "drawUsingOpenGL",
|
|
|
|
js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
|
|
|
|
if (!mGeckoChild->IsVisible())
|
|
|
|
return;
|
|
|
|
|
|
|
|
mWaitingForPaint = NO;
|
|
|
|
|
2015-11-26 07:32:47 +03:00
|
|
|
LayoutDeviceIntRect geckoBounds;
|
|
|
|
mGeckoChild->GetBounds(geckoBounds);
|
|
|
|
LayoutDeviceIntRegion region(geckoBounds);
|
2015-06-12 15:49:57 +03:00
|
|
|
|
2015-12-03 08:45:41 +03:00
|
|
|
mGeckoChild->PaintWindow(region);
|
2015-06-12 15:49:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Called asynchronously after setNeedsDisplay in order to avoid entering the
|
|
|
|
// normal drawing machinery.
|
|
|
|
- (void)drawUsingOpenGLCallback
|
|
|
|
{
|
|
|
|
if (mWaitingForPaint) {
|
|
|
|
[self drawUsingOpenGL];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The display system has told us that a portion of our view is dirty. Tell
|
|
|
|
// gecko to paint it
|
|
|
|
- (void)drawRect:(CGRect)aRect
|
|
|
|
{
|
|
|
|
CGContextRef cgContext = UIGraphicsGetCurrentContext();
|
|
|
|
[self drawRect:aRect inContext:cgContext];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)drawRect:(CGRect)aRect inContext:(CGContextRef)aContext
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_UPDATE
|
2015-11-10 08:37:32 +03:00
|
|
|
LayoutDeviceIntRect geckoBounds;
|
2015-06-12 15:49:57 +03:00
|
|
|
mGeckoChild->GetBounds(geckoBounds);
|
|
|
|
|
|
|
|
fprintf (stderr, "---- Update[%p][%p] [%f %f %f %f] cgc: %p\n gecko bounds: [%d %d %d %d]\n",
|
|
|
|
self, mGeckoChild,
|
|
|
|
aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height, aContext,
|
|
|
|
geckoBounds.x, geckoBounds.y, geckoBounds.width, geckoBounds.height);
|
|
|
|
|
|
|
|
CGAffineTransform xform = CGContextGetCTM(aContext);
|
|
|
|
fprintf (stderr, " xform in: [%f %f %f %f %f %f]\n", xform.a, xform.b, xform.c, xform.d, xform.tx, xform.ty);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
// For Gecko-initiated repaints in OpenGL mode, drawUsingOpenGL is
|
|
|
|
// directly called from a delayed perform callback - without going through
|
|
|
|
// drawRect.
|
|
|
|
// Paints that come through here are triggered by something that Cocoa
|
|
|
|
// controls, for example by window resizing or window focus changes.
|
|
|
|
|
|
|
|
// Do GL composition and return.
|
|
|
|
[self drawUsingOpenGL];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
PROFILER_LABEL("ChildView", "drawRect",
|
|
|
|
js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
|
|
|
|
// The CGContext that drawRect supplies us with comes with a transform that
|
|
|
|
// scales one user space unit to one Cocoa point, which can consist of
|
|
|
|
// multiple dev pixels. But Gecko expects its supplied context to be scaled
|
|
|
|
// to device pixels, so we need to reverse the scaling.
|
|
|
|
double scale = mGeckoChild->BackingScaleFactor();
|
|
|
|
CGContextSaveGState(aContext);
|
|
|
|
CGContextScaleCTM(aContext, 1.0 / scale, 1.0 / scale);
|
|
|
|
|
|
|
|
CGSize viewSize = [self bounds].size;
|
2016-05-30 18:26:30 +03:00
|
|
|
gfx::IntSize backingSize(viewSize.width * scale, viewSize.height * scale);
|
2015-06-12 15:49:57 +03:00
|
|
|
|
|
|
|
CGContextSaveGState(aContext);
|
|
|
|
|
2015-12-03 08:45:41 +03:00
|
|
|
LayoutDeviceIntRegion region =
|
|
|
|
LayoutDeviceIntRect(NSToIntRound(aRect.origin.x * scale),
|
|
|
|
NSToIntRound(aRect.origin.y * scale),
|
|
|
|
NSToIntRound(aRect.size.width * scale),
|
|
|
|
NSToIntRound(aRect.size.height * scale));
|
2015-06-12 15:49:57 +03:00
|
|
|
|
|
|
|
// Create Cairo objects.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxQuartzSurface> targetSurface;
|
2015-06-12 15:49:57 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxContext> targetContext;
|
2015-06-12 15:49:57 +03:00
|
|
|
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BackendType::COREGRAPHICS)) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfx::DrawTarget> dt =
|
2016-05-30 18:26:30 +03:00
|
|
|
gfx::Factory::CreateDrawTargetForCairoCGContext(aContext, backingSize);
|
2016-04-12 22:18:11 +03:00
|
|
|
if (!dt || !dt->IsValid()) {
|
|
|
|
gfxDevCrash(mozilla::gfx::LogReason::InvalidContext) << "Window context problem 1 " << backingSize;
|
|
|
|
return;
|
|
|
|
}
|
2015-06-12 15:49:57 +03:00
|
|
|
dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
|
2016-06-07 02:39:56 +03:00
|
|
|
targetContext = gfxContext::CreateOrNull(dt);
|
2015-06-12 15:49:57 +03:00
|
|
|
} else if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BackendType::CAIRO)) {
|
|
|
|
// This is dead code unless you mess with prefs, but keep it around for
|
|
|
|
// debugging.
|
|
|
|
targetSurface = new gfxQuartzSurface(aContext, backingSize);
|
|
|
|
targetSurface->SetAllowUseAsSource(false);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfx::DrawTarget> dt =
|
2015-06-12 15:49:57 +03:00
|
|
|
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(targetSurface,
|
2016-05-30 18:26:30 +03:00
|
|
|
backingSize);
|
2016-04-12 22:18:11 +03:00
|
|
|
if (!dt || !dt->IsValid()) {
|
|
|
|
gfxDevCrash(mozilla::gfx::LogReason::InvalidContext) << "Window context problem 2 " << backingSize;
|
|
|
|
return;
|
|
|
|
}
|
2015-06-12 15:49:57 +03:00
|
|
|
dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
|
2016-06-07 02:39:56 +03:00
|
|
|
targetContext = gfxContext::CreateOrNull(dt);
|
2015-06-12 15:49:57 +03:00
|
|
|
} else {
|
2016-04-12 22:18:11 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("COREGRAPHICS is the only supported backend");
|
2015-06-12 15:49:57 +03:00
|
|
|
}
|
2016-04-12 22:18:11 +03:00
|
|
|
MOZ_ASSERT(targetContext); // already checked for valid draw targets above
|
2015-06-12 15:49:57 +03:00
|
|
|
|
|
|
|
// Set up the clip region.
|
|
|
|
targetContext->NewPath();
|
2016-01-19 04:20:59 +03:00
|
|
|
for (auto iter = region.RectIter(); !iter.Done(); iter.Next()) {
|
|
|
|
const LayoutDeviceIntRect& r = iter.Get();
|
|
|
|
targetContext->Rectangle(gfxRect(r.x, r.y, r.width, r.height));
|
2015-06-12 15:49:57 +03:00
|
|
|
}
|
|
|
|
targetContext->Clip();
|
|
|
|
|
|
|
|
//nsAutoRetainCocoaObject kungFuDeathGrip(self);
|
|
|
|
bool painted = false;
|
|
|
|
if (mGeckoChild->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_BASIC) {
|
|
|
|
nsBaseWidget::AutoLayerManagerSetup
|
|
|
|
setupLayerManager(mGeckoChild, targetContext, BufferMode::BUFFER_NONE);
|
|
|
|
painted = mGeckoChild->PaintWindow(region);
|
|
|
|
} else if (mGeckoChild->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
|
|
|
// We only need this so that we actually get DidPaintWindow fired
|
|
|
|
painted = mGeckoChild->PaintWindow(region);
|
|
|
|
}
|
|
|
|
|
|
|
|
targetContext = nullptr;
|
|
|
|
targetSurface = nullptr;
|
|
|
|
|
|
|
|
CGContextRestoreGState(aContext);
|
|
|
|
|
|
|
|
// Undo the scale transform so that from now on the context is in
|
|
|
|
// CocoaPoints again.
|
|
|
|
CGContextRestoreGState(aContext);
|
|
|
|
if (!painted && [self isOpaque]) {
|
|
|
|
// Gecko refused to draw, but we've claimed to be opaque, so we have to
|
|
|
|
// draw something--fill with white.
|
|
|
|
CGContextSetRGBFillColor(aContext, 1, 1, 1, 1);
|
|
|
|
CGContextFillRect(aContext, aRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_UPDATE
|
|
|
|
fprintf (stderr, "---- update done ----\n");
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
CGContextSetRGBStrokeColor (aContext,
|
|
|
|
((((unsigned long)self) & 0xff)) / 255.0,
|
|
|
|
((((unsigned long)self) & 0xff00) >> 8) / 255.0,
|
|
|
|
((((unsigned long)self) & 0xff0000) >> 16) / 255.0,
|
|
|
|
0.5);
|
|
|
|
#endif
|
|
|
|
CGContextSetRGBStrokeColor(aContext, 1, 0, 0, 0.8);
|
|
|
|
CGContextSetLineWidth(aContext, 4.0);
|
|
|
|
CGContextStrokeRect(aContext, aRect);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, Inherited)
|
|
|
|
|
|
|
|
nsWindow::nsWindow()
|
|
|
|
: mNativeView(nullptr),
|
|
|
|
mVisible(false),
|
|
|
|
mParent(nullptr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsWindow::~nsWindow()
|
|
|
|
{
|
|
|
|
[mNativeView widgetDestroyed]; // Safe if mNativeView is nil.
|
|
|
|
TearDownView(); // Safe if called twice.
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsWindow::TearDownView()
|
|
|
|
{
|
|
|
|
if (!mNativeView)
|
|
|
|
return;
|
|
|
|
|
|
|
|
[mNativeView performSelectorOnMainThread:@selector(delayedTearDown) withObject:nil waitUntilDone:false];
|
|
|
|
mNativeView = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsWindow::IsTopLevel()
|
|
|
|
{
|
|
|
|
return mWindowType == eWindowType_toplevel ||
|
|
|
|
mWindowType == eWindowType_dialog ||
|
|
|
|
mWindowType == eWindowType_invisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// nsIWidget
|
|
|
|
//
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-11-16 11:35:18 +03:00
|
|
|
nsWindow::Create(nsIWidget* aParent,
|
2015-06-12 15:49:57 +03:00
|
|
|
nsNativeWidget aNativeParent,
|
2015-11-16 11:35:18 +03:00
|
|
|
const LayoutDeviceIntRect& aRect,
|
|
|
|
nsWidgetInitData* aInitData)
|
2015-06-12 15:49:57 +03:00
|
|
|
{
|
|
|
|
ALOG("nsWindow[%p]::Create %p/%p [%d %d %d %d]", (void*)this, (void*)aParent, (void*)aNativeParent, aRect.x, aRect.y, aRect.width, aRect.height);
|
|
|
|
nsWindow* parent = (nsWindow*) aParent;
|
|
|
|
ChildView* nativeParent = (ChildView*)aNativeParent;
|
|
|
|
|
|
|
|
if (parent == nullptr && nativeParent)
|
|
|
|
parent = nativeParent->mGeckoChild;
|
|
|
|
if (parent && nativeParent == nullptr)
|
|
|
|
nativeParent = parent->mNativeView;
|
|
|
|
|
|
|
|
// for toplevel windows, bounds are fixed to full screen size
|
|
|
|
if (parent == nullptr) {
|
|
|
|
if (nsAppShell::gWindow == nil) {
|
|
|
|
mBounds = UIKitScreenManager::GetBounds();
|
2015-11-16 11:35:18 +03:00
|
|
|
} else {
|
2015-06-12 15:49:57 +03:00
|
|
|
CGRect cgRect = [nsAppShell::gWindow bounds];
|
|
|
|
mBounds.x = cgRect.origin.x;
|
|
|
|
mBounds.y = cgRect.origin.y;
|
|
|
|
mBounds.width = cgRect.size.width;
|
|
|
|
mBounds.height = cgRect.size.height;
|
|
|
|
}
|
2015-11-16 11:35:18 +03:00
|
|
|
} else {
|
2015-11-23 07:32:29 +03:00
|
|
|
mBounds = aRect;
|
2015-06-12 15:49:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ALOG("nsWindow[%p]::Create bounds: %d %d %d %d", (void*)this,
|
|
|
|
mBounds.x, mBounds.y, mBounds.width, mBounds.height);
|
|
|
|
|
|
|
|
// Set defaults which can be overriden from aInitData in BaseCreate
|
|
|
|
mWindowType = eWindowType_toplevel;
|
|
|
|
mBorderStyle = eBorderStyle_default;
|
|
|
|
|
2016-01-13 10:32:55 +03:00
|
|
|
Inherited::BaseCreate(aParent, aInitData);
|
2015-06-12 15:49:57 +03:00
|
|
|
|
|
|
|
NS_ASSERTION(IsTopLevel() || parent, "non top level window doesn't have a parent!");
|
|
|
|
|
|
|
|
mNativeView = [[ChildView alloc] initWithFrame:DevPixelsToUIKitPoints(mBounds, BackingScaleFactor()) geckoChild:this];
|
|
|
|
mNativeView.hidden = YES;
|
|
|
|
|
|
|
|
if (parent) {
|
|
|
|
parent->mChildren.AppendElement(this);
|
|
|
|
mParent = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nativeParent) {
|
|
|
|
[nativeParent addSubview:mNativeView];
|
|
|
|
} else if (nsAppShell::gWindow) {
|
|
|
|
[nsAppShell::gWindow.rootViewController.view addSubview:mNativeView];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
[nsAppShell::gTopLevelViews addObject:mNativeView];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::Destroy(void)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < mChildren.Length(); ++i) {
|
|
|
|
// why do we still have children?
|
|
|
|
mChildren[i]->SetParent(nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mParent)
|
|
|
|
mParent->mChildren.RemoveElement(this);
|
|
|
|
|
|
|
|
[mNativeView widgetDestroyed];
|
|
|
|
|
|
|
|
nsBaseWidget::Destroy();
|
|
|
|
|
|
|
|
//ReportDestroyEvent();
|
|
|
|
|
|
|
|
TearDownView();
|
|
|
|
|
|
|
|
nsBaseWidget::OnDestroy();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::ConfigureChildren(const nsTArray<nsIWidget::Configuration>& config)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < config.Length(); ++i) {
|
|
|
|
nsWindow *childWin = (nsWindow*) config[i].mChild.get();
|
|
|
|
childWin->Resize(config[i].mBounds.x,
|
|
|
|
config[i].mBounds.y,
|
|
|
|
config[i].mBounds.width,
|
|
|
|
config[i].mBounds.height,
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::ReparentNativeWidget(nsIWidget* aNewParent)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::Show(bool aState)
|
|
|
|
{
|
|
|
|
if (aState != mVisible) {
|
|
|
|
mNativeView.hidden = aState ? NO : YES;
|
|
|
|
if (aState) {
|
|
|
|
UIView* parentView = mParent ? mParent->mNativeView : nsAppShell::gWindow.rootViewController.view;
|
|
|
|
[parentView bringSubviewToFront:mNativeView];
|
|
|
|
[mNativeView setNeedsDisplay];
|
|
|
|
}
|
|
|
|
mVisible = aState;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::SetModal(bool aModal)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::ConstrainPosition(bool aAllowSlop,
|
|
|
|
int32_t *aX,
|
|
|
|
int32_t *aY)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::Move(double aX, double aY)
|
|
|
|
{
|
|
|
|
if (!mNativeView || (mBounds.x == aX && mBounds.y == aY))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
//XXX: handle this
|
|
|
|
// The point we have is in Gecko coordinates (origin top-left). Convert
|
|
|
|
// it to Cocoa ones (origin bottom-left).
|
|
|
|
mBounds.x = aX;
|
|
|
|
mBounds.y = aY;
|
|
|
|
|
|
|
|
mNativeView.frame = DevPixelsToUIKitPoints(mBounds, BackingScaleFactor());
|
|
|
|
|
|
|
|
if (mVisible)
|
|
|
|
[mNativeView setNeedsDisplay];
|
|
|
|
|
|
|
|
ReportMoveEvent();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::Resize(double aX, double aY,
|
|
|
|
double aWidth, double aHeight,
|
|
|
|
bool aRepaint)
|
|
|
|
{
|
|
|
|
BOOL isMoving = (mBounds.x != aX || mBounds.y != aY);
|
|
|
|
BOOL isResizing = (mBounds.width != aWidth || mBounds.height != aHeight);
|
|
|
|
if (!mNativeView || (!isMoving && !isResizing))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
if (isMoving) {
|
|
|
|
mBounds.x = aX;
|
|
|
|
mBounds.y = aY;
|
|
|
|
}
|
|
|
|
if (isResizing) {
|
|
|
|
mBounds.width = aWidth;
|
|
|
|
mBounds.height = aHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
[mNativeView setFrame:DevPixelsToUIKitPoints(mBounds, BackingScaleFactor())];
|
|
|
|
|
|
|
|
if (mVisible && aRepaint)
|
|
|
|
[mNativeView setNeedsDisplay];
|
|
|
|
|
|
|
|
if (isMoving)
|
|
|
|
ReportMoveEvent();
|
|
|
|
|
|
|
|
if (isResizing)
|
|
|
|
ReportSizeEvent();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWindow::Resize(double aWidth, double aHeight, bool aRepaint)
|
|
|
|
{
|
|
|
|
if (!mNativeView || (mBounds.width == aWidth && mBounds.height == aHeight))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
mBounds.width = aWidth;
|
|
|
|
mBounds.height = aHeight;
|
|
|
|
|
|
|
|
[mNativeView setFrame:DevPixelsToUIKitPoints(mBounds, BackingScaleFactor())];
|
|
|
|
|
|
|
|
if (mVisible && aRepaint)
|
|
|
|
[mNativeView setNeedsDisplay];
|
|
|
|
|
|
|
|
ReportSizeEvent();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
|
|
|
nsIWidget *aWidget,
|
|
|
|
bool aActivate)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-08-29 04:12:41 +03:00
|
|
|
nsWindow::SetSizeMode(nsSizeMode aMode)
|
2015-06-12 15:49:57 +03:00
|
|
|
{
|
|
|
|
if (aMode == static_cast<int32_t>(mSizeMode)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
mSizeMode = static_cast<nsSizeMode>(aMode);
|
|
|
|
if (aMode == nsSizeMode_Maximized || aMode == nsSizeMode_Fullscreen) {
|
|
|
|
// Resize to fill screen
|
|
|
|
rv = nsBaseWidget::MakeFullScreen(true);
|
|
|
|
}
|
|
|
|
ReportSizeModeEvent(aMode);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-11-17 08:18:31 +03:00
|
|
|
nsWindow::Invalidate(const LayoutDeviceIntRect& aRect)
|
2015-06-12 15:49:57 +03:00
|
|
|
{
|
|
|
|
if (!mNativeView || !mVisible)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
MOZ_RELEASE_ASSERT(GetLayerManager()->GetBackendType() != LayersBackend::LAYERS_CLIENT,
|
|
|
|
"Shouldn't need to invalidate with accelerated OMTC layers!");
|
|
|
|
|
|
|
|
|
|
|
|
[mNativeView setNeedsLayout];
|
|
|
|
[mNativeView setNeedsDisplayInRect:DevPixelsToUIKitPoints(mBounds, BackingScaleFactor())];
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::SetFocus(bool aRaise)
|
|
|
|
{
|
|
|
|
[[mNativeView window] makeKeyWindow];
|
|
|
|
[mNativeView becomeFirstResponder];
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsWindow::WillPaintWindow()
|
|
|
|
{
|
|
|
|
if (mWidgetListener) {
|
|
|
|
mWidgetListener->WillPaintWindow(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-03 08:45:41 +03:00
|
|
|
bool nsWindow::PaintWindow(LayoutDeviceIntRegion aRegion)
|
2015-06-12 15:49:57 +03:00
|
|
|
{
|
|
|
|
if (!mWidgetListener)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool returnValue = false;
|
|
|
|
returnValue = mWidgetListener->PaintWindow(this, aRegion);
|
|
|
|
|
|
|
|
if (mWidgetListener) {
|
|
|
|
mWidgetListener->DidPaintWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsWindow::ReportMoveEvent()
|
|
|
|
{
|
|
|
|
NotifyWindowMoved(mBounds.x, mBounds.y);
|
|
|
|
}
|
|
|
|
|
2015-08-29 04:12:41 +03:00
|
|
|
void nsWindow::ReportSizeModeEvent(nsSizeMode aMode)
|
2015-06-12 15:49:57 +03:00
|
|
|
{
|
|
|
|
if (mWidgetListener) {
|
|
|
|
// This is terrible.
|
|
|
|
nsSizeMode theMode;
|
|
|
|
switch (aMode) {
|
|
|
|
case nsSizeMode_Maximized:
|
|
|
|
theMode = nsSizeMode_Maximized;
|
|
|
|
break;
|
|
|
|
case nsSizeMode_Fullscreen:
|
|
|
|
theMode = nsSizeMode_Fullscreen;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mWidgetListener->SizeModeChanged(theMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsWindow::ReportSizeEvent()
|
|
|
|
{
|
|
|
|
if (mWidgetListener) {
|
2015-11-10 08:37:32 +03:00
|
|
|
LayoutDeviceIntRect innerBounds;
|
2015-06-12 15:49:57 +03:00
|
|
|
GetClientBounds(innerBounds);
|
|
|
|
mWidgetListener->WindowResized(this, innerBounds.width, innerBounds.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-11-13 03:04:52 +03:00
|
|
|
nsWindow::GetScreenBounds(LayoutDeviceIntRect& aRect)
|
2015-06-12 15:49:57 +03:00
|
|
|
{
|
|
|
|
LayoutDeviceIntPoint p = WidgetToScreenOffset();
|
|
|
|
|
|
|
|
aRect.x = p.x;
|
|
|
|
aRect.y = p.y;
|
|
|
|
aRect.width = mBounds.width;
|
|
|
|
aRect.height = mBounds.height;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
LayoutDeviceIntPoint nsWindow::WidgetToScreenOffset()
|
|
|
|
{
|
|
|
|
LayoutDeviceIntPoint offset(0, 0);
|
|
|
|
if (mParent) {
|
|
|
|
offset = mParent->WidgetToScreenOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
CGPoint temp = [mNativeView convertPoint:temp toView:nil];
|
|
|
|
|
|
|
|
if (!mParent && nsAppShell::gWindow) {
|
|
|
|
// convert to screen coords
|
|
|
|
temp = [nsAppShell::gWindow convertPoint:temp toWindow:nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
offset.x += temp.x;
|
|
|
|
offset.y += temp.y;
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus& aStatus)
|
|
|
|
{
|
|
|
|
aStatus = nsEventStatus_eIgnore;
|
2016-04-14 11:03:14 +03:00
|
|
|
nsCOMPtr<nsIWidget> kungFuDeathGrip(aEvent->mWidget);
|
2015-06-12 15:49:57 +03:00
|
|
|
|
|
|
|
if (mWidgetListener)
|
|
|
|
aStatus = mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(void)
|
|
|
|
nsWindow::SetInputContext(const InputContext& aContext,
|
|
|
|
const InputContextAction& aAction)
|
|
|
|
{
|
|
|
|
//TODO: actually show VKB
|
|
|
|
mInputContext = aContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(mozilla::widget::InputContext)
|
|
|
|
nsWindow::GetInputContext()
|
|
|
|
{
|
|
|
|
return mInputContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWindow::SetBackgroundColor(const nscolor &aColor)
|
|
|
|
{
|
|
|
|
mNativeView.backgroundColor = [UIColor colorWithRed:NS_GET_R(aColor)
|
|
|
|
green:NS_GET_G(aColor)
|
|
|
|
blue:NS_GET_B(aColor)
|
|
|
|
alpha:NS_GET_A(aColor)];
|
|
|
|
}
|
|
|
|
|
|
|
|
void* nsWindow::GetNativeData(uint32_t aDataType)
|
|
|
|
{
|
|
|
|
void* retVal = nullptr;
|
|
|
|
|
|
|
|
switch (aDataType)
|
|
|
|
{
|
|
|
|
case NS_NATIVE_WIDGET:
|
|
|
|
case NS_NATIVE_DISPLAY:
|
|
|
|
retVal = (void*)mNativeView;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_NATIVE_WINDOW:
|
|
|
|
retVal = [mNativeView window];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_NATIVE_GRAPHIC:
|
|
|
|
NS_ERROR("Requesting NS_NATIVE_GRAPHIC on a UIKit child view!");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_NATIVE_OFFSETX:
|
|
|
|
retVal = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_NATIVE_OFFSETY:
|
|
|
|
retVal = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_NATIVE_PLUGIN_PORT:
|
|
|
|
// not implemented
|
|
|
|
break;
|
2015-12-11 09:15:57 +03:00
|
|
|
|
2015-12-11 09:15:57 +03:00
|
|
|
case NS_RAW_NATIVE_IME_CONTEXT:
|
2016-03-16 07:47:47 +03:00
|
|
|
retVal = GetPseudoIMEContext();
|
|
|
|
if (retVal) {
|
|
|
|
break;
|
|
|
|
}
|
2015-12-11 09:15:57 +03:00
|
|
|
retVal = NS_ONLY_ONE_NATIVE_IME_CONTEXT;
|
|
|
|
break;
|
2015-06-12 15:49:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
CGFloat
|
|
|
|
nsWindow::BackingScaleFactor()
|
|
|
|
{
|
|
|
|
if (mNativeView) {
|
|
|
|
return [mNativeView contentScaleFactor];
|
|
|
|
}
|
|
|
|
return [UIScreen mainScreen].scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
nsWindow::RoundsWidgetCoordinatesTo()
|
|
|
|
{
|
|
|
|
if (BackingScaleFactor() == 2.0) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|