Commit 9c24e430 authored by avi@chromium.org's avatar avi@chromium.org

Zero-sized windows are bad.

Eliminate three instances of them, and DCHECK on the condition for the future.

BUG=none
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10003005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132280 0039d316-1c4b-4281-b951-d872f2087c98
parent 8be5efdb
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "content/public/browser/notification_details.h" #include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_source.h" #include "content/public/browser/notification_source.h"
#include "ui/base/cocoa/window_size_constants.h"
using content::RenderViewHost; using content::RenderViewHost;
...@@ -129,7 +130,7 @@ class DevtoolsNotificationBridge : public content::NotificationObserver { ...@@ -129,7 +130,7 @@ class DevtoolsNotificationBridge : public content::NotificationObserver {
devMode:(BOOL)devMode { devMode:(BOOL)devMode {
scoped_nsobject<InfoBubbleWindow> window( scoped_nsobject<InfoBubbleWindow> window(
[[InfoBubbleWindow alloc] [[InfoBubbleWindow alloc]
initWithContentRect:NSZeroRect initWithContentRect:ui::kWindowSizeDeterminedLater
styleMask:NSBorderlessWindowMask styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered backing:NSBackingStoreBuffered
defer:YES]); defer:YES]);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "skia/ext/skia_utils_mac.h" #include "skia/ext/skia_utils_mac.h"
#import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
#import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h"
#include "ui/base/cocoa/window_size_constants.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/text/text_elider.h" #include "ui/base/text/text_elider.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
...@@ -322,7 +323,8 @@ bool OmniboxPopupViewMac::IsOpen() const { ...@@ -322,7 +323,8 @@ bool OmniboxPopupViewMac::IsOpen() const {
void OmniboxPopupViewMac::CreatePopupIfNeeded() { void OmniboxPopupViewMac::CreatePopupIfNeeded() {
if (!popup_) { if (!popup_) {
popup_.reset([[NSWindow alloc] initWithContentRect:NSZeroRect popup_.reset(
[[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater
styleMask:NSBorderlessWindowMask styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered backing:NSBackingStoreBuffered
defer:YES]); defer:YES]);
......
...@@ -183,7 +183,7 @@ void ShowPageInfoBubble(gfx::NativeWindow parent, ...@@ -183,7 +183,7 @@ void ShowPageInfoBubble(gfx::NativeWindow parent,
DCHECK(parentWindow); DCHECK(parentWindow);
// Use an arbitrary height because it will be changed by the bridge. // Use an arbitrary height because it will be changed by the bridge.
NSRect contentRect = NSMakeRect(0, 0, kWindowWidth, 0); NSRect contentRect = NSMakeRect(0, 0, kWindowWidth, 1);
// Create an empty window into which content is placed. // Create an empty window into which content is placed.
scoped_nsobject<InfoBubbleWindow> window( scoped_nsobject<InfoBubbleWindow> window(
[[InfoBubbleWindow alloc] initWithContentRect:contentRect [[InfoBubbleWindow alloc] initWithContentRect:contentRect
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
#import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h"
#import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h"
#include "ui/base/cocoa/window_size_constants.h"
#include "ui/base/text/text_elider.h" #include "ui/base/text/text_elider.h"
#include "ui/gfx/point.h" #include "ui/gfx/point.h"
...@@ -359,7 +360,7 @@ void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) { ...@@ -359,7 +360,7 @@ void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) {
void StatusBubbleMac::Create() { void StatusBubbleMac::Create() {
DCHECK(!window_); DCHECK(!window_);
window_ = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1) window_ = [[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater
styleMask:NSBorderlessWindowMask styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered backing:NSBackingStoreBuffered
defer:YES]; defer:YES];
......
...@@ -87,6 +87,20 @@ void RootDidAddSubview(id self, SEL _cmd, NSView* subview) { ...@@ -87,6 +87,20 @@ void RootDidAddSubview(id self, SEL _cmd, NSView* subview) {
styleMask:(NSUInteger)windowStyle styleMask:(NSUInteger)windowStyle
backing:(NSBackingStoreType)bufferingType backing:(NSBackingStoreType)bufferingType
defer:(BOOL)deferCreation { defer:(BOOL)deferCreation {
// It is invalid to create windows with zero width or height. It screws things
// up royally:
// - It causes console spew: <http://crbug.com/78973>
// - It breaks Expose: <http://sourceforge.net/projects/heat-meteo/forums/forum/268087/topic/4582610>
//
// This is a banned practice
// <http://www.chromium.org/developers/coding-style/cocoa-dos-and-donts>. Do
// not do this. Use kWindowSizeDeterminedLater in
// ui/base/cocoa/window_size_constants.h instead.
//
// (This is checked here because UnderlayOpenGLHostingWindow is the base of
// most Chromium windows, not because this is related to its functionality.)
DCHECK(contentRect.size.width > 0 &&
contentRect.size.height > 0);
if ((self = [super initWithContentRect:contentRect if ((self = [super initWithContentRect:contentRect
styleMask:windowStyle styleMask:windowStyle
backing:bufferingType backing:bufferingType
......
// Copyright (c) 2012 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.
#ifndef UI_BASE_COCOA_WINDOW_SIZE_CONSTANTS_H_
#define UI_BASE_COCOA_WINDOW_SIZE_CONSTANTS_H_
#pragma once
#include "ui/base/ui_export.h"
#import <Foundation/Foundation.h>
namespace ui {
// It is not valid to make a zero-sized window. Use this constant instead.
UI_EXPORT extern const NSRect kWindowSizeDeterminedLater;
} // namespace ui
#endif // UI_BASE_COCOA_WINDOW_SIZE_CONSTANTS_H_
// Copyright (c) 2012 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.
#include "ui/base/cocoa/window_size_constants.h"
namespace ui {
const NSRect kWindowSizeDeterminedLater = { {0, 0}, {1, 1} };
} // namespace ui
...@@ -101,6 +101,8 @@ ...@@ -101,6 +101,8 @@
'base/cocoa/nib_loading.mm', 'base/cocoa/nib_loading.mm',
'base/cocoa/underlay_opengl_hosting_window.h', 'base/cocoa/underlay_opengl_hosting_window.h',
'base/cocoa/underlay_opengl_hosting_window.mm', 'base/cocoa/underlay_opengl_hosting_window.mm',
'base/cocoa/window_size_constants.h',
'base/cocoa/window_size_constants.mm',
'base/cursor/cursor.cc', 'base/cursor/cursor.cc',
'base/cursor/cursor.h', 'base/cursor/cursor.h',
'base/cursor/cursor_win.cc', 'base/cursor/cursor_win.cc',
......
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