--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -3301,19 +3301,18 @@ AccumulateFrameBounds(nsIFrame* aContain
nsIFrame *trash1;
int32_t trash2;
nsRect lineBounds;
if (NS_SUCCEEDED(aLines->GetLine(index, &trash1, &trash2,
lineBounds))) {
frameBounds += frame->GetOffsetTo(f);
frame = f;
- if (lineBounds.y < frameBounds.y) {
- frameBounds.height = frameBounds.YMost() - lineBounds.y;
- frameBounds.y = lineBounds.y;
+ if (lineBounds.Y() < frameBounds.Y()) {
+ frameBounds.SetTopEdge(lineBounds.Y());
}
}
}
}
}
}
nsRect transformedBounds = nsLayoutUtils::TransformFrameRectToAncestor(frame,
@@ -3417,53 +3416,53 @@ static void ScrollToShowRect(nsIScrollab
if (((aFlags & nsIPresShell::SCROLL_OVERFLOW_HIDDEN) ||
ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN) &&
(!aVertical.mOnlyIfPerceivedScrollableDirection ||
(directions & nsIScrollableFrame::VERTICAL))) {
if (ComputeNeedToScroll(aVertical.mWhenToScroll,
lineSize.height,
- aRect.y,
+ aRect.Y(),
aRect.YMost(),
- visibleRect.y,
+ visibleRect.Y(),
visibleRect.YMost())) {
- nscoord maxHeight;
+ nscoord maxHeight, rangeY;
scrollPt.y = ComputeWhereToScroll(aVertical.mWhereToScroll,
scrollPt.y,
- aRect.y,
+ aRect.Y(),
aRect.YMost(),
- visibleRect.y,
+ visibleRect.Y(),
visibleRect.YMost(),
- &allowedRange.y, &maxHeight);
- allowedRange.height = maxHeight - allowedRange.y;
+ &rangeY, &maxHeight);
+ allowedRange.SetBoxY(rangeY, maxHeight);
needToScroll = true;
}
}
if (((aFlags & nsIPresShell::SCROLL_OVERFLOW_HIDDEN) ||
ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) &&
(!aHorizontal.mOnlyIfPerceivedScrollableDirection ||
(directions & nsIScrollableFrame::HORIZONTAL))) {
if (ComputeNeedToScroll(aHorizontal.mWhenToScroll,
lineSize.width,
- aRect.x,
+ aRect.X(),
aRect.XMost(),
- visibleRect.x,
+ visibleRect.X(),
visibleRect.XMost())) {
- nscoord maxWidth;
+ nscoord maxWidth, rangeX;
scrollPt.x = ComputeWhereToScroll(aHorizontal.mWhereToScroll,
scrollPt.x,
- aRect.x,
+ aRect.X(),
aRect.XMost(),
- visibleRect.x,
+ visibleRect.X(),
visibleRect.XMost(),
- &allowedRange.x, &maxWidth);
- allowedRange.width = maxWidth - allowedRange.x;
+ &rangeX, &maxWidth);
+ allowedRange.SetBoxX(rangeX, maxWidth);
needToScroll = true;
}
}
// If we don't need to scroll, then don't try since it might cancel
// a current smooth scroll operation.
if (needToScroll) {
nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT;
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1116,29 +1116,29 @@ GetDisplayPortFromMarginsData(nsIContent
// Scale the margins down to fit into the budget if necessary, maintaining
// their relative ratio.
float scale = 1.0f;
if (float(budget) < margins.TopBottom()) {
scale = float(budget) / margins.TopBottom();
}
float top = margins.top * scale;
float bottom = margins.bottom * scale;
- screenRect.y -= top;
- screenRect.height += top + bottom;
- }
- if (screenRect.width < maxWidthScreenPx) {
- int32_t budget = maxWidthScreenPx - screenRect.width;
+ screenRect.SetBoxY(screenRect.Y() - top,
+ screenRect.YMost() + bottom);
+ }
+ if (screenRect.Width() < maxWidthScreenPx) {
+ int32_t budget = maxWidthScreenPx - screenRect.Width();
float scale = 1.0f;
if (float(budget) < margins.LeftRight()) {
scale = float(budget) / margins.LeftRight();
}
float left = margins.left * scale;
float right = margins.right * scale;
- screenRect.x -= left;
- screenRect.width += left + right;
+ screenRect.SetBoxX(screenRect.X() - left,
+ screenRect.XMost() + right);
}
}
ScreenPoint scrollPosScreen = LayoutDevicePoint::FromAppUnits(scrollPos, auPerDevPixel)
* res;
// Round-out the display port to the nearest alignment (tiles)
screenRect += scrollPosScreen;
@@ -2499,61 +2499,67 @@ static void ConstrainToCoordValues(gfxFl
nsRect
nsLayoutUtils::RoundGfxRectToAppRect(const Rect &aRect, float aFactor)
{
/* Get a new Rect whose units are app units by scaling by the specified factor. */
Rect scaledRect = aRect;
scaledRect.ScaleRoundOut(aFactor);
/* We now need to constrain our results to the max and min values for coords. */
- ConstrainToCoordValues(scaledRect.x, scaledRect.width);
- ConstrainToCoordValues(scaledRect.y, scaledRect.height);
+ float x, y, width, height;
+ scaledRect.GetRect(&x, &y, &width, &height);
+
+ ConstrainToCoordValues(x, width);
+ ConstrainToCoordValues(y, height);
/* Now typecast everything back. This is guaranteed to be safe. */
- return nsRect(nscoord(scaledRect.X()), nscoord(scaledRect.Y()),
- nscoord(scaledRect.Width()), nscoord(scaledRect.Height()));
+ return nsRect(nscoord(x), nscoord(y), nscoord(width), nscoord(height));
}
nsRect
nsLayoutUtils::RoundGfxRectToAppRect(const gfxRect &aRect, float aFactor)
{
/* Get a new gfxRect whose units are app units by scaling by the specified factor. */
gfxRect scaledRect = aRect;
scaledRect.ScaleRoundOut(aFactor);
/* We now need to constrain our results to the max and min values for coords. */
- ConstrainToCoordValues(scaledRect.x, scaledRect.width);
- ConstrainToCoordValues(scaledRect.y, scaledRect.height);
+ double x, y, width, height;
+ scaledRect.GetRect(&x, &y, &width, &height);
+
+ ConstrainToCoordValues(x, width);
+ ConstrainToCoordValues(y, height);
/* Now typecast everything back. This is guaranteed to be safe. */
- return nsRect(nscoord(scaledRect.X()), nscoord(scaledRect.Y()),
- nscoord(scaledRect.Width()), nscoord(scaledRect.Height()));
+ return nsRect(nscoord(x), nscoord(y), nscoord(width), nscoord(height));
}
nsRegion
nsLayoutUtils::RoundedRectIntersectRect(const nsRect& aRoundedRect,
const nscoord aRadii[8],
const nsRect& aContainedRect)
{
// rectFullHeight and rectFullWidth together will approximately contain
// the total area of the frame minus the rounded corners.
nsRect rectFullHeight = aRoundedRect;
nscoord xDiff = std::max(aRadii[eCornerTopLeftX], aRadii[eCornerBottomLeftX]);
- rectFullHeight.x += xDiff;
- rectFullHeight.width -= std::max(aRadii[eCornerTopRightX],
- aRadii[eCornerBottomRightX]) + xDiff;
+ rectFullHeight.MoveByX(xDiff);
+ rectFullHeight.SetWidth(rectFullHeight.Width() -
+ (std::max(aRadii[eCornerTopRightX],
+ aRadii[eCornerBottomRightX]) + xDiff));
nsRect r1;
r1.IntersectRect(rectFullHeight, aContainedRect);
nsRect rectFullWidth = aRoundedRect;
nscoord yDiff = std::max(aRadii[eCornerTopLeftY], aRadii[eCornerTopRightY]);
- rectFullWidth.y += yDiff;
- rectFullWidth.height -= std::max(aRadii[eCornerBottomLeftY],
- aRadii[eCornerBottomRightY]) + yDiff;
+ rectFullWidth.MoveByY(yDiff);
+ rectFullWidth.SetHeight(rectFullWidth.Height() -
+ (std::max(aRadii[eCornerBottomLeftY],
+ aRadii[eCornerBottomRightY]) + yDiff));
nsRect r2;
r2.IntersectRect(rectFullWidth, aContainedRect);
nsRegion result;
result.Or(r1, r2);
return result;
}
@@ -2562,28 +2568,30 @@ nsLayoutUtils::RoundedRectIntersectIntRe
const RectCornerRadii& aCornerRadii,
const nsIntRect& aContainedRect)
{
// rectFullHeight and rectFullWidth together will approximately contain
// the total area of the frame minus the rounded corners.
nsIntRect rectFullHeight = aRoundedRect;
uint32_t xDiff = std::max(aCornerRadii.TopLeft().width,
aCornerRadii.BottomLeft().width);
- rectFullHeight.x += xDiff;
- rectFullHeight.width -= std::max(aCornerRadii.TopRight().width,
- aCornerRadii.BottomRight().width) + xDiff;
+ rectFullHeight.MoveByX(xDiff);
+ rectFullHeight.SetWidth(rectFullHeight.Width() -
+ (std::max(aCornerRadii.TopRight().width,
+ aCornerRadii.BottomRight().width) + xDiff));
nsIntRect r1;
r1.IntersectRect(rectFullHeight, aContainedRect);
nsIntRect rectFullWidth = aRoundedRect;
uint32_t yDiff = std::max(aCornerRadii.TopLeft().height,
aCornerRadii.TopRight().height);
- rectFullWidth.y += yDiff;
- rectFullWidth.height -= std::max(aCornerRadii.BottomLeft().height,
- aCornerRadii.BottomRight().height) + yDiff;
+ rectFullWidth.MoveByY(yDiff);
+ rectFullWidth.SetHeight(rectFullWidth.Height() -
+ (std::max(aCornerRadii.BottomLeft().height,
+ aCornerRadii.BottomRight().height) + yDiff));
nsIntRect r2;
r2.IntersectRect(rectFullWidth, aContainedRect);
nsIntRegion result;
result.Or(r1, r2);
return result;
}
@@ -7275,17 +7283,17 @@ nsLayoutUtils::DrawBackgroundImage(gfxCo
float aOpacity)
{
AUTO_PROFILER_LABEL("nsLayoutUtils::DrawBackgroundImage", GRAPHICS);
Maybe<SVGImageContext> svgContext(Some(SVGImageContext(Some(aImageSize))));
SVGImageContext::MaybeStoreContextPaint(svgContext, aForFrame, aImage);
/* Fast path when there is no need for image spacing */
- if (aRepeatSize.width == aDest.width && aRepeatSize.height == aDest.height) {
+ if (aRepeatSize == aDest.Size()) {
return DrawImageInternal(aContext, aPresContext, aImage,
aSamplingFilter, aDest, aFill, aAnchor,
aDirty, svgContext, aImageFlags, aExtendMode,
aOpacity);
}
nsPoint firstTilePos = GetBackgroundFirstTilePos(aDest.TopLeft(), aFill.TopLeft(), aRepeatSize);
for (int32_t i = firstTilePos.x; i < aFill.XMost(); i += aRepeatSize.width) {
@@ -7590,26 +7598,24 @@ nsLayoutUtils::GetTextRunOrientFlagsForS
}
}
/* static */ void
nsLayoutUtils::GetRectDifferenceStrips(const nsRect& aR1, const nsRect& aR2,
nsRect* aHStrip, nsRect* aVStrip) {
NS_ASSERTION(aR1.TopLeft() == aR2.TopLeft(),
"expected rects at the same position");
- nsRect unionRect(aR1.x, aR1.y, std::max(aR1.width, aR2.width),
- std::max(aR1.height, aR2.height));
- nscoord VStripStart = std::min(aR1.width, aR2.width);
- nscoord HStripStart = std::min(aR1.height, aR2.height);
+ nsRect unionRect(aR1.X(), aR1.Y(), std::max(aR1.Width(), aR2.Width()),
+ std::max(aR1.Height(), aR2.Height()));
+ nscoord VStripStart = std::min(aR1.Width(), aR2.Width());
+ nscoord HStripStart = std::min(aR1.Height(), aR2.Height());
*aVStrip = unionRect;
- aVStrip->x += VStripStart;
- aVStrip->width -= VStripStart;
+ aVStrip->SetLeftEdge(aVStrip->X() + VStripStart);
*aHStrip = unionRect;
- aHStrip->y += HStripStart;
- aHStrip->height -= HStripStart;
+ aHStrip->SetTopEdge(aHStrip->Y() + HStripStart);
}
nsDeviceContext*
nsLayoutUtils::GetDeviceContextForScreenInfo(nsPIDOMWindowOuter* aWindow)
{
if (!aWindow) {
return nullptr;
}
--- a/layout/generic/TextOverflow.cpp
+++ b/layout/generic/TextOverflow.cpp
@@ -117,24 +117,23 @@ static void
ClipMarker(const nsRect& aContentArea,
const nsRect& aMarkerRect,
DisplayListClipState::AutoSaveRestore& aClipState)
{
nscoord rightOverflow = aMarkerRect.XMost() - aContentArea.XMost();
nsRect markerRect = aMarkerRect;
if (rightOverflow > 0) {
// Marker overflows on the right side (content width < marker width).
- markerRect.width -= rightOverflow;
+ markerRect.SetWidth(markerRect.Width() - rightOverflow);
aClipState.ClipContentDescendants(markerRect);
} else {
- nscoord leftOverflow = aContentArea.x - aMarkerRect.x;
+ nscoord leftOverflow = aContentArea.X() - aMarkerRect.X();
if (leftOverflow > 0) {
// Marker overflows on the left side
- markerRect.width -= leftOverflow;
- markerRect.x += leftOverflow;
+ markerRect.SetLeftEdge(markerRect.X() + leftOverflow);
aClipState.ClipContentDescendants(markerRect);
}
}
}
static void
InflateIStart(WritingMode aWM, LogicalRect* aRect, nscoord aDelta)
{
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -1722,30 +1722,28 @@ ConsiderBlockEndEdgeOfChildren(const Wri
// visual, we can change this.
// XXX Currently, overflow areas are stored as physical rects, so we have
// to handle writing modes explicitly here. If we change overflow rects
// to be stored logically, this can be simplified again.
if (aWritingMode.IsVertical()) {
if (aWritingMode.IsVerticalLR()) {
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
nsRect& o = aOverflowAreas.Overflow(otype);
- o.width = std::max(o.XMost(), aBEndEdgeOfChildren) - o.x;
+ o.SetRightEdge(std::max(o.XMost(), aBEndEdgeOfChildren));
}
} else {
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
nsRect& o = aOverflowAreas.Overflow(otype);
- nscoord xmost = o.XMost();
- o.x = std::min(o.x, xmost - aBEndEdgeOfChildren);
- o.width = xmost - o.x;
+ o.SetLeftEdge(std::min(o.X(), o.XMost() - aBEndEdgeOfChildren));
}
}
} else {
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
nsRect& o = aOverflowAreas.Overflow(otype);
- o.height = std::max(o.YMost(), aBEndEdgeOfChildren) - o.y;
+ o.SetBottomEdge(std::max(o.YMost(), aBEndEdgeOfChildren));
}
}
}
void
nsBlockFrame::ComputeOverflowAreas(const nsRect& aBounds,
const nsStyleDisplay* aDisplay,
nscoord aBEndEdgeOfChildren,
@@ -6561,20 +6559,17 @@ static void ComputeVisualOverflowArea(ns
if (y < ya) {
ya = y;
}
if (ymost > yb) {
yb = ymost;
}
}
- aResult.x = xa;
- aResult.y = ya;
- aResult.width = xb - xa;
- aResult.height = yb - ya;
+ aResult.SetBox(xa, ya, xb, yb);
}
#endif
bool
nsBlockFrame::IsVisibleInSelection(nsISelection* aSelection)
{
if (mContent->IsAnyOfHTMLElements(nsGkAtoms::html, nsGkAtoms::body))
return true;
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -863,26 +863,25 @@ nsBulletFrame::CreateBulletRenderer(gfxC
nsRect rect(aPt, mRect.Size());
rect.Deflate(padding);
WritingMode wm = GetWritingMode();
bool isVertical = wm.IsVertical();
bool isClosed =
listStyleType->GetStyle() == NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED;
bool isDown = (!isVertical && !isClosed) || (isVertical && isClosed);
- nscoord diff = NSToCoordRound(0.1f * rect.height);
+ nscoord diff = NSToCoordRound(0.1f * rect.Height());
if (isDown) {
- rect.y += diff * 2;
- rect.height -= diff * 2;
+ rect.SetTopEdge(rect.Y() + diff * 2);
} else {
rect.Deflate(diff, 0);
}
nsPresContext *pc = PresContext();
- rect.x = pc->RoundAppUnitsToNearestDevPixels(rect.x);
- rect.y = pc->RoundAppUnitsToNearestDevPixels(rect.y);
+ rect.MoveTo(pc->RoundAppUnitsToNearestDevPixels(rect.X()),
+ pc->RoundAppUnitsToNearestDevPixels(rect.Y()));
RefPtr<PathBuilder> builder = drawTarget->CreatePathBuilder();
if (isDown) {
// to bottom
builder->MoveTo(NSPointToPoint(rect.TopLeft(), appUnitsPerDevPixel));
builder->LineTo(NSPointToPoint(rect.TopRight(), appUnitsPerDevPixel));
builder->LineTo(NSPointToPoint((rect.BottomLeft() + rect.BottomRight()) / 2,
appUnitsPerDevPixel));
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -1352,21 +1352,19 @@ ScrollFrameHelper::WantAsyncScroll() con
}
static nsRect
GetOnePixelRangeAroundPoint(const nsPoint& aPoint, bool aIsHorizontal)
{
nsRect allowedRange(aPoint, nsSize());
nscoord halfPixel = nsPresContext::CSSPixelsToAppUnits(0.5f);
if (aIsHorizontal) {
- allowedRange.x = aPoint.x - halfPixel;
- allowedRange.width = halfPixel*2 - 1;
+ allowedRange.SetRectX(aPoint.x - halfPixel, halfPixel*2 - 1);
} else {
- allowedRange.y = aPoint.y - halfPixel;
- allowedRange.height = halfPixel*2 - 1;
+ allowedRange.SetRectY(aPoint.y - halfPixel, halfPixel*2 - 1);
}
return allowedRange;
}
void
ScrollFrameHelper::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap)
{
@@ -3782,32 +3780,32 @@ ScrollFrameHelper::DecideScrollableLayer
rootCompBounds += CSSPoint::ToAppUnits(
nsLayoutUtils::GetCumulativeApzCallbackTransform(mOuter));
// We want to limit displayportBase to be no larger than rootCompBounds on
// either axis, but we don't want to just blindly intersect the two, because
// rootCompBounds might be offset from where displayportBase is (see bug
// 1327095 comment 8). Instead, we translate rootCompBounds so as to
// maximize the overlap with displayportBase, and *then* do the intersection.
- if (rootCompBounds.x > displayportBase.x && rootCompBounds.XMost() > displayportBase.XMost()) {
+ if (rootCompBounds.X() > displayportBase.X() && rootCompBounds.XMost() > displayportBase.XMost()) {
// rootCompBounds is at a greater x-position for both left and right, so translate it such
// that the XMost() values are the same. This will line up the right edge of the two rects,
// and might mean that rootCompbounds.x is smaller than displayportBase.x. We can avoid that
// by taking the min of the x delta and XMost() delta, but it doesn't really matter because
// the intersection between the two rects below will end up the same.
- rootCompBounds.x -= (rootCompBounds.XMost() - displayportBase.XMost());
- } else if (rootCompBounds.x < displayportBase.x && rootCompBounds.XMost() < displayportBase.XMost()) {
+ rootCompBounds.MoveByX(-(rootCompBounds.XMost() - displayportBase.XMost()));
+ } else if (rootCompBounds.X() < displayportBase.X() && rootCompBounds.XMost() < displayportBase.XMost()) {
// Analaogous code for when the rootCompBounds is at a smaller x-position.
- rootCompBounds.x = displayportBase.x;
+ rootCompBounds.MoveToX(displayportBase.X());
}
// Do the same for y-axis
- if (rootCompBounds.y > displayportBase.y && rootCompBounds.YMost() > displayportBase.YMost()) {
- rootCompBounds.y -= (rootCompBounds.YMost() - displayportBase.YMost());
- } else if (rootCompBounds.y < displayportBase.y && rootCompBounds.YMost() < displayportBase.YMost()) {
- rootCompBounds.y = displayportBase.y;
+ if (rootCompBounds.Y() > displayportBase.Y() && rootCompBounds.YMost() > displayportBase.YMost()) {
+ rootCompBounds.MoveByY(-(rootCompBounds.YMost() - displayportBase.YMost()));
+ } else if (rootCompBounds.Y() < displayportBase.Y() && rootCompBounds.YMost() < displayportBase.YMost()) {
+ rootCompBounds.MoveToY(displayportBase.Y());
}
// Now we can do the intersection
displayportBase = displayportBase.Intersect(rootCompBounds);
}
}
}
@@ -4843,23 +4841,24 @@ void ScrollFrameHelper::CurPosAttributeC
// updating our scrollbar.
if (mFrameIsUpdatingScrollbar)
return;
nsRect scrolledRect = GetScrolledRect();
nsPoint current = GetScrollPosition() - scrolledRect.TopLeft();
nsPoint dest;
- nsRect allowedRange;
+ nscoord arX, arY, arWidth, arHeight;
dest.x = GetCoordAttribute(mHScrollbarBox, nsGkAtoms::curpos, current.x,
- &allowedRange.x, &allowedRange.width);
+ &arX, &arWidth);
dest.y = GetCoordAttribute(mVScrollbarBox, nsGkAtoms::curpos, current.y,
- &allowedRange.y, &allowedRange.height);
+ &arY, &arHeight);
current += scrolledRect.TopLeft();
dest += scrolledRect.TopLeft();
+ nsRect allowedRange(arX, arY, arWidth, arHeight);
allowedRange += scrolledRect.TopLeft();
// Don't try to scroll if we're already at an acceptable place.
// Don't call Contains here since Contains returns false when the point is
// on the bottom or right edge of the rectangle.
if (allowedRange.ClampPoint(current) == current) {
return;
}
@@ -5024,20 +5023,22 @@ nsXULScrollFrame::AddRemoveScrollbar(nsB
nsSize hSize = mHelper.mHScrollbarBox->GetXULPrefSize(aState);
nsBox::AddMargin(mHelper.mHScrollbarBox, hSize);
mHelper.SetScrollbarVisibility(mHelper.mHScrollbarBox, aAdd);
// We can't directly pass mHasHorizontalScrollbar as the bool outparam for
// AddRemoveScrollbar() because it's a bool:1 bitfield. Hence this var:
bool hasHorizontalScrollbar;
+ nscoord scY = mHelper.mScrollPort.Y();
+ nscoord scHeight = mHelper.mScrollPort.Height();
bool fit = AddRemoveScrollbar(hasHorizontalScrollbar,
- mHelper.mScrollPort.y,
- mHelper.mScrollPort.height,
+ scY, scHeight,
hSize.height, aOnRightOrBottom, aAdd);
+ mHelper.mScrollPort.SetRectY(scY, scHeight);
mHelper.mHasHorizontalScrollbar = hasHorizontalScrollbar;
if (!fit) {
mHelper.SetScrollbarVisibility(mHelper.mHScrollbarBox, !aAdd);
}
return fit;
} else {
if (mHelper.mNeverHasVerticalScrollbar || !mHelper.mVScrollbarBox)
return false;
@@ -5045,20 +5046,22 @@ nsXULScrollFrame::AddRemoveScrollbar(nsB
nsSize vSize = mHelper.mVScrollbarBox->GetXULPrefSize(aState);
nsBox::AddMargin(mHelper.mVScrollbarBox, vSize);
mHelper.SetScrollbarVisibility(mHelper.mVScrollbarBox, aAdd);
// We can't directly pass mHasVerticalScrollbar as the bool outparam for
// AddRemoveScrollbar() because it's a bool:1 bitfield. Hence this var:
bool hasVerticalScrollbar;
+ nscoord scX = mHelper.mScrollPort.X();
+ nscoord scWidth = mHelper.mScrollPort.Width();
bool fit = AddRemoveScrollbar(hasVerticalScrollbar,
- mHelper.mScrollPort.x,
- mHelper.mScrollPort.width,
+ scX, scWidth,
vSize.width, aOnRightOrBottom, aAdd);
+ mHelper.mScrollPort.SetRectX(scX, scWidth);
mHelper.mHasVerticalScrollbar = hasVerticalScrollbar;
if (!fit) {
mHelper.SetScrollbarVisibility(mHelper.mVScrollbarBox, !aAdd);
}
return fit;
}
}
@@ -5708,56 +5711,53 @@ ScrollFrameHelper::AdjustScrollbarRectFo
else {
nsPoint offset;
nsIWidget* widget = aFrame->GetNearestWidget(offset);
LayoutDeviceIntRect widgetRect;
if (!widget || !widget->ShowsResizeIndicator(&widgetRect)) {
return;
}
- resizerRect = nsRect(aPresContext->DevPixelsToAppUnits(widgetRect.x) - offset.x,
- aPresContext->DevPixelsToAppUnits(widgetRect.y) - offset.y,
- aPresContext->DevPixelsToAppUnits(widgetRect.width),
- aPresContext->DevPixelsToAppUnits(widgetRect.height));
+ resizerRect = nsRect(aPresContext->DevPixelsToAppUnits(widgetRect.X()) - offset.x,
+ aPresContext->DevPixelsToAppUnits(widgetRect.Y()) - offset.y,
+ aPresContext->DevPixelsToAppUnits(widgetRect.Width()),
+ aPresContext->DevPixelsToAppUnits(widgetRect.Height()));
}
if (resizerRect.Contains(aRect.BottomRight() - nsPoint(1, 1))) {
if (aVertical) {
- aRect.height = std::max(0, resizerRect.y - aRect.y);
+ aRect.SetHeight(std::max(0, resizerRect.Y() - aRect.Y()));
} else {
- aRect.width = std::max(0, resizerRect.x - aRect.x);
+ aRect.SetWidth(std::max(0, resizerRect.X() - aRect.X()));
}
} else if (resizerRect.Contains(aRect.BottomLeft() + nsPoint(1, -1))) {
if (aVertical) {
- aRect.height = std::max(0, resizerRect.y - aRect.y);
+ aRect.SetHeight(std::max(0, resizerRect.Y() - aRect.Y()));
} else {
- nscoord xmost = aRect.XMost();
- aRect.x = std::max(aRect.x, resizerRect.XMost());
- aRect.width = xmost - aRect.x;
+ aRect.SetLeftEdge(std::max(aRect.X(), resizerRect.XMost()));
}
}
}
static void
AdjustOverlappingScrollbars(nsRect& aVRect, nsRect& aHRect)
{
if (aVRect.IsEmpty() || aHRect.IsEmpty())
return;
const nsRect oldVRect = aVRect;
const nsRect oldHRect = aHRect;
if (oldVRect.Contains(oldHRect.BottomRight() - nsPoint(1, 1))) {
- aHRect.width = std::max(0, oldVRect.x - oldHRect.x);
+ aHRect.SetWidth(std::max(0, oldVRect.X() - oldHRect.X()));
} else if (oldVRect.Contains(oldHRect.BottomLeft() - nsPoint(0, 1))) {
- nscoord overlap = std::min(oldHRect.width, oldVRect.XMost() - oldHRect.x);
- aHRect.x += overlap;
- aHRect.width -= overlap;
+ nscoord overlap = std::min(oldHRect.Width(), oldVRect.XMost() - oldHRect.X());
+ aHRect.SetLeftEdge(aHRect.X() + overlap);
}
if (oldHRect.Contains(oldVRect.BottomRight() - nsPoint(1, 1))) {
- aVRect.height = std::max(0, oldHRect.y - oldVRect.y);
+ aVRect.SetHeight(std::max(0, oldHRect.Y() - oldVRect.Y()));
}
}
void
ScrollFrameHelper::LayoutScrollbars(nsBoxLayoutState& aState,
const nsRect& aContentArea,
const nsRect& aOldScrollArea)
{
@@ -5779,34 +5779,31 @@ ScrollFrameHelper::LayoutScrollbars(nsBo
res = presShell->GetCumulativeResolution();
}
// place the scrollcorner
if (mScrollCornerBox || mResizerBox) {
NS_PRECONDITION(!mScrollCornerBox || mScrollCornerBox->IsXULBoxFrame(), "Must be a box frame!");
nsRect r(0, 0, 0, 0);
- if (aContentArea.x != mScrollPort.x || scrollbarOnLeft) {
+ if (aContentArea.X() != mScrollPort.X() || scrollbarOnLeft) {
// scrollbar (if any) on left
- r.x = aContentArea.x;
- r.width = mScrollPort.x - aContentArea.x;
- NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect");
+ r.SetBoxX(aContentArea.X(), mScrollPort.X());
+ NS_ASSERTION(r.Width() >= 0, "Scroll area should be inside client rect");
} else {
// scrollbar (if any) on right
- r.width = aContentArea.XMost() - mScrollPort.XMost();
- r.x = aContentArea.XMost() - r.width;
- NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect");
+ r.SetBoxX(mScrollPort.XMost(), aContentArea.XMost());
+ NS_ASSERTION(r.Width() >= 0, "Scroll area should be inside client rect");
}
- if (aContentArea.y != mScrollPort.y) {
+ if (aContentArea.Y() != mScrollPort.Y()) {
NS_ERROR("top scrollbars not supported");
} else {
// scrollbar (if any) on bottom
- r.height = aContentArea.YMost() - mScrollPort.YMost();
- r.y = aContentArea.YMost() - r.height;
- NS_ASSERTION(r.height >= 0, "Scroll area should be inside client rect");
+ r.SetBoxY(mScrollPort.YMost(), aContentArea.YMost());
+ NS_ASSERTION(r.Height() >= 0, "Scroll area should be inside client rect");
}
if (mScrollCornerBox) {
nsBoxFrame::LayoutChildAt(aState, mScrollCornerBox, r);
}
if (hasResizer) {
// if a resizer is present, get its size. Assume a default size of 15 pixels.
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -419,28 +419,31 @@ nsImageFrame::SourceRectToDest(const nsI
nsTransform2D sourceToDest;
if (!GetSourceToDestTransform(sourceToDest)) {
// Failed to generate transform matrix. Return our whole inner area,
// to be on the safe side (since this method is used for generating
// invalidation rects).
return GetInnerArea();
}
- sourceToDest.TransformCoord(&r.x, &r.y, &r.width, &r.height);
+ auto rX = r.X();
+ auto rY = r.Y();
+ auto rWidth = r.Width();
+ auto rHeight = r.Height();
+ sourceToDest.TransformCoord(&rX, &rY, &rWidth, &rHeight);
// Now, round the edges out to the pixel boundary.
nscoord scale = nsPresContext::CSSPixelsToAppUnits(1);
- nscoord right = r.x + r.width;
- nscoord bottom = r.y + r.height;
+ nscoord right = rX + rWidth;
+ nscoord bottom = rY + rHeight;
- r.x -= (scale + (r.x % scale)) % scale;
- r.y -= (scale + (r.y % scale)) % scale;
- r.width = right + ((scale - (right % scale)) % scale) - r.x;
- r.height = bottom + ((scale - (bottom % scale)) % scale) - r.y;
-
+ r.SetBox(rX - (scale + (rX % scale)) % scale,
+ rY - (scale + (rY % scale)) % scale,
+ right + ((scale - (right % scale)) % scale),
+ bottom + ((scale - (bottom % scale)) % scale));
return r;
}
// Note that we treat NS_EVENT_STATE_SUPPRESSED images as "OK". This means
// that we'll construct image frames for them as needed if their display is
// toggled from "none" (though we won't paint them, unless their visibility
// is changed too).
#define BAD_STATES (NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_USERDISABLED | \
@@ -1484,23 +1487,23 @@ nsImageFrame::DisplayAltFeedback(gfxCont
drawTarget->Fill(ellipse, color);
}
// Reduce the inner rect by the width of the icon, and leave an
// additional ICON_PADDING pixels for padding
int32_t paddedIconSize =
nsPresContext::CSSPixelsToAppUnits(ICON_SIZE + ICON_PADDING);
if (wm.IsVertical()) {
- inner.y += paddedIconSize;
- inner.height -= paddedIconSize;
+ inner.MoveByY(paddedIconSize);
+ inner.SetHeight(inner.Height() - paddedIconSize);
} else {
if (!flushRight) {
- inner.x += paddedIconSize;
+ inner.MoveByX(paddedIconSize);
}
- inner.width -= paddedIconSize;
+ inner.SetWidth(inner.Width() - paddedIconSize);
}
}
// If there's still room, display the alt-text
if (!inner.IsEmpty()) {
nsIContent* content = GetContent();
if (content) {
nsAutoString altText;
--- a/layout/generic/nsPageFrame.cpp
+++ b/layout/generic/nsPageFrame.cpp
@@ -525,20 +525,20 @@ nsPageFrame::BuildDisplayList(nsDisplayL
if (clipRect.Height() > expectedPageContentHeight) {
// We're doing print-selection, with one long page-content frame.
// Clip to the appropriate page-content slice for the current page.
NS_ASSERTION(mPageNum > 0, "page num should be positive");
// Note: The pageContentFrame's y-position has been set such that a zero
// y-value matches the top edge of the current page. So, to clip to the
// current page's content (in coordinates *relative* to the page content
// frame), we just negate its y-position and add the top margin.
- clipRect.y = NSToCoordCeil((-child->GetRect().y +
- mPD->mReflowMargin.top) / scale);
- clipRect.height = expectedPageContentHeight;
- NS_ASSERTION(clipRect.y < child->GetSize().height,
+ clipRect.SetRectY(NSToCoordCeil((-child->GetRect().Y() +
+ mPD->mReflowMargin.top) / scale),
+ expectedPageContentHeight);
+ NS_ASSERTION(clipRect.Y() < child->GetSize().height,
"Should be clipping to region inside the page content bounds");
}
clipRect += aBuilder->ToReferenceFrame(child);
nsDisplayList content;
{
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -7298,27 +7298,27 @@ nsTextFrame::DrawTextRunAndDecorations(R
gfxRect clipRect;
if (!skipClipping) {
// Get the inline-size according to the specified range.
gfxFloat clipLength = mTextRun->GetAdvanceWidth(aRange, aParams.provider);
nsRect visualRect = GetVisualOverflowRect();
const bool isInlineReversed = mTextRun->IsInlineReversed();
if (verticalDec) {
- clipRect.x = aParams.framePt.x + visualRect.x;
- clipRect.y = isInlineReversed ? aTextBaselinePt.y - clipLength
- : aTextBaselinePt.y;
- clipRect.width = visualRect.width;
- clipRect.height = clipLength;
+ clipRect.SetRect(aParams.framePt.x + visualRect.X(),
+ isInlineReversed ? aTextBaselinePt.y - clipLength
+ : aTextBaselinePt.y,
+ visualRect.Width(),
+ clipLength);
} else {
- clipRect.x = isInlineReversed ? aTextBaselinePt.x - clipLength
- : aTextBaselinePt.x;
- clipRect.y = aParams.framePt.y + visualRect.y;
- clipRect.width = clipLength;
- clipRect.height = visualRect.height;
+ clipRect.SetRect(isInlineReversed ? aTextBaselinePt.x - clipLength
+ : aTextBaselinePt.x,
+ aParams.framePt.y + visualRect.Y(),
+ clipLength,
+ visualRect.Height());
}
clipRect.Scale(1 / app);
clipRect.Round();
params.context->Clip(clipRect);
}
// Underlines
@@ -7846,24 +7846,22 @@ nsTextFrame::GetCharacterRectsInRange(in
gfxFloat advance =
mTextRun->GetAdvanceWidth(Range(iter.GetSkippedOffset(),
nextIter.GetSkippedOffset()),
&properties);
iSize = NSToCoordCeilClamped(advance);
}
if (mTextRun->IsVertical()) {
- rect.width = mRect.width;
- rect.height = iSize;
+ rect.SizeTo(mRect.Width(), iSize);
} else {
- rect.width = iSize;
- rect.height = mRect.height;
+ rect.SizeTo(iSize, mRect.Height());
if (StyleContext()->IsTextCombined()) {
- rect.width *= GetTextCombineScaleFactor(this);
+ rect.SetWidth(rect.Width() * GetTextCombineScaleFactor(this));
}
}
aRects.AppendElement(rect);
aInOffset++;
// Don't advance iter if we've reached the end
if (aInOffset < kEndOffset) {
iter.AdvanceOriginal(1);
}
@@ -8885,20 +8883,19 @@ nsTextFrame::ComputeSize(gfxContext *aRe
// Inlines and text don't compute size before reflow.
return LogicalSize(aWM, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
}
static nsRect
RoundOut(const gfxRect& aRect)
{
nsRect r;
- r.x = NSToCoordFloor(aRect.X());
- r.y = NSToCoordFloor(aRect.Y());
- r.width = NSToCoordCeil(aRect.XMost()) - r.x;
- r.height = NSToCoordCeil(aRect.YMost()) - r.y;
+ r.MoveTo(NSToCoordFloor(aRect.X()), NSToCoordFloor(aRect.Y()));
+ r.SizeTo(NSToCoordCeil(aRect.XMost()) - r.X(),
+ NSToCoordCeil(aRect.YMost()) - r.Y());
return r;
}
nsRect
nsTextFrame::ComputeTightBounds(DrawTarget* aDrawTarget) const
{
if (StyleContext()->HasTextDecorationLines() ||
(GetStateBits() & TEXT_HYPHEN_BREAK)) {
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -2033,19 +2033,17 @@ nsMathMLChar::ApplyTransforms(gfxContext
gfxPoint devPixelOffset(NSAppUnitsToFloatPixels(pt.x, aAppUnitsPerGfxUnit),
NSAppUnitsToFloatPixels(pt.y, aAppUnitsPerGfxUnit));
aThebesContext->SetMatrixDouble(
aThebesContext->CurrentMatrixDouble().PreTranslate(devPixelOffset).
PreScale(mScaleX, mScaleY));
}
// update the bounding rectangle.
- r.x = r.y = 0;
- r.width /= mScaleX;
- r.height /= mScaleY;
+ r.SetRect(0, 0, r.Width() / mScaleX, r.Height() / mScaleY);
}
void
nsMathMLChar::PaintForeground(nsIFrame* aForFrame,
gfxContext& aRenderingContext,
nsPoint aPt,
bool aIsSelected)
{
@@ -2198,19 +2196,19 @@ nsMathMLChar::PaintVertically(nsPresCont
for (i = 0; i < 2; ++i) {
if (end[i] > start[i+1]) {
end[i] = (end[i] + start[i+1]) / 2;
start[i+1] = end[i];
}
}
nsRect unionRect = aRect;
- unionRect.x += mBoundingMetrics.leftBearing;
- unionRect.width =
- mBoundingMetrics.rightBearing - mBoundingMetrics.leftBearing;
+ unionRect.SetRectX(unionRect.X() + mBoundingMetrics.leftBearing,
+ mBoundingMetrics.rightBearing -
+ mBoundingMetrics.leftBearing);
unionRect.Inflate(oneDevPixel, oneDevPixel);
gfxTextRun::DrawParams params(aThebesContext);
/////////////////////////////////////
// draw top, middle, bottom
for (i = 0; i <= 2; ++i) {
// glue can be null
@@ -2220,25 +2218,23 @@ nsMathMLChar::PaintVertically(nsPresCont
// pending outside
nsRect clipRect = unionRect;
// Clip at the join to get a solid edge (without overlap or gap), when
// this won't change the glyph too much. If the glyph is too small to
// clip then we'll overlap rather than have a gap.
nscoord height = mBmData[i].ascent + mBmData[i].descent;
if (height * (1.0 - NS_MATHML_DELIMITER_FACTOR) > oneDevPixel) {
if (0 == i) { // top
- clipRect.height = end[i] - clipRect.y;
+ clipRect.SetBottomEdge(end[i]);
}
else if (2 == i) { // bottom
- clipRect.height -= start[i] - clipRect.y;
- clipRect.y = start[i];
+ clipRect.SetTopEdge(start[i]);
}
else { // middle
- clipRect.y = start[i];
- clipRect.height = end[i] - start[i];
+ clipRect.SetBoxY(start[i], end[i]);
}
}
if (!clipRect.IsEmpty()) {
AutoPushClipRect clip(aThebesContext, oneDevPixel, clipRect);
mGlyphs[i]->Draw(Range(mGlyphs[i].get()), gfx::Point(dx, dy), params);
}
}
}
@@ -2330,29 +2326,29 @@ nsMathMLChar::PaintHorizontally(nsPresCo
DrawTarget& aDrawTarget = *aThebesContext->GetDrawTarget();
// Get the device pixel size in the horizontal direction.
// (This makes no effort to optimize for non-translation transformations.)
nscoord oneDevPixel = aPresContext->AppUnitsPerDevPixel();
// get metrics data to be re-used later
int32_t i = 0;
- nscoord dy = aRect.y + mBoundingMetrics.ascent;
+ nscoord dy = aRect.Y() + mBoundingMetrics.ascent;
nscoord offset[3], start[3], end[3];
for (i = 0; i <= 2; ++i) {
const nsBoundingMetrics& bm = mBmData[i];
nscoord dx;
if (0 == i) { // left
- dx = aRect.x - bm.leftBearing;
+ dx = aRect.X() - bm.leftBearing;
}
else if (2 == i) { // right
- dx = aRect.x + aRect.width - bm.rightBearing;
+ dx = aRect.XMost() - bm.rightBearing;
}
else { // middle
- dx = aRect.x + (aRect.width - bm.width)/2;
+ dx = aRect.X() + (aRect.Width() - bm.width)/2;
}
// _cairo_scaled_font_show_glyphs snaps origins to device pixels.
// Do this now so that we can get the other dimensions right.
// (This may not achieve much with non-rectangular transformations.)
dx = SnapToDevPixels(aThebesContext, oneDevPixel, nsPoint(dx, dy)).x;
// abcissa passed to Draw
offset[i] = dx;
// _cairo_scaled_font_glyph_device_extents rounds outwards to the nearest
@@ -2390,25 +2386,23 @@ nsMathMLChar::PaintHorizontally(nsPresCo
nscoord dx = offset[i];
nsRect clipRect = unionRect;
// Clip at the join to get a solid edge (without overlap or gap), when
// this won't change the glyph too much. If the glyph is too small to
// clip then we'll overlap rather than have a gap.
nscoord width = mBmData[i].rightBearing - mBmData[i].leftBearing;
if (width * (1.0 - NS_MATHML_DELIMITER_FACTOR) > oneDevPixel) {
if (0 == i) { // left
- clipRect.width = end[i] - clipRect.x;
+ clipRect.SetRightEdge(end[i]);
}
else if (2 == i) { // right
- clipRect.width -= start[i] - clipRect.x;
- clipRect.x = start[i];
+ clipRect.SetLeftEdge(start[i]);
}
else { // middle
- clipRect.x = start[i];
- clipRect.width = end[i] - start[i];
+ clipRect.SetBoxX(start[i], end[i]);
}
}
if (!clipRect.IsEmpty()) {
AutoPushClipRect clip(aThebesContext, oneDevPixel, clipRect);
mGlyphs[i]->Draw(Range(mGlyphs[i].get()), gfx::Point(dx, dy), params);
}
}
}
--- a/layout/painting/MaskLayerImageCache.h
+++ b/layout/painting/MaskLayerImageCache.h
@@ -104,17 +104,17 @@ public:
}
bool operator!=(const PixelRoundedRect& aOther) const {
return !(*this == aOther);
}
// Create a hash for this object.
PLDHashNumber Hash() const
{
- PLDHashNumber hash = HashBytes(&mRect.x, 4*sizeof(gfxFloat));
+ PLDHashNumber hash = HashBytes(&mRect, sizeof(mRect));
hash = AddToHash(hash, HashBytes(mRadii, 8*sizeof(gfxFloat)));
return hash;
}
gfx::Rect mRect;
// Indices into mRadii are the enum HalfCorner constants in gfx/2d/Types.h
gfxFloat mRadii[8];
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -526,26 +526,33 @@ JoinBoxesForBlockAxisSlice(nsIFrame* aFr
nscoord bSize = 0;
auto wm = aFrame->GetWritingMode();
nsIFrame* f = aFrame->GetNextContinuation();
for (; f; f = f->GetNextContinuation()) {
MOZ_ASSERT(!(f->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT),
"anonymous ib-split block shouldn't have border/background");
bSize += f->BSize(wm);
}
- (wm.IsVertical() ? borderArea.width : borderArea.height) += bSize;
+ if (wm.IsVertical()) {
+ borderArea.SetWidth(borderArea.Width() + bSize);
+ } else {
+ borderArea.SetHeight(borderArea.Height() + bSize);
+ }
bSize = 0;
f = aFrame->GetPrevContinuation();
for (; f; f = f->GetPrevContinuation()) {
MOZ_ASSERT(!(f->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT),
"anonymous ib-split block shouldn't have border/background");
bSize += f->BSize(wm);
}
- (wm.IsVertical() ? borderArea.x : borderArea.y) -= bSize;
- (wm.IsVertical() ? borderArea.width : borderArea.height) += bSize;
+ if (wm.IsVertical()) {
+ borderArea.SetLeftEdge(borderArea.X() - bSize);
+ } else {
+ borderArea.SetTopEdge(borderArea.Y() - bSize);
+ }
return borderArea;
}
/**
* Inflate aBorderArea which is relative to aFrame's origin to calculate
* a hypothetical non-split frame area for all the continuations.
* See "Joining Boxes for 'slice'" in
* http://dev.w3.org/csswg/css-break/#break-decoration
@@ -1718,38 +1725,28 @@ nsCSSRendering::PaintBoxShadowOuter(nsPr
aRenderingContext.Clip(path);
}
// Clip the shadow so that we only get the part that applies to aForFrame.
nsRect fragmentClip = shadowRectPlusBlur;
Sides skipSides = aForFrame->GetSkipSides();
if (!skipSides.IsEmpty()) {
if (skipSides.Left()) {
- nscoord xmost = fragmentClip.XMost();
- fragmentClip.x = aFrameArea.x;
- fragmentClip.width = xmost - fragmentClip.x;
+ fragmentClip.SetLeftEdge(aFrameArea.X());
}
if (skipSides.Right()) {
- nscoord xmost = fragmentClip.XMost();
- nscoord overflow = xmost - aFrameArea.XMost();
- if (overflow > 0) {
- fragmentClip.width -= overflow;
- }
+ fragmentClip.SetRightEdge(std::min(fragmentClip.XMost(),
+ aFrameArea.XMost()));
}
if (skipSides.Top()) {
- nscoord ymost = fragmentClip.YMost();
- fragmentClip.y = aFrameArea.y;
- fragmentClip.height = ymost - fragmentClip.y;
+ fragmentClip.SetTopEdge(aFrameArea.Y());
}
if (skipSides.Bottom()) {
- nscoord ymost = fragmentClip.YMost();
- nscoord overflow = ymost - aFrameArea.YMost();
- if (overflow > 0) {
- fragmentClip.height -= overflow;
- }
+ fragmentClip.SetBottomEdge(std::min(fragmentClip.YMost(),
+ aFrameArea.YMost()));
}
}
fragmentClip = fragmentClip.Intersect(aDirtyRect);
aRenderingContext.
Clip(NSRectToSnappedRect(fragmentClip,
aForFrame->PresContext()->AppUnitsPerDevPixel(),
aDrawTarget));
@@ -3608,48 +3605,46 @@ nsCSSRendering::DrawTableBorderSegment(D
? RoundFloatToPixel(((float)dashLength) / 2.0f,
aAppUnitsPerDevPixel)
: dashLength;
minDashLength = std::max(minDashLength, oneDevPixel);
nscoord numDashSpaces = 0;
nscoord startDashLength = minDashLength;
nscoord endDashLength = minDashLength;
if (horizontal) {
- GetDashInfo(aBorder.width, dashLength, aAppUnitsPerDevPixel,
+ GetDashInfo(aBorder.Width(), dashLength, aAppUnitsPerDevPixel,
numDashSpaces, startDashLength, endDashLength);
- nsRect rect(aBorder.x, aBorder.y, startDashLength, aBorder.height);
+ nsRect rect(aBorder.X(), aBorder.Y(), startDashLength, aBorder.Height());
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel);
- rect.x += startDashLength + dashLength;
- rect.width = aBorder.width
- - (startDashLength + endDashLength + dashLength);
+ rect.SetRectX(rect.X() + startDashLength + dashLength,
+ aBorder.Width()
+ - (startDashLength + endDashLength + dashLength));
DrawDashedSegment(aDrawTarget, rect, dashLength, aBorderColor,
aAppUnitsPerDevPixel, horizontal);
- rect.x += rect.width;
- rect.width = endDashLength;
+ rect.SetRectX(rect.XMost(), endDashLength);
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel);
}
else {
- GetDashInfo(aBorder.height, dashLength, aAppUnitsPerDevPixel,
+ GetDashInfo(aBorder.Height(), dashLength, aAppUnitsPerDevPixel,
numDashSpaces, startDashLength, endDashLength);
- nsRect rect(aBorder.x, aBorder.y, aBorder.width, startDashLength);
+ nsRect rect(aBorder.X(), aBorder.Y(), aBorder.Width(), startDashLength);
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel);
- rect.y += rect.height + dashLength;
- rect.height = aBorder.height
- - (startDashLength + endDashLength + dashLength);
+ rect.SetRectY(rect.YMost() + dashLength,
+ aBorder.Height()
+ - (startDashLength + endDashLength + dashLength));
DrawDashedSegment(aDrawTarget, rect, dashLength, aBorderColor,
aAppUnitsPerDevPixel, horizontal);
- rect.y += rect.height;
- rect.height = endDashLength;
+ rect.SetRectY(rect.YMost(), endDashLength);
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel);
}
}
break;
case NS_STYLE_BORDER_STYLE_GROOVE:
ridgeGroove = NS_STYLE_BORDER_STYLE_GROOVE; // and fall through to ridge
MOZ_FALLTHROUGH;
@@ -3672,78 +3667,75 @@ nsCSSRendering::DrawTableBorderSegment(D
mozilla::Side ridgeGrooveSide = (horizontal) ? eSideTop : eSideLeft;
// FIXME: In theory, this should use the visited-dependent
// background color, but I don't care.
nscolor bevelColor = MakeBevelColor(ridgeGrooveSide, ridgeGroove,
aBGColor, aBorderColor);
nsRect rect(aBorder);
nscoord half;
if (horizontal) { // top, bottom
- half = RoundFloatToPixel(0.5f * (float)aBorder.height,
+ half = RoundFloatToPixel(0.5f * (float)aBorder.Height(),
aAppUnitsPerDevPixel);
- rect.height = half;
+ rect.SetHeight(half);
if (eSideTop == aStartBevelSide) {
- rect.x += startBevel;
- rect.width -= startBevel;
+ rect.SetLeftEdge(rect.X() + startBevel);
}
if (eSideTop == aEndBevelSide) {
- rect.width -= endBevel;
+ rect.SetRightEdge(rect.XMost() - endBevel);
}
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
}
else { // left, right
- half = RoundFloatToPixel(0.5f * (float)aBorder.width,
+ half = RoundFloatToPixel(0.5f * (float)aBorder.Width(),
aAppUnitsPerDevPixel);
- rect.width = half;
+ rect.SetWidth(half);
if (eSideLeft == aStartBevelSide) {
- rect.y += startBevel;
- rect.height -= startBevel;
+ rect.SetTopEdge(rect.Y() + startBevel);
}
if (eSideLeft == aEndBevelSide) {
- rect.height -= endBevel;
+ rect.SetBottomEdge(rect.YMost() - endBevel);
}
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
}
rect = aBorder;
ridgeGrooveSide = (eSideTop == ridgeGrooveSide) ? eSideBottom : eSideRight;
// FIXME: In theory, this should use the visited-dependent
// background color, but I don't care.
bevelColor = MakeBevelColor(ridgeGrooveSide, ridgeGroove,
aBGColor, aBorderColor);
if (horizontal) {
- rect.y = rect.y + half;
- rect.height = aBorder.height - half;
+ rect.SetRectY(rect.Y() + half,
+ aBorder.Height() - half);
if (eSideBottom == aStartBevelSide) {
- rect.x += startBevel;
- rect.width -= startBevel;
+ rect.SetLeftEdge(rect.X() + startBevel);
}
if (eSideBottom == aEndBevelSide) {
- rect.width -= endBevel;
+ rect.SetRightEdge(rect.XMost() - endBevel);
}
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
}
else {
- rect.x = rect.x + half;
- rect.width = aBorder.width - half;
+ rect.SetRectX(rect.X() + half,
+ aBorder.Width() - half);
if (eSideRight == aStartBevelSide) {
- rect.y += aStartBevelOffset - startBevel;
- rect.height -= startBevel;
+ rect.SetRectY(rect.Y() + aStartBevelOffset - startBevel,
+ rect.Height() - startBevel);
}
if (eSideRight == aEndBevelSide) {
- rect.height -= endBevel;
+ rect.SetBottomEdge(rect.YMost() - endBevel);
}
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
}
}
break;
@@ -3758,73 +3750,71 @@ nsCSSRendering::DrawTableBorderSegment(D
(float)aStartBevelOffset,
aAppUnitsPerDevPixel) : 0;
nscoord endBevel = (aEndBevelOffset > 0)
? RoundFloatToPixel(0.333333f *
(float)aEndBevelOffset,
aAppUnitsPerDevPixel) : 0;
if (horizontal) { // top, bottom
nscoord thirdHeight = RoundFloatToPixel(0.333333f *
- (float)aBorder.height,
+ (float)aBorder.Height(),
aAppUnitsPerDevPixel);
// draw the top line or rect
- nsRect topRect(aBorder.x, aBorder.y, aBorder.width, thirdHeight);
+ nsRect topRect(aBorder.X(), aBorder.Y(), aBorder.Width(), thirdHeight);
if (eSideTop == aStartBevelSide) {
- topRect.x += aStartBevelOffset - startBevel;
- topRect.width -= aStartBevelOffset - startBevel;
+ topRect.SetLeftEdge(topRect.X() + aStartBevelOffset - startBevel);
}
if (eSideTop == aEndBevelSide) {
- topRect.width -= aEndBevelOffset - endBevel;
+ topRect.SetRightEdge(topRect.XMost() - (aEndBevelOffset - endBevel));
}
DrawSolidBorderSegment(aDrawTarget, topRect, aBorderColor,
aAppUnitsPerDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
// draw the botom line or rect
- nscoord heightOffset = aBorder.height - thirdHeight;
- nsRect bottomRect(aBorder.x, aBorder.y + heightOffset, aBorder.width, aBorder.height - heightOffset);
+ nscoord heightOffset = aBorder.Height() - thirdHeight;
+ nsRect bottomRect(aBorder.X(), aBorder.Y() + heightOffset,
+ aBorder.Width(), aBorder.Height() - heightOffset);
if (eSideBottom == aStartBevelSide) {
- bottomRect.x += aStartBevelOffset - startBevel;
- bottomRect.width -= aStartBevelOffset - startBevel;
+ bottomRect.SetLeftEdge(bottomRect.X() + aStartBevelOffset - startBevel);
}
if (eSideBottom == aEndBevelSide) {
- bottomRect.width -= aEndBevelOffset - endBevel;
+ bottomRect.SetRightEdge(bottomRect.XMost() - (aEndBevelOffset - endBevel));
}
DrawSolidBorderSegment(aDrawTarget, bottomRect, aBorderColor,
aAppUnitsPerDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
}
else { // left, right
- nscoord thirdWidth = RoundFloatToPixel(0.333333f * (float)aBorder.width,
+ nscoord thirdWidth = RoundFloatToPixel(0.333333f * (float)aBorder.Width(),
aAppUnitsPerDevPixel);
- nsRect leftRect(aBorder.x, aBorder.y, thirdWidth, aBorder.height);
+ nsRect leftRect(aBorder.X(), aBorder.Y(), thirdWidth, aBorder.Height());
if (eSideLeft == aStartBevelSide) {
- leftRect.y += aStartBevelOffset - startBevel;
- leftRect.height -= aStartBevelOffset - startBevel;
+ leftRect.SetTopEdge(leftRect.Y() + aStartBevelOffset - startBevel);
}
if (eSideLeft == aEndBevelSide) {
- leftRect.height -= aEndBevelOffset - endBevel;
+ leftRect.SetBottomEdge(leftRect.YMost() - (aEndBevelOffset - endBevel));
}
DrawSolidBorderSegment(aDrawTarget, leftRect, aBorderColor,
aAppUnitsPerDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
- nscoord widthOffset = aBorder.width - thirdWidth;
- nsRect rightRect(aBorder.x + widthOffset, aBorder.y, aBorder.width - widthOffset, aBorder.height);
+ nscoord widthOffset = aBorder.Width() - thirdWidth;
+ nsRect rightRect(aBorder.X() + widthOffset, aBorder.Y(),
+ aBorder.Width() - widthOffset, aBorder.Height());
if (eSideRight == aStartBevelSide) {
- rightRect.y += aStartBevelOffset - startBevel;
- rightRect.height -= aStartBevelOffset - startBevel;
+ rightRect.SetTopEdge(rightRect.Y() + aStartBevelOffset - startBevel);
}
if (eSideRight == aEndBevelSide) {
- rightRect.height -= aEndBevelOffset - endBevel;
+ rightRect.SetBottomEdge(rightRect.YMost() - (aEndBevelOffset - endBevel));
}
DrawSolidBorderSegment(aDrawTarget, rightRect, aBorderColor,
aAppUnitsPerDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
}
break;
}
@@ -3884,21 +3874,19 @@ nsCSSRendering::ExpandPaintingRectForDec
nsPresContext *pc = aFrame->PresContext();
Float framePosInBlock = Float(pc->AppUnitsToGfxUnits(framePosInBlockAppUnits));
int32_t rectPosInBlock =
int32_t(NS_round(framePosInBlock + aICoordInFrame));
int32_t extraStartEdge =
rectPosInBlock - (rectPosInBlock / int32_t(aCycleLength) * aCycleLength);
Rect rect(aClippedRect);
if (aVertical) {
- rect.y -= extraStartEdge;
- rect.height += extraStartEdge;
+ rect.SetTopEdge(rect.Y() - extraStartEdge);
} else {
- rect.x -= extraStartEdge;
- rect.width += extraStartEdge;
+ rect.SetLeftEdge(rect.X() - extraStartEdge);
}
return rect;
}
void
nsCSSRendering::PaintDecorationLine(nsIFrame* aFrame, DrawTarget& aDrawTarget,
const PaintDecorationLineParams& aParams)
{
@@ -3945,17 +3933,17 @@ nsCSSRendering::PaintDecorationLine(nsIF
strokeOptions.mDashPattern = dash;
strokeOptions.mDashLength = MOZ_ARRAY_LENGTH(dash);
strokeOptions.mLineCap = CapStyle::BUTT;
rect = ExpandPaintingRectForDecorationLine(aFrame, aParams.style,
rect, aParams.icoordInFrame,
dashWidth * 2,
aParams.vertical);
// We should continue to draw the last dash even if it is not in the rect.
- rect.width += dashWidth;
+ rect.SetWidth(rect.Width() + dashWidth);
break;
}
case NS_STYLE_TEXT_DECORATION_STYLE_DOTTED: {
autoPopClips.PushClipRect(rect);
Float dashWidth = lineThickness * DOT_LENGTH;
if (lineThickness > 2.0) {
dash[0] = 0.f;
dash[1] = dashWidth * 2.f;
@@ -3966,17 +3954,17 @@ nsCSSRendering::PaintDecorationLine(nsIF
}
strokeOptions.mDashPattern = dash;
strokeOptions.mDashLength = MOZ_ARRAY_LENGTH(dash);
rect = ExpandPaintingRectForDecorationLine(aFrame, aParams.style,
rect, aParams.icoordInFrame,
dashWidth * 2,
aParams.vertical);
// We should continue to draw the last dot even if it is not in the rect.
- rect.width += dashWidth;
+ rect.SetWidth(rect.Width() + dashWidth);
break;
}
case NS_STYLE_TEXT_DECORATION_STYLE_WAVY:
autoPopClips.PushClipRect(rect);
if (lineThickness > 2.0) {
drawOptions.mAntialiasMode = AntialiasMode::SUBPIXEL;
} else {
// Don't use anti-aliasing here. Because looks like lighter color wavy
@@ -4025,19 +4013,19 @@ nsCSSRendering::PaintDecorationLine(nsIF
* |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX| | lineThickness
* |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX| v
* +-------------------------------------------+
*/
Point p1a = rect.TopLeft();
Point p2a = aParams.vertical ? rect.BottomLeft() : rect.TopRight();
if (aParams.vertical) {
- rect.width -= lineThickness;
+ rect.SetWidth(rect.Width() - lineThickness);
} else {
- rect.height -= lineThickness;
+ rect.SetHeight(rect.Height() - lineThickness);
}
Point p1b = aParams.vertical ? rect.TopRight() : rect.BottomLeft();
Point p2b = rect.BottomRight();
if (textDrawer) {
textDrawer->AppendDecoration(
p1a, p2a, lineThickness, aParams.vertical, color,
--- a/layout/painting/nsCSSRenderingBorders.cpp
+++ b/layout/painting/nsCSSRenderingBorders.cpp
@@ -1190,34 +1190,34 @@ nsCSSBorderRenderer::FillSolidBorder(con
// If two sides meet at a corner that we're rendering, then
// make sure that we adjust one of the sides to avoid overlap.
// This is especially important in the case of colors with
// an alpha channel.
if ((aSides & (eSideBitsTop | eSideBitsLeft)) == (eSideBitsTop | eSideBitsLeft)) {
// adjust the left's top down a bit
- r[eSideLeft].y += aBorderSizes[eSideTop];
- r[eSideLeft].height -= aBorderSizes[eSideTop];
+ r[eSideLeft].MoveByY(aBorderSizes[eSideTop]);
+ r[eSideLeft].SetHeight(r[eSideLeft].Height() - aBorderSizes[eSideTop]);
}
if ((aSides & (eSideBitsTop | eSideBitsRight)) == (eSideBitsTop | eSideBitsRight)) {
// adjust the top's left a bit
- r[eSideTop].width -= aBorderSizes[eSideRight];
+ r[eSideTop].SetWidth(r[eSideTop].Width() - aBorderSizes[eSideRight]);
}
if ((aSides & (eSideBitsBottom | eSideBitsRight)) == (eSideBitsBottom | eSideBitsRight)) {
// adjust the right's bottom a bit
- r[eSideRight].height -= aBorderSizes[eSideBottom];
+ r[eSideRight].SetHeight(r[eSideRight].Height() - aBorderSizes[eSideBottom]);
}
if ((aSides & (eSideBitsBottom | eSideBitsLeft)) == (eSideBitsBottom | eSideBitsLeft)) {
// adjust the bottom's left a bit
- r[eSideBottom].x += aBorderSizes[eSideLeft];
- r[eSideBottom].width -= aBorderSizes[eSideLeft];
+ r[eSideBottom].MoveByX(aBorderSizes[eSideLeft]);
+ r[eSideBottom].SetWidth(r[eSideBottom].Width() - aBorderSizes[eSideLeft]);
}
// Filling these one by one is faster than filling them all at once.
for (uint32_t i = 0; i < 4; i++) {
if (aSides & (1 << i)) {
MaybeSnapToDevicePixels(r[i], *mDrawTarget, true);
mDrawTarget->FillRect(r[i], aColor);
}
--- a/layout/painting/nsImageRenderer.cpp
+++ b/layout/painting/nsImageRenderer.cpp
@@ -753,74 +753,68 @@ ComputeTile(nsRect& aFill,
StyleBorderImageRepeat aHFill,
StyleBorderImageRepeat aVFill,
const nsSize& aUnitSize,
nsSize& aRepeatSize)
{
nsRect tile;
switch (aHFill) {
case StyleBorderImageRepeat::Stretch:
- tile.x = aFill.x;
- tile.width = aFill.width;
- aRepeatSize.width = tile.width;
+ tile.SetRectX(aFill.X(), aFill.Width());
+ aRepeatSize.width = tile.Width();
break;
case StyleBorderImageRepeat::Repeat:
- tile.x = aFill.x + aFill.width/2 - aUnitSize.width/2;
- tile.width = aUnitSize.width;
- aRepeatSize.width = tile.width;
+ tile.SetRectX(aFill.X() + aFill.Width()/2 - aUnitSize.width/2,
+ aUnitSize.width);
+ aRepeatSize.width = tile.Width();
break;
case StyleBorderImageRepeat::Round:
- tile.x = aFill.x;
- tile.width = nsCSSRendering::ComputeRoundedSize(aUnitSize.width,
- aFill.width);
- aRepeatSize.width = tile.width;
+ tile.SetRectX(aFill.X(),
+ nsCSSRendering::ComputeRoundedSize(aUnitSize.width,
+ aFill.Width()));
+ aRepeatSize.width = tile.Width();
break;
case StyleBorderImageRepeat::Space:
{
nscoord space;
aRepeatSize.width =
nsCSSRendering::ComputeBorderSpacedRepeatSize(aUnitSize.width,
- aFill.width, space);
- tile.x = aFill.x + space;
- tile.width = aUnitSize.width;
- aFill.x = tile.x;
- aFill.width = aFill.width - space * 2;
+ aFill.Width(), space);
+ tile.SetRectX(aFill.X() + space, aUnitSize.width);
+ aFill.SetRectX(tile.X(), aFill.Width() - space * 2);
}
break;
default:
NS_NOTREACHED("unrecognized border-image fill style");
}
switch (aVFill) {
case StyleBorderImageRepeat::Stretch:
- tile.y = aFill.y;
- tile.height = aFill.height;
- aRepeatSize.height = tile.height;
+ tile.SetRectY(aFill.Y(), aFill.Height());
+ aRepeatSize.height = tile.Height();
break;
case StyleBorderImageRepeat::Repeat:
- tile.y = aFill.y + aFill.height/2 - aUnitSize.height/2;
- tile.height = aUnitSize.height;
- aRepeatSize.height = tile.height;
+ tile.SetRectY(aFill.Y() + aFill.Height()/2 - aUnitSize.height/2,
+ aUnitSize.height);
+ aRepeatSize.height = tile.Height();
break;
case StyleBorderImageRepeat::Round:
- tile.y = aFill.y;
- tile.height = nsCSSRendering::ComputeRoundedSize(aUnitSize.height,
- aFill.height);
- aRepeatSize.height = tile.height;
+ tile.SetRectY(aFill.Y(),
+ nsCSSRendering::ComputeRoundedSize(aUnitSize.height,
+ aFill.Height()));
+ aRepeatSize.height = tile.Height();
break;
case StyleBorderImageRepeat::Space:
{
nscoord space;
aRepeatSize.height =
nsCSSRendering::ComputeBorderSpacedRepeatSize(aUnitSize.height,
- aFill.height, space);
- tile.y = aFill.y + space;
- tile.height = aUnitSize.height;
- aFill.y = tile.y;
- aFill.height = aFill.height - space * 2;
+ aFill.Height(), space);
+ tile.SetRectY(aFill.Y() + space, aUnitSize.height);
+ aFill.SetRectY(tile.Y(), aFill.Height() - space * 2);
}
break;
default:
NS_NOTREACHED("unrecognized border-image fill style");
}
return tile;
}
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -4200,20 +4200,20 @@ nsComputedDOMStyle::DoGetImageRegion()
} else {
// create the cssvalues for the sides, stick them in the rect object
nsROCSSPrimitiveValue *topVal = new nsROCSSPrimitiveValue;
nsROCSSPrimitiveValue *rightVal = new nsROCSSPrimitiveValue;
nsROCSSPrimitiveValue *bottomVal = new nsROCSSPrimitiveValue;
nsROCSSPrimitiveValue *leftVal = new nsROCSSPrimitiveValue;
nsDOMCSSRect * domRect = new nsDOMCSSRect(topVal, rightVal,
bottomVal, leftVal);
- topVal->SetAppUnits(list->mImageRegion.y);
- rightVal->SetAppUnits(list->mImageRegion.width + list->mImageRegion.x);
- bottomVal->SetAppUnits(list->mImageRegion.height + list->mImageRegion.y);
- leftVal->SetAppUnits(list->mImageRegion.x);
+ topVal->SetAppUnits(list->mImageRegion.Y());
+ rightVal->SetAppUnits(list->mImageRegion.XMost());
+ bottomVal->SetAppUnits(list->mImageRegion.YMost());
+ leftVal->SetAppUnits(list->mImageRegion.X());
val->SetRect(domRect);
}
return val.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetInitialLetter()
@@ -5263,35 +5263,35 @@ nsComputedDOMStyle::DoGetClip()
nsROCSSPrimitiveValue *rightVal = new nsROCSSPrimitiveValue;
nsROCSSPrimitiveValue *bottomVal = new nsROCSSPrimitiveValue;
nsROCSSPrimitiveValue *leftVal = new nsROCSSPrimitiveValue;
nsDOMCSSRect * domRect = new nsDOMCSSRect(topVal, rightVal,
bottomVal, leftVal);
if (effects->mClipFlags & NS_STYLE_CLIP_TOP_AUTO) {
topVal->SetIdent(eCSSKeyword_auto);
} else {
- topVal->SetAppUnits(effects->mClip.y);
+ topVal->SetAppUnits(effects->mClip.Y());
}
if (effects->mClipFlags & NS_STYLE_CLIP_RIGHT_AUTO) {
rightVal->SetIdent(eCSSKeyword_auto);
} else {
- rightVal->SetAppUnits(effects->mClip.width + effects->mClip.x);
+ rightVal->SetAppUnits(effects->mClip.XMost());
}
if (effects->mClipFlags & NS_STYLE_CLIP_BOTTOM_AUTO) {
bottomVal->SetIdent(eCSSKeyword_auto);
} else {
- bottomVal->SetAppUnits(effects->mClip.height + effects->mClip.y);
+ bottomVal->SetAppUnits(effects->mClip.YMost());
}
if (effects->mClipFlags & NS_STYLE_CLIP_LEFT_AUTO) {
leftVal->SetIdent(eCSSKeyword_auto);
} else {
- leftVal->SetAppUnits(effects->mClip.x);
+ leftVal->SetAppUnits(effects->mClip.X());
}
val->SetRect(domRect);
}
return val.forget();
}
already_AddRefed<CSSValue>
@@ -5705,31 +5705,31 @@ nsComputedDOMStyle::GetAbsoluteOffset(mo
if (scrollFrame) {
scrollbarSizes = scrollFrame->GetActualScrollbarSizes();
}
}
nscoord offset = 0;
switch (aSide) {
case eSideTop:
- offset = rect.y - margin.top - border.top - scrollbarSizes.top;
+ offset = rect.Y() - margin.top - border.top - scrollbarSizes.top;
break;
case eSideRight:
- offset = containerRect.width - rect.width -
- rect.x - margin.right - border.right - scrollbarSizes.right;
+ offset = containerRect.Width() - rect.XMost() -
+ margin.right - border.right - scrollbarSizes.right;
break;
case eSideBottom:
- offset = containerRect.height - rect.height -
- rect.y - margin.bottom - border.bottom - scrollbarSizes.bottom;
+ offset = containerRect.Height() - rect.YMost() -
+ margin.bottom - border.bottom - scrollbarSizes.bottom;
break;
case eSideLeft:
- offset = rect.x - margin.left - border.left - scrollbarSizes.left;
+ offset = rect.X() - margin.left - border.left - scrollbarSizes.left;
break;
default:
NS_ERROR("Invalid side");
break;
}
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -106,20 +106,20 @@ AppUnitsToFloatCSSPixels(const gfxRect&
*
* @param aRect The rectangle to scale.
* @param aPoint The point around which to scale.
* @param aScale The scale amount.
*/
static void
ScaleAround(gfxRect& aRect, const gfxPoint& aPoint, double aScale)
{
- aRect.x = aPoint.x - aScale * (aPoint.x - aRect.x);
- aRect.y = aPoint.y - aScale * (aPoint.y - aRect.y);
- aRect.width *= aScale;
- aRect.height *= aScale;
+ aRect.SetRect(aPoint.x - aScale * (aPoint.x - aRect.X()),
+ aPoint.y - aScale * (aPoint.y - aRect.Y()),
+ aRect.Width() * aScale,
+ aRect.Height() * aScale);
}
/**
* Returns whether a gfxPoint lies within a gfxRect.
*/
static bool
Inside(const gfxRect& aRect, const gfxPoint& aPoint)
{
--- a/layout/svg/nsSVGImageFrame.cpp
+++ b/layout/svg/nsSVGImageFrame.cpp
@@ -370,18 +370,22 @@ nsIFrame*
nsSVGImageFrame::GetFrameForPoint(const gfxPoint& aPoint)
{
if (!(GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD) && !GetHitTestFlags()) {
return nullptr;
}
Rect rect;
SVGImageElement *element = static_cast<SVGImageElement*>(GetContent());
- element->GetAnimatedLengthValues(&rect.x, &rect.y,
- &rect.width, &rect.height, nullptr);
+ auto rectX = rect.X();
+ auto rectY = rect.Y();
+ auto rectW = rect.Width();
+ auto rectH = rect.Height();
+ element->GetAnimatedLengthValues(&rectX, &rectY, &rectW, &rectH, nullptr);
+ rect.SetRect(rectX, rectY, rectW, rectH);
if (!rect.Contains(ToPoint(aPoint))) {
return nullptr;
}
// Special case for raster images -- we only want to accept points that fall
// in the underlying image's (scaled to fit) native bounds. That region
// doesn't necessarily map to our <image> element's [x,y,width,height] if the
--- a/layout/svg/nsSVGViewportFrame.cpp
+++ b/layout/svg/nsSVGViewportFrame.cpp
@@ -239,21 +239,20 @@ nsIFrame*
nsSVGViewportFrame::GetFrameForPoint(const gfxPoint& aPoint)
{
NS_ASSERTION(!NS_SVGDisplayListHitTestingEnabled() ||
(mState & NS_FRAME_IS_NONDISPLAY),
"If display lists are enabled, only hit-testing of non-display "
"SVG should take this code path");
if (StyleDisplay()->IsScrollableOverflow()) {
- Rect clip;
+ float clipX = 0, clipY = 0, clipW = 0, clipH = 0;
static_cast<nsSVGElement*>(GetContent())->
- GetAnimatedLengthValues(&clip.x, &clip.y,
- &clip.width, &clip.height, nullptr);
- if (!clip.Contains(ToPoint(aPoint))) {
+ GetAnimatedLengthValues(&clipX, &clipY, &clipW, &clipH, nullptr);
+ if (!Rect(clipX, clipY, clipW, clipH).Contains(ToPoint(aPoint))) {
return nullptr;
}
}
return nsSVGDisplayContainerFrame::GetFrameForPoint(aPoint);
}
//----------------------------------------------------------------------
--- a/layout/xul/nsGroupBoxFrame.cpp
+++ b/layout/xul/nsGroupBoxFrame.cpp
@@ -228,34 +228,33 @@ nsGroupBoxFrame::PaintBorder(gfxContext&
result &=
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext,
PaintBorderFlags::SYNC_DECODE_IMAGES, skipSides);
aRenderingContext.Restore();
// draw right side
clipRect = rect;
- clipRect.x = groupRect.XMost();
- clipRect.width = rect.XMost() - groupRect.XMost();
- clipRect.height = border.top;
+ clipRect.MoveToX(groupRect.XMost());
+ clipRect.SizeTo(rect.XMost() - groupRect.XMost(), border.top);
aRenderingContext.Save();
aRenderingContext.Clip(
NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
result &=
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext,
PaintBorderFlags::SYNC_DECODE_IMAGES, skipSides);
aRenderingContext.Restore();
// draw bottom
clipRect = rect;
- clipRect.y += border.top;
- clipRect.height = mRect.height - (yoff + border.top);
+ clipRect.SetRectY(clipRect.Y() + border.top,
+ mRect.Height() - (yoff + border.top));
aRenderingContext.Save();
aRenderingContext.Clip(
NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
result &=
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext,
PaintBorderFlags::SYNC_DECODE_IMAGES, skipSides);
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -1738,30 +1738,37 @@ nsMenuPopupFrame::GetConstraintRect(cons
// for content shells, get the screen where the root frame is located.
// This is because we need to constrain the content to this content area,
// so we should use the same screen. Otherwise, use the screen where the
// anchor is located.
DesktopToLayoutDeviceScale scale =
PresContext()->DeviceContext()->GetDesktopToDeviceScale();
DesktopRect rect =
(mInContentShell ? aRootScreenRect : aAnchorRect) / scale;
- int32_t width = std::max(1, NSToIntRound(rect.width));
- int32_t height = std::max(1, NSToIntRound(rect.height));
- sm->ScreenForRect(rect.x, rect.y, width, height, getter_AddRefs(screen));
+ int32_t width = std::max(1, NSToIntRound(rect.Width()));
+ int32_t height = std::max(1, NSToIntRound(rect.Height()));
+ sm->ScreenForRect(rect.X(), rect.Y(), width, height, getter_AddRefs(screen));
if (screen) {
// Non-top-level popups (which will always be panels)
// should never overlap the OS bar:
bool dontOverlapOSBar = aPopupLevel != ePopupLevelTop;
// get the total screen area if the popup is allowed to overlap it.
- if (!dontOverlapOSBar && mMenuCanOverlapOSBar && !mInContentShell)
- screen->GetRect(&screenRectPixels.x, &screenRectPixels.y,
- &screenRectPixels.width, &screenRectPixels.height);
- else
- screen->GetAvailRect(&screenRectPixels.x, &screenRectPixels.y,
- &screenRectPixels.width, &screenRectPixels.height);
+ auto screenRectPixelsX = screenRectPixels.X();
+ auto screenRectPixelsY = screenRectPixels.Y();
+ auto screenRectPixelsW = screenRectPixels.Width();
+ auto screenRectPixelsH = screenRectPixels.Height();
+ if (!dontOverlapOSBar && mMenuCanOverlapOSBar && !mInContentShell) {
+ screen->GetRect(&screenRectPixelsX, &screenRectPixelsY,
+ &screenRectPixelsW, &screenRectPixelsH);
+ } else {
+ screen->GetAvailRect(&screenRectPixelsX, &screenRectPixelsY,
+ &screenRectPixelsW, &screenRectPixelsH);
+ }
+ screenRectPixels.SetRect(screenRectPixelsX, screenRectPixelsY,
+ screenRectPixelsW, screenRectPixelsH);
}
}
if (mInContentShell) {
// for content shells, clip to the client area rather than the screen area
screenRectPixels.IntersectRect(screenRectPixels, aRootScreenRect);
}
else if (!mOverrideConstraintRect.IsEmpty()) {
@@ -2382,17 +2389,17 @@ nsMenuPopupFrame::DestroyFrom(nsIFrame*
nsBoxFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
}
void
nsMenuPopupFrame::MoveTo(const CSSIntPoint& aPos, bool aUpdateAttrs)
{
nsIWidget* widget = GetWidget();
- if ((mScreenRect.x == aPos.x && mScreenRect.y == aPos.y) &&
+ if (mScreenRect.IsEqualXY(aPos.x, aPos.y) &&
(!widget || widget->GetClientOffset() == mLastClientOffset)) {
return;
}
// reposition the popup at the specified coordinates. Don't clear the anchor
// and position, because the popup can be reset to its anchor position by
// using (-1, -1) as coordinates. Subtract off the margin as it will be
// added to the position when SetPopupPosition is called.
--- a/layout/xul/nsResizerFrame.cpp
+++ b/layout/xul/nsResizerFrame.cpp
@@ -102,18 +102,24 @@ nsResizerFrame::HandleEvent(nsPresContex
nsresult rv = aEvent->mWidget->BeginResizeDrag(aEvent,
direction.mHorizontal, direction.mVertical);
// for native drags, don't set the fields below
if (rv != NS_ERROR_NOT_IMPLEMENTED)
break;
// if there's no native resize support, we need to do window
// resizing ourselves
- window->GetPositionAndSize(&mMouseDownRect.x, &mMouseDownRect.y,
- &mMouseDownRect.width, &mMouseDownRect.height);
+ auto mouseDownRectX = mMouseDownRect.X();
+ auto mouseDownRectY = mMouseDownRect.Y();
+ auto mouseDownRectW = mMouseDownRect.Width();
+ auto mouseDownRectH = mMouseDownRect.Height();
+ window->GetPositionAndSize(&mouseDownRectX, &mouseDownRectY,
+ &mouseDownRectW, &mouseDownRectH);
+ mMouseDownRect.SetRect( mouseDownRectX, mouseDownRectY,
+ mouseDownRectW, mouseDownRectH);
}
// remember current mouse coordinates
LayoutDeviceIntPoint refPoint;
if (!GetEventPoint(aEvent, refPoint))
return NS_OK;
mMouseDownPoint = refPoint + aEvent->mWidget->WidgetToScreenOffset();
@@ -186,39 +192,47 @@ nsResizerFrame::HandleEvent(nsPresContex
// Check if there are any size constraints on this window.
widget::SizeConstraints sizeConstraints;
if (window) {
nsCOMPtr<nsIWidget> widget;
window->GetMainWidget(getter_AddRefs(widget));
sizeConstraints = widget->GetSizeConstraints();
}
- AdjustDimensions(&rect.x, &rect.width, sizeConstraints.mMinSize.width,
+ auto rectX = rect.X();
+ auto rectY = rect.Y();
+ auto rectWidth = rect.Width();
+ auto rectHeight = rect.Height();
+ AdjustDimensions(&rectX, &rectWidth, sizeConstraints.mMinSize.width,
sizeConstraints.mMaxSize.width, mouseMove.x, direction.mHorizontal);
- AdjustDimensions(&rect.y, &rect.height, sizeConstraints.mMinSize.height,
+ AdjustDimensions(&rectY, &rectHeight, sizeConstraints.mMinSize.height,
sizeConstraints.mMaxSize.height, mouseMove.y, direction.mVertical);
+ rect.SetRect(rectX, rectY, rectWidth, rectHeight);
// Don't allow resizing a window or a popup past the edge of the screen,
// so adjust the rectangle to fit within the available screen area.
if (window) {
nsCOMPtr<nsIScreen> screen;
nsCOMPtr<nsIScreenManager> sm(do_GetService("@mozilla.org/gfx/screenmanager;1"));
if (sm) {
CSSIntRect frameRect = GetScreenRect();
// ScreenForRect requires display pixels, so scale from device pix
double scale;
window->GetUnscaledDevicePixelsPerCSSPixel(&scale);
- sm->ScreenForRect(NSToIntRound(frameRect.x / scale),
- NSToIntRound(frameRect.y / scale), 1, 1,
+ sm->ScreenForRect(NSToIntRound(frameRect.X() / scale),
+ NSToIntRound(frameRect.Y() / scale), 1, 1,
getter_AddRefs(screen));
if (screen) {
- LayoutDeviceIntRect screenRect;
- screen->GetRect(&screenRect.x, &screenRect.y,
- &screenRect.width, &screenRect.height);
- rect.IntersectRect(rect, screenRect);
+ int32_t screenRectX = 0, screenRectY = 0,
+ screenRectW = 0, screenRectH = 0;
+ screen->GetRect(&screenRectX, &screenRectY,
+ &screenRectW, &screenRectH);
+ rect.IntersectRect(rect,
+ LayoutDeviceIntRect(screenRectX, screenRectY,
+ screenRectW, screenRectH));
}
}
}
else if (menuPopupFrame) {
nsRect frameRect = menuPopupFrame->GetScreenRectInAppUnits();
nsIFrame* rootFrame = aPresContext->PresShell()->FrameManager()->GetRootFrame();
nsRect rootScreenRect = rootFrame->GetScreenRectInAppUnits();
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -542,19 +542,22 @@ nsSliderFrame::DoXULLayout(nsBoxLayoutSt
// right or bottom and increase leftwards or upwards. In this case, use the
// offset from the end instead of the beginning.
bool reverse =
mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir,
nsGkAtoms::reverse, eCaseMatters);
nscoord pos = reverse ? (maxPos - curPos) : (curPos - minPos);
// set the thumb's coord to be the current pos * the ratio.
- nsRect thumbRect(clientRect.x, clientRect.y, thumbSize.width, thumbSize.height);
- int32_t& thumbPos = (IsXULHorizontal() ? thumbRect.x : thumbRect.y);
- thumbPos += NSToCoordRound(pos * mRatio);
+ nsRect thumbRect(clientRect.X(), clientRect.Y(), thumbSize.width, thumbSize.height);
+ if (IsXULHorizontal()) {
+ thumbRect.MoveByX(NSToCoordRound(pos * mRatio));
+ } else {
+ thumbRect.MoveByY(NSToCoordRound(pos * mRatio));
+ }
nsRect oldThumbRect(thumbBox->GetRect());
LayoutChildAt(aState, thumbBox, thumbRect);
SyncLayout(aState);
// Redraw only if thumb changed size.
if (!oldThumbRect.IsEqualInterior(thumbRect))
@@ -1559,28 +1562,28 @@ nsSliderFrame::Notify(void)
nsRect thumbRect = thumbFrame->GetRect();
bool isHorizontal = IsXULHorizontal();
// See if the thumb has moved past our destination point.
// if it has we want to stop.
if (isHorizontal) {
if (mChange < 0) {
- if (thumbRect.x < mDestinationPoint.x)
+ if (thumbRect.X() < mDestinationPoint.x)
stop = true;
} else {
- if (thumbRect.x + thumbRect.width > mDestinationPoint.x)
+ if (thumbRect.XMost() > mDestinationPoint.x)
stop = true;
}
} else {
- if (mChange < 0) {
- if (thumbRect.y < mDestinationPoint.y)
+ if (mChange < 0) {
+ if (thumbRect.Y() < mDestinationPoint.y)
stop = true;
} else {
- if (thumbRect.y + thumbRect.height > mDestinationPoint.y)
+ if (thumbRect.YMost() > mDestinationPoint.y)
stop = true;
}
}
if (stop) {
StopRepeat();
} else {
--- a/layout/xul/nsSprocketLayout.cpp
+++ b/layout/xul/nsSprocketLayout.cpp
@@ -1018,23 +1018,36 @@ nsSprocketLayout::ChildResized(nsIFrame*
nsRect& aContainingRect,
int32_t aFlexes,
bool& aFinished)
{
nsRect childCurrentRect(aChildLayoutRect);
bool isHorizontal = IsXULHorizontal(aBox);
- nscoord childLayoutWidth = GET_WIDTH(aChildLayoutRect,isHorizontal);
- nscoord& childActualWidth = GET_WIDTH(aChildActualRect,isHorizontal);
- nscoord& containingWidth = GET_WIDTH(aContainingRect,isHorizontal);
+ nscoord childLayoutWidth, childActualWidth, containingWidth;
+ nscoord childActualHeight, containingHeight;
- //nscoord childLayoutHeight = GET_HEIGHT(aChildLayoutRect,isHorizontal);
- nscoord& childActualHeight = GET_HEIGHT(aChildActualRect,isHorizontal);
- nscoord& containingHeight = GET_HEIGHT(aContainingRect,isHorizontal);
+ // Actual and containing rectangles need to be updated
+ // from these cached values, as they may be modified.
+ if (isHorizontal) {
+ childLayoutWidth = aChildLayoutRect.Width();
+ childActualWidth = aChildActualRect.Width();
+ containingWidth = aContainingRect.Width();
+ // childLayoutHeight = aChildLayoutRect.Height();
+ childActualHeight = aChildActualRect.Height();
+ containingHeight = aContainingRect.Height();
+ } else {
+ childLayoutWidth = aChildLayoutRect.Height();
+ childActualWidth = aChildActualRect.Height();
+ containingWidth = aContainingRect.Height();
+ // childLayoutHeight = aChildLayoutRect.Width();
+ childActualHeight = aChildActualRect.Width();
+ containingHeight = aContainingRect.Width();
+ }
bool recompute = false;
// if we are a horizontal box see if the child will fit inside us.
if ( childActualHeight > containingHeight) {
// if we are a horizontal box and the child is bigger than our height
// ok if the height changed then we need to reflow everyone but us at the new height
@@ -1115,16 +1128,25 @@ nsSprocketLayout::ChildResized(nsIFrame*
containingWidth += aChildComputedSize->size - childLayoutWidth;
}
}
}
if (recompute)
ComputeChildSizes(aBox, aState, containingWidth, aBoxSizes, aComputedBoxSizes);
+ // Update the rectangles from new values
+ if (isHorizontal) {
+ aChildActualRect.SizeTo(childActualWidth, childActualHeight);
+ aContainingRect.SizeTo(containingWidth, containingHeight);
+ } else {
+ aChildActualRect.SizeTo(childActualHeight, childActualWidth);
+ aContainingRect.SizeTo(containingHeight, containingWidth);
+ }
+
if (!childCurrentRect.IsEqualInterior(aChildActualRect)) {
// the childRect includes the margin
// make sure we remove it before setting
// the bounds.
nsMargin margin(0,0,0,0);
aChild->GetXULMargin(margin);
nsRect rect(aChildActualRect);
if (rect.Width() >= margin.left + margin.right && rect.Height() >= margin.top + margin.bottom)
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -889,25 +889,25 @@ nsTreeBodyFrame::CheckOverflow(const Scr
}
else if (mVerticalOverflow && mRowCount <= mPageLength) {
mVerticalOverflow = false;
verticalOverflowChanged = true;
}
if (aParts.mColumnsFrame) {
nsRect bounds = aParts.mColumnsFrame->GetRect();
- if (bounds.width != 0) {
+ if (bounds.Width() != 0) {
/* Ignore overflows that are less than half a pixel. Yes these happen
all over the place when flex boxes are compressed real small.
Probably a result of a rounding errors somewhere in the layout code. */
- bounds.width += nsPresContext::CSSPixelsToAppUnits(0.5f);
- if (!mHorizontalOverflow && bounds.width < mHorzWidth) {
+ bounds.SetWidth(bounds.Width() + nsPresContext::CSSPixelsToAppUnits(0.5f));
+ if (!mHorizontalOverflow && bounds.Width() < mHorzWidth) {
mHorizontalOverflow = true;
horizontalOverflowChanged = true;
- } else if (mHorizontalOverflow && bounds.width >= mHorzWidth) {
+ } else if (mHorizontalOverflow && bounds.Width() >= mHorzWidth) {
mHorizontalOverflow = false;
horizontalOverflowChanged = true;
}
}
}
if (!horizontalOverflowChanged && !verticalOverflowChanged) {
return;
@@ -1256,37 +1256,37 @@ nsTreeBodyFrame::GetCoordsForCellItem(in
nsLayoutUtils::GetFontMetricsForStyleContext(textContext);
nscoord height = fm->MaxHeight();
nsMargin textMargin;
textContext->StyleMargin()->GetMargin(textMargin);
textRect.Deflate(textMargin);
// Center the text. XXX Obey vertical-align style prop?
- if (height < textRect.height) {
- textRect.y += (textRect.height - height) / 2;
- textRect.height = height;
+ if (height < textRect.Height()) {
+ textRect.SetRectY(textRect.Y() + (textRect.Height() - height) / 2,
+ height);
}
nsMargin bp(0,0,0,0);
GetBorderPadding(textContext, bp);
- textRect.height += bp.top + bp.bottom;
+ textRect.SetHeight(textRect.Height() + bp.top + bp.bottom);
AdjustForCellText(cellText, aRow, currCol, *rc, *fm, textRect);
theRect = textRect;
}
if (isRTL)
- theRect.x = mInnerBox.width - theRect.x - theRect.width;
-
- *aX = nsPresContext::AppUnitsToIntCSSPixels(theRect.x);
- *aY = nsPresContext::AppUnitsToIntCSSPixels(theRect.y);
- *aWidth = nsPresContext::AppUnitsToIntCSSPixels(theRect.width);
- *aHeight = nsPresContext::AppUnitsToIntCSSPixels(theRect.height);
+ theRect.MoveToX(mInnerBox.Width() - theRect.XMost());
+
+ *aX = nsPresContext::AppUnitsToIntCSSPixels(theRect.X());
+ *aY = nsPresContext::AppUnitsToIntCSSPixels(theRect.Y());
+ *aWidth = nsPresContext::AppUnitsToIntCSSPixels(theRect.Width());
+ *aHeight = nsPresContext::AppUnitsToIntCSSPixels(theRect.Height());
return NS_OK;
}
int32_t
nsTreeBodyFrame::GetRowAt(int32_t aX, int32_t aY)
{
if (mRowHeight <= 0)
@@ -1509,23 +1509,23 @@ nsTreeBodyFrame::GetItemWithinCellAt(nsc
nsRect cellRect(aCellRect);
nsMargin cellMargin;
cellContext->StyleMargin()->GetMargin(cellMargin);
cellRect.Deflate(cellMargin);
// Adjust the rect for its border and padding.
AdjustForBorderPadding(cellContext, cellRect);
- if (aX < cellRect.x || aX >= cellRect.x + cellRect.width) {
+ if (!cellRect.ContainsX(aX)) {
// The user clicked within the cell's margins/borders/padding. This constitutes a click on the cell.
return nsCSSAnonBoxes::mozTreeCell;
}
- nscoord currX = cellRect.x;
- nscoord remainingWidth = cellRect.width;
+ nscoord currX = cellRect.X();
+ nscoord remainingWidth = cellRect.Width();
// Handle right alignment hit testing.
bool isRTL = StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
nsPresContext* presContext = PresContext();
RefPtr<gfxContext> rc =
presContext->PresShell()->CreateReferenceRenderingContext();
@@ -1565,22 +1565,22 @@ nsTreeBodyFrame::GetItemWithinCellAt(nsc
// We will treat a click as hitting the twisty if it happens on the margins, borders, padding,
// or content of the twisty object. By allowing a "slop" into the margin, we make it a little
// bit easier for a user to hit the twisty. (We don't want to be too picky here.)
nsMargin twistyMargin;
twistyContext->StyleMargin()->GetMargin(twistyMargin);
twistyRect.Inflate(twistyMargin);
if (isRTL)
- twistyRect.x = currX + remainingWidth - twistyRect.width;
+ twistyRect.MoveToX(currX + remainingWidth - twistyRect.Width());
// Now we test to see if aX is actually within the twistyRect. If it is, and if the item should
// have a twisty, then we return "twisty". If it is within the rect but we shouldn't have a twisty,
// then we return "cell".
- if (aX >= twistyRect.x && aX < twistyRect.x + twistyRect.width) {
+ if (twistyRect.ContainsX(aX)) {
if (hasTwisty)
return nsCSSAnonBoxes::mozTreeTwisty;
else
return nsCSSAnonBoxes::mozTreeCell;
}
if (!isRTL)
currX += twistyRect.Width();
@@ -1592,28 +1592,28 @@ nsTreeBodyFrame::GetItemWithinCellAt(nsc
// Resolve style for the image.
nsStyleContext* imageContext = GetPseudoStyleContext(nsCSSAnonBoxes::mozTreeImage);
nsRect iconSize = GetImageSize(aRowIndex, aColumn, false, imageContext);
nsMargin imageMargin;
imageContext->StyleMargin()->GetMargin(imageMargin);
iconSize.Inflate(imageMargin);
- iconRect.width = iconSize.width;
+ iconRect.SetWidth(iconSize.Width());
if (isRTL)
- iconRect.x = currX + remainingWidth - iconRect.width;
-
- if (aX >= iconRect.x && aX < iconRect.x + iconRect.width) {
+ iconRect.MoveToX(currX + remainingWidth - iconRect.Width());
+
+ if (iconRect.ContainsX(aX)) {
// The user clicked on the image.
return nsCSSAnonBoxes::mozTreeImage;
}
if (!isRTL)
- currX += iconRect.width;
- remainingWidth -= iconRect.width;
+ currX += iconRect.Width();
+ remainingWidth -= iconRect.Width();
nsAutoString cellText;
mView->GetCellText(aRowIndex, aColumn, cellText);
// We're going to measure this text so we need to ensure bidi is enabled if
// necessary
CheckTextForBidi(cellText);
nsRect textRect(currX, cellRect.Y(), remainingWidth, cellRect.Height());
@@ -1625,17 +1625,17 @@ nsTreeBodyFrame::GetItemWithinCellAt(nsc
textRect.Deflate(textMargin);
AdjustForBorderPadding(textContext, textRect);
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetFontMetricsForStyleContext(textContext);
AdjustForCellText(cellText, aRowIndex, aColumn, *rc, *fm, textRect);
- if (aX >= textRect.x && aX < textRect.x + textRect.width)
+ if (textRect.ContainsX(aX))
return nsCSSAnonBoxes::mozTreeCellText;
else
return nsCSSAnonBoxes::mozTreeCell;
}
void
nsTreeBodyFrame::GetCellAt(nscoord aX, nscoord aY, int32_t* aRow,
nsTreeColumn** aCol,
@@ -1660,17 +1660,17 @@ nsTreeBodyFrame::GetCellAt(nscoord aX, n
if (NS_FAILED(rv)) {
NS_NOTREACHED("column has no frame");
continue;
}
if (!OffsetForHorzScroll(cellRect, false))
continue;
- if (aX >= cellRect.x && aX < cellRect.x + cellRect.width) {
+ if (cellRect.ContainsX(aX)) {
// We know the column hit now.
*aCol = currCol;
if (currCol->IsCycler())
// Cyclers contain only images. Fill this in immediately and return.
*aChildElt = nsCSSAnonBoxes::mozTreeImage;
else
*aChildElt = GetItemWithinCellAt(aX, cellRect, *aRow, currCol);
@@ -1689,26 +1689,26 @@ nsTreeBodyFrame::GetCellWidth(int32_t aR
// The rect for the current cell.
nscoord colWidth;
nsresult rv = aCol->GetWidthInTwips(this, &colWidth);
NS_ENSURE_SUCCESS(rv, rv);
nsRect cellRect(0, 0, colWidth, mRowHeight);
- int32_t overflow = cellRect.x+cellRect.width-(mInnerBox.x+mInnerBox.width);
+ int32_t overflow = cellRect.XMost() - mInnerBox.XMost();
if (overflow > 0)
- cellRect.width -= overflow;
+ cellRect.SetWidth(cellRect.Width() - overflow);
// Adjust borders and padding for the cell.
nsStyleContext* cellContext = GetPseudoStyleContext(nsCSSAnonBoxes::mozTreeCell);
nsMargin bp(0,0,0,0);
GetBorderPadding(cellContext, bp);
- aCurrentSize = cellRect.width;
+ aCurrentSize = cellRect.Width();
aDesiredSize = bp.left + bp.right;
if (aCol->IsPrimary()) {
// If the current Column is a Primary, then we need to take into account
// the indentation and possibly a twisty.
// The amount of indentation is the indentation width (|mIndentation|) by the level.
int32_t level;
@@ -2241,53 +2241,53 @@ nsRect nsTreeBodyFrame::GetImageSize(int
bool useImageRegion = true;
nsCOMPtr<imgIContainer> image;
GetImage(aRowIndex, aCol, aUseContext, aStyleContext, useImageRegion, getter_AddRefs(image));
const nsStylePosition* myPosition = aStyleContext->StylePosition();
const nsStyleList* myList = aStyleContext->StyleList();
if (useImageRegion) {
- r.x += myList->mImageRegion.x;
- r.y += myList->mImageRegion.y;
+ r.MoveTo(r.X() + myList->mImageRegion.X(),
+ r.Y() + myList->mImageRegion.Y());
}
if (myPosition->mWidth.GetUnit() == eStyleUnit_Coord) {
int32_t val = myPosition->mWidth.GetCoordValue();
- r.width += val;
+ r.SetWidth(r.Width() + val);
}
- else if (useImageRegion && myList->mImageRegion.width > 0)
- r.width += myList->mImageRegion.width;
+ else if (useImageRegion && myList->mImageRegion.Width() > 0)
+ r.SetWidth(r.Width() + myList->mImageRegion.Width());
else
needWidth = true;
if (myPosition->mHeight.GetUnit() == eStyleUnit_Coord) {
int32_t val = myPosition->mHeight.GetCoordValue();
- r.height += val;
+ r.SetHeight(r.Height() + val);
}
- else if (useImageRegion && myList->mImageRegion.height > 0)
- r.height += myList->mImageRegion.height;
+ else if (useImageRegion && myList->mImageRegion.Height() > 0)
+ r.SetHeight(r.Height() + myList->mImageRegion.Height());
else
needHeight = true;
if (image) {
if (needWidth || needHeight) {
// Get the natural image size.
if (needWidth) {
// Get the size from the image.
nscoord width;
image->GetWidth(&width);
- r.width += nsPresContext::CSSPixelsToAppUnits(width);
+ r.SetWidth(r.Width() + nsPresContext::CSSPixelsToAppUnits(width));
}
if (needHeight) {
nscoord height;
image->GetHeight(&height);
- r.height += nsPresContext::CSSPixelsToAppUnits(height);
+ r.SetHeight(r.Height() + nsPresContext::CSSPixelsToAppUnits(height));
}
}
}
return r;
}
// GetImageDestSize returns the destination size of the image.
@@ -2410,19 +2410,19 @@ nsTreeBodyFrame::GetImageSourceRect(nsSt
(myList->mImageRegion.Width() > 0 || myList->mImageRegion.Height() > 0)) {
// CSS has specified an image region.
r = myList->mImageRegion;
}
else if (image) {
// Use the actual image size.
nscoord coord;
image->GetWidth(&coord);
- r.width = nsPresContext::CSSPixelsToAppUnits(coord);
+ r.SetWidth(nsPresContext::CSSPixelsToAppUnits(coord));
image->GetHeight(&coord);
- r.height = nsPresContext::CSSPixelsToAppUnits(coord);
+ r.SetHeight(nsPresContext::CSSPixelsToAppUnits(coord));
}
return r;
}
int32_t nsTreeBodyFrame::GetRowHeight()
{
// Look up the correct height. It is equal to the specified height
--- a/layout/xul/tree/nsTreeColumns.cpp
+++ b/layout/xul/tree/nsTreeColumns.cpp
@@ -110,22 +110,21 @@ nsTreeColumn::GetRect(nsTreeBodyFrame* a
nsIFrame* frame = GetFrame();
if (!frame) {
*aResult = nsRect();
return NS_ERROR_FAILURE;
}
bool isRTL = aBodyFrame->StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
*aResult = frame->GetRect();
- aResult->y = aY;
- aResult->height = aHeight;
+ aResult->SetRectY(aY, aHeight);
if (isRTL)
- aResult->x += aBodyFrame->mAdjustWidth;
+ aResult->MoveByX(aBodyFrame->mAdjustWidth);
else if (IsLastVisible(aBodyFrame))
- aResult->width += aBodyFrame->mAdjustWidth;
+ aResult->SetWidth(aResult->Width() + aBodyFrame->mAdjustWidth);
return NS_OK;
}
nsresult
nsTreeColumn::GetXInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult)
{
nsIFrame* frame = GetFrame();
if (!frame) {