diff --git a/view/nsViewManager.cpp b/view/nsViewManager.cpp index b345a74f6461..2c56bc0a743a 100644 --- a/view/nsViewManager.cpp +++ b/view/nsViewManager.cpp @@ -606,9 +606,8 @@ nsViewManager::InvalidateWidgetArea(nsView *aWidgetView, leftOver.Sub(aDamagedRegion, children); if (!leftOver.IsEmpty()) { - const nsRect* r; - for (nsRegionRectIterator iter(leftOver); (r = iter.Next());) { - LayoutDeviceIntRect bounds = ViewToWidget(aWidgetView, *r); + for (auto iter = leftOver.RectIter(); !iter.Done(); iter.Next()) { + LayoutDeviceIntRect bounds = ViewToWidget(aWidgetView, iter.Get()); widget->Invalidate(bounds); } } diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index bcc72f25f47b..63f3ba32460c 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -32,9 +32,8 @@ using namespace mozilla::widget; static void InvalidateRegion(nsIWidget* aWidget, const LayoutDeviceIntRegion& aRegion) { - LayoutDeviceIntRegion::OldRectIterator it(aRegion); - while(const LayoutDeviceIntRect* r = it.Next()) { - aWidget->Invalidate(*r); + for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) { + aWidget->Invalidate(iter.Get()); } } diff --git a/widget/cocoa/VibrancyManager.mm b/widget/cocoa/VibrancyManager.mm index 411554e9b150..e1eed593c46d 100644 --- a/widget/cocoa/VibrancyManager.mm +++ b/widget/cocoa/VibrancyManager.mm @@ -28,12 +28,13 @@ VibrancyManager::UpdateVibrantRegion(VibrancyType aType, vr.effectViews.SwapElements(viewsToRecycle); // vr.effectViews is now empty. - LayoutDeviceIntRegion::OldRectIterator iter(aRegion); - const LayoutDeviceIntRect* iterRect = nullptr; - for (size_t i = 0; (iterRect = iter.Next()) || i < viewsToRecycle.Length(); ++i) { - if (iterRect) { + size_t i = 0; + for (auto iter = aRegion.RectIter(); + !iter.Done() || i < viewsToRecycle.Length(); + i++) { + if (!iter.Done()) { NSView* view = nil; - NSRect rect = mCoordinateConverter.DevPixelsToCocoaPoints(*iterRect); + NSRect rect = mCoordinateConverter.DevPixelsToCocoaPoints(iter.Get()); if (i < viewsToRecycle.Length()) { view = viewsToRecycle[i]; [view setFrame:rect]; @@ -47,6 +48,7 @@ VibrancyManager::UpdateVibrantRegion(VibrancyType aType, [view release]; } vr.effectViews.AppendElement(view); + iter.Next(); } else { // Our new region is made of less rects than the old region, so we can // remove this view. We only have a weak reference to it, so removing it @@ -71,9 +73,8 @@ VibrancyManager::ClearVibrantRegion(const VibrantRegion& aVibrantRegion) const { [[NSColor clearColor] set]; - LayoutDeviceIntRegion::OldRectIterator iter(aVibrantRegion.region); - while (const LayoutDeviceIntRect* rect = iter.Next()) { - NSRectFill(mCoordinateConverter.DevPixelsToCocoaPoints(*rect)); + for (auto iter = aVibrantRegion.region.RectIter(); !iter.Done(); iter.Next()) { + NSRectFill(mCoordinateConverter.DevPixelsToCocoaPoints(iter.Get())); } } diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 0f2545ab59c6..e3ab0969a6e9 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -3753,13 +3753,10 @@ NSEvent* gLastDragMouseDownEvent = nil; RefPtr targetContext = new gfxContext(dt); // Set up the clip region. - LayoutDeviceIntRegion::OldRectIterator iter(region); targetContext->NewPath(); - for (;;) { - const LayoutDeviceIntRect* r = iter.Next(); - if (!r) - break; - targetContext->Rectangle(gfxRect(r->x, r->y, r->width, r->height)); + for (auto iter = region.RectIter(); !iter.Done(); iter.Next()) { + const LayoutDeviceIntRect& r = iter.Get(); + targetContext->Rectangle(gfxRect(r.x, r.y, r.width, r.height)); } targetContext->Clip(); @@ -4632,13 +4629,8 @@ NewCGSRegionFromRegion(const LayoutDeviceIntRegion& aRegion, CGRect (^aRectConverter)(const LayoutDeviceIntRect&)) { nsTArray rects; - LayoutDeviceIntRegion::OldRectIterator iter(aRegion); - for (;;) { - const LayoutDeviceIntRect* r = iter.Next(); - if (!r) { - break; - } - rects.AppendElement(aRectConverter(*r)); + for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) { + rects.AppendElement(aRectConverter(iter.Get())); } CGSRegionObj region; diff --git a/widget/gonk/HwcUtils.cpp b/widget/gonk/HwcUtils.cpp index 16bec42af57e..a8f030f3c05c 100644 --- a/widget/gonk/HwcUtils.cpp +++ b/widget/gonk/HwcUtils.cpp @@ -107,19 +107,19 @@ HwcUtils::PrepareVisibleRegion(const nsIntRegion& aVisible, layerBufferTransform.TransformBounds(ThebesRect(aBufferRect)); gfxMatrix inverse = gfx::ThebesMatrix(aLayerBufferTransform); inverse.Invert(); - nsIntRegionRectIterator rect(aVisible); aIsVisible = false; - while (const nsIntRect* visibleRect = rect.Next()) { - hwc_rect_t visibleRectScreen; - gfxRect screenRect; - screenRect = layerTransform.TransformBounds(ThebesRect(*visibleRect)); + for (auto iter = aVisible.RectIter(); !iter.Done(); iter.Next()) { + gfxRect screenRect = + layerTransform.TransformBounds(ThebesRect(iter.Get())); screenRect.IntersectRect(screenRect, bufferRect); screenRect.IntersectRect(screenRect, ThebesRect(aClip)); screenRect.Round(); if (screenRect.IsEmpty()) { continue; } + + hwc_rect_t visibleRectScreen; visibleRectScreen.left = screenRect.x; visibleRectScreen.top = screenRect.y; visibleRectScreen.right = screenRect.XMost(); diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 875fe1803509..aa81ad8241b2 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -757,9 +757,8 @@ void nsBaseWidget::ArrayFromRegion(const LayoutDeviceIntRegion& aRegion, nsTArray& aRects) { - const LayoutDeviceIntRect* r; - for (LayoutDeviceIntRegion::OldRectIterator iter(aRegion); (r = iter.Next()); ) { - aRects.AppendElement(*r); + for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) { + aRects.AppendElement(iter.Get()); } } diff --git a/widget/nsShmImage.cpp b/widget/nsShmImage.cpp index 784f3dc758a6..87465fa37245 100644 --- a/widget/nsShmImage.cpp +++ b/widget/nsShmImage.cpp @@ -142,12 +142,12 @@ nsShmImage::Put(Display* aDisplay, Drawable aWindow, LayoutDeviceIntRegion bounded; bounded.And(aRegion, LayoutDeviceIntRect(0, 0, mImage->width, mImage->height)); - LayoutDeviceIntRegion::OldRectIterator iter(bounded); - for (const LayoutDeviceIntRect *r = iter.Next(); r; r = iter.Next()) { + for (auto iter = bounded.RectIter(); !iter.Done(); iter.Next()) { + const LayoutDeviceIntRect& r = iter.Get(); XShmPutImage(aDisplay, aWindow, gc, mImage, - r->x, r->y, - r->x, r->y, - r->width, r->height, + r.x, r.y, + r.x, r.y, + r.width, r.height, False); } diff --git a/widget/uikit/nsWindow.mm b/widget/uikit/nsWindow.mm index ff8d75929f80..31298cd3d7ff 100644 --- a/widget/uikit/nsWindow.mm +++ b/widget/uikit/nsWindow.mm @@ -377,13 +377,10 @@ private: } // Set up the clip region. - LayoutDeviceIntRegion::OldRectIterator iter(region); targetContext->NewPath(); - for (;;) { - const LayoutDeviceIntRect* r = iter.Next(); - if (!r) - break; - targetContext->Rectangle(gfxRect(r->x, r->y, r->width, r->height)); + for (auto iter = region.RectIter(); !iter.Done(); iter.Next()) { + const LayoutDeviceIntRect& r = iter.Get(); + targetContext->Rectangle(gfxRect(r.x, r.y, r.width, r.height)); } targetContext->Clip();