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

Side by Side Diff: views/controls/image_view.cc

Issue 1616004: Fix Regression for Accessible Names (Closed)
Patch Set: Created 10 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/controls/image_view.h" 5 #include "views/controls/image_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gfx/canvas.h" 8 #include "gfx/canvas.h"
9 #include "gfx/insets.h" 9 #include "gfx/insets.h"
10 10
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 paint.setFilterBitmap(true); 129 paint.setFilterBitmap(true);
130 canvas->DrawBitmapInt(image_, 0, 0, image_width, image_height, 130 canvas->DrawBitmapInt(image_, 0, 0, image_width, image_height,
131 x, y, image_size_.width(), image_size_.height(), 131 x, y, image_size_.width(), image_size_.height(),
132 true, paint); 132 true, paint);
133 } else { 133 } else {
134 ComputeImageOrigin(image_width, image_height, &x, &y); 134 ComputeImageOrigin(image_width, image_height, &x, &y);
135 canvas->DrawBitmapInt(image_, x, y); 135 canvas->DrawBitmapInt(image_, x, y);
136 } 136 }
137 } 137 }
138 138
139 bool ImageView::GetAccessibleName(std::wstring* name) {
140 DCHECK(name);
141 *name = tooltip_text_;
142 return !name->empty();
143 }
144
145 bool ImageView::GetAccessibleRole(AccessibilityTypes::Role* role) { 139 bool ImageView::GetAccessibleRole(AccessibilityTypes::Role* role) {
146 if (!role) 140 if (!role)
147 return false; 141 return false;
148 142
149 *role = AccessibilityTypes::ROLE_GRAPHIC; 143 *role = AccessibilityTypes::ROLE_GRAPHIC;
150 return true; 144 return true;
151 } 145 }
152 146
153 void ImageView::SetHorizontalAlignment(Alignment ha) { 147 void ImageView::SetHorizontalAlignment(Alignment ha) {
154 if (ha != horiz_alignment_) { 148 if (ha != horiz_alignment_) {
(...skipping 12 matching lines...) Expand all
167 SchedulePaint(); 161 SchedulePaint();
168 } 162 }
169 } 163 }
170 164
171 ImageView::Alignment ImageView::GetVerticalAlignment() { 165 ImageView::Alignment ImageView::GetVerticalAlignment() {
172 return vert_alignment_; 166 return vert_alignment_;
173 } 167 }
174 168
175 void ImageView::SetTooltipText(const std::wstring& tooltip) { 169 void ImageView::SetTooltipText(const std::wstring& tooltip) {
176 tooltip_text_ = tooltip; 170 tooltip_text_ = tooltip;
171 SetAccessibleName(tooltip);
177 } 172 }
178 173
179 std::wstring ImageView::GetTooltipText() { 174 std::wstring ImageView::GetTooltipText() {
180 return tooltip_text_; 175 return tooltip_text_;
181 } 176 }
182 177
183 bool ImageView::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { 178 bool ImageView::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
184 if (tooltip_text_.empty()) 179 if (tooltip_text_.empty())
185 return false; 180 return false;
186 181
187 *tooltip = GetTooltipText(); 182 *tooltip = GetTooltipText();
188 return true; 183 return true;
189 } 184 }
190 185
191 } // namespace views 186 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698