summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/render_widget_host_view_mac.mm
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 16:51:47 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 16:51:47 +0000
commitd40305001bfd61bef7e118c8580895f68d36b163 (patch)
tree05a4a731233c5cb3deb56306019231e22d474deb /content/browser/renderer_host/render_widget_host_view_mac.mm
parentea75f30985b5b24627bed4c613a1ef403235aa02 (diff)
downloadchromium_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 'content/browser/renderer_host/render_widget_host_view_mac.mm')
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.mm10
1 files changed, 6 insertions, 4 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index a8d05a8..69bb0cf 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -852,8 +852,9 @@ void RenderWidgetHostViewMac::CopyFromCompositingSurface(
gfx::Rect src_gl_subrect = src_subrect;
src_gl_subrect.set_y(GetViewBounds().height() - src_subrect.bottom());
- gfx::Rect src_pixel_gl_subrect =
- gfx::ToEnclosingRect(src_gl_subrect.Scale(scale));
+ gfx::RectF scaled_src_gl_subrect = src_gl_subrect;
+ scaled_src_gl_subrect.Scale(scale);
+ gfx::Rect src_pixel_gl_subrect = gfx::ToEnclosingRect(scaled_src_gl_subrect);
compositing_iosurface_->CopyTo(
src_pixel_gl_subrect,
dst_pixel_size,
@@ -1118,7 +1119,7 @@ gfx::Rect RenderWidgetHostViewMac::GetFirstRectForCompositionRange(
*actual_range = ui::Range(range.start(), end_idx);
gfx::Rect rect = composition_bounds_[range.start()];
for (size_t i = range.start() + 1; i < end_idx; ++i) {
- rect = rect.Union(composition_bounds_[i]);
+ rect.Union(composition_bounds_[i]);
}
return rect;
}
@@ -2269,7 +2270,8 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
// smaller and the renderer hasn't yet repainted.
int yOffset = NSHeight([self bounds]) - backingStore->size().height();
- gfx::Rect paintRect = bitmapRect.Intersect(damagedRect);
+ gfx::Rect paintRect = bitmapRect;
+ paintRect.Intersect(damagedRect);
if (!paintRect.IsEmpty()) {
// if we have a CGLayer, draw that into the window
if (backingStore->cg_layer()) {