summaryrefslogtreecommitdiffstats
path: root/widget/cocoa/ViewRegion.mm
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /widget/cocoa/ViewRegion.mm
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'widget/cocoa/ViewRegion.mm')
-rw-r--r--widget/cocoa/ViewRegion.mm53
1 files changed, 25 insertions, 28 deletions
diff --git a/widget/cocoa/ViewRegion.mm b/widget/cocoa/ViewRegion.mm
index 62e76d2df8..5b275a18a3 100644
--- a/widget/cocoa/ViewRegion.mm
+++ b/widget/cocoa/ViewRegion.mm
@@ -12,8 +12,8 @@
using namespace mozilla;
ViewRegion::~ViewRegion() {
- for (size_t i = 0; i < mViews.Length(); i++) {
- [mViews[i] removeFromSuperview];
+ for (NSView* view : mViews) {
+ [view removeFromSuperview];
}
}
@@ -33,34 +33,31 @@ bool ViewRegion::UpdateRegion(const LayoutDeviceIntRegion& aRegion,
nsTArray<NSView*> viewsToRecycle = std::move(mViews);
// The mViews array is now empty.
- size_t i = 0;
- for (auto iter = aRegion.RectIter();
- !iter.Done() || i < viewsToRecycle.Length(); i++) {
- if (!iter.Done()) {
- NSView* view = nil;
- NSRect rect = aCoordinateConverter.DevPixelsToCocoaPoints(iter.Get());
- if (i < viewsToRecycle.Length()) {
- view = viewsToRecycle[i];
- } else {
- view = aViewCreationCallback();
- [aContainerView addSubview:view];
-
- // Now that the view is in the view hierarchy, it'll be kept alive by
- // its superview, so we can drop our reference.
- [view release];
- }
- if (!NSEqualRects(rect, [view frame])) {
- [view setFrame:rect];
- }
- [view setNeedsDisplay:YES];
- mViews.AppendElement(view);
- iter.Next();
+ size_t viewsRecycled = 0;
+ for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
+ NSRect rect = aCoordinateConverter.DevPixelsToCocoaPoints(iter.Get());
+ NSView* view = nil;
+ if (viewsRecycled < viewsToRecycle.Length()) {
+ view = viewsToRecycle[viewsRecycled++];
} else {
- // Our new region is made of fewer rects than the old region, so we can
- // remove this view. We only have a weak reference to it, so removing it
- // from the view hierarchy will release it.
- [viewsToRecycle[i] removeFromSuperview];
+ view = aViewCreationCallback();
+ [aContainerView addSubview:view];
+
+ // Now that the view is in the view hierarchy, it'll be kept alive by
+ // its superview, so we can drop our reference.
+ [view release];
}
+ if (!NSEqualRects(rect, view.frame)) {
+ view.frame = rect;
+ }
+ view.needsDisplay = YES;
+ mViews.AppendElement(view);
+ }
+ for (NSView* view : Span(viewsToRecycle).From(viewsRecycled)) {
+ // Our new region is made of fewer rects than the old region, so we can
+ // remove this view. We only have a weak reference to it, so removing it
+ // from the view hierarchy will release it.
+ [view removeFromSuperview];
}
mRegion = aRegion;