• newt's avatar
    Reduce infobar lag on KitKat from 1000ms to 100ms. · 6e4b88e2
    newt authored
    This fixes four compounding inefficiencies that caused infobar layouts
    to take waaaay longer than they should have (over 1 second in the direst
    cases!). The worst manifestation of this problem could be seen by
    opening the change-language panel on the translate infobar on a pre-L
    device. This resulted in 3 300ms measures as well as 250ms spent
    measuring text.
    
    The fixes are:
     - InfoBarLayout was measuring each InfoBarControlLayout twice: once
       with UNSPECIFIED width and once with an exact width. Since
       InfoBarControlLayouts handle layout logic internally, they should
       only be measured once, with an exact width.
     - The infobar view's width was WRAP_CONTENT, which caused its parent,
       the wrapper view, to measure it twice. This is fixed by setting
       the width to MATCH_PARENT.
     - TranslateLanguagePanel.onItemSelected() is called twice when the
       translate panel is first created to set the initial values of the
       spinners. This resulted in two superfluous measure/layout/draw
       passes. As a fix, TranslateLanguagePanel.onItemSelected() only calls
       reloadSpinners() if the selected language has actually changed.
     - TranslateLanguagePanel.setUpSpinners() took 250ms to determine the
       width of the longest language. This CL makes this measuring logic
       smarter and avoids redundant work in two different ways: it only
       measures each language once (not once per spinner), and it only
       measures "Page language: " and "Translation language: " once.
       (instead of once per language per spinner = ~140 times each)
    
    BUG=564406
    
    Review URL: https://codereview.chromium.org/1560573002
    
    Cr-Commit-Position: refs/heads/master@{#367464}
    6e4b88e2
infobar_wrapper.xml 537 Bytes