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) {
const char ImageView::kViewClassName[] = "ImageView";
ImageView::ImageView()
: horiz_alignment_(CENTER),
vert_alignment_(CENTER),
: horizontal_alignment_(CENTER),
vertical_alignment_(CENTER),
last_paint_scale_(0.f),
last_painted_bitmap_pixels_(NULL) {}
last_painted_bitmap_pixels_(nullptr) {}
ImageView::~ImageView() {}
......@@ -40,7 +40,7 @@ void ImageView::SetImage(const gfx::ImageSkia& img) {
if (IsImageEqual(img))
return;
last_painted_bitmap_pixels_ = NULL;
last_painted_bitmap_pixels_ = nullptr;
gfx::Size pref_size(GetPreferredSize());
image_ = img;
if (pref_size != GetPreferredSize())
......@@ -93,31 +93,39 @@ gfx::Size ImageView::GetImageSize() const {
gfx::Point ImageView::ComputeImageOrigin(const gfx::Size& image_size) const {
gfx::Insets insets = GetInsets();
int x;
int x = 0;
// 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
// 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.
Alignment actual_horiz_alignment = horiz_alignment_;
if (base::i18n::IsRTL() && (horiz_alignment_ != CENTER))
actual_horiz_alignment = (horiz_alignment_ == LEADING) ? TRAILING : LEADING;
switch (actual_horiz_alignment) {
case LEADING: x = insets.left(); break;
case TRAILING: x = width() - insets.right() - image_size.width(); break;
Alignment actual_horizontal_alignment = horizontal_alignment_;
if (base::i18n::IsRTL() && (horizontal_alignment_ != CENTER)) {
actual_horizontal_alignment =
(horizontal_alignment_ == LEADING) ? TRAILING : LEADING;
}
switch (actual_horizontal_alignment) {
case LEADING:
x = insets.left();
break;
case TRAILING:
x = width() - insets.right() - image_size.width();
break;
case CENTER:
x = (width() - insets.width() - image_size.width()) / 2 + insets.left();
break;
default: NOTREACHED(); x = 0; break;
}
int y;
switch (vert_alignment_) {
case LEADING: y = insets.top(); break;
case TRAILING: y = height() - insets.bottom() - image_size.height(); break;
int y = 0;
switch (vertical_alignment_) {
case LEADING:
y = insets.top();
break;
case TRAILING:
y = height() - insets.bottom() - image_size.height();
break;
case CENTER:
y = (height() - insets.height() - image_size.height()) / 2 + insets.top();
break;
default: NOTREACHED(); y = 0; break;
}
return gfx::Point(x, y);
......@@ -137,26 +145,26 @@ const char* ImageView::GetClassName() const {
return kViewClassName;
}
void ImageView::SetHorizontalAlignment(Alignment ha) {
if (ha != horiz_alignment_) {
horiz_alignment_ = ha;
void ImageView::SetHorizontalAlignment(Alignment alignment) {
if (alignment != horizontal_alignment_) {
horizontal_alignment_ = alignment;
SchedulePaint();
}
}
ImageView::Alignment ImageView::GetHorizontalAlignment() const {
return horiz_alignment_;
return horizontal_alignment_;
}
void ImageView::SetVerticalAlignment(Alignment va) {
if (va != vert_alignment_) {
vert_alignment_ = va;
void ImageView::SetVerticalAlignment(Alignment alignment) {
if (alignment != vertical_alignment_) {
vertical_alignment_ = alignment;
SchedulePaint();
}
}
ImageView::Alignment ImageView::GetVerticalAlignment() const {
return vert_alignment_;
return vertical_alignment_;
}
void ImageView::SetTooltipText(const base::string16& tooltip) {
......@@ -184,7 +192,7 @@ gfx::Size ImageView::CalculatePreferredSize() const {
views::PaintInfo::ScaleType ImageView::GetPaintScaleType() const {
// 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
// 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
......@@ -197,7 +205,7 @@ views::PaintInfo::ScaleType ImageView::GetPaintScaleType() const {
void ImageView::OnPaintImage(gfx::Canvas* canvas) {
last_paint_scale_ = canvas->image_scale();
last_painted_bitmap_pixels_ = NULL;
last_painted_bitmap_pixels_ = nullptr;
if (image_.isNull())
return;
......
......@@ -106,10 +106,10 @@ class VIEWS_EXPORT ImageView : public View {
gfx::ImageSkia image_;
// Horizontal alignment.
Alignment horiz_alignment_;
Alignment horizontal_alignment_;
// Vertical alignment.
Alignment vert_alignment_;
Alignment vertical_alignment_;
// The current 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