Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 cr.define('cr.ui', function() { | |
| 6 var hideInk = false; | |
| 7 | |
| 8 document.addEventListener('mousedown', function() { | |
|
dpapad
2017/05/02 00:13:22
As discussed in person, can we make this file re-e
Dan Beam
2017/05/02 02:55:11
Done.
| |
| 9 hideInk = true; | |
| 10 }, true); | |
| 11 document.addEventListener('touchstart', function() { | |
|
dpapad
2017/05/02 00:13:22
Maybe we can use 'pointerdown' instead of mousedow
Dan Beam
2017/05/02 02:55:11
Done.
| |
| 12 hideInk = true; | |
| 13 }, true); | |
| 14 document.addEventListener('keydown', function() { | |
| 15 hideInk = false; | |
| 16 }, true); | |
| 17 | |
| 18 /** | |
| 19 * Attempts to track whether focus outlines should be shown, and if they | |
| 20 * shouldn't, removes the "ink" (ripple) from a control while focusing it. | |
| 21 * This is helpful when a user is clicking/touching, because it's not super | |
| 22 * helpful to show focus ripples in that case. This is Polymer-specific. | |
| 23 * @param {Element} toFocus | |
|
dpapad
2017/05/02 00:13:22
I think focus() only exists on HTMLElemnet, but no
Dan Beam
2017/05/02 02:55:11
Done. (I originally didn't do this intentionally t
| |
| 24 */ | |
| 25 function focusWithoutInk(toFocus) { | |
| 26 assert('noink' in toFocus); | |
| 27 assert(document == toFocus.ownerDocument); | |
| 28 | |
| 29 var origNoInk; | |
| 30 | |
| 31 if (hideInk) { | |
| 32 origNoInk = toFocus.noink; | |
| 33 toFocus.noink = true; | |
| 34 } | |
| 35 | |
| 36 toFocus.focus(); | |
| 37 | |
| 38 if (hideInk) | |
| 39 toFocus.noink = origNoInk; | |
| 40 } | |
| 41 | |
| 42 return {focusWithoutInk: focusWithoutInk}; | |
| 43 }); | |
| OLD | NEW |