Bug 1224403 (part 4) - Make {Get,Set}NonClientMargins() return/take a LayoutDeviceIntMargin. r=kats.

This required adding {To,From}UnknownMargin().

--HG--
extra : rebase_source : de7e8f56604825bcc1babe5e05a8f8623a402cad
This commit is contained in:
Nicholas Nethercote 2015-11-11 23:05:04 -08:00
parent f703d45de5
commit e2fe66176b
11 changed files with 43 additions and 24 deletions

View File

@ -3641,7 +3641,7 @@ nsDOMWindowUtils::SetChromeMargin(int32_t aTop,
nsCOMPtr<nsIWidget> widget;
baseWindow->GetMainWidget(getter_AddRefs(widget));
if (widget) {
nsIntMargin margins(aTop, aRight, aBottom, aLeft);
LayoutDeviceIntMargin margins(aTop, aRight, aBottom, aLeft);
return widget->SetNonClientMargins(margins);
}
}

View File

@ -2007,7 +2007,7 @@ public:
explicit MarginSetter(nsIWidget* aWidget) :
mWidget(aWidget), mMargin(-1, -1, -1, -1)
{}
MarginSetter(nsIWidget *aWidget, const nsIntMargin& aMargin) :
MarginSetter(nsIWidget *aWidget, const LayoutDeviceIntMargin& aMargin) :
mWidget(aWidget), mMargin(aMargin)
{}
@ -2021,7 +2021,7 @@ public:
private:
nsCOMPtr<nsIWidget> mWidget;
nsIntMargin mMargin;
LayoutDeviceIntMargin mMargin;
};
void
@ -2046,7 +2046,9 @@ nsXULElement::SetChromeMargins(const nsAttrValue* aValue)
gotMargins = nsContentUtils::ParseIntMarginValue(tmp, margins);
}
if (gotMargins) {
nsContentUtils::AddScriptRunner(new MarginSetter(mainWidget, margins));
nsContentUtils::AddScriptRunner(
new MarginSetter(
mainWidget, LayoutDeviceIntMargin::FromUnknownMargin(margins)));
}
}

View File

@ -32,6 +32,19 @@ struct IntMarginTyped:
IntMarginTyped() : Super() {}
IntMarginTyped(int32_t aTop, int32_t aRight, int32_t aBottom, int32_t aLeft) :
Super(aTop, aRight, aBottom, aLeft) {}
// XXX When all of the code is ported, the following functions to convert
// to and from unknown types should be removed.
static IntMarginTyped<units> FromUnknownMargin(const IntMarginTyped<UnknownUnits>& aMargin) {
return IntMarginTyped<units>(aMargin.top, aMargin.right,
aMargin.bottom, aMargin.left);
}
IntMarginTyped<UnknownUnits> ToUnknownMargin() const {
return IntMarginTyped<UnknownUnits>(this->top, this->right,
this->bottom, this->left);
}
};
typedef IntMarginTyped<UnknownUnits> IntMargin;
@ -83,8 +96,8 @@ struct IntRectTyped :
void RoundIn() {}
void RoundOut() {}
// XXX When all of the code is ported, the following functions to convert to and from
// unknown types should be removed.
// XXX When all of the code is ported, the following functions to convert
// to and from unknown types should be removed.
static IntRectTyped<units> FromUnknownRect(const IntRectTyped<UnknownUnits>& rect) {
return IntRectTyped<units>(rect.x, rect.y, rect.width, rect.height);

View File

@ -340,7 +340,7 @@ public:
virtual void SetWindowAnimationType(WindowAnimationType aType) override;
virtual void SetDrawsTitle(bool aDrawTitle) override;
virtual void SetUseBrightTitlebarForeground(bool aBrightForeground) override;
NS_IMETHOD SetNonClientMargins(nsIntMargin &margins) override;
NS_IMETHOD SetNonClientMargins(mozilla::LayoutDeviceIntMargin &margins) override;
NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive) override;
virtual void SetDrawsInTitlebar(bool aState) override;
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override;

View File

@ -2167,7 +2167,7 @@ nsCocoaWindow::SetUseBrightTitlebarForeground(bool aBrightForeground)
NS_OBJC_END_TRY_ABORT_BLOCK;
}
NS_IMETHODIMP nsCocoaWindow::SetNonClientMargins(nsIntMargin &margins)
NS_IMETHODIMP nsCocoaWindow::SetNonClientMargins(LayoutDeviceIntMargin &margins)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;

View File

@ -1347,13 +1347,13 @@ nsBaseWidget::GetClientOffsetUntyped()
}
NS_IMETHODIMP
nsBaseWidget::GetNonClientMargins(nsIntMargin &margins)
nsBaseWidget::GetNonClientMargins(LayoutDeviceIntMargin &margins)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsBaseWidget::SetNonClientMargins(nsIntMargin &margins)
nsBaseWidget::SetNonClientMargins(LayoutDeviceIntMargin &margins)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -191,8 +191,10 @@ public:
NS_IMETHOD GetClientBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetScreenBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetRestoredBoundsUntyped(nsIntRect &aRect) override;
NS_IMETHOD GetNonClientMargins(nsIntMargin &margins) override;
NS_IMETHOD SetNonClientMargins(nsIntMargin &margins) override;
NS_IMETHOD GetNonClientMargins(
mozilla::LayoutDeviceIntMargin &margins) override;
NS_IMETHOD SetNonClientMargins(
mozilla::LayoutDeviceIntMargin &margins) override;
virtual nsIntPoint GetClientOffsetUntyped() override;
NS_IMETHOD EnableDragDrop(bool aEnable) override;
NS_IMETHOD GetAttention(int32_t aCycleCount) override;

View File

@ -879,9 +879,8 @@ class nsIWidget : public nsISupports {
/**
* Get the non-client area dimensions of the window.
*
*/
NS_IMETHOD GetNonClientMargins(nsIntMargin &margins) = 0;
NS_IMETHOD GetNonClientMargins(mozilla::LayoutDeviceIntMargin &margins) = 0;
/**
* Sets the non-client area dimensions of the window. Pass -1 to restore
@ -895,7 +894,7 @@ class nsIWidget : public nsISupports {
* dimensions between zero and size < system default.
*
*/
NS_IMETHOD SetNonClientMargins(nsIntMargin &margins) = 0;
NS_IMETHOD SetNonClientMargins(mozilla::LayoutDeviceIntMargin &margins) = 0;
/**
* Get the client offset from the window origin.

View File

@ -2018,17 +2018,17 @@ nsWindow::SetDrawsInTitlebar(bool aState)
if (aState) {
// top, right, bottom, left for nsIntMargin
nsIntMargin margins(0, -1, -1, -1);
LayoutDeviceIntMargin margins(0, -1, -1, -1);
SetNonClientMargins(margins);
}
else {
nsIntMargin margins(-1, -1, -1, -1);
LayoutDeviceIntMargin margins(-1, -1, -1, -1);
SetNonClientMargins(margins);
}
}
NS_IMETHODIMP
nsWindow::GetNonClientMargins(nsIntMargin &margins)
nsWindow::GetNonClientMargins(LayoutDeviceIntMargin &margins)
{
nsWindow * window = GetTopLevelWindow(true);
if (window && window != this) {
@ -2303,7 +2303,7 @@ nsWindow::UpdateNonClientMargins(int32_t aSizeMode, bool aReflowWindow)
}
NS_IMETHODIMP
nsWindow::SetNonClientMargins(nsIntMargin &margins)
nsWindow::SetNonClientMargins(LayoutDeviceIntMargin &margins)
{
if (!mIsTopWidgetWindow ||
mBorderStyle == eBorderStyle_none)

View File

@ -195,8 +195,10 @@ public:
virtual void UpdateOpaqueRegion(const nsIntRegion& aOpaqueRegion);
#endif // MOZ_XUL
virtual nsIMEUpdatePreference GetIMEUpdatePreference();
NS_IMETHOD GetNonClientMargins(nsIntMargin &margins);
NS_IMETHOD SetNonClientMargins(nsIntMargin &margins);
NS_IMETHOD GetNonClientMargins(
mozilla::LayoutDeviceIntMargin &margins) override;
NS_IMETHOD SetNonClientMargins(
mozilla::LayoutDeviceIntMargin &margins) override;
void SetDrawsInTitlebar(bool aState);
already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawing() override;
virtual void EndRemoteDrawing() override;
@ -517,9 +519,9 @@ protected:
// Pre-calculated outward offset applied to default frames
mozilla::LayoutDeviceIntMargin mNonClientOffset;
// Margins set by the owner
nsIntMargin mNonClientMargins;
mozilla::LayoutDeviceIntMargin mNonClientMargins;
// Margins we'd like to set once chrome is reshown:
nsIntMargin mFutureMarginsOnceChromeShows;
mozilla::LayoutDeviceIntMargin mFutureMarginsOnceChromeShows;
// Indicates we need to apply margins once toggling chrome into showing:
bool mFutureMarginsToUse;

View File

@ -1428,7 +1428,8 @@ void nsXULWindow::SyncAttributesToWidget()
nsIntMargin margins;
windowElement->GetAttribute(NS_LITERAL_STRING("chromemargin"), attr);
if (nsContentUtils::ParseIntMarginValue(attr, margins)) {
mWindow->SetNonClientMargins(margins);
LayoutDeviceIntMargin tmp = LayoutDeviceIntMargin::FromUnknownMargin(margins);
mWindow->SetNonClientMargins(tmp);
}
// "windowtype" attribute