Commit fd04cb26 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Simplify NonClientView Layout slightly.

The old code assumes children might need layout even when not invalid.  This was
originally added to fix http://crbug.com/8511 .  This seems like a bogus fix; if
the metrics of something in the nonclient area change in such a way that we
actually notice and make it to NonClientView::Layout(), we should have had an
opportunity to invalid child layouts as needed.  I suspect this doesn't actually
happen anymore (some of the rest of that bugfix is already gone), but if it does
we should fix in a different way.

This also reorders definitions to match declaration order, removes a bunch of
section-break comments that are atypical style nowadays, and adds some TODOs for
further refactoring.


Bug: none
Change-Id: Ib386921c85c43ee05473acf1ac1b660a68d28809
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1823642
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712323}
parent c062ef9e
......@@ -212,6 +212,10 @@ NonClientFrameViewAsh::NonClientFrameViewAsh(views::Widget* frame)
window_util::InstallResizeHandleWindowTargeterForWindow(frame_window);
// |header_view_| is set as the non client view's overlay view so that it can
// overlay the web contents in immersive fullscreen.
// TODO(pkasting): Consider having something like NonClientViewAsh, which
// would avoid the need to expose an "overlay view" concept on the
// cross-platform class, and might allow for simpler creation/ownership/
// plumbing.
frame->non_client_view()->SetOverlayView(overlay_view_);
// A delegate may be set which takes over the responsibilities of the
......
This diff is collapsed.
......@@ -214,11 +214,6 @@ class VIEWS_EXPORT NonClientView : public View, public ViewTargeterDelegate {
client_view_ = client_view;
}
// Layout just the frame view. This is necessary on Windows when non-client
// metrics such as the position of the window controls changes independently
// of a window resize message.
void LayoutFrameView();
// Set the accessible name of this view.
void SetAccessibleName(const base::string16& name);
......@@ -228,7 +223,6 @@ class VIEWS_EXPORT NonClientView : public View, public ViewTargeterDelegate {
gfx::Size GetMaximumSize() const override;
void Layout() override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override;
protected:
......
......@@ -70,6 +70,7 @@ TEST_F(NonClientViewTest, OnlyLayoutChildViewsOnce) {
widget.Init(std::move(params));
NonClientView* non_client_view = widget.non_client_view();
non_client_view->Layout();
auto* frame_view =
static_cast<NonClientFrameTestView*>(non_client_view->frame_view());
......@@ -79,20 +80,15 @@ TEST_F(NonClientViewTest, OnlyLayoutChildViewsOnce) {
int initial_frame_view_layouts = frame_view->layout_count();
int initial_client_view_layouts = client_view->layout_count();
// Make sure it does no layout when nothing has changed.
non_client_view->Layout();
EXPECT_EQ(frame_view->layout_count(), initial_frame_view_layouts + 1);
EXPECT_EQ(client_view->layout_count(), initial_client_view_layouts + 1);
// One more time to make sure it does the layout
// even though nothing has changed.
non_client_view->Layout();
EXPECT_EQ(frame_view->layout_count(), initial_frame_view_layouts + 2);
EXPECT_EQ(client_view->layout_count(), initial_client_view_layouts + 2);
EXPECT_EQ(frame_view->layout_count(), initial_frame_view_layouts);
EXPECT_EQ(client_view->layout_count(), initial_client_view_layouts);
// Ensure changing bounds triggers a (single) layout.
widget.SetBounds(gfx::Rect(0, 0, 161, 100));
EXPECT_EQ(frame_view->layout_count(), initial_frame_view_layouts + 3);
EXPECT_EQ(client_view->layout_count(), initial_client_view_layouts + 3);
EXPECT_EQ(frame_view->layout_count(), initial_frame_view_layouts + 1);
EXPECT_EQ(client_view->layout_count(), initial_client_view_layouts + 1);
}
} // namespace test
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment