chore: Move draggable regions implementation from NativeBrowserView into InspectableWebContentsView (#35007)
* hore: Move draggable regions implementation from NativeBrowserView into InspectableWebContentsView The draggable regions implementation is related to WebView, so InspectableWebContentsView is a more appropriate place to put it there. Also, this refactoring will allow the subsequent extension of the WebContentsView API, which will eventually replace BrowserView API. * fix: Lint error * fix: Adjusted owner-window
This commit is contained in:
parent
f2c341b655
commit
23d4a252c6
18 changed files with 397 additions and 360 deletions
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "shell/browser/ui/drag_util.h"
|
||||
#include "shell/browser/ui/views/inspectable_web_contents_view_views.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
#include "ui/views/background.h"
|
||||
|
@ -25,25 +24,6 @@ void NativeBrowserViewViews::SetAutoResizeFlags(uint8_t flags) {
|
|||
ResetAutoResizeProportions();
|
||||
}
|
||||
|
||||
void NativeBrowserViewViews::UpdateDraggableRegions(
|
||||
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.
|
||||
// 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();
|
||||
for (auto& snapped_region : draggable_regions_) {
|
||||
snapped_region->bounds.Offset(offset);
|
||||
}
|
||||
draggable_region_ = DraggableRegionsToSkRegion(draggable_regions_);
|
||||
}
|
||||
|
||||
void NativeBrowserViewViews::SetAutoResizeProportions(
|
||||
const gfx::Size& window_size) {
|
||||
if ((auto_resize_flags_ & AutoResizeFlags::kAutoResizeHorizontal) &&
|
||||
|
@ -132,9 +112,6 @@ void NativeBrowserViewViews::SetBounds(const gfx::Rect& bounds) {
|
|||
|
||||
view->InvalidateLayout();
|
||||
view->SchedulePaint();
|
||||
|
||||
// Ensure draggable regions are properly updated to reflect new bounds.
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
}
|
||||
|
||||
gfx::Rect NativeBrowserViewViews::GetBounds() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue