• Peter Kasting's avatar
    Clean up/simplify StyledLabel, part 1. · a0e644e1
    Peter Kasting authored
    * Makes CreateLabelRange() a member function (and renames it CreateLabel()) to
      allow it to use various members that are currently passed as arguments the
      same way at both callsites.  This makes the code simpler and more
      future-proof.  It also allows moving the color-related functionality in from
      the caller.
    * To allow CreateLabel() to be const, moves the set_listener() call to the
      caller side.  Only one caller needs this anyway.
    * Stop calling AdvanceOneLine() in the "very first line was empty" case, where
      it will have no effect, since |new_line| is false and there are no views to
      adjust.
    * The final post-loop call of AdvanceOneLine() doesn't actually care about
      whether |new_line| is set to false (since the adjusted values won't be read
      afterwards).  Combined with the change above, this means the |new_line| arg
      can be eliminated entirely.
    * Change |max_line_height| (which sounds like the max height of all lines) to
      the less-ambiguous (and shorter) |line_height|, since it's the height of the
      current line.
    * At the end of the loop, adjust |remaining_string| before calling
      AdvanceOneLine() instead of after.  These are independent, so this has no
      effect, but it will allow for a control flow change in a subsequent patch.
    
    Bug: 1015717
    Change-Id: Ie1858c29b70f5c8ff1e9ba005a7fddb5e446e133
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1875028
    Commit-Queue: Peter Kasting <pkasting@chromium.org>
    Auto-Submit: Peter Kasting <pkasting@chromium.org>
    Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#708814}
    a0e644e1
styled_label.h 8.59 KB