Skip to content

Commit

Permalink
fix: BrowserViews not painting their WebContents (#29919)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jul 29, 2021
1 parent 9cc1b55 commit 639f039
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
20 changes: 13 additions & 7 deletions shell/browser/native_browser_view_views.cc
Expand Up @@ -7,7 +7,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 @@ -47,7 +47,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 @@ -61,7 +61,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 @@ -78,7 +78,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 @@ -122,7 +122,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 @@ -131,14 +131,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
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
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

0 comments on commit 639f039

Please sign in to comment.