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

Unified Diff: ui/snapshot/snapshot_android.cc

Issue 340603002: android: Fix snapshot height by including toolbar offset (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: set pixel test expect to fail Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/android/window_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/snapshot/snapshot_android.cc
diff --git a/ui/snapshot/snapshot_android.cc b/ui/snapshot/snapshot_android.cc
index 9713cff3ec1da7e6303149ed777bf186834e0b3e..aec755516c87e029bd495bc165412b0636f17435 100644
--- a/ui/snapshot/snapshot_android.cc
+++ b/ui/snapshot/snapshot_android.cc
@@ -11,6 +11,7 @@
#include "ui/base/android/window_android.h"
#include "ui/base/android/window_android_compositor.h"
#include "ui/gfx/display.h"
+#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/screen.h"
#include "ui/snapshot/snapshot_async.h"
@@ -44,7 +45,14 @@ static void MakeAsyncCopyRequest(
gfx::Rect source_rect_in_pixel =
gfx::ToEnclosingRect(gfx::ScaleRect(source_rect, device_scale_factor));
- request->set_area(source_rect_in_pixel);
+ // Account for the toolbar offset.
+ gfx::Vector2dF offset = window->content_offset();
+ gfx::Rect adjusted_source_rect(gfx::ToRoundedPoint(
+ gfx::PointF(source_rect_in_pixel.x() + offset.x(),
+ source_rect_in_pixel.y() + offset.y())),
+ source_rect_in_pixel.size());
+
+ request->set_area(adjusted_source_rect);
window->GetCompositor()->RequestCopyOfOutputOnRootLayer(request.Pass());
}
« no previous file with comments | « ui/base/android/window_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698