Skip to content

Commit

Permalink
Bug 1423559: Use BaseRect access methods instead of member variables …
Browse files Browse the repository at this point in the history
…in widget/ r=mstange

MozReview-Commit-ID: AqnztoUbsmk

--HG--
extra : rebase_source : 76a232a08b42ed73b4922c03bc0f2e9d1769203b
  • Loading branch information
msreckovic committed Jan 10, 2018
1 parent 2413f47 commit bd27b86
Show file tree
Hide file tree
Showing 21 changed files with 219 additions and 260 deletions.
2 changes: 1 addition & 1 deletion widget/CompositorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ CompositorWidget::GetBackBufferDrawTarget(gfx::DrawTarget* aScreenTarget,
target->SetTransform(gfx::Matrix());
if (!aClearRect.IsEmpty()) {
gfx::IntRect clearRect = aClearRect.ToUnknownRect() - aRect.ToUnknownRect().TopLeft();
target->ClearRect(gfx::Rect(clearRect.x, clearRect.y, clearRect.width, clearRect.height));
target->ClearRect(gfx::Rect(clearRect.X(), clearRect.Y(), clearRect.Width(), clearRect.Height()));
}
} else {
target = aScreenTarget->CreateSimilarDrawTarget(size, format);
Expand Down
24 changes: 12 additions & 12 deletions widget/ContentCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ class GetRectText : public nsAutoCString
explicit GetRectText(const LayoutDeviceIntRect& aRect)
{
AssignLiteral("{ x=");
AppendInt(aRect.x);
AppendInt(aRect.X());
AppendLiteral(", y=");
AppendInt(aRect.y);
AppendInt(aRect.Y());
AppendLiteral(", width=");
AppendInt(aRect.width);
AppendInt(aRect.Width());
AppendLiteral(", height=");
AppendInt(aRect.height);
AppendInt(aRect.Height());
AppendLiteral(" }");
}
virtual ~GetRectText() {}
Expand Down Expand Up @@ -293,11 +293,11 @@ ContentCacheInChild::QueryCharRect(nsIWidget* aWidget,
aCharRect = textRect.mReply.mRect;

// Guarantee the rect is not empty.
if (NS_WARN_IF(!aCharRect.height)) {
aCharRect.height = 1;
if (NS_WARN_IF(!aCharRect.Height())) {
aCharRect.SetHeight(1);
}
if (NS_WARN_IF(!aCharRect.width)) {
aCharRect.width = 1;
if (NS_WARN_IF(!aCharRect.Width())) {
aCharRect.SetWidth(1);
}
return true;
}
Expand Down Expand Up @@ -1081,20 +1081,20 @@ ContentCacheInParent::GetCaretRect(uint32_t aOffset,
}

if (mSelection.mWritingMode.IsVertical()) {
aCaretRect.y = aCaretRect.YMost();
aCaretRect.MoveToY(aCaretRect.YMost());
} else {
// XXX bidi-unaware.
aCaretRect.x = aCaretRect.XMost();
aCaretRect.MoveToX(aCaretRect.XMost());
}
}

// XXX This is not bidi aware because we don't cache each character's
// direction. However, this is usually used by IME, so, assuming the
// character is in LRT context must not cause any problem.
if (mSelection.mWritingMode.IsVertical()) {
aCaretRect.height = mCaret.IsValid() ? mCaret.mRect.height : 1;
aCaretRect.SetHeight(mCaret.IsValid() ? mCaret.mRect.Height() : 1);
} else {
aCaretRect.width = mCaret.IsValid() ? mCaret.mRect.width : 1;
aCaretRect.SetWidth(mCaret.IsValid() ? mCaret.mRect.Width() : 1);
}
return true;
}
Expand Down
5 changes: 1 addition & 4 deletions widget/IMEData.h
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,7 @@ struct IMENotification final

void Set(const nsIntRect& aRect)
{
mX = aRect.x;
mY = aRect.y;
mWidth = aRect.Width();
mHeight = aRect.Height();
aRect.GetRect(&mX, &mY, &mWidth, &mHeight);
}
nsIntRect AsIntRect() const
{
Expand Down
21 changes: 9 additions & 12 deletions widget/PuppetWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ PuppetWidget::InfallibleCreate(nsIWidget* aParent,
mLayerManager = parent->GetLayerManager();
}
else {
Resize(mBounds.x, mBounds.y, mBounds.width, mBounds.height, false);
Resize(mBounds.X(), mBounds.Y(), mBounds.Width(), mBounds.Height(), false);
}
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
Expand Down Expand Up @@ -224,7 +224,7 @@ PuppetWidget::Show(bool aState)
// of no use anymore (and is actually actively harmful - see
// bug 1323586).
mPreviouslyAttachedWidgetListener = nullptr;
Resize(mBounds.width, mBounds.height, false);
Resize(mBounds.Width(), mBounds.Height(), false);
Invalidate(mBounds);
}
}
Expand Down Expand Up @@ -257,9 +257,9 @@ PuppetWidget::Resize(double aWidth,
if (!oldBounds.IsEqualEdges(mBounds) && mAttachedWidgetListener) {
if (GetCurrentWidgetListener() &&
GetCurrentWidgetListener() != mAttachedWidgetListener) {
GetCurrentWidgetListener()->WindowResized(this, mBounds.width, mBounds.height);
GetCurrentWidgetListener()->WindowResized(this, mBounds.Width(), mBounds.Height());
}
mAttachedWidgetListener->WindowResized(this, mBounds.width, mBounds.height);
mAttachedWidgetListener->WindowResized(this, mBounds.Width(), mBounds.Height());
}
}

Expand All @@ -274,11 +274,11 @@ PuppetWidget::ConfigureChildren(const nsTArray<Configuration>& aConfigurations)
w->SetWindowClipRegion(configuration.mClipRegion, true);
LayoutDeviceIntRect bounds = w->GetBounds();
if (bounds.Size() != configuration.mBounds.Size()) {
w->Resize(configuration.mBounds.x, configuration.mBounds.y,
configuration.mBounds.width, configuration.mBounds.height,
w->Resize(configuration.mBounds.X(), configuration.mBounds.Y(),
configuration.mBounds.Width(), configuration.mBounds.Height(),
true);
} else if (bounds.TopLeft() != configuration.mBounds.TopLeft()) {
w->Move(configuration.mBounds.x, configuration.mBounds.y);
w->Move(configuration.mBounds.X(), configuration.mBounds.Y());
}
w->SetWindowClipRegion(configuration.mClipRegion, false);
}
Expand Down Expand Up @@ -1314,18 +1314,15 @@ nsIntSize
PuppetWidget::GetScreenDimensions()
{
nsIntRect r = ScreenConfig().rect();
return nsIntSize(r.width, r.height);
return nsIntSize(r.Width(), r.Height());
}

NS_IMETHODIMP
PuppetScreen::GetRect(int32_t *outLeft, int32_t *outTop,
int32_t *outWidth, int32_t *outHeight)
{
nsIntRect r = ScreenConfig().rect();
*outLeft = r.x;
*outTop = r.y;
*outWidth = r.width;
*outHeight = r.height;
r.GetRect(outLeft, outTop, outWidth, outHeight);
return NS_OK;
}

Expand Down
5 changes: 2 additions & 3 deletions widget/PuppetWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ class PuppetWidget : public nsBaseWidget
double aHeight,
bool aRepaint) override
{
if (mBounds.x != aX || mBounds.y != aY) {
if (!mBounds.IsEqualXY(aX, aY)) {
NotifyWindowMoved(aX, aY);
}
mBounds.x = aX;
mBounds.y = aY;
mBounds.MoveTo(aX, aY);
return Resize(aWidth, aHeight, aRepaint);
}

Expand Down
20 changes: 4 additions & 16 deletions widget/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ Screen::GetRect(int32_t* aOutLeft,
int32_t* aOutWidth,
int32_t* aOutHeight)
{
*aOutLeft = mRect.x;
*aOutTop = mRect.y;
*aOutWidth = mRect.width;
*aOutHeight = mRect.height;
mRect.GetRect(aOutLeft, aOutTop, aOutWidth, aOutHeight);
return NS_OK;
}

Expand All @@ -83,10 +80,7 @@ Screen::GetRectDisplayPix(int32_t* aOutLeft,
int32_t* aOutWidth,
int32_t* aOutHeight)
{
*aOutLeft = mRectDisplayPix.x;
*aOutTop = mRectDisplayPix.y;
*aOutWidth = mRectDisplayPix.width;
*aOutHeight = mRectDisplayPix.height;
mRectDisplayPix.GetRect(aOutLeft, aOutTop, aOutWidth, aOutHeight);
return NS_OK;
}

Expand All @@ -96,10 +90,7 @@ Screen::GetAvailRect(int32_t* aOutLeft,
int32_t* aOutWidth,
int32_t* aOutHeight)
{
*aOutLeft = mAvailRect.x;
*aOutTop = mAvailRect.y;
*aOutWidth = mAvailRect.width;
*aOutHeight = mAvailRect.height;
mAvailRect.GetRect(aOutLeft, aOutTop, aOutWidth, aOutHeight);
return NS_OK;
}

Expand All @@ -109,10 +100,7 @@ Screen::GetAvailRectDisplayPix(int32_t* aOutLeft,
int32_t* aOutWidth,
int32_t* aOutHeight)
{
*aOutLeft = mAvailRectDisplayPix.x;
*aOutTop = mAvailRectDisplayPix.y;
*aOutWidth = mAvailRectDisplayPix.width;
*aOutHeight = mAvailRectDisplayPix.height;
mAvailRectDisplayPix.GetRect(aOutLeft, aOutTop, aOutWidth, aOutHeight);
return NS_OK;
}

Expand Down
2 changes: 1 addition & 1 deletion widget/ScreenManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ ScreenManager::ScreenForRect(int32_t aX, int32_t aY,
// calculate the surface area
DesktopIntRect screenRect(x, y, width, height);
screenRect.IntersectRect(screenRect, windowRect);
uint32_t tempArea = screenRect.width * screenRect.height;
uint32_t tempArea = screenRect.Area();
if (tempArea > area) {
which = screen.get();
area = tempArea;
Expand Down
30 changes: 15 additions & 15 deletions widget/WidgetUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ ComputeTransformForRotation(const nsIntRect& aBounds,
case ROTATION_0:
break;
case ROTATION_90:
transform.PreTranslate(aBounds.width, 0);
transform.PreTranslate(aBounds.Width(), 0);
transform.PreRotate(floatPi / 2);
break;
case ROTATION_180:
transform.PreTranslate(aBounds.width, aBounds.height);
transform.PreTranslate(aBounds.Width(), aBounds.Height());
transform.PreRotate(floatPi);
break;
case ROTATION_270:
transform.PreTranslate(0, aBounds.height);
transform.PreTranslate(0, aBounds.Height());
transform.PreRotate(floatPi * 3 / 2);
break;
default:
Expand All @@ -61,15 +61,15 @@ ComputeTransformForUnRotation(const nsIntRect& aBounds,
case ROTATION_0:
break;
case ROTATION_90:
transform.PreTranslate(0, aBounds.height);
transform.PreTranslate(0, aBounds.Height());
transform.PreRotate(floatPi * 3 / 2);
break;
case ROTATION_180:
transform.PreTranslate(aBounds.width, aBounds.height);
transform.PreTranslate(aBounds.Width(), aBounds.Height());
transform.PreRotate(floatPi);
break;
case ROTATION_270:
transform.PreTranslate(aBounds.width, 0);
transform.PreTranslate(aBounds.Width(), 0);
transform.PreRotate(floatPi / 2);
break;
default:
Expand All @@ -86,17 +86,17 @@ nsIntRect RotateRect(nsIntRect aRect,
case ROTATION_0:
return aRect;
case ROTATION_90:
return nsIntRect(aRect.y,
aBounds.width - aRect.x - aRect.width,
aRect.height, aRect.width);
return nsIntRect(aRect.Y(),
aBounds.Width() - aRect.XMost(),
aRect.Height(), aRect.Width());
case ROTATION_180:
return nsIntRect(aBounds.width - aRect.x - aRect.width,
aBounds.height - aRect.y - aRect.height,
aRect.width, aRect.height);
return nsIntRect(aBounds.Width() - aRect.XMost(),
aBounds.Height() - aRect.YMost(),
aRect.Width(), aRect.Height());
case ROTATION_270:
return nsIntRect(aBounds.height - aRect.y - aRect.height,
aRect.x,
aRect.height, aRect.width);
return nsIntRect(aBounds.Height() - aRect.YMost(),
aRect.X(),
aRect.Height(), aRect.Width());
default:
MOZ_CRASH("Unknown rotation");
}
Expand Down
8 changes: 4 additions & 4 deletions widget/cocoa/nsCocoaUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ class nsCocoaUtils
DevPixelsToCocoaPoints(const LayoutDeviceIntRect& aRect,
CGFloat aBackingScale)
{
return NSMakeRect((CGFloat)aRect.x / aBackingScale,
(CGFloat)aRect.y / aBackingScale,
(CGFloat)aRect.width / aBackingScale,
(CGFloat)aRect.height / aBackingScale);
return NSMakeRect((CGFloat)aRect.X() / aBackingScale,
(CGFloat)aRect.Y() / aBackingScale,
(CGFloat)aRect.Width() / aBackingScale,
(CGFloat)aRect.Height() / aBackingScale);
}

// Returns the given y coordinate, which must be in screen coordinates,
Expand Down
15 changes: 7 additions & 8 deletions widget/headless/HeadlessWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,12 @@ HeadlessWidget::Move(double aX, double aY)
// Since a popup window's x/y coordinates are in relation to
// the parent, the parent might have moved so we always move a
// popup window.
if (x == mBounds.x && y == mBounds.y &&
if (mBounds.IsEqualXY(x, y) &&
mWindowType != eWindowType_popup) {
return;
}

mBounds.x = x;
mBounds.y = y;
mBounds.MoveTo(x, y);
NotifyRollupGeometryChange();
}

Expand Down Expand Up @@ -325,13 +324,13 @@ HeadlessWidget::Resize(double aWidth,
mBounds.SizeTo(LayoutDeviceIntSize(width, height));

if (mCompositorWidget) {
mCompositorWidget->NotifyClientSizeChanged(LayoutDeviceIntSize(mBounds.width, mBounds.height));
mCompositorWidget->NotifyClientSizeChanged(LayoutDeviceIntSize(mBounds.Width(), mBounds.Height()));
}
if (mWidgetListener) {
mWidgetListener->WindowResized(this, mBounds.width, mBounds.height);
mWidgetListener->WindowResized(this, mBounds.Width(), mBounds.Height());
}
if (mAttachedWidgetListener) {
mAttachedWidgetListener->WindowResized(this, mBounds.width, mBounds.height);
mAttachedWidgetListener->WindowResized(this, mBounds.Width(), mBounds.Height());
}
}

Expand All @@ -342,7 +341,7 @@ HeadlessWidget::Resize(double aX,
double aHeight,
bool aRepaint)
{
if (mBounds.x != aX || mBounds.y != aY) {
if (!mBounds.IsEqualXY(aX, aY)) {
NotifyWindowMoved(aX, aY);
}
return Resize(aWidth, aHeight, aRepaint);
Expand Down Expand Up @@ -380,7 +379,7 @@ HeadlessWidget::ApplySizeModeSideEffects()

switch(mSizeMode) {
case nsSizeMode_Normal: {
Resize(mRestoreBounds.x, mRestoreBounds.y, mRestoreBounds.width, mRestoreBounds.height, false);
Resize(mRestoreBounds.X(), mRestoreBounds.Y(), mRestoreBounds.Width(), mRestoreBounds.Height(), false);
break;
}
case nsSizeMode_Minimized:
Expand Down
Loading

0 comments on commit bd27b86

Please sign in to comment.