fix: draggable regions updating on bounds change (#34582)
This commit is contained in:
parent
d2e539c7d4
commit
20538c4f34
1 changed files with 8 additions and 4 deletions
|
@ -27,6 +27,9 @@ void NativeBrowserViewViews::SetAutoResizeFlags(uint8_t flags) {
|
||||||
|
|
||||||
void NativeBrowserViewViews::UpdateDraggableRegions(
|
void NativeBrowserViewViews::UpdateDraggableRegions(
|
||||||
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
||||||
|
if (&draggable_regions_ != ®ions)
|
||||||
|
draggable_regions_ = mojo::Clone(regions);
|
||||||
|
|
||||||
// We need to snap the regions to the bounds of the current BrowserView.
|
// We need to snap the regions to the bounds of the current BrowserView.
|
||||||
// For example, if an attached BrowserView is draggable but its bounds are
|
// For example, if an attached BrowserView is draggable but its bounds are
|
||||||
// { x: 200, y: 100, width: 300, height: 300 }
|
// { x: 200, y: 100, width: 300, height: 300 }
|
||||||
|
@ -35,12 +38,10 @@ void NativeBrowserViewViews::UpdateDraggableRegions(
|
||||||
// assumed that the regions begin in the top left corner as they
|
// assumed that the regions begin in the top left corner as they
|
||||||
// would for the main client window.
|
// would for the main client window.
|
||||||
auto const offset = GetBounds().OffsetFromOrigin();
|
auto const offset = GetBounds().OffsetFromOrigin();
|
||||||
auto snapped_regions = mojo::Clone(regions);
|
for (auto& snapped_region : draggable_regions_) {
|
||||||
for (auto& snapped_region : snapped_regions) {
|
|
||||||
snapped_region->bounds.Offset(offset);
|
snapped_region->bounds.Offset(offset);
|
||||||
}
|
}
|
||||||
|
draggable_region_ = DraggableRegionsToSkRegion(draggable_regions_);
|
||||||
draggable_region_ = DraggableRegionsToSkRegion(snapped_regions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeBrowserViewViews::SetAutoResizeProportions(
|
void NativeBrowserViewViews::SetAutoResizeProportions(
|
||||||
|
@ -128,6 +129,9 @@ void NativeBrowserViewViews::SetBounds(const gfx::Rect& bounds) {
|
||||||
auto* view = iwc_view->GetView();
|
auto* view = iwc_view->GetView();
|
||||||
view->SetBoundsRect(bounds);
|
view->SetBoundsRect(bounds);
|
||||||
ResetAutoResizeProportions();
|
ResetAutoResizeProportions();
|
||||||
|
|
||||||
|
// Ensure draggable regions are properly updated to reflect new bounds.
|
||||||
|
UpdateDraggableRegions(draggable_regions_);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Rect NativeBrowserViewViews::GetBounds() {
|
gfx::Rect NativeBrowserViewViews::GetBounds() {
|
||||||
|
|
Loading…
Reference in a new issue