Improve updateOriginsEliding_ performance.

This CL is part of the effort to improve performance of the password manager
settings. In particular, this CL fixes layout thrashing in the
updateOriginsEliding_ code. Prior to this change the code was first reading
style information from the DOM and then changing it in a loop.

This change creates a canvas element that is not part of the DOM.
It then uses the canvas to do the text measurements, thus avoiding the
repainting of the DOM. In the end, it writes the final obtained string in the
DOM, and thus does not change the display of the saved passwords.

Reference: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/measureText

BUG=651049
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2439453005
Cr-Commit-Position: refs/heads/master@{#427028}
1 file changed