diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-23 16:51:47 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-23 16:51:47 +0000 |
commit | d40305001bfd61bef7e118c8580895f68d36b163 (patch) | |
tree | 05a4a731233c5cb3deb56306019231e22d474deb /ui/views/win | |
parent | ea75f30985b5b24627bed4c613a1ef403235aa02 (diff) | |
download | chromium_src-d40305001bfd61bef7e118c8580895f68d36b163.zip chromium_src-d40305001bfd61bef7e118c8580895f68d36b163.tar.gz chromium_src-d40305001bfd61bef7e118c8580895f68d36b163.tar.bz2 |
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
Review URL: https://codereview.chromium.org/11110004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163579 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/win')
-rw-r--r-- | ui/views/win/hwnd_message_handler.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc index c52deb5..c96a474 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -842,7 +842,7 @@ void HWNDMessageHandler::SchedulePaintInRect(const gfx::Rect& rect) { if (use_layered_buffer_) { // We must update the back-buffer immediately, since Windows' handling of // invalid rects is somewhat mysterious. - invalid_rect_ = invalid_rect_.Union(rect); + invalid_rect_.Union(rect); // In some situations, such as drag and drop, when Windows itself runs a // nested message loop our message loop appears to be starved and we don't @@ -2034,7 +2034,8 @@ void HWNDMessageHandler::OnWindowPosChanging(WINDOWPOS* window_pos) { int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); new_window_rect.Inset(-border_thickness, -border_thickness); } else { - new_window_rect = gfx::Rect(window_rect).AdjustToFit(work_area); + new_window_rect = gfx::Rect(window_rect); + new_window_rect.AdjustToFit(work_area); } window_pos->x = new_window_rect.x(); window_pos->y = new_window_rect.y(); |