Chromium Code Reviews| Index: ui/webui/resources/js/cr/ui/focus_without_ink.js |
| diff --git a/ui/webui/resources/js/cr/ui/focus_without_ink.js b/ui/webui/resources/js/cr/ui/focus_without_ink.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cf91e526ff916be577dcb32f65d482109e2cf5bc |
| --- /dev/null |
| +++ b/ui/webui/resources/js/cr/ui/focus_without_ink.js |
| @@ -0,0 +1,28 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +cr.define('cr.ui', function() { |
| + var outline = cr.ui.FocusOutlineManager.forDocument(document); |
| + |
| + /** @param {Element} toFocus */ |
| + function focusWithoutInk(toFocus) { |
|
dpapad
2017/04/28 17:36:46
Can you add a short sentence explaining the purpos
Dan Beam
2017/04/29 02:56:31
Done.
|
| + // TODO(dbeam): assert('noink' in toFocus); |
|
dpapad
2017/04/28 17:36:46
Why not doing this as part of this CL?
Dan Beam
2017/04/29 02:56:31
if we don't merge, i'll add it now. if we do merg
|
| + // TODO(dbeam): assert(document == toFocus.ownerDocument); |
| + |
| + var origNoInk; |
| + |
| + var hideInk = !outline.visible; |
| + if (hideInk) { |
| + origNoInk = toFocus.noink; |
| + toFocus.noink = true; |
| + } |
| + |
| + toFocus.focus(); |
| + |
| + if (hideInk) |
| + toFocus.noink = origNoInk; |
| + } |
| + |
| + return {focusWithoutInk: focusWithoutInk}; |
| +}); |