Commit a6d3776a authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

views: fix bug in tree node bounds calculation

A couple of bounds calculations used bounds().x(). bounds() is
relative to the parent, where as these calculations are meant to be
relative to the tree. So, they shouldn't use bounds().x() and should
instead always be 0 based.

BUG=779983
TEST=none

Change-Id: I92ffd99c9c7caef25b06bb7bdf3c05bbae466775
Reviewed-on: https://chromium-review.googlesource.com/777768Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517897}
parent d28a9196
...@@ -890,8 +890,7 @@ TreeView::InternalNode* TreeView::GetInternalNodeForModelNode( ...@@ -890,8 +890,7 @@ TreeView::InternalNode* TreeView::GetInternalNodeForModelNode(
gfx::Rect TreeView::GetBoundsForNode(InternalNode* node) { gfx::Rect TreeView::GetBoundsForNode(InternalNode* node) {
int row, ignored_depth; int row, ignored_depth;
row = GetRowForInternalNode(node, &ignored_depth); row = GetRowForInternalNode(node, &ignored_depth);
return gfx::Rect(bounds().x(), row * row_height_, bounds().width(), return gfx::Rect(0, row * row_height_, width(), row_height_);
row_height_);
} }
gfx::Rect TreeView::GetBackgroundBoundsForNode(InternalNode* node) { gfx::Rect TreeView::GetBackgroundBoundsForNode(InternalNode* node) {
...@@ -927,7 +926,7 @@ gfx::Rect TreeView::GetAuxiliaryTextBoundsForNode(InternalNode* node) { ...@@ -927,7 +926,7 @@ gfx::Rect TreeView::GetAuxiliaryTextBoundsForNode(InternalNode* node) {
if (width < 0) if (width < 0)
return gfx::Rect(); return gfx::Rect();
int x = base::i18n::IsRTL() int x = base::i18n::IsRTL()
? bounds().x() + kTextHorizontalPadding ? kTextHorizontalPadding
: bounds().right() - width - kTextHorizontalPadding; : bounds().right() - width - kTextHorizontalPadding;
return gfx::Rect(x, text_bounds.y(), width, text_bounds.height()); return gfx::Rect(x, text_bounds.y(), width, text_bounds.height());
} }
...@@ -1094,10 +1093,10 @@ bool TreeView::IsPointInExpandControl(InternalNode* node, ...@@ -1094,10 +1093,10 @@ bool TreeView::IsPointInExpandControl(InternalNode* node,
int row = GetRowForInternalNode(node, &depth); int row = GetRowForInternalNode(node, &depth);
int arrow_dx = depth * kIndent + kHorizontalInset; int arrow_dx = depth * kIndent + kHorizontalInset;
gfx::Rect arrow_bounds(bounds().x() + arrow_dx, row * row_height_, gfx::Rect arrow_bounds(arrow_dx, row * row_height_, kArrowRegionSize,
kArrowRegionSize, row_height_); row_height_);
if (base::i18n::IsRTL()) if (base::i18n::IsRTL())
arrow_bounds.set_x(bounds().width() - arrow_dx - kArrowRegionSize); arrow_bounds.set_x(width() - arrow_dx - kArrowRegionSize);
return arrow_bounds.Contains(point); return arrow_bounds.Contains(point);
} }
......
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