Skip to content

Commit

Permalink
Cros lock screen: fix login bubble misplacement issue for RTL language
Browse files Browse the repository at this point in the history
In RTL case, the coordinate system is from right to left and the origin is the right upper corner. The coordinates for everything on the lock screen should be the same in both LTR and RTL cases and therefor mirroring is not needed.

The misplacement is due to doing mirroring in `ConvertPointToTarget` when finding the position of the bubble. We need to remove the mirroring effect in order to find the correct position for login bubble.

Bug: 937245
Change-Id: I4c4ce54ab7617a5c4c56e861afb7a103b045ef8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2505869
Commit-Queue: Denis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: Roman Aleksandrov <raleksandrov@google.com>
Reviewed-by: Denis Kuznetsov [CET] <antrim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822175}
  • Loading branch information
Yunke Zhou authored and Commit Bot committed Oct 29, 2020
1 parent 8289327 commit 0219d22
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ash/login/ui/login_base_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,20 @@ gfx::Point LoginBaseBubbleView::CalculatePosition() {
// calculated by using the root view's coordinates system. kShowAbove and
// kShowBelow are less complicated, they only use the coordinate system of the
// the anchor view's parent.

// In RTL case, we are doing mirroring in `ConvertPointToTarget` when finding
// the position of the bubble. However, there's no need to mirror since the
// coordinate system is from right to left and the origin is the right upper
// corner. `GetMirroredXWithWidthInView` is called to cancel out the mirroring
// effect and returning the correct position for the bubble.
gfx::Point anchor_position = GetAnchorView()->bounds().origin();
gfx::Point origin;
ConvertPointToTarget(GetAnchorView()->parent() /*source*/,
GetAnchorView()->GetWidget()->GetRootView() /*target*/,
&anchor_position);
&origin);
origin.set_x(parent()->GetMirroredXWithWidthInView(
origin.x(), GetAnchorView()->parent()->width()));
anchor_position += origin.OffsetFromOrigin();
auto bounds = GetBoundsAvailableToShowBubble();
gfx::Size bubble_size(width() + 2 * horizontal_padding_,
height() + vertical_padding_);
Expand Down

0 comments on commit 0219d22

Please sign in to comment.