DescriptionJust set borders once when creating a views::LabelButton
When creating a LabelButton, OnNativeThemeChanged(ui::NativeTheme*) is
currently called 2 or 3 times:
- via a SetStyle(STYLE_TEXTBUTTON) call in the LabelButton constructor
(passes null)
- for STYLE_BUTTON buttons, via a second SetStyle(STYLE_BUTTON) call
shortly after construction (passes null since the button is not yet in a
Widget)
- by an ancestor View when added to a Widget's view hierarchy for the
first time.
Each call creates and sets the button border painters, which are not
simple. The first call also calls virtual functions from a constructor,
which may not even provide a correct border for a subclass. Also,
subclasses that make their own SetBorder() call do not even want borders
provided by LabelButton::UpdateThemedBorder(), but they currently get
them created anyway (which they then replace).
Since the first 1-2 borders that are created will always be replaced
when the view is added to a Widget, don't create borders then.
Instead, SetStyle() now just sets things up for an anticipated call to
OnNativeThemeChanged() to finish creating the borders.
After this, LabelButton no longer calls virtual methods from its
constructor.
BUG=506729, 508410
Committed: https://crrev.com/c6db86a78cba9a415fb75b0a595ad84d9651056c
Cr-Commit-Position: refs/heads/master@{#338796}
Patch Set 1 #Patch Set 2 : Fix Tests #Patch Set 3 : nits, format #Patch Set 4 : Fix BookmarkBarViewTest and GlobalErrorServiceBrowserTest #
Total comments: 18
Patch Set 5 : SetContentSize properly (account for window frame) #Patch Set 6 : More realistic means for reporting the preferred size #Patch Set 7 : respond to comments, more tests, obsolete SetAccessibleName #Patch Set 8 : self review #
Total comments: 3
Messages
Total messages: 17 (5 generated)
|