summaryrefslogtreecommitdiff
path: root/chromium/ui/views/window/non_client_view.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/views/window/non_client_view.cc')
-rw-r--r--chromium/ui/views/window/non_client_view.cc62
1 files changed, 26 insertions, 36 deletions
diff --git a/chromium/ui/views/window/non_client_view.cc b/chromium/ui/views/window/non_client_view.cc
index 73170394a79..7c45c43d07f 100644
--- a/chromium/ui/views/window/non_client_view.cc
+++ b/chromium/ui/views/window/non_client_view.cc
@@ -10,8 +10,9 @@
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/hit_test.h"
+#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/gfx/geometry/rect_conversions.h"
-#include "ui/views/metadata/metadata_impl_macros.h"
+#include "ui/views/layout/fill_layout.h"
#include "ui/views/rect_based_targeting_utils.h"
#include "ui/views/view_targeter.h"
#include "ui/views/widget/root_view.h"
@@ -24,18 +25,6 @@
namespace views {
-namespace {
-
-// The frame view and the client view are always at these specific indices,
-// because the RootView message dispatch sends messages to items higher in the
-// z-order first and we always want the client view to have first crack at
-// handling mouse messages.
-constexpr int kFrameViewIndex = 0;
-constexpr int kClientViewIndex = 1;
-// The overlay view is always on top (view == children().back()).
-
-} // namespace
-
NonClientFrameView::~NonClientFrameView() = default;
bool NonClientFrameView::ShouldPaintAsActive() const {
@@ -129,18 +118,19 @@ void NonClientFrameView::OnThemeChanged() {
SchedulePaint();
}
-NonClientFrameView::NonClientFrameView() {
- SetEventTargeter(std::make_unique<views::ViewTargeter>(this));
-}
+void NonClientFrameView::Layout() {
+ if (GetLayoutManager())
+ GetLayoutManager()->Layout(this);
-// ViewTargeterDelegate:
-bool NonClientFrameView::DoesIntersectRect(const View* target,
- const gfx::Rect& rect) const {
- CHECK_EQ(target, this);
+ views::ClientView* client_view = GetWidget()->client_view();
+ client_view->SetBoundsRect(GetBoundsForClientView());
+ SkPath client_clip;
+ if (GetClientMask(client_view->size(), &client_clip))
+ client_view->SetClipPath(client_clip);
+}
- // For the default case, we assume the non-client frame view never overlaps
- // the client view.
- return !GetWidget()->client_view()->bounds().Intersects(rect);
+NonClientFrameView::NonClientFrameView() {
+ SetEventTargeter(std::make_unique<views::ViewTargeter>(this));
}
#if defined(OS_WIN)
@@ -165,13 +155,18 @@ NonClientView::~NonClientView() {
void NonClientView::SetFrameView(
std::unique_ptr<NonClientFrameView> frame_view) {
- // See comment in header about ownership.
- frame_view->set_owned_by_client();
- if (frame_view_.get())
- RemoveChildView(frame_view_.get());
+ // If there is an existing frame view, ensure that the ClientView remains
+ // attached to the Widget by moving the ClientView to the new frame before
+ // removing the old frame from the view hierarchy.
+ std::unique_ptr<NonClientFrameView> old_frame_view = std::move(frame_view_);
frame_view_ = std::move(frame_view);
- if (parent())
- AddChildViewAt(frame_view_.get(), kFrameViewIndex);
+ if (parent()) {
+ AddChildViewAt(frame_view_.get(), 0);
+ frame_view_->AddChildViewAt(client_view_, 0);
+ }
+
+ if (old_frame_view)
+ RemoveChildView(old_frame_view.get());
}
void NonClientView::SetOverlayView(View* view) {
@@ -262,11 +257,6 @@ void NonClientView::Layout() {
// into a View hierarchy once" ( http://codereview.chromium.org/27317 ), but
// where that is still the case it should simply be fixed.
frame_view_->SetBoundsRect(GetLocalBounds());
- client_view_->SetBoundsRect(frame_view_->GetBoundsForClientView());
-
- SkPath client_clip;
- if (frame_view_->GetClientMask(client_view_->size(), &client_clip))
- client_view_->SetClipPath(client_clip);
if (overlay_view_)
overlay_view_->SetBoundsRect(GetLocalBounds());
@@ -302,8 +292,8 @@ void NonClientView::ViewHierarchyChanged(
// the various setters, and create and add children directly in the
// constructor.
if (details.is_add && GetWidget() && details.child == this) {
- AddChildViewAt(frame_view_.get(), kFrameViewIndex);
- AddChildViewAt(client_view_, kClientViewIndex);
+ AddChildViewAt(frame_view_.get(), 0);
+ frame_view_->AddChildViewAt(client_view_, 0);
if (overlay_view_)
AddChildView(overlay_view_);
}