mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 890156 - patch 0.3 - Create a version of nsIWidget::Create that takes Desktop pixels, because that's what we actually need to pass in some cases. r=mstange
This commit is contained in:
parent
035ddfb30d
commit
86bbb7e2c4
@ -59,6 +59,10 @@ public:
|
||||
nsNativeWidget aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
nsWidgetInitData* aInitData = nullptr) override { return NS_OK; }
|
||||
NS_IMETHOD Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const DesktopIntRect& aRect,
|
||||
nsWidgetInitData* aInitData = nullptr) override { return NS_OK; }
|
||||
NS_IMETHOD Show(bool aState) override { return NS_OK; }
|
||||
virtual bool IsVisible() const override { return true; }
|
||||
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIWidget
|
||||
using PuppetWidget::Create; // for Create signature not overridden here
|
||||
NS_IMETHOD Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
nsWidgetInitData* aInitData = nullptr) override;
|
||||
|
@ -53,6 +53,7 @@ protected:
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
using nsBaseWidget::Create; // for Create signature not overridden here
|
||||
NS_IMETHOD Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
// nsIWidget
|
||||
//
|
||||
|
||||
using nsBaseWidget::Create; // for Create signature not overridden here
|
||||
NS_IMETHOD Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
|
@ -255,6 +255,11 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSPIWIDGETCOCOA
|
||||
|
||||
NS_IMETHOD Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const DesktopIntRect& aRect,
|
||||
nsWidgetInitData* aInitData = nullptr) override;
|
||||
|
||||
NS_IMETHOD Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
|
@ -183,14 +183,14 @@ nsCocoaWindow::~nsCocoaWindow()
|
||||
// Find the screen that overlaps aRect the most,
|
||||
// if none are found default to the mainScreen.
|
||||
static NSScreen*
|
||||
FindTargetScreenForRect(const LayoutDeviceIntRect& aRect)
|
||||
FindTargetScreenForRect(const DesktopIntRect& aRect)
|
||||
{
|
||||
NSScreen *targetScreen = [NSScreen mainScreen];
|
||||
NSEnumerator *screenEnum = [[NSScreen screens] objectEnumerator];
|
||||
int largestIntersectArea = 0;
|
||||
while (NSScreen *screen = [screenEnum nextObject]) {
|
||||
LayoutDeviceIntRect screenRect =
|
||||
LayoutDeviceIntRect::FromUnknownRect(
|
||||
DesktopIntRect screenRect =
|
||||
DesktopIntRect::FromUnknownRect(
|
||||
nsCocoaUtils::CocoaRectToGeckoRect([screen visibleFrame]));
|
||||
screenRect = screenRect.Intersect(aRect);
|
||||
int area = screenRect.width * screenRect.height;
|
||||
@ -206,7 +206,7 @@ FindTargetScreenForRect(const LayoutDeviceIntRect& aRect)
|
||||
// or to aScreen if a screen is passed in
|
||||
// NB: this operates with aRect in desktop pixels
|
||||
static void
|
||||
FitRectToVisibleAreaForScreen(LayoutDeviceIntRect& aRect, NSScreen* aScreen)
|
||||
FitRectToVisibleAreaForScreen(DesktopIntRect& aRect, NSScreen* aScreen)
|
||||
{
|
||||
if (!aScreen) {
|
||||
aScreen = FindTargetScreenForRect(aRect);
|
||||
@ -252,7 +252,7 @@ static bool UseNativePopupWindows()
|
||||
// aRect here is specified in desktop pixels
|
||||
nsresult nsCocoaWindow::Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
const DesktopIntRect& aRect,
|
||||
nsWidgetInitData* aInitData)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
@ -261,7 +261,7 @@ nsresult nsCocoaWindow::Create(nsIWidget* aParent,
|
||||
// we have to provide an autorelease pool (see bug 559075).
|
||||
nsAutoreleasePool localPool;
|
||||
|
||||
LayoutDeviceIntRect newBounds = aRect;
|
||||
DesktopIntRect newBounds = aRect;
|
||||
FitRectToVisibleAreaForScreen(newBounds, nullptr);
|
||||
|
||||
// Set defaults which can be overriden from aInitData in BaseCreate
|
||||
@ -291,12 +291,8 @@ nsresult nsCocoaWindow::Create(nsIWidget* aParent,
|
||||
}
|
||||
// now we can convert newBounds to device pixels for the window we created,
|
||||
// as the child view expects a rect expressed in the dev pix of its parent
|
||||
double scale = BackingScaleFactor();
|
||||
newBounds.x *= scale;
|
||||
newBounds.y *= scale;
|
||||
newBounds.width *= scale;
|
||||
newBounds.height *= scale;
|
||||
return CreatePopupContentView(newBounds);
|
||||
DesktopToLayoutDeviceScale scale(BackingScaleFactor());
|
||||
return CreatePopupContentView(RoundedToInt(newBounds * scale));
|
||||
}
|
||||
|
||||
mIsAnimationSuppressed = aInitData->mIsAnimationSuppressed;
|
||||
@ -306,6 +302,16 @@ nsresult nsCocoaWindow::Create(nsIWidget* aParent,
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
nsresult nsCocoaWindow::Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
nsWidgetInitData* aInitData)
|
||||
{
|
||||
DesktopToLayoutDeviceScale scale(GetDefaultScaleInternal());
|
||||
DesktopIntRect desktopRect = RoundedToInt(aRect / scale);
|
||||
return Create(aParent, aNativeParent, desktopRect, aInitData);
|
||||
}
|
||||
|
||||
static unsigned int WindowMaskForBorderStyle(nsBorderStyle aBorderStyle)
|
||||
{
|
||||
bool allOrDefault = (aBorderStyle == eBorderStyle_all ||
|
||||
@ -1535,9 +1541,9 @@ nsresult nsCocoaWindow::DoResize(double aX, double aY,
|
||||
int32_t height = NSToIntRound(aHeight * scale);
|
||||
ConstrainSize(&width, &height);
|
||||
|
||||
LayoutDeviceIntRect newBounds(NSToIntRound(aX), NSToIntRound(aY),
|
||||
NSToIntRound(width / scale),
|
||||
NSToIntRound(height / scale));
|
||||
DesktopIntRect newBounds(NSToIntRound(aX), NSToIntRound(aY),
|
||||
NSToIntRound(width / scale),
|
||||
NSToIntRound(height / scale));
|
||||
|
||||
// constrain to the screen that contains the largest area of the new rect
|
||||
FitRectToVisibleAreaForScreen(newBounds, aConstrainToCurrentScreen ?
|
||||
@ -1682,7 +1688,7 @@ GetBackingScaleFactor(NSWindow* aWindow)
|
||||
// Then identify the screen it belongs to, and return its scale factor.
|
||||
NSScreen *screen =
|
||||
FindTargetScreenForRect(
|
||||
LayoutDeviceIntRect::FromUnknownRect(nsCocoaUtils::CocoaRectToGeckoRect(frame)));
|
||||
DesktopIntRect::FromUnknownRect(nsCocoaUtils::CocoaRectToGeckoRect(frame)));
|
||||
return nsCocoaUtils::GetBackingScaleFactor(screen);
|
||||
}
|
||||
|
||||
|
@ -46,10 +46,11 @@ public:
|
||||
static nsEventStatus DispatchKeyInput(mozilla::WidgetKeyboardEvent& aEvent);
|
||||
static void DispatchTouchInput(mozilla::MultiTouchInput& aInput);
|
||||
|
||||
using nsBaseWidget::Create; // for Create signature not overridden here
|
||||
NS_IMETHOD Create(nsIWidget* aParent,
|
||||
void* aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
nsWidgetInitData* aInitData);
|
||||
nsWidgetInitData* aInitData) override;
|
||||
NS_IMETHOD Destroy(void);
|
||||
|
||||
NS_IMETHOD Show(bool aState);
|
||||
|
@ -95,6 +95,7 @@ public:
|
||||
bool AreBoundsSane(void);
|
||||
|
||||
// nsIWidget
|
||||
using nsBaseWidget::Create; // for Create signature not overridden here
|
||||
NS_IMETHOD Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
|
@ -349,6 +349,7 @@ class nsIWidget : public nsISupports {
|
||||
typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
|
||||
typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
|
||||
typedef mozilla::ScreenIntPoint ScreenIntPoint;
|
||||
typedef mozilla::DesktopIntRect DesktopIntRect;
|
||||
|
||||
// Used in UpdateThemeGeometries.
|
||||
struct ThemeGeometry {
|
||||
@ -399,8 +400,10 @@ class nsIWidget : public nsISupports {
|
||||
* independent top level windows).
|
||||
*
|
||||
* The dimensions given in aRect are specified in the parent's
|
||||
* coordinate system, or for parentless widgets such as top-level
|
||||
* windows, in global CSS pixels.
|
||||
* device coordinate system.
|
||||
* This must not be called for parentless widgets such as top-level
|
||||
* windows, which use the desktop pixel coordinate system; a separate
|
||||
* method is provided for these.
|
||||
*
|
||||
* @param aParent parent nsIWidget
|
||||
* @param aNativeParent native parent widget
|
||||
@ -413,6 +416,26 @@ class nsIWidget : public nsISupports {
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
nsWidgetInitData* aInitData = nullptr) = 0;
|
||||
|
||||
/*
|
||||
* As above, but with aRect specified in DesktopPixel units (for top-level
|
||||
* widgets).
|
||||
* Default implementation just converts aRect to device pixels and calls
|
||||
* through to device-pixel Create, but platforms may override this if the
|
||||
* mapping is not straightforward or the native platform needs to use the
|
||||
* desktop pixel values directly.
|
||||
*/
|
||||
NS_IMETHOD Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const DesktopIntRect& aRect,
|
||||
nsWidgetInitData* aInitData = nullptr)
|
||||
{
|
||||
// GetDefaultScaleInternal() here is a placeholder, to be replaced by
|
||||
// GetDesktopToDeviceScale in a later patch
|
||||
mozilla::DesktopToLayoutDeviceScale scale(GetDefaultScaleInternal());
|
||||
LayoutDeviceIntRect devPixRect = RoundedToInt(aRect * scale);
|
||||
return Create(aParent, aNativeParent, devPixRect, aInitData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate, initialize, and return a widget that is a child of
|
||||
* |this|. The returned widget (if nonnull) has gone through the
|
||||
|
@ -95,6 +95,7 @@ public:
|
||||
using nsWindowBase::DispatchPluginEvent;
|
||||
|
||||
// nsIWidget interface
|
||||
using nsWindowBase::Create; // for Create signature not overridden here
|
||||
NS_IMETHOD Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
|
@ -145,7 +145,7 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
|
||||
|
||||
// XXX: need to get the default window size from prefs...
|
||||
// Doesn't come from prefs... will come from CSS/XUL/RDF
|
||||
LayoutDeviceIntRect r(initialX, initialY, aInitialWidth, aInitialHeight);
|
||||
DesktopIntRect deskRect(initialX, initialY, aInitialWidth, aInitialHeight);
|
||||
|
||||
// Create top level window
|
||||
mWindow = do_CreateInstance(kWindowCID, &rv);
|
||||
@ -173,8 +173,10 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
|
||||
mWindow->SetWidgetListener(this);
|
||||
mWindow->Create((nsIWidget *)parentWidget, // Parent nsIWidget
|
||||
nullptr, // Native parent widget
|
||||
r, // Widget dimensions
|
||||
deskRect, // Widget dimensions
|
||||
&widgetInitData); // Widget initialization data
|
||||
|
||||
LayoutDeviceIntRect r;
|
||||
mWindow->GetClientBounds(r);
|
||||
// Match the default background color of content. Important on windows
|
||||
// since we no longer use content child widgets.
|
||||
|
Loading…
Reference in New Issue
Block a user