Commit c5100866 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

mac: update ViewTreeValidator for 10.14

This change has ViewTreeValidator account for the changed interior structure
of NSButton on 10.14. This fixes FirstRunDialogControllerTest's
LayoutWithLongStrings.

Bug: 892176
Change-Id: Icc9e977034a98fbb587719770c326d082adb3743
Reviewed-on: https://chromium-review.googlesource.com/c/1316113
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605105}
parent f7c11345
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ui/base/test/view_tree_validator.h" #include "ui/base/test/view_tree_validator.h"
#include <Cocoa/Cocoa.h> #include <Cocoa/Cocoa.h>
#include "base/mac/mac_util.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
namespace { namespace {
...@@ -28,6 +29,15 @@ bool IsLocalizable(NSView* view) { ...@@ -28,6 +29,15 @@ bool IsLocalizable(NSView* view) {
[view isKindOfClass:[NSText class]]; [view isKindOfClass:[NSText class]];
} }
// Returns whether to expect children of |view| to perhaps not fit within its
// bounds.
bool IgnoreChildBoundsChecks(NSView* view) {
// On macOS 10.14, NSButton has a subview of a private helper class whose
// bounds extend a bit outside the NSButton itself. We don't care about this
// helper class's bounds being outside the button.
return base::mac::IsOS10_14() && [view isKindOfClass:[NSButton class]];
}
} // namespace } // namespace
namespace ui { namespace ui {
...@@ -39,7 +49,8 @@ base::Optional<ViewTreeProblemDetails> ValidateViewTree(NSView* root) { ...@@ -39,7 +49,8 @@ base::Optional<ViewTreeProblemDetails> ValidateViewTree(NSView* root) {
// 1: Check that every subview's frame lies entirely inside this view's // 1: Check that every subview's frame lies entirely inside this view's
// bounds. // bounds.
for (NSView* child in view.subviews) { for (NSView* child in view.subviews) {
if (!NSContainsRect(view.bounds, child.frame)) { if (!NSContainsRect(view.bounds, child.frame) &&
!IgnoreChildBoundsChecks(view)) {
return base::Optional<ViewTreeProblemDetails>( return base::Optional<ViewTreeProblemDetails>(
{ViewTreeProblemDetails::VIEW_OUTSIDE_PARENT, child, view}); {ViewTreeProblemDetails::VIEW_OUTSIDE_PARENT, child, view});
} }
......
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