fix: draggable regions calculation in BrowserWindow/BrowserView (#26690)

This commit is contained in:
Shelley Vohr 2020-11-30 21:02:04 -08:00 committed by GitHub
parent 4e3e3d414d
commit acfbbe9869
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 37 deletions

View file

@ -71,25 +71,21 @@ void BrowserWindow::UpdateDraggableRegions(
// Draggable regions are implemented by having the whole web view draggable
// and overlaying regions that are not draggable.
if (&draggable_regions_ != &regions) {
draggable_regions_.clear();
for (const auto& r : regions)
draggable_regions_.push_back(r.Clone());
}
auto browser_views = window_->browser_views();
for (NativeBrowserView* view : browser_views) {
view->UpdateDraggableRegions(draggable_regions_);
}
if (&draggable_regions_ != &regions)
draggable_regions_ = mojo::Clone(regions);
std::vector<gfx::Rect> drag_exclude_rects;
if (regions.empty()) {
drag_exclude_rects.push_back(gfx::Rect(0, 0, webViewWidth, webViewHeight));
drag_exclude_rects.emplace_back(0, 0, webViewWidth, webViewHeight);
} else {
drag_exclude_rects = CalculateNonDraggableRegions(
DraggableRegionsToSkRegion(regions), webViewWidth, webViewHeight);
}
for (NativeBrowserView* view : window_->browser_views()) {
view->UpdateDraggableRegions(drag_exclude_rects);
}
// Create and add a ControlRegionView for each region that needs to be
// excluded from the dragging.
for (const auto& rect : drag_exclude_rects) {