Commit 62655f97 authored by pkasting@chromium.org's avatar pkasting@chromium.org

Non-functional cleanup:

* Clarify some comments.
* Simplify some redundant boolean logic.
* Add a helper function for something a lot of callers were checking manually.
* Fix lint.
Review URL: http://codereview.chromium.org/27247

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10546 0039d316-1c4b-4281-b951-d872f2087c98
parent 6cf8200b
......@@ -126,15 +126,15 @@ static const struct {
class ResizeCorner : public views::View {
public:
ResizeCorner(const BrowserWindow* parent)
explicit ResizeCorner(const BrowserView* parent)
: parent_(parent) {
}
virtual void Paint(ChromeCanvas* canvas) {
if (parent_ && (parent_->IsMaximized() || parent_->IsFullscreen()))
if (parent_ && !parent_->CanCurrentlyResize())
return;
SkBitmap * bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed(
SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed(
IDR_TEXTAREA_RESIZER);
bitmap->buildMipMap(false);
bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT);
......@@ -144,20 +144,19 @@ class ResizeCorner : public views::View {
canvas->save();
}
canvas->DrawBitmapInt(*bitmap, width() - bitmap->width(),
height() - bitmap->height());
height() - bitmap->height());
if (rtl_dir)
canvas->restore();
}
static gfx::Size GetSize() {
return gfx::Size(views::NativeScrollBar::GetVerticalScrollBarWidth(),
views::NativeScrollBar::GetHorizontalScrollBarHeight());
views::NativeScrollBar::GetHorizontalScrollBarHeight());
}
virtual gfx::Size GetPreferredSize() {
if (parent_ && (parent_->IsMaximized() || parent_->IsFullscreen()))
return gfx::Size();
return GetSize();
return (parent_ && !parent_->CanCurrentlyResize()) ?
gfx::Size() : GetSize();
}
virtual void Layout() {
......@@ -167,12 +166,12 @@ class ResizeCorner : public views::View {
// No need to handle Right to left text direction here,
// our parent must take care of it for us...
SetBounds(parent_view->width() - ps.width(),
parent_view->height() - ps.height(), ps.width(), ps.height());
parent_view->height() - ps.height(), ps.width(), ps.height());
}
}
private:
const BrowserWindow* parent_;
const BrowserView* parent_;
DISALLOW_COPY_AND_ASSIGN(ResizeCorner);
};
......@@ -259,6 +258,10 @@ void BrowserView::WindowMoveOrResizeStarted() {
tab_contents->AsWebContents()->WindowMoveOrResizeStarted();
}
bool BrowserView::CanCurrentlyResize() const {
return !IsMaximized() && !IsFullscreen();
}
gfx::Rect BrowserView::GetToolbarBounds() const {
return toolbar_->bounds();
}
......@@ -715,8 +718,7 @@ bool BrowserView::IsBookmarkBarVisible() const {
}
gfx::Rect BrowserView::GetRootWindowResizerRect() const {
// There is no resize corner when we are maximized or full screen
if (IsMaximized() || IsFullscreen())
if (!CanCurrentlyResize())
return gfx::Rect();
// We don't specify a resize corner size if we have a bottom shelf either.
......@@ -1108,8 +1110,7 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) {
// area of the window. So we need to treat hit-tests in these regions as
// hit-tests of the titlebar.
// There is not resize corner when we are maximised
if (!IsMaximized() && !IsFullscreen()) {
if (CanCurrentlyResize()) {
CRect client_rect;
::GetClientRect(frame_->GetWindow()->GetHWND(), &client_rect);
gfx::Size resize_corner_size = ResizeCorner::GetSize();
......
......@@ -72,6 +72,11 @@ class BrowserView : public BrowserWindow,
// initiated.
void WindowMoveOrResizeStarted();
// Returns whether the browser can be resized _now_. This differs from
// CanResize() below, which returns whether the window is ever resizable in
// principle.
bool CanCurrentlyResize() const;
// Returns the bounds of the toolbar, in BrowserView coordinates.
gfx::Rect GetToolbarBounds() const;
......
......@@ -669,10 +669,9 @@ int OpaqueNonClientView::TopResizeHeight() const {
}
int OpaqueNonClientView::NonClientBorderThickness() const {
// In maximized mode, we don't show a client edge.
// When we fill the screen, we don't show a client edge.
return FrameBorderThickness() +
((frame_->IsMaximized() || browser_view_->IsFullscreen()) ?
0 : kClientEdgeThickness);
(browser_view_->CanCurrentlyResize() ? kClientEdgeThickness : 0);
}
int OpaqueNonClientView::NonClientTopBorderHeight() const {
......@@ -681,9 +680,8 @@ int OpaqueNonClientView::NonClientTopBorderHeight() const {
return TitleCoordinates(&title_top_spacing, &title_thickness);
}
return FrameBorderThickness() +
((frame_->IsMaximized() || browser_view_->IsFullscreen()) ?
0 : kNonClientRestoredExtraThickness);
return FrameBorderThickness() + (browser_view_->CanCurrentlyResize() ?
kNonClientRestoredExtraThickness : 0);
}
int OpaqueNonClientView::UnavailablePixelsAtBottomOfNonClientHeight() const {
......
......@@ -630,7 +630,7 @@ DWORD Window::CalculateWindowStyle() {
DWORD window_styles = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_SYSMENU;
bool can_resize = window_delegate_->CanResize();
bool can_maximize = window_delegate_->CanMaximize();
if ((can_resize && can_maximize) || can_maximize) {
if (can_maximize) {
window_styles |= WS_OVERLAPPEDWINDOW;
} else if (can_resize) {
window_styles |= WS_OVERLAPPED | WS_THICKFRAME;
......
......@@ -43,12 +43,12 @@ class WindowDelegate {
virtual DialogDelegate* AsDialogDelegate() { return NULL; }
// Returns true if the window can be resized.
// Returns true if the window can ever be resized.
virtual bool CanResize() const {
return false;
}
// Returns true if the window can be maximized.
// Returns true if the window can ever be maximized.
virtual bool CanMaximize() const {
return false;
}
......
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