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

Unified Diff: gfx/rect.cc

Issue 6254004: Move more web widgets painting from webkit to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync and fix width100percent-checkbox Created 9 years, 11 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 | « gfx/rect.h ('k') | webkit/glue/webthemeengine_impl_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gfx/rect.cc
diff --git a/gfx/rect.cc b/gfx/rect.cc
index e9c666c22d052c05421717325f20fef9cbf286d5..a1a72cb41b8005b2ff01934d59375c49683aa619 100644
--- a/gfx/rect.cc
+++ b/gfx/rect.cc
@@ -234,6 +234,14 @@ Point Rect::CenterPoint() const {
return Point(x() + (width() + 1) / 2, y() + (height() + 1) / 2);
}
+Rect Rect::Center(const gfx::Size& size) const {
+ int new_width = std::min(width(), size.width());
+ int new_height = std::min(height(), size.height());
+ int new_x = x() + (width() - new_width) / 2;
+ int new_y = y() + (height() - new_height) / 2;
+ return Rect(new_x, new_y, new_width, new_height);
+}
+
bool Rect::SharesEdgeWith(const gfx::Rect& rect) const {
return (y() == rect.y() && height() == rect.height() &&
(x() == rect.right() || right() == rect.x())) ||
« no previous file with comments | « gfx/rect.h ('k') | webkit/glue/webthemeengine_impl_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698