OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/accessibility/blink_ax_tree_source.h" | 5 #include "content/renderer/accessibility/blink_ax_tree_source.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 std::string name = UTF16ToUTF8(src.deprecatedTitle()); | 227 std::string name = UTF16ToUTF8(src.deprecatedTitle()); |
228 | 228 |
229 std::string value; | 229 std::string value; |
230 if (src.valueDescription().length()) { | 230 if (src.valueDescription().length()) { |
231 dst->AddStringAttribute(ui::AX_ATTR_VALUE, | 231 dst->AddStringAttribute(ui::AX_ATTR_VALUE, |
232 UTF16ToUTF8(src.valueDescription())); | 232 UTF16ToUTF8(src.valueDescription())); |
233 } else { | 233 } else { |
234 dst->AddStringAttribute(ui::AX_ATTR_VALUE, UTF16ToUTF8(src.stringValue())); | 234 dst->AddStringAttribute(ui::AX_ATTR_VALUE, UTF16ToUTF8(src.stringValue())); |
235 } | 235 } |
236 | 236 |
237 if (dst->role == ui::AX_ROLE_COLOR_WELL) { | 237 if (dst->role == ui::AX_ROLE_COLOR_WELL) |
238 int r, g, b; | 238 dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE, src.colorValue()); |
239 src.colorValue(r, g, b); | 239 |
240 dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE_RED, r); | 240 |
241 dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE_GREEN, g); | 241 // Text attributes. |
242 dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE_BLUE, b); | 242 if (src.backgroundColor()) |
243 } | 243 dst->AddIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, src.backgroundColor()); |
| 244 |
| 245 if (src.color()) |
| 246 dst->AddIntAttribute(ui::AX_ATTR_COLOR, src.color()); |
| 247 |
| 248 // Font size is in pixels. |
| 249 if (src.fontSize()) |
| 250 dst->AddFloatAttribute(ui::AX_ATTR_FONT_SIZE, src.fontSize()); |
244 | 251 |
245 if (src.invalidState()) { | 252 if (src.invalidState()) { |
246 dst->AddIntAttribute(ui::AX_ATTR_INVALID_STATE, | 253 dst->AddIntAttribute(ui::AX_ATTR_INVALID_STATE, |
247 AXInvalidStateFromBlink(src.invalidState())); | 254 AXInvalidStateFromBlink(src.invalidState())); |
248 } | 255 } |
249 if (src.invalidState() == blink::WebAXInvalidStateOther) { | 256 if (src.invalidState() == blink::WebAXInvalidStateOther) { |
250 dst->AddStringAttribute(ui::AX_ATTR_ARIA_INVALID_VALUE, | 257 dst->AddStringAttribute(ui::AX_ATTR_ARIA_INVALID_VALUE, |
251 UTF16ToUTF8(src.ariaInvalidValue())); | 258 UTF16ToUTF8(src.ariaInvalidValue())); |
252 } | 259 } |
253 | 260 |
254 if (dst->role == ui::AX_ROLE_INLINE_TEXT_BOX) { | 261 if (src.textDirection()) { |
255 dst->AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 262 dst->AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
256 AXTextDirectionFromBlink(src.textDirection())); | 263 AXTextDirectionFromBlink(src.textDirection())); |
| 264 } |
257 | 265 |
| 266 if (src.textStyle()) { |
| 267 dst->AddIntAttribute(ui::AX_ATTR_TEXT_STYLE, |
| 268 AXTextStyleFromBlink(src.textStyle())); |
| 269 } |
| 270 |
| 271 |
| 272 if (dst->role == ui::AX_ROLE_INLINE_TEXT_BOX) { |
258 WebVector<int> src_character_offsets; | 273 WebVector<int> src_character_offsets; |
259 src.characterOffsets(src_character_offsets); | 274 src.characterOffsets(src_character_offsets); |
260 std::vector<int32> character_offsets; | 275 std::vector<int32> character_offsets; |
261 character_offsets.reserve(src_character_offsets.size()); | 276 character_offsets.reserve(src_character_offsets.size()); |
262 for (size_t i = 0; i < src_character_offsets.size(); ++i) | 277 for (size_t i = 0; i < src_character_offsets.size(); ++i) |
263 character_offsets.push_back(src_character_offsets[i]); | 278 character_offsets.push_back(src_character_offsets[i]); |
264 dst->AddIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets); | 279 dst->AddIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets); |
265 | 280 |
266 WebVector<int> src_word_starts; | 281 WebVector<int> src_word_starts; |
267 WebVector<int> src_word_ends; | 282 WebVector<int> src_word_ends; |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); | 628 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); |
614 } | 629 } |
615 | 630 |
616 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { | 631 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { |
617 if (render_frame_ && render_frame_->GetWebFrame()) | 632 if (render_frame_ && render_frame_->GetWebFrame()) |
618 return render_frame_->GetWebFrame()->document(); | 633 return render_frame_->GetWebFrame()->document(); |
619 return WebDocument(); | 634 return WebDocument(); |
620 } | 635 } |
621 | 636 |
622 } // namespace content | 637 } // namespace content |
OLD | NEW |