Commit 33175057 authored by Biao She's avatar Biao She Committed by Commit Bot

Use local origin of an element to calculate element bounds

(0, 0) was always an element center previously. But with the concept of
local_origin for an element introduced, this is no longer true. This CL uses
(local_origin, 0) instead of using (0, 0, 0) when construct an element's
bound.

Bug: NONE
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: If5b03f0c0a0a4329ce19ecc1a465469f57d77983
Reviewed-on: https://chromium-review.googlesource.com/779560
Commit-Queue: Biao She <bshe@chromium.org>
Reviewed-by: default avatarIan Vollick <vollick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517917}
parent a576e5a4
......@@ -460,7 +460,7 @@ void UiElement::DoLayOutChildren() {
if (!child->IsVisible()) {
continue;
}
gfx::Point3F child_center;
gfx::Point3F child_center(child->local_origin());
child->LocalTransform().TransformPoint(&child_center);
gfx::RectF local_rect =
gfx::RectF(child_center.x() - 0.5 * child->size().width(),
......
......@@ -64,6 +64,16 @@ TEST(UiElement, BoundsContainChildren) {
parent->DoLayOutChildren();
EXPECT_RECT_NEAR(gfx::RectF(-0.5f, 0.5f, 9.2f, 7.4f),
gfx::RectF(parent->local_origin(), parent->size()), epsilon);
auto grand_parent = base::MakeUnique<UiElement>();
grand_parent->set_bounds_contain_children(true);
grand_parent->set_padding(0.1, 0.2);
grand_parent->AddChild(std::move(parent));
grand_parent->DoLayOutChildren();
EXPECT_RECT_NEAR(
gfx::RectF(-0.5f, 0.5f, 9.4f, 7.8f),
gfx::RectF(grand_parent->local_origin(), grand_parent->size()), epsilon);
}
TEST(UiElements, AnimateSize) {
......
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