Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Issue 1228213003: Just set borders once when creating a views::LabelButton (Closed)

Created:
5 years, 5 months ago by tapted
Modified:
5 years, 5 months ago
CC:
chrome-apps-syd-reviews_chromium.org, chromium-reviews, markusheintz_, raymes+watch_chromium.org, tfarina
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Just 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
Unified diffs Side-by-side diffs Delta from patch set Stats (+253 lines, -211 lines) Patch
M chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc View 1 2 3 4 5 6 7 3 chunks +27 lines, -18 lines 2 comments Download
M chrome/browser/ui/views/global_error_bubble_view.cc View 1 2 3 1 chunk +0 lines, -1 line 0 comments Download
M chrome/browser/ui/views/toolbar/wrench_menu.cc View 1 2 2 chunks +2 lines, -4 lines 0 comments Download
M chrome/browser/ui/views/website_settings/permission_selector_view.cc View 3 chunks +4 lines, -11 lines 0 comments Download
M chrome/test/base/view_event_test_base.h View 1 2 3 4 5 2 chunks +5 lines, -5 lines 0 comments Download
M chrome/test/base/view_event_test_base.cc View 1 2 3 4 5 5 chunks +8 lines, -16 lines 0 comments Download
M ui/views/controls/button/blue_button_unittest.cc View 1 2 3 4 5 6 7 1 chunk +29 lines, -32 lines 0 comments Download
M ui/views/controls/button/label_button.h View 1 chunk +1 line, -1 line 0 comments Download
M ui/views/controls/button/label_button.cc View 1 2 3 4 5 6 2 chunks +17 lines, -19 lines 1 comment Download
M ui/views/controls/button/label_button_unittest.cc View 1 2 3 4 5 6 7 6 chunks +160 lines, -104 lines 0 comments Download

Messages

Total messages: 17 (5 generated)
tapted
Hi sadrul & msw, please take a look sadrul: ui/views msw: c/b/ui/views
5 years, 5 months ago (2015-07-10 03:28:51 UTC) #3
msw
https://codereview.chromium.org/1228213003/diff/60001/ui/views/controls/button/blue_button_unittest.cc File ui/views/controls/button/blue_button_unittest.cc (right): https://codereview.chromium.org/1228213003/diff/60001/ui/views/controls/button/blue_button_unittest.cc#newcode18 ui/views/controls/button/blue_button_unittest.cc:18: class TestBlueButton : public BlueButton { nit: TestBlueButton seems ...
5 years, 5 months ago (2015-07-10 18:35:50 UTC) #4
msw
sorry, a few more https://codereview.chromium.org/1228213003/diff/60001/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc File chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc (right): https://codereview.chromium.org/1228213003/diff/60001/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc#newcode290 chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc:290: // Create the Widget. This ...
5 years, 5 months ago (2015-07-10 18:40:07 UTC) #5
tapted
https://codereview.chromium.org/1228213003/diff/60001/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc File chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc (right): https://codereview.chromium.org/1228213003/diff/60001/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc#newcode290 chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc:290: // Create the Widget. This ensures the following calculation ...
5 years, 5 months ago (2015-07-13 07:41:22 UTC) #7
msw
lgtm; thanks for adding the ax test. https://codereview.chromium.org/1228213003/diff/160001/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc File chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc (right): https://codereview.chromium.org/1228213003/diff/160001/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc#newcode334 chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc:334: // This ...
5 years, 5 months ago (2015-07-13 17:54:04 UTC) #8
sadrul
nice! lgtm
5 years, 5 months ago (2015-07-14 03:26:55 UTC) #9
tapted
Thanks! https://codereview.chromium.org/1228213003/diff/160001/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc File chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc (right): https://codereview.chromium.org/1228213003/diff/160001/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc#newcode334 chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc:334: // This code looks a bit hacky, but ...
5 years, 5 months ago (2015-07-14 05:36:12 UTC) #10
tapted
+Paweł. PTAL for OWNERS in chrome/test
5 years, 5 months ago (2015-07-14 05:36:25 UTC) #12
Paweł Hajdan Jr.
chrome/test LGTM
5 years, 5 months ago (2015-07-14 23:31:42 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1228213003/160001
5 years, 5 months ago (2015-07-15 00:09:44 UTC) #15
commit-bot: I haz the power
Committed patchset #8 (id:160001)
5 years, 5 months ago (2015-07-15 01:20:36 UTC) #16
commit-bot: I haz the power
5 years, 5 months ago (2015-07-15 01:21:42 UTC) #17
Message was sent while issue was closed.
Patchset 8 (id:??) landed as
https://crrev.com/c6db86a78cba9a415fb75b0a595ad84d9651056c
Cr-Commit-Position: refs/heads/master@{#338796}

Powered by Google App Engine
This is Rietveld 408576698