Aura: Fix window resizing for large drags.

* Fix a DCHECK due to a negative width when resizing the right edge past the left one, and vice versa.
* Fix the window moving when resizing its left edge past the minimum size, ditto for top edge.
* Add unit tests for above.
* Add GetMinimizeSize() method to aura::WindowDelegate interface.

BUG=104245
TEST=aura_shell_unittests, manual

Review URL: http://codereview.chromium.org/8618009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111244 0039d316-1c4b-4281-b951-d872f2087c98
parent f552df55
...@@ -396,7 +396,8 @@ void RenderWidgetHostViewAura::UnlockMouse() { ...@@ -396,7 +396,8 @@ void RenderWidgetHostViewAura::UnlockMouse() {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// RenderWidgetHostViewAura, aura::WindowDelegate implementation: // RenderWidgetHostViewAura, aura::WindowDelegate implementation:
void RenderWidgetHostViewAura::OnBoundsChanging(gfx::Rect* new_bounds) { gfx::Size RenderWidgetHostViewAura::GetMinimumSize() const {
return gfx::Size();
} }
void RenderWidgetHostViewAura::OnBoundsChanged(const gfx::Rect& old_bounds, void RenderWidgetHostViewAura::OnBoundsChanged(const gfx::Rect& old_bounds,
......
...@@ -99,7 +99,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura ...@@ -99,7 +99,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
virtual void UnlockMouse() OVERRIDE; virtual void UnlockMouse() OVERRIDE;
// Overridden from aura::WindowDelegate: // Overridden from aura::WindowDelegate:
virtual void OnBoundsChanging(gfx::Rect* new_bounds) OVERRIDE; virtual gfx::Size GetMinimumSize() const OVERRIDE;
virtual void OnBoundsChanged(const gfx::Rect& old_bounds, virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE; const gfx::Rect& new_bounds) OVERRIDE;
virtual void OnFocus() OVERRIDE; virtual void OnFocus() OVERRIDE;
......
...@@ -31,7 +31,9 @@ class DemoWindowDelegate : public aura::WindowDelegate { ...@@ -31,7 +31,9 @@ class DemoWindowDelegate : public aura::WindowDelegate {
explicit DemoWindowDelegate(SkColor color) : color_(color) {} explicit DemoWindowDelegate(SkColor color) : color_(color) {}
// Overridden from WindowDelegate: // Overridden from WindowDelegate:
virtual void OnBoundsChanging(gfx::Rect* new_bounds) OVERRIDE {} virtual gfx::Size GetMinimumSize() const OVERRIDE {
return gfx::Size();
}
virtual void OnBoundsChanged(const gfx::Rect& old_bounds, virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE {} const gfx::Rect& new_bounds) OVERRIDE {}
virtual void OnFocus() OVERRIDE {} virtual void OnFocus() OVERRIDE {}
......
...@@ -22,7 +22,8 @@ TestWindowDelegate::TestWindowDelegate() { ...@@ -22,7 +22,8 @@ TestWindowDelegate::TestWindowDelegate() {
TestWindowDelegate::~TestWindowDelegate() { TestWindowDelegate::~TestWindowDelegate() {
} }
void TestWindowDelegate::OnBoundsChanging(gfx::Rect* new_bounds) { gfx::Size TestWindowDelegate::GetMinimumSize() const {
return gfx::Size();
} }
void TestWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds, void TestWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds,
......
...@@ -20,7 +20,7 @@ class TestWindowDelegate : public WindowDelegate { ...@@ -20,7 +20,7 @@ class TestWindowDelegate : public WindowDelegate {
virtual ~TestWindowDelegate(); virtual ~TestWindowDelegate();
// Overridden from WindowDelegate: // Overridden from WindowDelegate:
virtual void OnBoundsChanging(gfx::Rect* new_bounds) OVERRIDE; virtual gfx::Size GetMinimumSize() const OVERRIDE;
virtual void OnBoundsChanged(const gfx::Rect& old_bounds, virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE; const gfx::Rect& new_bounds) OVERRIDE;
virtual void OnFocus() OVERRIDE; virtual void OnFocus() OVERRIDE;
......
...@@ -440,9 +440,14 @@ void Window::WindowDetachedFromDesktop(aura::Window* window) { ...@@ -440,9 +440,14 @@ void Window::WindowDetachedFromDesktop(aura::Window* window) {
void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { void Window::SetBoundsInternal(const gfx::Rect& new_bounds) {
gfx::Rect actual_new_bounds(new_bounds); gfx::Rect actual_new_bounds(new_bounds);
// Gives delegate a change to examine and change the new bounds. // Ensure we don't go smaller than our minimum bounds.
if (delegate_) if (delegate_) {
delegate_->OnBoundsChanging(&actual_new_bounds); const gfx::Size& min_size = delegate_->GetMinimumSize();
actual_new_bounds.set_width(
std::max(min_size.width(), actual_new_bounds.width()));
actual_new_bounds.set_height(
std::max(min_size.height(), actual_new_bounds.height()));
}
const gfx::Rect old_bounds = layer_->GetTargetBounds(); const gfx::Rect old_bounds = layer_->GetTargetBounds();
......
...@@ -14,6 +14,7 @@ namespace gfx { ...@@ -14,6 +14,7 @@ namespace gfx {
class Canvas; class Canvas;
class Point; class Point;
class Rect; class Rect;
class Size;
} }
namespace aura { namespace aura {
...@@ -26,9 +27,8 @@ class TouchEvent; ...@@ -26,9 +27,8 @@ class TouchEvent;
// Delegate interface for aura::Window. // Delegate interface for aura::Window.
class AURA_EXPORT WindowDelegate { class AURA_EXPORT WindowDelegate {
public: public:
// Called before the Window's position and/or size changes and deleage could // Returns the window's minimum size, or size 0,0 if there is no limit.
// take this opportunity to examine and change the new bounds. virtual gfx::Size GetMinimumSize() const = 0;
virtual void OnBoundsChanging(gfx::Rect* new_bounds) = 0;
// Called when the Window's position and/or size changes. // Called when the Window's position and/or size changes.
virtual void OnBoundsChanged(const gfx::Rect& old_bounds, virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
......
...@@ -106,15 +106,25 @@ int GetSizeChangeDirectionForWindowComponent(int window_component) { ...@@ -106,15 +106,25 @@ int GetSizeChangeDirectionForWindowComponent(int window_component) {
return size_change_direction; return size_change_direction;
} }
int GetXMultiplierForWindowComponent(int window_component) { // Returns true for resize components along the right edge, where a drag in
return window_component == HTTOPRIGHT ? -1 : 1; // positive x will make the window larger.
bool IsRightEdge(int window_component) {
return window_component == HTTOPRIGHT ||
window_component == HTRIGHT ||
window_component == HTBOTTOMRIGHT ||
window_component == HTGROWBOX;
} }
int GetYMultiplierForWindowComponent(int window_component) { // Returns true for resize components in along the bottom edge, where a drag
return window_component == HTBOTTOMLEFT ? -1 : 1; // in positive y will make the window larger.
bool IsBottomEdge(int window_component) {
return window_component == HTBOTTOMLEFT ||
window_component == HTBOTTOM ||
window_component == HTBOTTOMRIGHT ||
window_component == HTGROWBOX;
} }
} } // namespace
ToplevelWindowEventFilter::ToplevelWindowEventFilter(aura::Window* owner) ToplevelWindowEventFilter::ToplevelWindowEventFilter(aura::Window* owner)
: EventFilter(owner), : EventFilter(owner),
...@@ -143,8 +153,7 @@ bool ToplevelWindowEventFilter::PreHandleMouseEvent(aura::Window* target, ...@@ -143,8 +153,7 @@ bool ToplevelWindowEventFilter::PreHandleMouseEvent(aura::Window* target,
// pressed without mouse move event. // pressed without mouse move event.
UpdateWindowComponentForEvent(target, event); UpdateWindowComponentForEvent(target, event);
mouse_down_bounds_ = target->bounds(); mouse_down_bounds_ = target->bounds();
mouse_down_offset_in_target_ = event->location(); mouse_down_offset_in_parent_ = event->location();
mouse_down_offset_in_parent_ = mouse_down_offset_in_target_;
aura::Window::ConvertPointToWindow(target, target->parent(), aura::Window::ConvertPointToWindow(target, target->parent(),
&mouse_down_offset_in_parent_); &mouse_down_offset_in_parent_);
return GetBoundsChangeForWindowComponent(window_component_) != return GetBoundsChangeForWindowComponent(window_component_) !=
...@@ -192,8 +201,21 @@ bool ToplevelWindowEventFilter::HandleDrag(aura::Window* target, ...@@ -192,8 +201,21 @@ bool ToplevelWindowEventFilter::HandleDrag(aura::Window* target,
target->GetIntProperty(aura::kShowStateKey) != ui::SHOW_STATE_DEFAULT) target->GetIntProperty(aura::kShowStateKey) != ui::SHOW_STATE_DEFAULT)
return false; return false;
target->SetBounds(gfx::Rect(GetOriginForDrag(bounds_change, target, event), // Dragging a window moves the local coordinate frame, so do arithmetic
GetSizeForDrag(bounds_change, target, event))); // in the parent coordinate frame.
gfx::Point event_location_in_parent(event->location());
aura::Window::ConvertPointToWindow(target, target->parent(),
&event_location_in_parent);
int delta_x = event_location_in_parent.x() - mouse_down_offset_in_parent_.x();
int delta_y = event_location_in_parent.y() - mouse_down_offset_in_parent_.y();
// The minimize size constraint may limit how much we change the window
// position. For example, dragging the left edge to the right should stop
// repositioning the window when the minimize size is reached.
gfx::Size size = GetSizeForDrag(bounds_change, target, &delta_x, &delta_y);
gfx::Point origin = GetOriginForDrag(bounds_change, delta_x, delta_y);
target->SetBounds(gfx::Rect(origin, size));
return true; return true;
} }
...@@ -206,23 +228,16 @@ void ToplevelWindowEventFilter::UpdateWindowComponentForEvent( ...@@ -206,23 +228,16 @@ void ToplevelWindowEventFilter::UpdateWindowComponentForEvent(
gfx::Point ToplevelWindowEventFilter::GetOriginForDrag( gfx::Point ToplevelWindowEventFilter::GetOriginForDrag(
int bounds_change, int bounds_change,
aura::Window* target, int delta_x,
aura::MouseEvent* event) const { int delta_y) const {
gfx::Point origin = mouse_down_bounds_.origin(); gfx::Point origin = mouse_down_bounds_.origin();
if (bounds_change & kBoundsChange_Repositions) { if (bounds_change & kBoundsChange_Repositions) {
int pos_change_direction = int pos_change_direction =
GetPositionChangeDirectionForWindowComponent(window_component_); GetPositionChangeDirectionForWindowComponent(window_component_);
if (pos_change_direction & kBoundsChangeDirection_Horizontal)
if (pos_change_direction & kBoundsChangeDirection_Horizontal) { origin.Offset(delta_x, 0);
origin.set_x(event->location().x()); if (pos_change_direction & kBoundsChangeDirection_Vertical)
origin.Offset(-mouse_down_offset_in_target_.x(), 0); origin.Offset(0, delta_y);
origin.Offset(target->bounds().x(), 0);
}
if (pos_change_direction & kBoundsChangeDirection_Vertical) {
origin.set_y(event->location().y());
origin.Offset(0, -mouse_down_offset_in_target_.y());
origin.Offset(0, target->bounds().y());
}
} }
return origin; return origin;
} }
...@@ -230,40 +245,56 @@ gfx::Point ToplevelWindowEventFilter::GetOriginForDrag( ...@@ -230,40 +245,56 @@ gfx::Point ToplevelWindowEventFilter::GetOriginForDrag(
gfx::Size ToplevelWindowEventFilter::GetSizeForDrag( gfx::Size ToplevelWindowEventFilter::GetSizeForDrag(
int bounds_change, int bounds_change,
aura::Window* target, aura::Window* target,
aura::MouseEvent* event) const { int* delta_x,
int* delta_y) const {
gfx::Size size = mouse_down_bounds_.size(); gfx::Size size = mouse_down_bounds_.size();
if (bounds_change & kBoundsChange_Resizes) { if (bounds_change & kBoundsChange_Resizes) {
gfx::Size min_size = target->delegate()->GetMinimumSize();
int size_change_direction = int size_change_direction =
GetSizeChangeDirectionForWindowComponent(window_component_); GetSizeChangeDirectionForWindowComponent(window_component_);
size.SetSize(
gfx::Point event_location_in_parent(event->location()); GetWidthForDrag(size_change_direction, min_size.width(), delta_x),
aura::Window::ConvertPointToWindow(target, target->parent(), GetHeightForDrag(size_change_direction, min_size.height(), delta_y));
&event_location_in_parent);
// The math changes depending on whether the window is being resized, or
// repositioned in addition to being resized.
int first_x = bounds_change & kBoundsChange_Repositions ?
mouse_down_offset_in_parent_.x() : event_location_in_parent.x();
int first_y = bounds_change & kBoundsChange_Repositions ?
mouse_down_offset_in_parent_.y() : event_location_in_parent.y();
int second_x = bounds_change & kBoundsChange_Repositions ?
event_location_in_parent.x() : mouse_down_offset_in_parent_.x();
int second_y = bounds_change & kBoundsChange_Repositions ?
event_location_in_parent.y() : mouse_down_offset_in_parent_.y();
int x_multiplier = GetXMultiplierForWindowComponent(window_component_);
int y_multiplier = GetYMultiplierForWindowComponent(window_component_);
int width = size.width() +
(size_change_direction & kBoundsChangeDirection_Horizontal ?
x_multiplier * (first_x - second_x) : 0);
int height = size.height() +
(size_change_direction & kBoundsChangeDirection_Vertical ?
y_multiplier * (first_y - second_y) : 0);
size.SetSize(width, height);
} }
return size; return size;
} }
int ToplevelWindowEventFilter::GetWidthForDrag(int size_change_direction,
int min_width,
int* delta_x) const {
int width = mouse_down_bounds_.width();
if (size_change_direction & kBoundsChangeDirection_Horizontal) {
// Along the right edge, positive delta_x increases the window size.
int x_multiplier = IsRightEdge(window_component_) ? 1 : -1;
width += x_multiplier * (*delta_x);
// Ensure we don't shrink past the minimum width and clamp delta_x
// for the window origin computation.
if (width < min_width) {
width = min_width;
*delta_x = -x_multiplier * (mouse_down_bounds_.width() - min_width);
}
}
return width;
}
int ToplevelWindowEventFilter::GetHeightForDrag(int size_change_direction,
int min_height,
int* delta_y) const {
int height = mouse_down_bounds_.height();
if (size_change_direction & kBoundsChangeDirection_Vertical) {
// Along the bottom edge, positive delta_y increases the window size.
int y_multiplier = IsBottomEdge(window_component_) ? 1 : -1;
height += y_multiplier * (*delta_y);
// Ensure we don't shrink past the minimum height and clamp delta_y
// for the window origin computation.
if (height < min_height) {
height = min_height;
*delta_y = -y_multiplier * (mouse_down_bounds_.height() - min_height);
}
}
return height;
}
} // namespace aura } // namespace aura
...@@ -53,17 +53,29 @@ class AURA_SHELL_EXPORT ToplevelWindowEventFilter : public aura::EventFilter { ...@@ -53,17 +53,29 @@ class AURA_SHELL_EXPORT ToplevelWindowEventFilter : public aura::EventFilter {
// Calculates the new origin of the window during a drag. // Calculates the new origin of the window during a drag.
gfx::Point GetOriginForDrag(int bounds_change, gfx::Point GetOriginForDrag(int bounds_change,
aura::Window* target, int delta_x,
aura::MouseEvent* event) const; int delta_y) const;
// Calculates the new size of the window during a drag. // Calculates the new size of the |target| window during a drag.
// If the size is constrained, |delta_x| and |delta_y| may be clamped.
gfx::Size GetSizeForDrag(int bounds_change, gfx::Size GetSizeForDrag(int bounds_change,
aura::Window* target, aura::Window* target,
aura::MouseEvent* event) const; int* delta_x,
int* delta_y) const;
// The mouse position in the target window when the mouse was pressed, in
// target window coordinates. // Calculates new width of a window during a drag where the mouse
gfx::Point mouse_down_offset_in_target_; // position changed by |delta_x|. |delta_x| may be clamped if the window
// size is constrained by |min_width|.
int GetWidthForDrag(int size_change_direction,
int min_width,
int* delta_x) const;
// Calculates new height of a window during a drag where the mouse
// position changed by |delta_y|. |delta_y| may be clamped if the window
// size is constrained by |min_height|.
int GetHeightForDrag(int size_change_direction,
int min_height,
int* delta_y) const;
// The mouse position in the target window when the mouse was pressed, in // The mouse position in the target window when the mouse was pressed, in
// the target window's parent's coordinates. // the target window's parent's coordinates.
......
...@@ -43,13 +43,8 @@ class TestWindowDelegate : public aura::test::TestWindowDelegate { ...@@ -43,13 +43,8 @@ class TestWindowDelegate : public aura::test::TestWindowDelegate {
private: private:
// Overridden from aura::Test::TestWindowDelegate: // Overridden from aura::Test::TestWindowDelegate:
virtual void OnBoundsChanging(gfx::Rect* new_bounds) OVERRIDE { virtual gfx::Size GetMinimumSize() const OVERRIDE {
if (!min_size_.IsEmpty()) { return min_size_;
new_bounds->set_width(std::max(min_size_.width(),
new_bounds->width()));
new_bounds->set_height(std::max(min_size_.height(),
new_bounds->height()));
}
} }
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE { virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE {
return hittest_code_; return hittest_code_;
...@@ -126,7 +121,7 @@ TEST_F(ToplevelWindowEventFilterTest, GrowBox) { ...@@ -126,7 +121,7 @@ TEST_F(ToplevelWindowEventFilterTest, GrowBox) {
scoped_ptr<aura::Window> w1(CreateWindow(HTGROWBOX)); scoped_ptr<aura::Window> w1(CreateWindow(HTGROWBOX));
TestWindowDelegate* window_delegate = TestWindowDelegate* window_delegate =
static_cast<TestWindowDelegate*>(w1->delegate()); static_cast<TestWindowDelegate*>(w1->delegate());
window_delegate->set_min_size(gfx::Size(50, 50)); window_delegate->set_min_size(gfx::Size(40, 40));
gfx::Point position = w1->bounds().origin(); gfx::Point position = w1->bounds().origin();
aura::test::EventGenerator generator; aura::test::EventGenerator generator;
...@@ -147,7 +142,7 @@ TEST_F(ToplevelWindowEventFilterTest, GrowBox) { ...@@ -147,7 +142,7 @@ TEST_F(ToplevelWindowEventFilterTest, GrowBox) {
// Enforce minimum size. // Enforce minimum size.
generator.DragMouseBy(-60, -60); generator.DragMouseBy(-60, -60);
EXPECT_EQ(position, w1->bounds().origin()); EXPECT_EQ(position, w1->bounds().origin());
EXPECT_EQ(gfx::Size(50, 50), w1->bounds().size()); EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
} }
TEST_F(ToplevelWindowEventFilterTest, Right) { TEST_F(ToplevelWindowEventFilterTest, Right) {
...@@ -223,5 +218,87 @@ TEST_F(ToplevelWindowEventFilterTest, Client) { ...@@ -223,5 +218,87 @@ TEST_F(ToplevelWindowEventFilterTest, Client) {
EXPECT_EQ(bounds, w1->bounds()); EXPECT_EQ(bounds, w1->bounds());
} }
TEST_F(ToplevelWindowEventFilterTest, LeftPastMinimum) {
scoped_ptr<aura::Window> w1(CreateWindow(HTLEFT));
TestWindowDelegate* window_delegate =
static_cast<TestWindowDelegate*>(w1->delegate());
window_delegate->set_min_size(gfx::Size(40, 40));
// Simulate a large left-to-right drag. Window width should be clamped to
// minimum and position change should be limited as well.
DragFromCenterBy(w1.get(), 333, 0);
EXPECT_EQ(gfx::Point(60, 0), w1->bounds().origin());
EXPECT_EQ(gfx::Size(40, 100), w1->bounds().size());
}
TEST_F(ToplevelWindowEventFilterTest, RightPastMinimum) {
scoped_ptr<aura::Window> w1(CreateWindow(HTRIGHT));
TestWindowDelegate* window_delegate =
static_cast<TestWindowDelegate*>(w1->delegate());
window_delegate->set_min_size(gfx::Size(40, 40));
gfx::Point position = w1->bounds().origin();
// Simulate a large right-to-left drag. Window width should be clamped to
// minimum and position should not change.
DragFromCenterBy(w1.get(), -333, 0);
EXPECT_EQ(position, w1->bounds().origin());
EXPECT_EQ(gfx::Size(40, 100), w1->bounds().size());
}
TEST_F(ToplevelWindowEventFilterTest, TopLeftPastMinimum) {
scoped_ptr<aura::Window> w1(CreateWindow(HTTOPLEFT));
TestWindowDelegate* window_delegate =
static_cast<TestWindowDelegate*>(w1->delegate());
window_delegate->set_min_size(gfx::Size(40, 40));
// Simulate a large top-left to bottom-right drag. Window width should be
// clamped to minimum and position should be limited.
DragFromCenterBy(w1.get(), 333, 444);
EXPECT_EQ(gfx::Point(60, 60), w1->bounds().origin());
EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
}
TEST_F(ToplevelWindowEventFilterTest, TopRightPastMinimum) {
scoped_ptr<aura::Window> w1(CreateWindow(HTTOPRIGHT));
TestWindowDelegate* window_delegate =
static_cast<TestWindowDelegate*>(w1->delegate());
window_delegate->set_min_size(gfx::Size(40, 40));
// Simulate a large top-right to bottom-left drag. Window size should be
// clamped to minimum, x position should not change, and y position should
// be clamped.
DragFromCenterBy(w1.get(), -333, 444);
EXPECT_EQ(gfx::Point(0, 60), w1->bounds().origin());
EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
}
TEST_F(ToplevelWindowEventFilterTest, BottomLeftPastMinimum) {
scoped_ptr<aura::Window> w1(CreateWindow(HTBOTTOMLEFT));
TestWindowDelegate* window_delegate =
static_cast<TestWindowDelegate*>(w1->delegate());
window_delegate->set_min_size(gfx::Size(40, 40));
// Simulate a large bottom-left to top-right drag. Window size should be
// clamped to minimum, x position should be clamped, and y position should
// not change.
DragFromCenterBy(w1.get(), 333, -444);
EXPECT_EQ(gfx::Point(60, 0), w1->bounds().origin());
EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
}
TEST_F(ToplevelWindowEventFilterTest, BottomRightPastMinimum) {
scoped_ptr<aura::Window> w1(CreateWindow(HTBOTTOMRIGHT));
TestWindowDelegate* window_delegate =
static_cast<TestWindowDelegate*>(w1->delegate());
window_delegate->set_min_size(gfx::Size(40, 40));
gfx::Point position = w1->bounds().origin();
// Simulate a large bottom-right to top-left drag. Window size should be
// clamped to minimum and position should not change.
DragFromCenterBy(w1.get(), -333, -444);
EXPECT_EQ(position, w1->bounds().origin());
EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
}
} // namespace test } // namespace test
} // namespace aura } // namespace aura
...@@ -537,11 +537,8 @@ void NativeWidgetAura::DispatchKeyEventPostIME(const KeyEvent& key) { ...@@ -537,11 +537,8 @@ void NativeWidgetAura::DispatchKeyEventPostIME(const KeyEvent& key) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// NativeWidgetAura, aura::WindowDelegate implementation: // NativeWidgetAura, aura::WindowDelegate implementation:
void NativeWidgetAura::OnBoundsChanging(gfx::Rect* new_bounds) { gfx::Size NativeWidgetAura::GetMinimumSize() const {
// Enforces a minimum size. return delegate_->GetMinimumSize();
const gfx::Size& min_size = delegate_->GetMinimumSize();
new_bounds->set_width(std::max(min_size.width(), new_bounds->width()));
new_bounds->set_height(std::max(min_size.height(), new_bounds->height()));
} }
void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds, void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds,
......
...@@ -121,7 +121,7 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, ...@@ -121,7 +121,7 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate,
virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE; virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE;
// Overridden from aura::WindowDelegate: // Overridden from aura::WindowDelegate:
virtual void OnBoundsChanging(gfx::Rect* new_bounds) OVERRIDE; virtual gfx::Size GetMinimumSize() const OVERRIDE;
virtual void OnBoundsChanged(const gfx::Rect& old_bounds, virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE; const gfx::Rect& new_bounds) OVERRIDE;
virtual void OnFocus() OVERRIDE; virtual void OnFocus() OVERRIDE;
......
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