fix: draggable views on BrowserViews on Windows (#26738)

This commit is contained in:
Shelley Vohr 2020-12-01 15:03:00 -08:00 committed by GitHub
parent cdcee04bbe
commit 528b0f0e74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 0 deletions

View file

@ -4,6 +4,11 @@
#include "shell/browser/native_browser_view_views.h"
#include <memory>
#include <utility>
#include <vector>
#include "shell/browser/ui/drag_util.h"
#include "shell/browser/ui/inspectable_web_contents_view.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/background.h"
@ -22,6 +27,25 @@ void NativeBrowserViewViews::SetAutoResizeFlags(uint8_t flags) {
ResetAutoResizeProportions();
}
void NativeBrowserViewViews::UpdateDraggableRegions(
const std::vector<mojom::DraggableRegionPtr>& regions) {
// 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
// { x: 200, y: 100, width: 300, height: 300 }
// then we need to add 200 to the x-value and 100 to the
// y-value of each of the passed regions or it will be incorrectly
// assumed that the regions begin in the top left corner as they
// would for the main client window.
auto const offset = GetBounds().OffsetFromOrigin();
auto snapped_regions = mojo::Clone(regions);
for (auto& snapped_region : snapped_regions) {
snapped_region->bounds.Offset(offset);
snapped_region->draggable = true;
}
draggable_region_ = DraggableRegionsToSkRegion(snapped_regions);
}
void NativeBrowserViewViews::SetAutoResizeProportions(
const gfx::Size& window_size) {
if ((auto_resize_flags_ & AutoResizeFlags::kAutoResizeHorizontal) &&