Commit 8b4f60bf authored by Dave Schuyler's avatar Dave Schuyler Committed by Commit Bot

[Views] fix spelling of 'slightly'

This CL fixes a typo in a comment. Along the way abbreviations were
expanded and NULL swapped for nullptr to match current standards.

There are no logic changes in this CL.

Bug: None
Change-Id: I406d7c3ff9782e95a81ade89141a8121e4728185
Reviewed-on: https://chromium-review.googlesource.com/1054850
Commit-Queue: Dave Schuyler <dschuyler@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558554}
parent 1d22ea1d
...@@ -29,10 +29,10 @@ void* GetBitmapPixels(const gfx::ImageSkia& img, float image_scale) { ...@@ -29,10 +29,10 @@ void* GetBitmapPixels(const gfx::ImageSkia& img, float image_scale) {
const char ImageView::kViewClassName[] = "ImageView"; const char ImageView::kViewClassName[] = "ImageView";
ImageView::ImageView() ImageView::ImageView()
: horiz_alignment_(CENTER), : horizontal_alignment_(CENTER),
vert_alignment_(CENTER), vertical_alignment_(CENTER),
last_paint_scale_(0.f), last_paint_scale_(0.f),
last_painted_bitmap_pixels_(NULL) {} last_painted_bitmap_pixels_(nullptr) {}
ImageView::~ImageView() {} ImageView::~ImageView() {}
...@@ -40,7 +40,7 @@ void ImageView::SetImage(const gfx::ImageSkia& img) { ...@@ -40,7 +40,7 @@ void ImageView::SetImage(const gfx::ImageSkia& img) {
if (IsImageEqual(img)) if (IsImageEqual(img))
return; return;
last_painted_bitmap_pixels_ = NULL; last_painted_bitmap_pixels_ = nullptr;
gfx::Size pref_size(GetPreferredSize()); gfx::Size pref_size(GetPreferredSize());
image_ = img; image_ = img;
if (pref_size != GetPreferredSize()) if (pref_size != GetPreferredSize())
...@@ -93,31 +93,39 @@ gfx::Size ImageView::GetImageSize() const { ...@@ -93,31 +93,39 @@ gfx::Size ImageView::GetImageSize() const {
gfx::Point ImageView::ComputeImageOrigin(const gfx::Size& image_size) const { gfx::Point ImageView::ComputeImageOrigin(const gfx::Size& image_size) const {
gfx::Insets insets = GetInsets(); gfx::Insets insets = GetInsets();
int x; int x = 0;
// In order to properly handle alignment of images in RTL locales, we need // In order to properly handle alignment of images in RTL locales, we need
// to flip the meaning of trailing and leading. For example, if the // to flip the meaning of trailing and leading. For example, if the
// horizontal alignment is set to trailing, then we'll use left alignment for // horizontal alignment is set to trailing, then we'll use left alignment for
// the image instead of right alignment if the UI layout is RTL. // the image instead of right alignment if the UI layout is RTL.
Alignment actual_horiz_alignment = horiz_alignment_; Alignment actual_horizontal_alignment = horizontal_alignment_;
if (base::i18n::IsRTL() && (horiz_alignment_ != CENTER)) if (base::i18n::IsRTL() && (horizontal_alignment_ != CENTER)) {
actual_horiz_alignment = (horiz_alignment_ == LEADING) ? TRAILING : LEADING; actual_horizontal_alignment =
switch (actual_horiz_alignment) { (horizontal_alignment_ == LEADING) ? TRAILING : LEADING;
case LEADING: x = insets.left(); break; }
case TRAILING: x = width() - insets.right() - image_size.width(); break; switch (actual_horizontal_alignment) {
case LEADING:
x = insets.left();
break;
case TRAILING:
x = width() - insets.right() - image_size.width();
break;
case CENTER: case CENTER:
x = (width() - insets.width() - image_size.width()) / 2 + insets.left(); x = (width() - insets.width() - image_size.width()) / 2 + insets.left();
break; break;
default: NOTREACHED(); x = 0; break;
} }
int y; int y = 0;
switch (vert_alignment_) { switch (vertical_alignment_) {
case LEADING: y = insets.top(); break; case LEADING:
case TRAILING: y = height() - insets.bottom() - image_size.height(); break; y = insets.top();
break;
case TRAILING:
y = height() - insets.bottom() - image_size.height();
break;
case CENTER: case CENTER:
y = (height() - insets.height() - image_size.height()) / 2 + insets.top(); y = (height() - insets.height() - image_size.height()) / 2 + insets.top();
break; break;
default: NOTREACHED(); y = 0; break;
} }
return gfx::Point(x, y); return gfx::Point(x, y);
...@@ -137,26 +145,26 @@ const char* ImageView::GetClassName() const { ...@@ -137,26 +145,26 @@ const char* ImageView::GetClassName() const {
return kViewClassName; return kViewClassName;
} }
void ImageView::SetHorizontalAlignment(Alignment ha) { void ImageView::SetHorizontalAlignment(Alignment alignment) {
if (ha != horiz_alignment_) { if (alignment != horizontal_alignment_) {
horiz_alignment_ = ha; horizontal_alignment_ = alignment;
SchedulePaint(); SchedulePaint();
} }
} }
ImageView::Alignment ImageView::GetHorizontalAlignment() const { ImageView::Alignment ImageView::GetHorizontalAlignment() const {
return horiz_alignment_; return horizontal_alignment_;
} }
void ImageView::SetVerticalAlignment(Alignment va) { void ImageView::SetVerticalAlignment(Alignment alignment) {
if (va != vert_alignment_) { if (alignment != vertical_alignment_) {
vert_alignment_ = va; vertical_alignment_ = alignment;
SchedulePaint(); SchedulePaint();
} }
} }
ImageView::Alignment ImageView::GetVerticalAlignment() const { ImageView::Alignment ImageView::GetVerticalAlignment() const {
return vert_alignment_; return vertical_alignment_;
} }
void ImageView::SetTooltipText(const base::string16& tooltip) { void ImageView::SetTooltipText(const base::string16& tooltip) {
...@@ -184,7 +192,7 @@ gfx::Size ImageView::CalculatePreferredSize() const { ...@@ -184,7 +192,7 @@ gfx::Size ImageView::CalculatePreferredSize() const {
views::PaintInfo::ScaleType ImageView::GetPaintScaleType() const { views::PaintInfo::ScaleType ImageView::GetPaintScaleType() const {
// ImageView contains an image which is rastered at the device scale factor. // ImageView contains an image which is rastered at the device scale factor.
// By default, the paint commands are recorded at a scale factor slighlty // By default, the paint commands are recorded at a scale factor slightly
// different from the device scale factor. Re-rastering the image at this // different from the device scale factor. Re-rastering the image at this
// paint recording scale will result in a distorted image. Paint recording // paint recording scale will result in a distorted image. Paint recording
// scale might also not be uniform along the x & y axis, thus resulting in // scale might also not be uniform along the x & y axis, thus resulting in
...@@ -197,7 +205,7 @@ views::PaintInfo::ScaleType ImageView::GetPaintScaleType() const { ...@@ -197,7 +205,7 @@ views::PaintInfo::ScaleType ImageView::GetPaintScaleType() const {
void ImageView::OnPaintImage(gfx::Canvas* canvas) { void ImageView::OnPaintImage(gfx::Canvas* canvas) {
last_paint_scale_ = canvas->image_scale(); last_paint_scale_ = canvas->image_scale();
last_painted_bitmap_pixels_ = NULL; last_painted_bitmap_pixels_ = nullptr;
if (image_.isNull()) if (image_.isNull())
return; return;
......
...@@ -106,10 +106,10 @@ class VIEWS_EXPORT ImageView : public View { ...@@ -106,10 +106,10 @@ class VIEWS_EXPORT ImageView : public View {
gfx::ImageSkia image_; gfx::ImageSkia image_;
// Horizontal alignment. // Horizontal alignment.
Alignment horiz_alignment_; Alignment horizontal_alignment_;
// Vertical alignment. // Vertical alignment.
Alignment vert_alignment_; Alignment vertical_alignment_;
// The current tooltip text. // The current tooltip text.
base::string16 tooltip_text_; base::string16 tooltip_text_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment