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

Issue 6541030: View API/implementation cleanup:... (Closed)

Created:
9 years, 10 months ago by Peter Kasting
Modified:
9 years, 7 months ago
CC:
chromium-reviews
Visibility:
Public.

Description

View API/implementation cleanup: * Don't include the container type ("vector") in the typedef for "a bunch of children". Users generally should not know or care what the container is, so this makes reading easier as the code is not constantly pointing out to you, "hey! I'm a vector!" Added bonus: less verbose, allows condensing a lot of loop declarations onto one line. * Consistently put getters before setters. * Remove 4-arg form of SetBounds() and make people use Rects (we should move the codebase towards Points, Sizes, and Rects wherever possible). * Use "origin" instead of "position" to be consistent with Rect's terminology. * Minor naming changes, e.g. GetViewById() -> GetViewByID(). * Remove const qualifier on member functions that are not logically const. This also got rid of all the const_cast<>()s. * Better comments. * Use const ref args for Views whenever the provided View is not being modified, to make that obvious to the caller. * Turn some accessors into pairs of (non-const, const) accessors. In these cases make the non-const version call the const version. (GetWidget() does this in the header because the const version is virtual; this way people who override the const version can see why they don't need to override the non-const version). * Make RemoveChildView() take a bool for consistency with RemoveAllChildViews() (also eliminates the need to return a View*). * Add STL-style iterators and rename a few accessors to match STL terminology ("size" instead of "count"). * Turn IsFocusable() into a cheap inline getter. * Greatly simplify private tree ops ("NotifyHierarchyChangedXXX()") by realizing that they were always being called with |parent| == |this|. * Declare iterators inside loops, not above them. * Standardize iterator naming to |i|. The existing code wasn't always consistent, and while there's nothing wrong with |it|, using that would have made almost every loop declaration into two lines instead of one. * Simpler code, sometimes by using STL algorithms. * Unindent via early-returns. * Use CHECK_NE() and similar where possible. * Fix memory corruption in RemoveAllChildViews() due to using an iterator after modifying its container. BUG=none TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=75642

Patch Set 1 #

Total comments: 8

Patch Set 2 : '' #

Patch Set 3 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+342 lines, -366 lines) Patch
M ui/views/demo/main.cc View 1 2 4 chunks +9 lines, -7 lines 0 comments Download
M ui/views/events/event.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M ui/views/events/event_win.cc View 1 2 5 chunks +26 lines, -26 lines 0 comments Download
M ui/views/focus/focus_manager.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M ui/views/focus/focus_search.cc View 1 2 6 chunks +10 lines, -11 lines 0 comments Download
M ui/views/layout/fill_layout.cc View 1 2 1 chunk +5 lines, -5 lines 0 comments Download
M ui/views/rendering/border_unittest.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M ui/views/view.h View 1 13 chunks +82 lines, -52 lines 0 comments Download
M ui/views/view.cc View 1 21 chunks +170 lines, -225 lines 0 comments Download
M ui/views/view_unittest.cc View 1 2 3 chunks +30 lines, -30 lines 0 comments Download
M ui/views/views.gyp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M ui/views/widget/root_view_unittest.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M ui/views/widget/widget.cc View 1 2 4 chunks +5 lines, -5 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Peter Kasting
9 years, 10 months ago (2011-02-18 18:55:10 UTC) #1
Ben Goodger (Google)
http://codereview.chromium.org/6541030/diff/1/ui/views/view.cc File ui/views/view.cc (right): http://codereview.chromium.org/6541030/diff/1/ui/views/view.cc#newcode318 ui/views/view.cc:318: GetFocusManager()); Why do you define this here but the ...
9 years, 10 months ago (2011-02-18 19:02:28 UTC) #2
Peter Kasting
New snap up. http://codereview.chromium.org/6541030/diff/1/ui/views/view.cc File ui/views/view.cc (right): http://codereview.chromium.org/6541030/diff/1/ui/views/view.cc#newcode318 ui/views/view.cc:318: GetFocusManager()); On 2011/02/18 19:02:28, Ben Goodger ...
9 years, 10 months ago (2011-02-18 19:09:43 UTC) #3
Ben Goodger (Google)
LGTM... please run the views_demo exe and see if it still works with event handling. ...
9 years, 10 months ago (2011-02-18 20:24:50 UTC) #4
Peter Kasting
9 years, 10 months ago (2011-02-18 21:37:19 UTC) #5
On 2011/02/18 20:24:50, Ben Goodger wrote:
> LGTM... please run the views_demo exe and see if it still works with event
> handling. :-)

Given that it's undocumented, I'm not totally sure.  It looks to me like it
works, except that closing the window does not terminate the program.  Maybe you
should apply this patch and take a look.

I fixed views.gyp to work and all the projects in views.sln to build.  The
unittests all work except for focus not being updated properly in the root view
test, which is a bug that predates this change.

Powered by Google App Engine
This is Rietveld 408576698