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

Issue 11110004: Make gfx::Rect class operations consistently mutate the class they are called on. (Closed)

Created:
8 years, 2 months ago by danakj
Modified:
8 years, 2 months ago
CC:
chromium-reviews, sadrul, yusukes+watch_chromium.org, samarth, gideonwald, dcheng, rsesek+watch_chromium.org, Shishir, dominich, ben+watch_chromium.org, jam, apatrick_chromium, joi+watch-content_chromium.org, darin-cc_chromium.org, jennb, jonathan.backer, penghuang+watch_chromium.org, jianli, pam+watch_chromium.org, piman+watch_chromium.org, Jered, Ian Vollick, tfarina, Dmitry Titov, David Black, cc-bugs_chromium.org, James Su, piman, backer, jbauman, sreeram
Base URL:
http://git.chromium.org/chromium/src.git@master
Visibility:
Public.

Description

Make gfx::Rect class operations consistently mutate the class they are called on. Currently some methods mutate the class, and some return a new value, requiring API users to know what kind of method they are calling each time, and making inconsistent code. For example: gfx::Rect rect; rect.Inset(1, 1, 1, 1); rect = rect.Intersect(other_rect); rect.Offset(1, 1); Instead of: gfx::Rect rect; rect.Inset(1, 1, 1, 1); rect.Intersect(other_rect); rect.Offset(1, 1); We could go either way - making the class immutable or all methods return a new instance - but I believe it is better to instead make all methods mutate the class. This allows for shorter lines of code by avoiding having to repeat the object's name twice in order to change it. This patch changes gfx::Rect classes and all the callsites that uses these methods. It should make no change in behaviour, so no new tests added. R=sky BUG=147395 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=163579

Patch Set 1 #

Patch Set 2 : #

Total comments: 7

Patch Set 3 : build fixes #

Patch Set 4 : winfixes #

Patch Set 5 : winfix2 #

Patch Set 6 : macfix #

Patch Set 7 : rebase #

Patch Set 8 : lookthru #

Patch Set 9 : undo-ppapi #

Patch Set 10 : mactypo #

Patch Set 11 : rebase #

Patch Set 12 : cc/ fixes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+380 lines, -279 lines) Patch
M ash/desktop_background/desktop_background_view.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M ash/display/multi_display_manager.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -1 line 0 comments Download
M ash/drag_drop/drag_drop_controller_unittest.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M ash/launcher/launcher_view.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -1 line 0 comments Download
M ash/launcher/launcher_view_unittest.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +5 lines, -5 lines 0 comments Download
M ash/system/drive/tray_drive.cc View 1 2 3 chunks +6 lines, -3 lines 0 comments Download
M ash/system/tray/tray_views.cc View 1 2 1 chunk +4 lines, -3 lines 0 comments Download
M ash/system/user/tray_user.cc View 1 2 2 chunks +4 lines, -2 lines 0 comments Download
M ash/tooltips/tooltip_controller.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M ash/tooltips/tooltip_controller_unittest.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M ash/wm/base_layout_manager.cc View 1 2 1 chunk +3 lines, -1 line 0 comments Download
M ash/wm/partial_screenshot_view.cc View 1 2 1 chunk +3 lines, -1 line 0 comments Download
M ash/wm/shelf_layout_manager.cc View 1 2 2 chunks +4 lines, -2 lines 0 comments Download
M ash/wm/system_modal_container_layout_manager.cc View 1 2 1 chunk +3 lines, -1 line 0 comments Download
M ash/wm/window_util.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M ash/wm/workspace/workspace_layout_manager2.cc View 1 2 1 chunk +3 lines, -1 line 0 comments Download
M ash/wm/workspace/workspace_window_resizer.cc View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
M cc/delegated_renderer_layer_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +2 lines, -1 line 0 comments Download
M cc/direct_renderer.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +4 lines, -3 lines 0 comments Download
M cc/draw_quad.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +2 lines, -1 line 0 comments Download
M cc/gl_renderer.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -3 lines 0 comments Download
M cc/software_renderer.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/instant/instant_controller.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/notifications/balloon_collection_impl.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/gtk/browser_toolbar_gtk.cc View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/ui/panels/panel_manager.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/tabs/dock_info.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/ui/views/extensions/extension_dialog.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/views/notifications/balloon_view_views.cc View 1 2 3 chunks +6 lines, -3 lines 0 comments Download
M chrome/browser/ui/views/toolbar_view.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/ui/window_sizer/window_sizer.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/window_sizer/window_sizer_common_unittest.cc View 1 1 chunk +2 lines, -1 line 0 comments Download
M content/browser/renderer_host/accelerated_surface_container_mac.cc View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M content/browser/renderer_host/backing_store_aura.cc View 1 2 3 chunks +12 lines, -7 lines 0 comments Download
M content/browser/renderer_host/backing_store_mac.mm View 1 2 3 4 5 6 7 8 9 2 chunks +6 lines, -4 lines 0 comments Download
M content/browser/renderer_host/backing_store_win.cc View 1 chunk +2 lines, -1 line 0 comments Download
M content/browser/renderer_host/gtk_window_utils.cc View 1 chunk +1 line, -1 line 0 comments Download
M content/browser/renderer_host/render_widget_host_view_aura.cc View 1 2 3 4 5 6 7 8 9 10 5 chunks +8 lines, -5 lines 0 comments Download
M content/browser/renderer_host/render_widget_host_view_gtk.cc View 1 2 3 chunks +8 lines, -5 lines 0 comments Download
M content/browser/renderer_host/render_widget_host_view_mac.mm View 1 2 3 4 5 3 chunks +6 lines, -4 lines 0 comments Download
M content/browser/renderer_host/render_widget_host_view_win.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +4 lines, -2 lines 0 comments Download
M content/common/gpu/image_transport_surface.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -1 line 0 comments Download
M content/plugin/webplugin_proxy.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +3 lines, -2 lines 0 comments Download
M content/renderer/browser_plugin/browser_plugin_backing_store.cc View 3 chunks +9 lines, -5 lines 0 comments Download
M content/renderer/disambiguation_popup_helper.cc View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M content/renderer/paint_aggregator.cc View 6 chunks +14 lines, -10 lines 0 comments Download
M content/renderer/paint_aggregator_unittest.cc View 1 2 4 chunks +8 lines, -4 lines 0 comments Download
M content/renderer/render_widget.cc View 1 2 3 4 5 6 7 8 9 10 5 chunks +14 lines, -8 lines 0 comments Download
M content/renderer/webplugin_delegate_proxy.cc View 1 2 3 4 5 6 6 chunks +10 lines, -6 lines 0 comments Download
M ui/app_list/apps_grid_view.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -1 line 0 comments Download
M ui/app_list/page_switcher.cc View 1 2 2 chunks +4 lines, -3 lines 0 comments Download
M ui/app_list/search_result_view.cc View 1 2 3 chunks +7 lines, -3 lines 0 comments Download
M ui/base/gestures/gesture_point.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M ui/base/native_theme/native_theme_base.cc View 2 chunks +4 lines, -2 lines 0 comments Download
M ui/base/win/hwnd_util.cc View 1 1 chunk +2 lines, -1 line 0 comments Download
M ui/gfx/blit.cc View 1 chunk +3 lines, -3 lines 0 comments Download
M ui/gfx/image/image_skia_operations.cc View 3 4 5 6 7 8 9 10 2 chunks +6 lines, -3 lines 0 comments Download
M ui/gfx/rect.h View 1 2 1 chunk +0 lines, -9 lines 0 comments Download
M ui/gfx/rect_base.h View 1 2 3 1 chunk +9 lines, -9 lines 0 comments Download
M ui/gfx/rect_base_impl.h View 1 2 3 7 chunks +30 lines, -23 lines 0 comments Download
M ui/gfx/rect_f.h View 1 2 3 1 chunk +5 lines, -4 lines 0 comments Download
M ui/gfx/rect_unittest.cc View 1 2 6 chunks +39 lines, -41 lines 0 comments Download
M ui/gfx/render_text_win.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M ui/gfx/screen_gtk.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M ui/gfx/screen_mac.mm View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M ui/views/animation/bounds_animator.cc View 1 2 1 chunk +3 lines, -5 lines 0 comments Download
M ui/views/animation/bounds_animator_unittest.cc View 1 2 2 chunks +3 lines, -2 lines 0 comments Download
M ui/views/layout/box_layout.cc View 1 2 2 chunks +4 lines, -3 lines 0 comments Download
M ui/views/view.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M ui/views/view_unittest.cc View 1 2 2 chunks +3 lines, -4 lines 0 comments Download
M ui/views/widget/desktop_root_window_host_linux.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M ui/views/widget/native_widget_aura.cc View 1 2 2 chunks +4 lines, -3 lines 0 comments Download
M ui/views/widget/root_view.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M ui/views/widget/tooltip_manager_win.cc View 1 2 3 4 1 chunk +3 lines, -1 line 0 comments Download
M ui/views/widget/widget.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M ui/views/win/hwnd_message_handler.cc View 1 2 3 2 chunks +3 lines, -2 lines 0 comments Download
M webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc View 1 chunk +3 lines, -2 lines 0 comments Download
M webkit/plugins/npapi/webplugin_delegate_impl_mac.mm View 1 2 3 4 5 6 7 1 chunk +3 lines, -3 lines 0 comments Download
M webkit/plugins/ppapi/ppapi_plugin_instance.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +5 lines, -2 lines 0 comments Download
M webkit/plugins/ppapi/ppb_graphics_2d_impl.cc View 3 chunks +11 lines, -4 lines 0 comments Download
M webkit/plugins/ppapi/ppb_scrollbar_impl.cc View 1 chunk +1 line, -1 line 0 comments Download
M webkit/plugins/webview_plugin.cc View 1 chunk +2 lines, -1 line 0 comments Download
M webkit/tools/test_shell/webwidget_host_gtk.cc View 1 2 chunks +3 lines, -3 lines 0 comments Download
M webkit/tools/test_shell/webwidget_host_mac.mm View 1 2 3 4 5 6 7 5 chunks +8 lines, -8 lines 0 comments Download
M webkit/tools/test_shell/webwidget_host_win.cc View 1 2 3 5 chunks +7 lines, -7 lines 0 comments Download

Messages

Total messages: 30 (0 generated)
danakj
The actual changes are in rect.h rect_f.h rect_base.h and rect_base_impl.h The rest are just fluff ...
8 years, 2 months ago (2012-10-12 00:48:28 UTC) #1
tfarina
http://codereview.chromium.org/11110004/diff/1047/ui/gfx/rect_base.h File ui/gfx/rect_base.h (right): http://codereview.chromium.org/11110004/diff/1047/ui/gfx/rect_base.h#newcode125 ui/gfx/rect_base.h:125: // Become a rectangle that has the same center ...
8 years, 2 months ago (2012-10-12 01:37:27 UTC) #2
sky
LGTM . this results in a bit more code, but it is less error prone. ...
8 years, 2 months ago (2012-10-12 16:26:37 UTC) #3
danakj
http://codereview.chromium.org/11110004/diff/1047/ui/gfx/rect_base_impl.h File ui/gfx/rect_base_impl.h (right): http://codereview.chromium.org/11110004/diff/1047/ui/gfx/rect_base_impl.h#newcode193 ui/gfx/rect_base_impl.h:193: // special case empty rects... On 2012/10/12 16:26:38, sky ...
8 years, 2 months ago (2012-10-19 20:33:52 UTC) #4
danakj
Looking for a bunch of OWNERS for this change. Please take a look. There should ...
8 years, 2 months ago (2012-10-19 22:12:57 UTC) #5
danakj
annnd.. i didnt cc owners.
8 years, 2 months ago (2012-10-19 22:13:17 UTC) #6
danakj
Looking for a bunch of OWNERS for this change. Please take a look. There should ...
8 years, 2 months ago (2012-10-19 22:14:37 UTC) #7
xiyuan
ui/app_list LGTM
8 years, 2 months ago (2012-10-19 22:18:13 UTC) #8
stevenjb
ash/system LGTM
8 years, 2 months ago (2012-10-19 22:48:11 UTC) #9
sadrul
ui/views/ LGTM (note that sky@ covers this too)
8 years, 2 months ago (2012-10-19 23:15:06 UTC) #10
piman
lgtm
8 years, 2 months ago (2012-10-20 00:03:05 UTC) #11
jam
webkit/plugins lgtm
8 years, 2 months ago (2012-10-20 02:33:35 UTC) #12
Nico
I'm not sure I buy the change description. """ but I believe it is better ...
8 years, 2 months ago (2012-10-20 03:14:43 UTC) #13
danakj
On 2012/10/20 03:14:43, Nico wrote: > I'm not sure I buy the change description. > ...
8 years, 2 months ago (2012-10-20 03:20:58 UTC) #14
danakj
On 2012/10/20 03:20:58, danakj wrote: > On 2012/10/20 03:14:43, Nico wrote: > > I'm not ...
8 years, 2 months ago (2012-10-20 03:25:56 UTC) #15
(unused - use chromium)
On Fri, Oct 19, 2012 at 8:20 PM, <danakj@chromium.org> wrote: > On 2012/10/20 03:14:43, Nico ...
8 years, 2 months ago (2012-10-20 03:30:13 UTC) #16
danakj
On Sat, Oct 20, 2012 at 3:30 AM, Nico Weber <thakis@google.com> wrote: > On Fri, ...
8 years, 2 months ago (2012-10-20 03:54:04 UTC) #17
sky
Here's my response earlier: "LGTM . this results in a bit more code, but it ...
8 years, 2 months ago (2012-10-22 15:18:22 UTC) #18
(unused - use chromium)
On Mon, Oct 22, 2012 at 8:18 AM, <sky@chromium.org> wrote: > Here's my response earlier: ...
8 years, 2 months ago (2012-10-22 15:27:43 UTC) #19
sreeram
Why not have the best of both worlds? class Rect { void Subtract(...) {...} Rect ...
8 years, 2 months ago (2012-10-22 15:44:30 UTC) #20
danakj
On Mon, Oct 22, 2012 at 11:43 AM, Sreeram Ramachandran <sreeram@chromium.org> wrote: > Why not ...
8 years, 2 months ago (2012-10-22 15:47:55 UTC) #21
sreeram
On 2012/10/22 15:47:55, danakj wrote: > On Mon, Oct 22, 2012 at 11:43 AM, Sreeram ...
8 years, 2 months ago (2012-10-22 15:49:10 UTC) #22
danakj
On Mon, Oct 22, 2012 at 11:49 AM, <sreeram@chromium.org> wrote: > On 2012/10/22 15:47:55, danakj ...
8 years, 2 months ago (2012-10-22 15:57:25 UTC) #23
sreeram
On 2012/10/22 15:57:25, danakj wrote: > On Mon, Oct 22, 2012 at 11:49 AM, <mailto:sreeram@chromium.org> ...
8 years, 2 months ago (2012-10-22 16:15:28 UTC) #24
sreeram
On 2012/10/22 16:15:28, sreeram wrote: > return static_cast<const Int>(first).Subtract(second); Self nit: Use const_cast<> instead.
8 years, 2 months ago (2012-10-22 16:18:30 UTC) #25
danakj
On 2012/10/22 16:15:28, sreeram wrote: > On 2012/10/22 15:57:25, danakj wrote: > > On Mon, ...
8 years, 2 months ago (2012-10-22 16:32:27 UTC) #26
(unused - use chromium)
On Mon, Oct 22, 2012 at 9:32 AM, <danakj@chromium.org> wrote: > On 2012/10/22 16:15:28, sreeram ...
8 years, 2 months ago (2012-10-22 16:33:38 UTC) #27
sreeram
On 2012/10/22 16:33:38, thakis wrote: > On Mon, Oct 22, 2012 at 9:32 AM, <mailto:danakj@chromium.org> ...
8 years, 2 months ago (2012-10-22 16:43:03 UTC) #28
jamesr
webkit/ lgtm
8 years, 2 months ago (2012-10-22 17:47:35 UTC) #29
commit-bot: I haz the power
8 years, 2 months ago (2012-10-23 00:49:08 UTC) #30

Powered by Google App Engine
This is Rietveld 408576698