Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(696)

Side by Side Diff: ui/views/bubble/bubble_frame_view.cc

Issue 22903022: Limit constrained windows to the size of the parent view. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/bubble/bubble_frame_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/bubble/bubble_frame_view.h" 5 #include "ui/views/bubble/bubble_frame_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "grit/ui_resources.h" 9 #include "grit/ui_resources.h"
10 #include "ui/base/hit_test.h" 10 #include "ui/base/hit_test.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 gfx::Insets BubbleFrameView::GetInsets() const { 161 gfx::Insets BubbleFrameView::GetInsets() const {
162 gfx::Insets insets = content_margins_; 162 gfx::Insets insets = content_margins_;
163 const int title_height = title_->text().empty() ? 0 : 163 const int title_height = title_->text().empty() ? 0 :
164 title_->GetPreferredSize().height() + kTitleTopInset + kTitleBottomInset; 164 title_->GetPreferredSize().height() + kTitleTopInset + kTitleBottomInset;
165 const int close_height = close_->visible() ? close_->height() : 0; 165 const int close_height = close_->visible() ? close_->height() : 0;
166 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0); 166 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0);
167 return insets; 167 return insets;
168 } 168 }
169 169
170 gfx::Size BubbleFrameView::GetPreferredSize() { 170 gfx::Size BubbleFrameView::GetPreferredSize() {
171 const gfx::Size client(GetWidget()->client_view()->GetPreferredSize()); 171 return GetSizeForClientSize(GetWidget()->client_view()->GetPreferredSize());
172 gfx::Size size(GetUpdatedWindowBounds(gfx::Rect(), client, false).size()); 172 }
173
174 gfx::Size BubbleFrameView::GetMinimumSize() {
175 return GetSizeForClientSize(GetWidget()->client_view()->GetMinimumSize());
176 }
177
178 gfx::Size BubbleFrameView::GetSizeForClientSize(const gfx::Size& client_size) {
msw 2013/08/23 19:57:25 nit: Move this function to match the declaration o
Rune Fevang 2013/08/23 20:17:45 Done.
179 gfx::Size size(
180 GetUpdatedWindowBounds(gfx::Rect(), client_size, false).size());
173 // Accommodate the width of the title bar elements. 181 // Accommodate the width of the title bar elements.
174 int title_bar_width = GetInsets().width() + border()->GetInsets().width(); 182 int title_bar_width = GetInsets().width() + border()->GetInsets().width();
175 if (!title_->text().empty()) 183 if (!title_->text().empty())
176 title_bar_width += kTitleLeftInset + title_->GetPreferredSize().width(); 184 title_bar_width += kTitleLeftInset + title_->GetPreferredSize().width();
177 if (close_->visible()) 185 if (close_->visible())
178 title_bar_width += close_->width() + 1; 186 title_bar_width += close_->width() + 1;
179 if (titlebar_extra_view_ != NULL) 187 if (titlebar_extra_view_ != NULL)
180 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); 188 title_bar_width += titlebar_extra_view_->GetPreferredSize().width();
181 size.SetToMax(gfx::Size(title_bar_width, 0)); 189 size.SetToMax(gfx::Size(title_bar_width, 0));
182 return size; 190 return size;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble 336 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble
329 // window needs to be moved to the right and that means we need to move arrow 337 // window needs to be moved to the right and that means we need to move arrow
330 // to the left, and that means negative offset. 338 // to the left, and that means negative offset.
331 bubble_border_->set_arrow_offset( 339 bubble_border_->set_arrow_offset(
332 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); 340 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust);
333 if (offscreen_adjust) 341 if (offscreen_adjust)
334 SchedulePaint(); 342 SchedulePaint();
335 } 343 }
336 344
337 } // namespace views 345 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_frame_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698