summaryrefslogtreecommitdiffstats
path: root/webkit/plugins
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 /webkit/plugins
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 'webkit/plugins')
-rw-r--r--webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc5
-rw-r--r--webkit/plugins/npapi/webplugin_delegate_impl_mac.mm6
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc7
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc15
-rw-r--r--webkit/plugins/ppapi/ppb_scrollbar_impl.cc2
-rw-r--r--webkit/plugins/webview_plugin.cc3
6 files changed, 25 insertions, 13 deletions
diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc b/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc
index 52aa70b..869ea9f 100644
--- a/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc
+++ b/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc
@@ -355,12 +355,13 @@ void WebPluginDelegateImpl::WindowlessPaint(cairo_t* context,
// "real" means as seen by Chrome
// "apparent" means as seen by the plugin.
- gfx::Rect draw_rect = window_rect_.Intersect(damage_rect);
+ gfx::Rect draw_rect = window_rect_;
+ draw_rect.Intersect(damage_rect);
// clip_rect_ is relative to the plugin
gfx::Rect clip_rect_window = clip_rect_;
clip_rect_window.Offset(window_rect_.x(), window_rect_.y());
- draw_rect = draw_rect.Intersect(clip_rect_window);
+ draw_rect.Intersect(clip_rect_window);
// These offsets represent by how much the view is shifted to accomodate
// Flash (the coordinates of X relative to O in the diagram above).
diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm b/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm
index 806bdeb..685d019 100644
--- a/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm
+++ b/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm
@@ -455,16 +455,16 @@ void WebPluginDelegateImpl::WindowlessPaint(gfx::NativeDrawingContext context,
base::StatsRate plugin_paint("Plugin.Paint");
base::StatsScope<base::StatsRate> scope(plugin_paint);
- gfx::Rect paint_rect;
+ gfx::Rect paint_rect = damage_rect;
if (use_buffer_context_) {
// Plugin invalidates trigger asynchronous paints with the original
// invalidation rect; the plugin may be resized before the paint is handled,
// so we need to ensure that the damage rect is still sane.
- paint_rect = damage_rect.Intersect(
+ paint_rect.Intersect(
gfx::Rect(0, 0, window_rect_.width(), window_rect_.height()));
} else {
// Use the actual window region when drawing directly to the window context.
- paint_rect = damage_rect.Intersect(window_rect_);
+ paint_rect.Intersect(window_rect_);
}
ScopedActiveDelegate active_delegate(this);
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 134b10e..3872805 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -1065,11 +1065,14 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint(
gfx::Rect pixel_plugin_backing_store_rect(
0, 0, image_data->width(), image_data->height());
float scale = GetBoundGraphics2D()->GetScale();
+ gfx::RectF scaled_backing_store_rect = pixel_plugin_backing_store_rect;
+ scaled_backing_store_rect.Scale(scale);
gfx::Rect plugin_backing_store_rect =
- gfx::ToEnclosedRect(pixel_plugin_backing_store_rect.Scale(scale));
+ gfx::ToEnclosedRect(scaled_backing_store_rect);
gfx::Rect clip_page = PP_ToGfxRect(view_data_.clip_rect);
- gfx::Rect plugin_paint_rect = plugin_backing_store_rect.Intersect(clip_page);
+ gfx::Rect plugin_paint_rect = plugin_backing_store_rect;
+ plugin_paint_rect.Intersect(clip_page);
if (!plugin_paint_rect.Contains(relative_paint_bounds))
return false;
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index 85c27d9..923b88d 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -376,7 +376,8 @@ int32_t PPB_Graphics2D_Impl::Flush(scoped_refptr<TrackedCallback> callback,
// Set |no_update_visible| to false if the change overlaps the visible
// area.
- gfx::Rect visible_changed_rect = clip.Intersect(op_rect);
+ gfx::Rect visible_changed_rect = clip;
+ visible_changed_rect.Intersect(op_rect);
if (!visible_changed_rect.IsEmpty())
no_update_visible = false;
@@ -560,7 +561,8 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas,
CGContextDrawImage(canvas, bitmap_rect, image);
#else
- gfx::Rect invalidate_rect = plugin_rect.Intersect(paint_rect);
+ gfx::Rect invalidate_rect = plugin_rect;
+ invalidate_rect.Intersect(paint_rect);
SkRect sk_invalidate_rect = gfx::RectToSkRect(invalidate_rect);
SkAutoCanvasRestore auto_restore(canvas, true);
canvas->clipRect(sk_invalidate_rect);
@@ -647,12 +649,17 @@ bool PPB_Graphics2D_Impl::ConvertToLogicalPixels(float scale,
// Take the enclosing rectangle after scaling so a rectangle scaled down then
// scaled back up by the inverse scale would fully contain the entire area
// affected by the original rectangle.
- *op_rect = gfx::ToEnclosingRect(op_rect->Scale(scale));
+ gfx::RectF scaled_rect = *op_rect;
+ scaled_rect.Scale(scale);
+ *op_rect = gfx::ToEnclosingRect(scaled_rect);
if (delta) {
gfx::Point original_delta = *delta;
float inverse_scale = 1.0f / scale;
*delta = gfx::ToFlooredPoint(delta->Scale(scale));
- if (original_rect != gfx::ToEnclosingRect(op_rect->Scale(inverse_scale)) ||
+
+ gfx::RectF inverse_scaled_rect = *op_rect;
+ inverse_scaled_rect.Scale(inverse_scale);
+ if (original_rect != gfx::ToEnclosingRect(inverse_scaled_rect) ||
original_delta != gfx::ToFlooredPoint(delta->Scale(inverse_scale))) {
return false;
}
diff --git a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
index 1a190bb..7242de6 100644
--- a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
+++ b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
@@ -211,7 +211,7 @@ void PPB_Scrollbar_Impl::invalidateScrollbarRect(
rect.y,
rect.width,
rect.height);
- dirty_ = dirty_.Union(gfx_rect);
+ dirty_.Union(gfx_rect);
// Can't call into the client to tell them about the invalidate right away,
// since the PPB_Scrollbar_Impl code is still in the middle of updating its
// internal state.
diff --git a/webkit/plugins/webview_plugin.cc b/webkit/plugins/webview_plugin.cc
index 7d3dc7e..9888b73 100644
--- a/webkit/plugins/webview_plugin.cc
+++ b/webkit/plugins/webview_plugin.cc
@@ -120,7 +120,8 @@ bool WebViewPlugin::getFormValue(WebString& value) {
}
void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) {
- gfx::Rect paintRect(rect_.Intersect(rect));
+ gfx::Rect paintRect = rect_;
+ paintRect.Intersect(rect);
if (paintRect.IsEmpty())
return;