mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
PixelPaint: Make "Crop Image to Content" work with disjoint layers
This commit is contained in:
parent
c98ec85fb5
commit
55e103deb5
Notes:
sideshowbarker
2024-07-17 11:33:34 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/55e103deb5 Pull-request: https://github.com/SerenityOS/serenity/pull/17593 Reviewed-by: https://github.com/gmta ✅
@ -665,7 +665,8 @@ Optional<Gfx::IntRect> Image::nonempty_content_bounding_rect() const
|
||||
for (auto const& layer : m_layers) {
|
||||
auto layer_content_rect_in_layer_coordinates = layer->nonempty_content_bounding_rect();
|
||||
if (!layer_content_rect_in_layer_coordinates.has_value())
|
||||
continue;
|
||||
layer_content_rect_in_layer_coordinates = layer->rect();
|
||||
|
||||
auto layer_content_rect_in_image_coordinates = layer_content_rect_in_layer_coordinates->translated(layer->location());
|
||||
if (!bounding_rect.has_value())
|
||||
bounding_rect = layer_content_rect_in_image_coordinates;
|
||||
@ -673,6 +674,10 @@ Optional<Gfx::IntRect> Image::nonempty_content_bounding_rect() const
|
||||
bounding_rect = bounding_rect->united(layer_content_rect_in_image_coordinates);
|
||||
}
|
||||
|
||||
bounding_rect->intersect(rect());
|
||||
if (bounding_rect == rect())
|
||||
return OptionalNone {};
|
||||
|
||||
return bounding_rect;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user