summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ntp_background_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ntp_background_util.cc')
-rw-r--r--chrome/browser/ntp_background_util.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/chrome/browser/ntp_background_util.cc b/chrome/browser/ntp_background_util.cc
index c6682d0..297a0f0 100644
--- a/chrome/browser/ntp_background_util.cc
+++ b/chrome/browser/ntp_background_util.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/ntp_background_util.h"
+#include <cmath>
+
#include "base/logging.h"
#include "chrome/browser/themes/theme_service.h"
#include "grit/theme_resources.h"
@@ -22,15 +24,22 @@ void PaintThemeBackground(
int width = area.width() + ntp_background->width();
int height = area.height() + ntp_background->height();
- if (alignment & ThemeService::ALIGN_BOTTOM)
+ if (alignment & ThemeService::ALIGN_BOTTOM) {
y_pos += area.height() + tab_contents_height - ntp_background->height();
+ } else if (alignment & ThemeService::ALIGN_TOP) {
+ // no op
+ } else { // ALIGN_CENTER
+ y_pos += std::floor(area.height() + tab_contents_height / 2.0 -
+ ntp_background->height() / 2.0 + 0.5);
+ }
if (alignment & ThemeService::ALIGN_RIGHT) {
x_pos += area.width() - ntp_background->width();
} else if (alignment & ThemeService::ALIGN_LEFT) {
// no op
} else { // ALIGN_CENTER
- x_pos += area.width() / 2 - ntp_background->width() / 2;
+ x_pos +=
+ std::floor(area.width() / 2.0 - ntp_background->width() / 2.0 + 0.5);
}
if (tiling != ThemeService::REPEAT &&
@@ -68,7 +77,7 @@ void NtpBackgroundUtil::PaintBackgroundDetachedMode(ui::ThemeProvider* tp,
tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_TILING, &tiling);
int alignment;
if (tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT,
- &alignment)) {
+ &alignment)) {
SkBitmap* ntp_background = tp->GetBitmapNamed(IDR_THEME_NTP_BACKGROUND);
PaintThemeBackground(