| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/accessibility/browser_accessibility_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_win.h" |
| 6 | 6 |
| 7 #include <UIAutomationClient.h> | 7 #include <UIAutomationClient.h> |
| 8 #include <UIAutomationCoreApi.h> | 8 #include <UIAutomationCoreApi.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 4299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4310 // TODO(nektar): Figure out the current value of pixels per inch. | 4310 // TODO(nektar): Figure out the current value of pixels per inch. |
| 4311 float points = font_size * 72.0 / 96.0; | 4311 float points = font_size * 72.0 / 96.0; |
| 4312 attributes.push_back(L"font-size:" + | 4312 attributes.push_back(L"font-size:" + |
| 4313 base::UTF8ToUTF16(base::DoubleToString(points)) + | 4313 base::UTF8ToUTF16(base::DoubleToString(points)) + |
| 4314 L"pt"); | 4314 L"pt"); |
| 4315 } | 4315 } |
| 4316 | 4316 |
| 4317 auto text_style = | 4317 auto text_style = |
| 4318 static_cast<ui::AXTextStyle>(GetIntAttribute(ui::AX_ATTR_TEXT_STYLE)); | 4318 static_cast<ui::AXTextStyle>(GetIntAttribute(ui::AX_ATTR_TEXT_STYLE)); |
| 4319 if (text_style == ui::AX_TEXT_STYLE_NONE) { | 4319 if (text_style == ui::AX_TEXT_STYLE_NONE) { |
| 4320 attributes.push_back(L"font-style:normal"); |
| 4320 attributes.push_back(L"font-weight:normal"); | 4321 attributes.push_back(L"font-weight:normal"); |
| 4321 attributes.push_back(L"font-style:normal"); | |
| 4322 } else { | 4322 } else { |
| 4323 if (text_style & ui::AX_TEXT_STYLE_ITALIC) { |
| 4324 attributes.push_back(L"font-style:italic"); |
| 4325 } else { |
| 4326 attributes.push_back(L"font-style:normal"); |
| 4327 } |
| 4328 |
| 4323 if (text_style & ui::AX_TEXT_STYLE_BOLD) { | 4329 if (text_style & ui::AX_TEXT_STYLE_BOLD) { |
| 4324 attributes.push_back(L"font-weight:bold"); | 4330 attributes.push_back(L"font-weight:bold"); |
| 4325 } else { | 4331 } else { |
| 4326 attributes.push_back(L"font-weight:normal"); | 4332 attributes.push_back(L"font-weight:normal"); |
| 4327 } | 4333 } |
| 4328 | |
| 4329 base::string16 font_style; | |
| 4330 if (text_style & ui::AX_TEXT_STYLE_ITALIC) | |
| 4331 font_style += L",italic"; | |
| 4332 if (text_style & ui::AX_TEXT_STYLE_UNDERLINE) | |
| 4333 font_style += L",underline"; | |
| 4334 if (text_style & ui::AX_TEXT_STYLE_LINE_THROUGH) | |
| 4335 font_style += L",line-through"; | |
| 4336 // TODO(nektar): Support more font style attributes in Blink. | |
| 4337 | |
| 4338 if (font_style.empty()) { | |
| 4339 font_style = L"normal"; | |
| 4340 } else { | |
| 4341 // Remove the leading comma. | |
| 4342 font_style.erase(0, 1); | |
| 4343 } | |
| 4344 attributes.push_back(L"font-style:" + font_style); | |
| 4345 } | 4334 } |
| 4346 | 4335 |
| 4347 auto invalid_state = static_cast<ui::AXInvalidState>( | 4336 auto invalid_state = static_cast<ui::AXInvalidState>( |
| 4348 GetIntAttribute(ui::AX_ATTR_INVALID_STATE)); | 4337 GetIntAttribute(ui::AX_ATTR_INVALID_STATE)); |
| 4349 switch (invalid_state) { | 4338 switch (invalid_state) { |
| 4350 case ui::AX_INVALID_STATE_NONE: | 4339 case ui::AX_INVALID_STATE_NONE: |
| 4351 case ui::AX_INVALID_STATE_FALSE: | 4340 case ui::AX_INVALID_STATE_FALSE: |
| 4352 attributes.push_back(L"invalid:false"); | 4341 attributes.push_back(L"invalid:false"); |
| 4353 break; | 4342 break; |
| 4354 case ui::AX_INVALID_STATE_TRUE: | 4343 case ui::AX_INVALID_STATE_TRUE: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4385 if (language.empty()) { | 4374 if (language.empty()) { |
| 4386 attributes.push_back(L"language:en-US"); | 4375 attributes.push_back(L"language:en-US"); |
| 4387 } else { | 4376 } else { |
| 4388 SanitizeStringAttributeForIA2(language, &language); | 4377 SanitizeStringAttributeForIA2(language, &language); |
| 4389 attributes.push_back(L"language:" + language); | 4378 attributes.push_back(L"language:" + language); |
| 4390 } | 4379 } |
| 4391 | 4380 |
| 4392 // TODO(nektar): Add Blink support for the following attributes. | 4381 // TODO(nektar): Add Blink support for the following attributes. |
| 4393 // Currently set to their default values as dictated by the IA2 Spec. | 4382 // Currently set to their default values as dictated by the IA2 Spec. |
| 4394 attributes.push_back(L"text-line-through-mode:continuous"); | 4383 attributes.push_back(L"text-line-through-mode:continuous"); |
| 4395 attributes.push_back(L"text-line-through-style:none"); | 4384 if (text_style & ui::AX_TEXT_STYLE_LINE_THROUGH) { |
| 4385 // TODO(nektar): Figure out a more specific value. |
| 4386 attributes.push_back(L"text-line-through-style:solid"); |
| 4387 } else { |
| 4388 attributes.push_back(L"text-line-through-style:none"); |
| 4389 } |
| 4396 // Default value must be the empty string. | 4390 // Default value must be the empty string. |
| 4397 attributes.push_back(L"text-line-through-text:"); | 4391 attributes.push_back(L"text-line-through-text:"); |
| 4398 attributes.push_back(L"text-line-through-type:none"); | 4392 if (text_style & ui::AX_TEXT_STYLE_LINE_THROUGH) { |
| 4393 // TODO(nektar): Figure out a more specific value. |
| 4394 attributes.push_back(L"text-line-through-type:single"); |
| 4395 } else { |
| 4396 attributes.push_back(L"text-line-through-type:none"); |
| 4397 } |
| 4399 attributes.push_back(L"text-line-through-width:auto"); | 4398 attributes.push_back(L"text-line-through-width:auto"); |
| 4400 attributes.push_back(L"text-outline:false"); | 4399 attributes.push_back(L"text-outline:false"); |
| 4401 attributes.push_back(L"text-position:baseline"); | 4400 attributes.push_back(L"text-position:baseline"); |
| 4402 attributes.push_back(L"text-shadow:none"); | 4401 attributes.push_back(L"text-shadow:none"); |
| 4403 attributes.push_back(L"text-underline-mode:continuous"); | 4402 attributes.push_back(L"text-underline-mode:continuous"); |
| 4404 attributes.push_back(L"text-underline-style:none"); | 4403 if (text_style & ui::AX_TEXT_STYLE_UNDERLINE) { |
| 4405 attributes.push_back(L"text-underline-type:none"); | 4404 // TODO(nektar): Figure out a more specific value. |
| 4405 attributes.push_back(L"text-underline-style:solid"); |
| 4406 attributes.push_back(L"text-underline-type:single"); |
| 4407 } else { |
| 4408 attributes.push_back(L"text-underline-style:none"); |
| 4409 attributes.push_back(L"text-underline-type:none"); |
| 4410 } |
| 4406 attributes.push_back(L"text-underline-width:auto"); | 4411 attributes.push_back(L"text-underline-width:auto"); |
| 4407 | 4412 |
| 4408 auto text_direction = static_cast<ui::AXTextDirection>( | 4413 auto text_direction = static_cast<ui::AXTextDirection>( |
| 4409 GetIntAttribute(ui::AX_ATTR_TEXT_DIRECTION)); | 4414 GetIntAttribute(ui::AX_ATTR_TEXT_DIRECTION)); |
| 4410 switch (text_direction) { | 4415 switch (text_direction) { |
| 4411 case ui::AX_TEXT_DIRECTION_NONE: | 4416 case ui::AX_TEXT_DIRECTION_NONE: |
| 4412 case ui::AX_TEXT_DIRECTION_LTR: | 4417 case ui::AX_TEXT_DIRECTION_LTR: |
| 4413 attributes.push_back(L"writing-mode:lr"); | 4418 attributes.push_back(L"writing-mode:lr"); |
| 4414 break; | 4419 break; |
| 4415 case ui::AX_TEXT_DIRECTION_RTL: | 4420 case ui::AX_TEXT_DIRECTION_RTL: |
| (...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5786 return static_cast<BrowserAccessibilityWin*>(obj); | 5791 return static_cast<BrowserAccessibilityWin*>(obj); |
| 5787 } | 5792 } |
| 5788 | 5793 |
| 5789 const BrowserAccessibilityWin* | 5794 const BrowserAccessibilityWin* |
| 5790 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { | 5795 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { |
| 5791 DCHECK(!obj || obj->IsNative()); | 5796 DCHECK(!obj || obj->IsNative()); |
| 5792 return static_cast<const BrowserAccessibilityWin*>(obj); | 5797 return static_cast<const BrowserAccessibilityWin*>(obj); |
| 5793 } | 5798 } |
| 5794 | 5799 |
| 5795 } // namespace content | 5800 } // namespace content |
| OLD | NEW |