Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: BrowserViews not painting their WebContents #30335

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 13 additions & 7 deletions shell/browser/native_browser_view_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <vector>

#include "shell/browser/ui/drag_util.h"
#include "shell/browser/ui/inspectable_web_contents_view.h"
#include "shell/browser/ui/views/inspectable_web_contents_view_views.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/background.h"
#include "ui/views/view.h"
Expand Down Expand Up @@ -49,7 +49,7 @@ void NativeBrowserViewViews::SetAutoResizeProportions(
const gfx::Size& window_size) {
if ((auto_resize_flags_ & AutoResizeFlags::kAutoResizeHorizontal) &&
!auto_horizontal_proportion_set_) {
auto* iwc_view = GetInspectableWebContentsView();
InspectableWebContentsView* iwc_view = GetInspectableWebContentsView();
if (!iwc_view)
return;
auto* view = iwc_view->GetView();
Expand All @@ -63,7 +63,7 @@ void NativeBrowserViewViews::SetAutoResizeProportions(
}
if ((auto_resize_flags_ & AutoResizeFlags::kAutoResizeVertical) &&
!auto_vertical_proportion_set_) {
auto* iwc_view = GetInspectableWebContentsView();
InspectableWebContentsView* iwc_view = GetInspectableWebContentsView();
if (!iwc_view)
return;
auto* view = iwc_view->GetView();
Expand All @@ -80,7 +80,7 @@ void NativeBrowserViewViews::SetAutoResizeProportions(
void NativeBrowserViewViews::AutoResize(const gfx::Rect& new_window,
int width_delta,
int height_delta) {
auto* iwc_view = GetInspectableWebContentsView();
InspectableWebContentsView* iwc_view = GetInspectableWebContentsView();
if (!iwc_view)
return;
auto* view = iwc_view->GetView();
Expand Down Expand Up @@ -124,7 +124,7 @@ void NativeBrowserViewViews::ResetAutoResizeProportions() {
}

void NativeBrowserViewViews::SetBounds(const gfx::Rect& bounds) {
auto* iwc_view = GetInspectableWebContentsView();
InspectableWebContentsView* iwc_view = GetInspectableWebContentsView();
if (!iwc_view)
return;
auto* view = iwc_view->GetView();
Expand All @@ -133,14 +133,20 @@ void NativeBrowserViewViews::SetBounds(const gfx::Rect& bounds) {
}

gfx::Rect NativeBrowserViewViews::GetBounds() {
auto* iwc_view = GetInspectableWebContentsView();
InspectableWebContentsView* iwc_view = GetInspectableWebContentsView();
if (!iwc_view)
return gfx::Rect();
return iwc_view->GetView()->bounds();
}

void NativeBrowserViewViews::RenderViewReady() {
InspectableWebContentsView* iwc_view = GetInspectableWebContentsView();
if (iwc_view)
iwc_view->GetView()->Layout();
}

void NativeBrowserViewViews::SetBackgroundColor(SkColor color) {
auto* iwc_view = GetInspectableWebContentsView();
InspectableWebContentsView* iwc_view = GetInspectableWebContentsView();
if (!iwc_view)
return;
auto* view = iwc_view->GetView();
Expand Down
3 changes: 3 additions & 0 deletions shell/browser/native_browser_view_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class NativeBrowserViewViews : public NativeBrowserView {
void UpdateDraggableRegions(
const std::vector<mojom::DraggableRegionPtr>& regions) override;

// WebContentsObserver:
void RenderViewReady() override;

SkRegion* draggable_region() const { return draggable_region_.get(); }

private:
Expand Down
6 changes: 3 additions & 3 deletions shell/browser/ui/views/inspectable_web_contents_view_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ class InspectableWebContentsViewViews : public InspectableWebContentsView,
const DevToolsContentsResizingStrategy& strategy) override;
void SetTitle(const std::u16string& title) override;

// views::View:
void Layout() override;

InspectableWebContents* inspectable_web_contents() {
return inspectable_web_contents_;
}

const std::u16string& GetTitle() const { return title_; }

private:
// views::View:
void Layout() override;

// Owns us.
InspectableWebContents* inspectable_web_contents_;

Expand Down