diff options
author | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-16 14:42:16 +0000 |
---|---|---|
committer | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-16 14:42:16 +0000 |
commit | db4b1ddd79cf992a7dd76f2f86612099084d1b9d (patch) | |
tree | 6a840c3ad47661db89efd655441318e00381bd22 /chrome/browser/cocoa | |
parent | 1290cdfb74e4ea063ef0c0857624c5b3bd8a2bdd (diff) | |
download | chromium_src-db4b1ddd79cf992a7dd76f2f86612099084d1b9d.zip chromium_src-db4b1ddd79cf992a7dd76f2f86612099084d1b9d.tar.gz chromium_src-db4b1ddd79cf992a7dd76f2f86612099084d1b9d.tar.bz2 |
Fix the error found by -Wextra, disable part of the test because it doesn't seem like it ever would have passed in the first place.
BUG=46663
TEST=none
Review URL: http://codereview.chromium.org/2802006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49941 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/translate_infobar.mm | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/chrome/browser/cocoa/translate_infobar.mm b/chrome/browser/cocoa/translate_infobar.mm index c6e0ae3..949967f 100644 --- a/chrome/browser/cocoa/translate_infobar.mm +++ b/chrome/browser/cocoa/translate_infobar.mm @@ -21,6 +21,9 @@ #include "grit/locale_settings.h" #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" +// http://crbug.com/46663 disabled since it never worked. +#define DISABLE_VERIFY_CONTROL_ORDER 1 + // Colors for translate infobar gradient background. const int kGreyTopColor[] = {0xC0, 0xC0, 0xC0}; const int kGreyBottomColor[] = {0xCC, 0xCC, 0xCC}; @@ -61,17 +64,26 @@ void VerticallyCenterView(NSView *toMove) { // Check that the control |before| is ordered visually before the |after| // control. // Also, check that there is space between them. +// http://crbug.com/46663 the code below seems to be the reverse of this +// comment. +#if !defined(DISABLE_VERIFY_CONTROL_ORDER) bool VerifyControlOrderAndSpacing(id before, id after) { - NSRect beforeFrame = [before frame]; - NSRect afterFrame = [after frame]; - NSUInteger spaceBetweenControls = -1; - + CGFloat spaceBetweenControls = 0; + if (before && after) { + // When messaging nil, the rects won't always be zeroed (only sizeof(id) is + // going to be zeroed by the Objective-C runtime, rest will be uninitialized + // memory). + NSRect beforeFrame = [before frame]; + NSRect afterFrame = [after frame]; spaceBetweenControls = NSMaxX(beforeFrame) - NSMinX(afterFrame); // RTL case to be used when we have an RTL version of this UI. // spaceBetweenControls = NSMaxX(afterFrame) - NSMinX(beforeFrame); + } + return (spaceBetweenControls >= 0); } +#endif // !defined(DISABLE_VERIFY_CONTROL_ORDER) // Creates a label control in the style we need for the translate infobar's // labels within |bounds|. @@ -771,6 +783,13 @@ class TranslateNotificationObserverBridge : } // Step 2: Check that controls are ordered correctly with no overlap. +#if !defined(DISABLE_VERIFY_CONTROL_ORDER) + // http://crbug.com/46663 this appears to be invalid. + // VerifyControlOrderAndSpacing had an unsigned >= 0 bug, so it used to always + // return true. With that bug fixed, this loop now can return a failure. + // Scanning the code, it's not clear how this would pass since not all + // controls are visible and it needs the array order to always match display + // order. id previousControl = nil; for (NSUInteger i = 0; i < [allControls count]; ++i) { id control = [allControls objectAtIndex:i]; @@ -783,6 +802,7 @@ class TranslateNotificationObserverBridge : } previousControl = control; } +#endif // !defined(DISABLE_VERIFY_CONTROL_ORDER) // Step 3: Check other misc. attributes of layout. if (state == TranslateInfoBarDelegate::kTranslateError && translationPending) |