summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-08 19:48:19 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-08 19:48:19 +0000
commit6f02bc09e8176a592e38ec118f70595a7672fcbf (patch)
treefc7b4f29058643cf9a94b166982815dd9fc70aec
parent942dd7327db269b13d8f1e3155f13165af723395 (diff)
downloadchromium_src-6f02bc09e8176a592e38ec118f70595a7672fcbf.zip
chromium_src-6f02bc09e8176a592e38ec118f70595a7672fcbf.tar.gz
chromium_src-6f02bc09e8176a592e38ec118f70595a7672fcbf.tar.bz2
Allow constrained popups to resize themselves...up to 10 times. (Then we ignore their pleas for resizes since they're obviously up to no good.)
BUG=1255747 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@585 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/constrained_window.h3
-rw-r--r--chrome/browser/views/constrained_window_impl.cc34
-rw-r--r--chrome/browser/views/constrained_window_impl.h8
3 files changed, 29 insertions, 16 deletions
diff --git a/chrome/browser/constrained_window.h b/chrome/browser/constrained_window.h
index 32fa071..7f67398 100644
--- a/chrome/browser/constrained_window.h
+++ b/chrome/browser/constrained_window.h
@@ -129,9 +129,6 @@ class ConstrainedWindow {
// Closes the Constrained Window.
virtual void CloseConstrainedWindow() = 0;
- // Tells the Constrained Window to resize to the specified size.
- virtual void ResizeConstrainedWindow(int width, int height) = 0;
-
// Repositions the Constrained Window so that the lower right corner
// of the titlebar is at the passed in |anchor_point|.
virtual void RepositionConstrainedWindowTo(
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc
index 2755b34..fd13b85 100644
--- a/chrome/browser/views/constrained_window_impl.cc
+++ b/chrome/browser/views/constrained_window_impl.cc
@@ -955,14 +955,6 @@ void ConstrainedWindowImpl::CloseConstrainedWindow() {
Close();
}
-void ConstrainedWindowImpl::ResizeConstrainedWindow(int width, int height) {
- gfx::Size window_size =
- non_client_view_->CalculateWindowSizeForClientSize(width, height);
- ::SetWindowPos(GetHWND(), NULL, 0, 0, window_size.width(),
- window_size.height(),
- SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
-}
-
void ConstrainedWindowImpl::RepositionConstrainedWindowTo(
const gfx::Point& anchor_point) {
anchor_point_ = anchor_point;
@@ -1085,6 +1077,8 @@ void ConstrainedWindowImpl::MoveContents(TabContents* source,
const gfx::Rect& pos) {
if (!IsSuppressedConstrainedWindow())
SetWindowBounds(pos);
+ else
+ ResizeConstrainedWindow(pos.width(), pos.height());
}
bool ConstrainedWindowImpl::IsPopup(TabContents* source) {
@@ -1145,16 +1139,34 @@ void ConstrainedWindowImpl::ResizeConstrainedTitlebar() {
CRect this_bounds;
GetClientRect(&this_bounds);
- // First determine the height of the title bar of a constrained window, so
+ ResizeConstrainedWindow(this_bounds.Width(), this_bounds.Height());
+}
+
+void ConstrainedWindowImpl::ResizeConstrainedWindow(int width, int height) {
+ DCHECK(constrained_contents_)
+ << "ResizeConstrainedTitlebar() is only valid for web popups";
+
+ // Make sure we aren't larger then our containing tab contents.
+ if (width > anchor_point_.x())
+ width = anchor_point_.x();
+
+ // Determine the height of the title bar of a constrained window, so
// that we can offset by that much vertically if necessary...
int titlebar_height = non_client_view()->CalculateTitlebarHeight();
int visible_titlebar_pixels =
static_cast<int>(titlebar_height * titlebar_visibility_);
- int x = anchor_point_.x() - this_bounds.Width();
+ int x = anchor_point_.x() - width;
int y = anchor_point_.y() - visible_titlebar_pixels;
- SetWindowPos(NULL, x, y, this_bounds.Width(), visible_titlebar_pixels,
+
+ // NOTE: Previously, we passed in |visible_titlebar_pixels| instead
+ // of |height|. This didn't actually change any of the properties of
+ // the child HWNDS. If we ever set the |anchor_point_| intelligently
+ // so that it deals with scrollbars, we'll need to change height
+ // back to |visible_titlebar_pixels| and find a different solution,
+ // otherwise part of the window will be displayed over the scrollbar.
+ SetWindowPos(NULL, x, y, width, height,
SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
diff --git a/chrome/browser/views/constrained_window_impl.h b/chrome/browser/views/constrained_window_impl.h
index 31a6d04..7ccd067 100644
--- a/chrome/browser/views/constrained_window_impl.h
+++ b/chrome/browser/views/constrained_window_impl.h
@@ -67,7 +67,6 @@ class ConstrainedWindowImpl : public ConstrainedWindow,
// Overridden from ConstrainedWindow:
virtual void CloseConstrainedWindow();
virtual void ActivateConstrainedWindow();
- virtual void ResizeConstrainedWindow(int width, int height);
virtual void RepositionConstrainedWindowTo(const gfx::Point& anchor_point);
virtual bool IsSuppressedConstrainedWindow() const;
virtual void WasHidden();
@@ -138,12 +137,17 @@ class ConstrainedWindowImpl : public ConstrainedWindow,
void Init(TabContents* owner);
// Called after changing either the anchor point or titlebar
- // visibility of a suppressed popup. This does the actual resizing.
+ // visibility of a suppressed popup.
//
// @see RepositionConstrainedWindowTo
// @see SetTitlebarVisibilityPercentage
void ResizeConstrainedTitlebar();
+ // Called to change the size of a constrained window. Moves the
+ // window to the anchor point (taking titlebar visibility into
+ // account) and sets the pop up size.
+ void ResizeConstrainedWindow(int width, int height);
+
// Initialize the Constrained Window as a Constrained Dialog containing a
// ChromeViews::View client area.
void InitAsDialog(const gfx::Rect& initial_bounds);