Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1539)

Unified Diff: chrome/browser/chromeos/ui/accessibility_focus_ring.cc

Issue 602813003: Animate the accessibility focus ring and fix some minor visual issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@focus_ring_in_chromevox
Patch Set: Correct upstream branch Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/ui/accessibility_focus_ring.cc
diff --git a/chrome/browser/chromeos/ui/accessibility_focus_ring.cc b/chrome/browser/chromeos/ui/accessibility_focus_ring.cc
index 676170500078c7192106d37a6b0c3e4cdf7f77bc..e60c6e39ea0aa5f5f19f523d8e03f21edf32aa4e 100644
--- a/chrome/browser/chromeos/ui/accessibility_focus_ring.cc
+++ b/chrome/browser/chromeos/ui/accessibility_focus_ring.cc
@@ -4,21 +4,41 @@
#include "chrome/browser/chromeos/ui/accessibility_focus_ring.h"
+#include "base/logging.h"
+
namespace chromeos {
// static
AccessibilityFocusRing AccessibilityFocusRing::CreateWithRect(
const gfx::Rect& bounds, int margin) {
+ // Compute the height of the top and bottom cap.
+ int cap_height = std::min(bounds.height() / 2, margin * 2);
+
gfx::Rect top(bounds.x(), bounds.y(),
- bounds.width(), bounds.height() / 4);
+ bounds.width(), cap_height);
+ gfx::Rect bottom(bounds.x(), bounds.bottom() - cap_height,
+ bounds.width(), cap_height);
gfx::Rect body(bounds.x(), top.bottom(),
- bounds.width(), bounds.height() / 2);
- gfx::Rect bottom(bounds.x(), body.bottom(),
- bounds.width(), bounds.bottom() - body.bottom());
+ bounds.width(), bottom.y() - top.bottom());
+
return CreateWithParagraphShape(top, body, bottom, margin);
}
// static
+AccessibilityFocusRing AccessibilityFocusRing::Interpolate(
+ const AccessibilityFocusRing& r1,
+ const AccessibilityFocusRing& r2,
+ double fraction) {
+ AccessibilityFocusRing dst;
+ for (int i = 0; i < 36; i++) {
xiyuan 2014/09/24 19:40:35 nit: ++i
dmazzoni 2014/09/24 21:40:56 Done.
+ dst.points[i] = gfx::Point(
+ r1.points[i].x() * (1 - fraction) + r2.points[i].x() * fraction,
+ r1.points[i].y() * (1 - fraction) + r2.points[i].y() * fraction);
+ }
+ return dst;
+}
+
+// static
AccessibilityFocusRing AccessibilityFocusRing::CreateWithParagraphShape(
const gfx::Rect& orig_top_line,
const gfx::Rect& orig_body,
@@ -28,6 +48,9 @@ AccessibilityFocusRing AccessibilityFocusRing::CreateWithParagraphShape(
gfx::Rect middle = orig_body;
gfx::Rect bottom = orig_bottom_line;
+ int min_height = std::min(top.height(), bottom.height());
+ margin = std::min(margin, min_height / 2);
+
if (top.x() <= middle.x() + 2 * margin) {
top.set_width(top.width() + top.x() - middle.x());
top.set_x(middle.x());
@@ -44,6 +67,10 @@ AccessibilityFocusRing AccessibilityFocusRing::CreateWithParagraphShape(
bottom.set_width(middle.right() - bottom.x());
}
+ LogRect("Top2", top);
+ LogRect("Body2", middle);
+ LogRect("Bottom2", bottom);
xiyuan 2014/09/24 19:40:35 Where is LogRect defined?
dmazzoni 2014/09/24 21:40:56 Sorry, left that in while debugging. Gone.
+
AccessibilityFocusRing ring;
ring.points[0] = gfx::Point(top.x(), top.bottom() - margin);
ring.points[1] = gfx::Point(top.x(), top.y() + margin);

Powered by Google App Engine
This is Rietveld 408576698