summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authorskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 19:28:10 +0000
committerskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 19:28:10 +0000
commitcda45c034ced09ca661c538c871c602372ff032a (patch)
treeb48c8562448e16ef605e25b114aa1160218ac471 /chrome/browser/cocoa
parent68c243b40bef0b0d55d8783a0625146d7709bb8f (diff)
downloadchromium_src-cda45c034ced09ca661c538c871c602372ff032a.zip
chromium_src-cda45c034ced09ca661c538c871c602372ff032a.tar.gz
chromium_src-cda45c034ced09ca661c538c871c602372ff032a.tar.bz2
Disable scroll bars on resizing popups below a maximum size.
This CL requires a patch to webkit to compile. That patch is tracked here: https://bugs.webkit.org/show_bug.cgi?id=35257 This CL makes a change on Mac and Linux. Windows will follow in a sepperate change. BUG=30247 TEST=Manual testing using the test case attached to the bug and the sample extensions. Review URL: http://codereview.chromium.org/657012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40036 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/extension_view_mac.h11
-rw-r--r--chrome/browser/cocoa/extension_view_mac.mm16
-rw-r--r--chrome/browser/cocoa/extensions/extension_popup_controller.mm28
3 files changed, 40 insertions, 15 deletions
diff --git a/chrome/browser/cocoa/extension_view_mac.h b/chrome/browser/cocoa/extension_view_mac.h
index 4ce4c13..5fb0f54 100644
--- a/chrome/browser/cocoa/extension_view_mac.h
+++ b/chrome/browser/cocoa/extension_view_mac.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -49,6 +49,15 @@ class ExtensionViewMac {
// connection.
void RenderViewCreated();
+ // The minimum/maximum dimensions of the popup.
+ // The minimum is just a little larger than the size of the button itself.
+ // The maximum is an arbitrary number that should be smaller than most
+ // screens.
+ static const CGFloat kMinWidth;
+ static const CGFloat kMinHeight;
+ static const CGFloat kMaxWidth;
+ static const CGFloat kMaxHeight;
+
private:
RenderViewHost* render_view_host() const;
diff --git a/chrome/browser/cocoa/extension_view_mac.mm b/chrome/browser/cocoa/extension_view_mac.mm
index 0ff029a..ca00978 100644
--- a/chrome/browser/cocoa/extension_view_mac.mm
+++ b/chrome/browser/cocoa/extension_view_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,6 +8,12 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
+// The minimum/maximum dimensions of the popup.
+const CGFloat ExtensionViewMac::kMinWidth = 25.0;
+const CGFloat ExtensionViewMac::kMinHeight = 25.0;
+const CGFloat ExtensionViewMac::kMaxWidth = 800.0;
+const CGFloat ExtensionViewMac::kMaxHeight = 600.0;
+
ExtensionViewMac::ExtensionViewMac(ExtensionHost* extension_host,
Browser* browser)
: is_toolstrip_(true),
@@ -69,6 +75,14 @@ void ExtensionViewMac::UpdatePreferredSize(const gfx::Size& new_size) {
}
void ExtensionViewMac::RenderViewCreated() {
+ // Do not allow webkit to draw scroll bars on views smaller than
+ // the largest size view allowed. The view will be resized to make
+ // scroll bars unnecessary. Scroll bars change the height of the
+ // view, so not drawing them is necessary to avoid infinite resizing.
+ gfx::Size largest_popup_size(
+ CGSizeMake(ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight));
+ extension_host_->DisableScrollbarsForSmallWindows(largest_popup_size);
+
if (!pending_background_.empty() && render_view_host()->view()) {
render_widget_host_view_->SetBackground(pending_background_);
pending_background_.reset();
diff --git a/chrome/browser/cocoa/extensions/extension_popup_controller.mm b/chrome/browser/cocoa/extensions/extension_popup_controller.mm
index 4606a92..72271b5 100644
--- a/chrome/browser/cocoa/extensions/extension_popup_controller.mm
+++ b/chrome/browser/cocoa/extensions/extension_popup_controller.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,21 +15,19 @@
#include "chrome/browser/profile.h"
#include "chrome/common/notification_service.h"
-// The minimum/maximum dimensions of the popup.
-// The minimum is just a little larger than the size of the button itself.
-// The maximum is an arbitrary number that should be smaller than most screens.
namespace {
-const CGFloat kMinWidth = 25;
-const CGFloat kMinHeight = 25;
-const CGFloat kMaxWidth = 800;
-const CGFloat kMaxHeight = 600;
-
// The duration for any animations that might be invoked by this controller.
const NSTimeInterval kAnimationDuration = 0.2;
// There should only be one extension popup showing at one time. Keep a
// reference to it here.
static ExtensionPopupController* gPopup;
+
+// Given a value and a rage, clamp the value into the range.
+CGFloat Clamp(CGFloat value, CGFloat min, CGFloat max) {
+ return std::max(min, std::min(max, value));
+}
+
} // namespace
@interface ExtensionPopupController(Private)
@@ -179,8 +177,12 @@ static ExtensionPopupController* gPopup;
extensionFrame_ = [extensionView_ frame];
// Constrain the size of the view.
[extensionView_ setFrameSize:NSMakeSize(
- std::max(kMinWidth, std::min(kMaxWidth, NSWidth(extensionFrame_))),
- std::max(kMinHeight, std::min(kMaxHeight, NSHeight(extensionFrame_))))];
+ Clamp(NSWidth(extensionFrame_),
+ ExtensionViewMac::kMinWidth,
+ ExtensionViewMac::kMaxWidth),
+ Clamp(NSHeight(extensionFrame_),
+ ExtensionViewMac::kMinHeight,
+ ExtensionViewMac::kMaxHeight))];
// Pad the window by half of the rounded corner radius to prevent the
// extension's view from bleeding out over the corners.
@@ -238,13 +240,13 @@ static ExtensionPopupController* gPopup;
// Private (TestingAPI)
+ (NSSize)minPopupSize {
- NSSize minSize = {kMinWidth, kMinHeight};
+ NSSize minSize = {ExtensionViewMac::kMinWidth, ExtensionViewMac::kMinHeight};
return minSize;
}
// Private (TestingAPI)
+ (NSSize)maxPopupSize {
- NSSize maxSize = {kMaxWidth, kMaxHeight};
+ NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight};
return maxSize;
}