Chromium Code Reviews| Index: content/browser/accessibility/browser_accessibility.cc |
| diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc |
| index 7bb165b62668ca110bd4bb4a272e67d45329ef66..7bf09ccfcf738954df61f87e0dbcb5151e5a0dbd 100644 |
| --- a/content/browser/accessibility/browser_accessibility.cc |
| +++ b/content/browser/accessibility/browser_accessibility.cc |
| @@ -230,8 +230,9 @@ BrowserAccessibility* BrowserAccessibility::InternalGetChild( |
| } |
| BrowserAccessibility* BrowserAccessibility::GetParent() const { |
| - if (!node_ || !manager_) |
| - return NULL; |
| + if (!instance_active()) |
| + return nullptr; |
| + |
| ui::AXNode* parent = node_->parent(); |
| if (parent) |
| return manager_->GetFromAXNode(parent); |
| @@ -362,8 +363,8 @@ gfx::Rect BrowserAccessibility::GetLocalBoundsForRange(int start, int len) |
| int local_end = overlap_end - child_start; |
| gfx::Rect child_rect = child->GetLocation(); |
| - int text_direction = child->GetIntAttribute( |
| - ui::AX_ATTR_TEXT_DIRECTION); |
| + auto text_direction = static_cast<ui::AXTextDirection>( |
| + child->GetIntAttribute(ui::AX_ATTR_TEXT_DIRECTION)); |
| const std::vector<int32_t>& character_offsets = |
| child->GetIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS); |
| int start_pixel_offset = |
| @@ -631,6 +632,66 @@ bool BrowserAccessibility::GetFloatAttribute( |
| return GetData().GetFloatAttribute(attribute, value); |
| } |
| +bool BrowserAccessibility::HasInheritedStringAttribute( |
| + ui::AXStringAttribute attribute) const { |
| + if (!instance_active()) |
| + return false; |
| + |
| + if (GetData().HasStringAttribute(attribute)) |
| + return true; |
| + return GetParent() && GetParent()->HasInheritedStringAttribute(attribute); |
| +} |
| + |
| +std::string BrowserAccessibility::GetInheritedStringAttribute( |
| + ui::AXStringAttribute attribute) const { |
| + if (!instance_active()) |
| + return std::string(); |
| + |
| + std::string value; |
| + if (GetInheritedStringAttribute(attribute, &value)) |
| + return value; |
| + return std::string(); |
| +} |
| + |
| +bool BrowserAccessibility::GetInheritedStringAttribute( |
| + ui::AXStringAttribute attribute, |
| + std::string* value) const { |
| + if (!instance_active()) { |
| + *value = std::string(); |
| + return false; |
| + } |
| + |
| + if (GetData().GetStringAttribute(attribute, value)) |
| + return true; |
| + return GetParent() && |
| + GetParent()->GetData().GetStringAttribute(attribute, value); |
| +} |
| + |
| +base::string16 BrowserAccessibility::GetInheritedString16Attribute( |
| + ui::AXStringAttribute attribute) const { |
| + if (!instance_active()) |
| + return base::string16(); |
| + |
| + base::string16 value; |
| + if (GetInheritedString16Attribute(attribute, &value)) |
| + return value; |
| + return base::string16(); |
| +} |
| + |
| +bool BrowserAccessibility::GetInheritedString16Attribute( |
| + ui::AXStringAttribute attribute, |
| + base::string16* value) const { |
| + if (!instance_active()) { |
| + *value = base::string16(); |
| + return false; |
| + } |
| + |
| + if (GetData().GetString16Attribute(attribute, value)) |
| + return true; |
| + return GetParent() && |
| + GetParent()->GetData().GetString16Attribute(attribute, value); |
| +} |
| + |
| bool BrowserAccessibility::HasIntAttribute( |
| ui::AXIntAttribute attribute) const { |
| return GetData().HasIntAttribute(attribute); |
| @@ -849,6 +910,21 @@ base::string16 BrowserAccessibility::GetInnerText() const { |
| return text; |
| } |
| +// static |
| +// TODO(nektar): Figure out if there is an existing Skia function to use |
|
dmazzoni
2016/03/07 23:38:10
You can use SkColorGetR, etc. from SkColor.h
|
| +// instead. |
| +void BrowserAccessibility::RGBAToColorValues(unsigned int color, |
| + unsigned int* red, |
| + unsigned int* green, |
| + unsigned int* blue, |
| + unsigned int* alpha) { |
| + DCHECK(red && green && blue && alpha); |
| + *alpha = (color >> 24) & 0xFF; |
| + *red = (color >> 16) & 0xFF; |
| + *green = (color >> 8) & 0xFF; |
| + *blue = color & 0xFF; |
| +} |
| + |
| void BrowserAccessibility::FixEmptyBounds(gfx::Rect* bounds) const |
| { |
| if (bounds->width() > 0 && bounds->height() > 0) |