Commit 36adf646 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Add RTL support for focus rings (Reland with fix for flaky test)

We do not currently flip the canvas for focus rings when RTL is enabled.
This can cause certain focus rings to be drawn incorrectly for
their corresponding buttons.

Some views change their canvas flipping on RTL behavior after installing focus rings.
This can cause a recently added DCHECK to fail.

Bug: 986571, 960284
Change-Id: Ic24db27c1faee1c62bafbb0de1db3426bf5c23e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1719673
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682117}
parent ab2767aa
......@@ -67,6 +67,10 @@ void FocusRing::Layout() {
gfx::Rect focus_bounds = parent()->GetLocalBounds();
focus_bounds.Inset(gfx::Insets(PlatformStyle::kFocusHaloInset));
SetBoundsRect(focus_bounds);
// Need to match canvas direction with the parent. This is required to ensure
// asymmetric focus ring shapes match their respective buttons in RTL mode.
EnableCanvasFlippingForRTLUI(parent()->flip_canvas_on_paint_for_rtl_ui());
}
void FocusRing::ViewHierarchyChanged(
......@@ -101,6 +105,8 @@ void FocusRing::OnPaint(gfx::Canvas* canvas) {
path = GetHighlightPath(parent());
DCHECK(IsPathUseable(path));
DCHECK_EQ(flip_canvas_on_paint_for_rtl_ui(),
parent()->flip_canvas_on_paint_for_rtl_ui());
SkRect bounds;
SkRRect rbounds;
if (path.isRect(&bounds)) {
......
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