diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 22:06:35 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 22:06:35 +0000 |
commit | 9c24e430a9c7e8970802dc4e2554ee8a706f652e (patch) | |
tree | 1bb680f77068f992208066209e835095a7f60303 /ui/base/cocoa | |
parent | 8be5efdb6baed4102eb06f7e183900e34041c574 (diff) | |
download | chromium_src-9c24e430a9c7e8970802dc4e2554ee8a706f652e.zip chromium_src-9c24e430a9c7e8970802dc4e2554ee8a706f652e.tar.gz chromium_src-9c24e430a9c7e8970802dc4e2554ee8a706f652e.tar.bz2 |
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
Diffstat (limited to 'ui/base/cocoa')
-rw-r--r-- | ui/base/cocoa/underlay_opengl_hosting_window.mm | 14 | ||||
-rw-r--r-- | ui/base/cocoa/window_size_constants.h | 20 | ||||
-rw-r--r-- | ui/base/cocoa/window_size_constants.mm | 11 |
3 files changed, 45 insertions, 0 deletions
diff --git a/ui/base/cocoa/underlay_opengl_hosting_window.mm b/ui/base/cocoa/underlay_opengl_hosting_window.mm index 6ed0624..b82decd 100644 --- a/ui/base/cocoa/underlay_opengl_hosting_window.mm +++ b/ui/base/cocoa/underlay_opengl_hosting_window.mm @@ -87,6 +87,20 @@ void RootDidAddSubview(id self, SEL _cmd, NSView* subview) { styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType 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 styleMask:windowStyle backing:bufferingType diff --git a/ui/base/cocoa/window_size_constants.h b/ui/base/cocoa/window_size_constants.h new file mode 100644 index 0000000..9f33336 --- /dev/null +++ b/ui/base/cocoa/window_size_constants.h @@ -0,0 +1,20 @@ +// 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_ diff --git a/ui/base/cocoa/window_size_constants.mm b/ui/base/cocoa/window_size_constants.mm new file mode 100644 index 0000000..c635599 --- /dev/null +++ b/ui/base/cocoa/window_size_constants.mm @@ -0,0 +1,11 @@ +// 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 |