Chromium Code Reviews| Index: content/browser/accessibility/browser_accessibility_com_win.cc |
| diff --git a/content/browser/accessibility/browser_accessibility_win.cc b/content/browser/accessibility/browser_accessibility_com_win.cc |
| similarity index 67% |
| copy from content/browser/accessibility/browser_accessibility_win.cc |
| copy to content/browser/accessibility/browser_accessibility_com_win.cc |
| index 22410f8cb62a26edaf79b3c1d170d80200b50aa8..6e6efad2287b9e65e3ba2ca7161e8188ebcb3dc9 100644 |
| --- a/content/browser/accessibility/browser_accessibility_win.cc |
| +++ b/content/browser/accessibility/browser_accessibility_com_win.cc |
| @@ -1,8 +1,8 @@ |
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "content/browser/accessibility/browser_accessibility_win.h" |
| +#include "content/browser/accessibility/browser_accessibility_com_win.h" |
| #include <UIAutomationClient.h> |
| #include <UIAutomationCoreApi.h> |
| @@ -22,6 +22,7 @@ |
| #include "content/browser/accessibility/browser_accessibility_event_win.h" |
| #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
| #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| +#include "content/browser/accessibility/browser_accessibility_win.h" |
| #include "content/common/accessibility_messages.h" |
| #include "content/common/accessibility_mode.h" |
| #include "content/public/common/content_client.h" |
| @@ -202,7 +203,7 @@ enum { |
| }; |
| #define WIN_ACCESSIBILITY_API_HISTOGRAM(enum_value) \ |
| - UMA_HISTOGRAM_ENUMERATION("Accessibility.WinAPIs", enum_value, UMA_API_MAX) |
| + UMA_HISTOGRAM_ENUMERATION("Accessibility.WinAPIs", enum_value, UMA_API_MAX) |
| // There is no easy way to decouple |kScreenReader| and |kHTML| accessibility |
| // modes when Windows screen readers are used. For example, certain roles use |
| @@ -211,14 +212,17 @@ const uint32_t kScreenReaderAndHTMLAccessibilityModes = |
| content::AccessibilityMode::kScreenReader | |
| content::AccessibilityMode::kHTML; |
| -const WCHAR *const IA2_RELATION_DETAILS = L"details"; |
| -const WCHAR *const IA2_RELATION_DETAILS_FOR = L"detailsFor"; |
| -const WCHAR *const IA2_RELATION_ERROR_MESSAGE = L"errorMessage"; |
| +const WCHAR* const IA2_RELATION_DETAILS = L"details"; |
| +const WCHAR* const IA2_RELATION_DETAILS_FOR = L"detailsFor"; |
| +const WCHAR* const IA2_RELATION_ERROR_MESSAGE = L"errorMessage"; |
| } // namespace |
| namespace content { |
| +using AXPlatformPositionInstance = AXPlatformPosition::AXPositionInstance; |
| +using AXPlatformRange = ui::AXRange<AXPlatformPositionInstance::element_type>; |
| + |
| // These nonstandard GUIDs are taken directly from the Mozilla sources |
| // (accessible/src/msaa/nsAccessNodeWrap.cpp); some documentation is here: |
| // http://developer.mozilla.org/en/Accessibility/AT-APIs/ImplementationFeatures/MSAA |
| @@ -232,7 +236,7 @@ const GUID GUID_IAccessibleContentDocument = { |
| 0x4d8f, |
| {0x95, 0x21, 0x07, 0xed, 0x28, 0xfb, 0x07, 0x2e}}; |
| -const base::char16 BrowserAccessibilityWin::kEmbeddedCharacter = L'\xfffc'; |
| +const base::char16 BrowserAccessibilityComWin::kEmbeddedCharacter = L'\xfffc'; |
| void AddAccessibilityModeFlags(AccessibilityMode mode_flags) { |
| BrowserAccessibilityStateImpl::GetInstance()->AddAccessibilityModeFlags( |
| @@ -250,13 +254,13 @@ class BrowserAccessibilityRelation |
| : public CComObjectRootEx<CComMultiThreadModel>, |
| public IAccessibleRelation { |
| BEGIN_COM_MAP(BrowserAccessibilityRelation) |
| - COM_INTERFACE_ENTRY(IAccessibleRelation) |
| + COM_INTERFACE_ENTRY(IAccessibleRelation) |
| END_COM_MAP() |
| CONTENT_EXPORT BrowserAccessibilityRelation() {} |
| CONTENT_EXPORT virtual ~BrowserAccessibilityRelation() {} |
| - CONTENT_EXPORT void Initialize(BrowserAccessibilityWin* owner, |
| + CONTENT_EXPORT void Initialize(BrowserAccessibilityComWin* owner, |
| const base::string16& type); |
| CONTENT_EXPORT void AddTarget(int target_id); |
| CONTENT_EXPORT void RemoveTarget(int target_id); |
| @@ -268,10 +272,11 @@ class BrowserAccessibilityRelation |
| // IAccessibleRelation methods. |
| CONTENT_EXPORT STDMETHODIMP get_relationType(BSTR* relation_type) override; |
| CONTENT_EXPORT STDMETHODIMP get_nTargets(long* n_targets) override; |
| - CONTENT_EXPORT STDMETHODIMP |
| - get_target(long target_index, IUnknown** target) override; |
| - CONTENT_EXPORT STDMETHODIMP |
| - get_targets(long max_targets, IUnknown** targets, long* n_targets) override; |
| + CONTENT_EXPORT STDMETHODIMP get_target(long target_index, |
| + IUnknown** target) override; |
| + CONTENT_EXPORT STDMETHODIMP get_targets(long max_targets, |
| + IUnknown** targets, |
| + long* n_targets) override; |
| // IAccessibleRelation methods not implemented. |
| CONTENT_EXPORT STDMETHODIMP |
| @@ -281,11 +286,11 @@ class BrowserAccessibilityRelation |
| private: |
| base::string16 type_; |
| - base::win::ScopedComPtr<BrowserAccessibilityWin> owner_; |
| + base::win::ScopedComPtr<BrowserAccessibilityComWin> owner_; |
| std::vector<int> target_ids_; |
| }; |
| -void BrowserAccessibilityRelation::Initialize(BrowserAccessibilityWin* owner, |
| +void BrowserAccessibilityRelation::Initialize(BrowserAccessibilityComWin* owner, |
| const base::string16& type) { |
| owner_ = owner; |
| type_ = type; |
| @@ -306,7 +311,7 @@ STDMETHODIMP BrowserAccessibilityRelation::get_relationType( |
| if (!relation_type) |
| return E_INVALIDARG; |
| - if (!owner_->instance_active()) |
| + if (!owner_->GetOwner()->instance_active()) |
| return E_FAIL; |
| *relation_type = SysAllocString(type_.c_str()); |
| @@ -318,14 +323,14 @@ STDMETHODIMP BrowserAccessibilityRelation::get_nTargets(long* n_targets) { |
| if (!n_targets) |
| return E_INVALIDARG; |
| - if (!owner_->instance_active()) |
| + if (!owner_->GetOwner()->instance_active()) |
| return E_FAIL; |
| *n_targets = static_cast<long>(target_ids_.size()); |
| for (long i = *n_targets - 1; i >= 0; --i) { |
| - BrowserAccessibilityWin* result = owner_->GetFromID(target_ids_[i]); |
| - if (!result || !result->instance_active()) { |
| + BrowserAccessibilityComWin* result = owner_->GetFromID(target_ids_[i]); |
| + if (!result || !result->GetOwner()->instance_active()) { |
| *n_targets = 0; |
| break; |
| } |
| @@ -338,7 +343,11 @@ STDMETHODIMP BrowserAccessibilityRelation::get_target(long target_index, |
| if (!target) |
| return E_INVALIDARG; |
| - if (!owner_->instance_active()) |
| + if (!owner_->GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| + auto* manager = owner_->GetOwner()->manager(); |
| + if (!manager) |
| return E_FAIL; |
| if (target_index < 0 || |
| @@ -346,12 +355,12 @@ STDMETHODIMP BrowserAccessibilityRelation::get_target(long target_index, |
| return E_INVALIDARG; |
| } |
| - BrowserAccessibility* result = owner_->GetFromID(target_ids_[target_index]); |
| + BrowserAccessibility* result = manager->GetFromID(target_ids_[target_index]); |
| if (!result || !result->instance_active()) |
| return E_FAIL; |
| *target = static_cast<IAccessible*>( |
| - ToBrowserAccessibilityWin(result)->NewReference()); |
| + ToBrowserAccessibilityComWin(result)->NewReference()); |
| return S_OK; |
| } |
| @@ -361,7 +370,7 @@ STDMETHODIMP BrowserAccessibilityRelation::get_targets(long max_targets, |
| if (!targets || !n_targets) |
| return E_INVALIDARG; |
| - if (!owner_->instance_active()) |
| + if (!owner_->GetOwner()->instance_active()) |
| return E_FAIL; |
| long count = static_cast<long>(target_ids_.size()); |
| @@ -382,39 +391,24 @@ STDMETHODIMP BrowserAccessibilityRelation::get_targets(long max_targets, |
| } |
| // |
| -// BrowserAccessibilityWin::WinAttributes |
| +// BrowserAccessibilityComWin::WinAttributes |
| // |
| -BrowserAccessibilityWin::WinAttributes::WinAttributes() |
| - : ia_role(0), |
| - ia_state(0), |
| - ia2_role(0), |
| - ia2_state(0) { |
| -} |
| +BrowserAccessibilityComWin::WinAttributes::WinAttributes() |
| + : ia_role(0), ia_state(0), ia2_role(0), ia2_state(0) {} |
| -BrowserAccessibilityWin::WinAttributes::~WinAttributes() { |
| -} |
| +BrowserAccessibilityComWin::WinAttributes::~WinAttributes() {} |
| // |
| -// BrowserAccessibilityWin |
| +// BrowserAccessibilityComWin |
| // |
| - |
| -// static |
| -BrowserAccessibility* BrowserAccessibility::Create() { |
| - ui::win::CreateATLModuleIfNeeded(); |
| - CComObject<BrowserAccessibilityWin>* instance; |
| - HRESULT hr = CComObject<BrowserAccessibilityWin>::CreateInstance(&instance); |
| - DCHECK(SUCCEEDED(hr)); |
| - return instance->NewReference(); |
| -} |
| - |
| -BrowserAccessibilityWin::BrowserAccessibilityWin() |
| - : win_attributes_(new WinAttributes()), |
| +BrowserAccessibilityComWin::BrowserAccessibilityComWin() |
| + : owner_(nullptr), |
| + win_attributes_(new WinAttributes()), |
| previous_scroll_x_(0), |
| - previous_scroll_y_(0) { |
| -} |
| + previous_scroll_y_(0) {} |
| -BrowserAccessibilityWin::~BrowserAccessibilityWin() { |
| +BrowserAccessibilityComWin::~BrowserAccessibilityComWin() { |
| for (BrowserAccessibilityRelation* relation : relations_) |
| relation->Release(); |
| } |
| @@ -423,100 +417,116 @@ BrowserAccessibilityWin::~BrowserAccessibilityWin() { |
| // IAccessible methods. |
| // |
| // Conventions: |
| -// * Always test for instance_active() first and return E_FAIL if it's false. |
| +// * Always test for GetOwner() and GetOwner()->instance_active first and |
| +// return E_FAIL if either are false. |
| // * Always check for invalid arguments first, even if they're unused. |
| // * Return S_FALSE if the only output is a string argument and it's empty. |
| // |
| -HRESULT BrowserAccessibilityWin::accDoDefaultAction(VARIANT var_id) { |
| +HRESULT BrowserAccessibilityComWin::accDoDefaultAction(VARIANT var_id) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_DO_DEFAULT_ACTION); |
| - if (!instance_active()) |
| + |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| - BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| + auto* manager = GetOwner()->manager(); |
| + if (!manager) |
| + return E_FAIL; |
| + |
| + BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| if (!target) |
| return E_INVALIDARG; |
| // Return an error if it's not clickable. |
| - if (!target->HasIntAttribute(ui::AX_ATTR_ACTION)) |
| + if (!target->GetOwner()->HasIntAttribute(ui::AX_ATTR_ACTION)) |
| return DISP_E_MEMBERNOTFOUND; |
| - manager_->DoDefaultAction(*target); |
| + manager->DoDefaultAction(*target->GetOwner()); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left, |
| - LONG y_top, |
| - VARIANT* child) { |
| +STDMETHODIMP BrowserAccessibilityComWin::accHitTest(LONG x_left, |
| + LONG y_top, |
| + VARIANT* child) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST); |
| - if (!instance_active()) |
| + |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| + auto* manager = GetOwner()->manager(); |
| + if (!manager) |
| return E_FAIL; |
| if (!child) |
| return E_INVALIDARG; |
| gfx::Point point(x_left, y_top); |
| - if (!GetScreenBoundsRect().Contains(point)) { |
| + if (!GetOwner()->GetScreenBoundsRect().Contains(point)) { |
| // Return S_FALSE and VT_EMPTY when outside the object's boundaries. |
| child->vt = VT_EMPTY; |
| return S_FALSE; |
| } |
| - BrowserAccessibility* result = manager_->CachingAsyncHitTest(point); |
| - if (result == this) { |
| + BrowserAccessibility* result = manager->CachingAsyncHitTest(point); |
| + if (result == GetOwner()) { |
| // Point is within this object. |
| child->vt = VT_I4; |
| child->lVal = CHILDID_SELF; |
| } else { |
| child->vt = VT_DISPATCH; |
| - child->pdispVal = ToBrowserAccessibilityWin(result)->NewReference(); |
| + child->pdispVal = ToBrowserAccessibilityComWin(result)->NewReference(); |
| } |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left, |
| - LONG* y_top, |
| - LONG* width, |
| - LONG* height, |
| - VARIANT var_id) { |
| +STDMETHODIMP BrowserAccessibilityComWin::accLocation(LONG* x_left, |
| + LONG* y_top, |
| + LONG* width, |
| + LONG* height, |
| + VARIANT var_id) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_LOCATION); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| - return GetPlatformNodeWin()->accLocation(x_left, y_top, width, height, |
| - var_id); |
| + return AXPlatformNodeWin::accLocation(x_left, y_top, width, height, var_id); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::accNavigate(LONG nav_dir, |
| - VARIANT start, |
| - VARIANT* end) { |
| +STDMETHODIMP BrowserAccessibilityComWin::accNavigate(LONG nav_dir, |
| + VARIANT start, |
| + VARIANT* end) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_NAVIGATE); |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| // Forward all directions but NAVDIR_ to the platform node implementation. |
| if (nav_dir != NAVDIR_DOWN && nav_dir != NAVDIR_UP && |
| nav_dir != NAVDIR_LEFT && nav_dir != NAVDIR_RIGHT) { |
| - return GetPlatformNodeWin()->accNavigate(nav_dir, start, end); |
| + return AXPlatformNodeWin::accNavigate(nav_dir, start, end); |
| } |
| - BrowserAccessibilityWin* target = GetTargetFromChildID(start); |
| + BrowserAccessibilityComWin* target = GetTargetFromChildID(start); |
| if (!target) |
| return E_INVALIDARG; |
| BrowserAccessibility* result = nullptr; |
| switch (nav_dir) { |
| case NAVDIR_DOWN: |
| - result = target->GetTableCell(GetTableRow() + GetTableRowSpan(), |
| - GetTableColumn()); |
| + result = target->GetOwner()->GetTableCell( |
| + GetOwner()->GetTableRow() + GetOwner()->GetTableRowSpan(), |
| + GetOwner()->GetTableColumn()); |
| break; |
| case NAVDIR_UP: |
| - result = target->GetTableCell(GetTableRow() - 1, GetTableColumn()); |
| + result = target->GetOwner()->GetTableCell(GetOwner()->GetTableRow() - 1, |
| + GetOwner()->GetTableColumn()); |
| break; |
| case NAVDIR_LEFT: |
| - result = target->GetTableCell(GetTableRow(), GetTableColumn() - 1); |
| + result = target->GetOwner()->GetTableCell( |
| + GetOwner()->GetTableRow(), GetOwner()->GetTableColumn() - 1); |
| break; |
| case NAVDIR_RIGHT: |
| - result = target->GetTableCell(GetTableRow(), |
| - GetTableColumn() + GetTableColumnSpan()); |
| + result = target->GetOwner()->GetTableCell( |
| + GetOwner()->GetTableRow(), |
| + GetOwner()->GetTableColumn() + GetOwner()->GetTableColumnSpan()); |
| break; |
| } |
| @@ -526,14 +536,14 @@ STDMETHODIMP BrowserAccessibilityWin::accNavigate(LONG nav_dir, |
| } |
| end->vt = VT_DISPATCH; |
| - end->pdispVal = ToBrowserAccessibilityWin(result)->NewReference(); |
| + end->pdispVal = ToBrowserAccessibilityComWin(result)->NewReference(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, |
| - IDispatch** disp_child) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accChild(VARIANT var_child, |
| + IDispatch** disp_child) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!disp_child) |
| @@ -541,7 +551,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, |
| *disp_child = NULL; |
| - BrowserAccessibilityWin* target = GetTargetFromChildID(var_child); |
| + BrowserAccessibilityComWin* target = GetTargetFromChildID(var_child); |
| if (!target) |
| return E_INVALIDARG; |
| @@ -549,45 +559,46 @@ STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accChildCount(LONG* child_count) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD_COUNT); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!child_count) |
| return E_INVALIDARG; |
| - *child_count = PlatformChildCount(); |
| + *child_count = GetOwner()->PlatformChildCount(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id, |
| - BSTR* def_action) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accDefaultAction( |
| + VARIANT var_id, |
| + BSTR* def_action) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DEFAULT_ACTION); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!def_action) |
| return E_INVALIDARG; |
| - BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| + BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| if (!target) |
| return E_INVALIDARG; |
| return target->get_localizedName(0, def_action); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, |
| - BSTR* desc) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accDescription(VARIANT var_id, |
| + BSTR* desc) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DESCRIPTION); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!desc) |
| return E_INVALIDARG; |
| - BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| + BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| if (!target) |
| return E_INVALIDARG; |
| @@ -601,81 +612,90 @@ STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accFocus(VARIANT* focus_child) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accFocus(VARIANT* focus_child) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_FOCUS); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| + auto* manager = GetOwner()->manager(); |
| + if (!manager) |
| return E_FAIL; |
| if (!focus_child) |
| return E_INVALIDARG; |
| BrowserAccessibilityWin* focus = |
| - static_cast<BrowserAccessibilityWin*>(manager_->GetFocus()); |
| - if (focus == this) { |
| + static_cast<BrowserAccessibilityWin*>(manager->GetFocus()); |
| + if (focus == GetOwner()) { |
| focus_child->vt = VT_I4; |
| focus_child->lVal = CHILDID_SELF; |
| } else if (focus == NULL) { |
| focus_child->vt = VT_EMPTY; |
| } else { |
| focus_child->vt = VT_DISPATCH; |
| - focus_child->pdispVal = focus->NewReference(); |
| + focus_child->pdispVal = focus->GetCOM()->NewReference(); |
| } |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accHelp(VARIANT var_id, BSTR* help) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accHelp(VARIANT var_id, |
| + BSTR* help) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| - return GetPlatformNodeWin()->get_accHelp(var_id, help); |
| + return AXPlatformNodeWin::get_accHelp(var_id, help); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, |
| - BSTR* acc_key) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accKeyboardShortcut( |
| + VARIANT var_id, |
| + BSTR* acc_key) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_KEYBOARD_SHORTCUT); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!acc_key) |
| return E_INVALIDARG; |
| - BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| + BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| if (!target) |
| return E_INVALIDARG; |
| if (target->HasStringAttribute(ui::AX_ATTR_KEY_SHORTCUTS)) { |
| - return target->GetStringAttributeAsBstr( |
| - ui::AX_ATTR_KEY_SHORTCUTS, acc_key); |
| + return target->GetStringAttributeAsBstr(ui::AX_ATTR_KEY_SHORTCUTS, acc_key); |
| } |
| - return target->GetStringAttributeAsBstr( |
| - ui::AX_ATTR_SHORTCUT, acc_key); |
| + return target->GetStringAttributeAsBstr(ui::AX_ATTR_SHORTCUT, acc_key); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accName(VARIANT var_id, |
| + BSTR* name) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_NAME); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| - return GetPlatformNodeWin()->get_accName(var_id, name); |
| + return AXPlatformNodeWin::get_accName(var_id, name); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accParent( |
| + IDispatch** disp_parent) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_PARENT); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!disp_parent) |
| return E_INVALIDARG; |
| - IAccessible* parent_obj = ToBrowserAccessibilityWin(PlatformGetParent()); |
| + IAccessible* parent_obj = |
| + ToBrowserAccessibilityComWin(GetOwner()->PlatformGetParent()); |
| if (parent_obj == NULL) { |
| // This happens if we're the root of the tree; |
| // return the IAccessible for the window. |
| - parent_obj = |
| - manager_->ToBrowserAccessibilityManagerWin()->GetParentIAccessible(); |
| + parent_obj = GetOwner() |
| + ->manager() |
| + ->ToBrowserAccessibilityManagerWin() |
| + ->GetParentIAccessible(); |
| // |parent| can only be NULL if the manager was created before the parent |
| // IAccessible was known and it wasn't subsequently set before a client |
| // requested it. This has been fixed. |parent| may also be NULL during |
| @@ -692,16 +712,16 @@ STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accRole(VARIANT var_id, |
| - VARIANT* role) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accRole(VARIANT var_id, |
| + VARIANT* role) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_ROLE); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!role) |
| return E_INVALIDARG; |
| - BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| + BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| if (!target) |
| return E_INVALIDARG; |
| @@ -715,37 +735,41 @@ STDMETHODIMP BrowserAccessibilityWin::get_accRole(VARIANT var_id, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, |
| - VARIANT* state) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accState(VARIANT var_id, |
| + VARIANT* state) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_STATE); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| + auto* manager = GetOwner()->manager(); |
| + if (!manager) |
| return E_FAIL; |
| if (!state) |
| return E_INVALIDARG; |
| - BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| + BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| if (!target) |
| return E_INVALIDARG; |
| state->vt = VT_I4; |
| state->lVal = target->ia_state(); |
| - if (manager_->GetFocus() == this) |
| + if (manager->GetFocus() == GetOwner()) |
| state->lVal |= STATE_SYSTEM_FOCUSED; |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id, |
| - BSTR* value) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accValue(VARIANT var_id, |
| + BSTR* value) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_VALUE); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!value) |
| return E_INVALIDARG; |
| - BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| + BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| if (!target) |
| return E_INVALIDARG; |
| @@ -761,7 +785,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id, |
| // Expose color well value. |
| if (target->ia2_role() == IA2_ROLE_COLOR_CHOOSER) { |
| unsigned int color = static_cast<unsigned int>( |
| - target->GetIntAttribute(ui::AX_ATTR_COLOR_VALUE)); |
| + target->GetOwner()->GetIntAttribute(ui::AX_ATTR_COLOR_VALUE)); |
| unsigned int red = SkColorGetR(color); |
| unsigned int green = SkColorGetG(color); |
| unsigned int blue = SkColorGetB(color); |
| @@ -779,24 +803,24 @@ STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, |
| - VARIANT var_id, |
| - LONG* topic_id) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accHelpTopic(BSTR* help_file, |
| + VARIANT var_id, |
| + LONG* topic_id) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC); |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accSelection(VARIANT* selected) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
|
dmazzoni
2017/05/08 04:45:24
I don't see any purpose for BrowserAccessibility::
dougt
2017/05/08 16:53:36
I would like to only test GetOwner() in a follow u
|
| return E_FAIL; |
| - if (GetRole() != ui::AX_ROLE_LIST_BOX) |
| + if (GetOwner()->GetRole() != ui::AX_ROLE_LIST_BOX) |
| return E_NOTIMPL; |
| unsigned long selected_count = 0; |
| - for (size_t i = 0; i < InternalChildCount(); ++i) { |
| - if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) |
| + for (size_t i = 0; i < GetOwner()->InternalChildCount(); ++i) { |
| + if (GetOwner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) |
| ++selected_count; |
| } |
| @@ -806,11 +830,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { |
| } |
| if (selected_count == 1) { |
| - for (size_t i = 0; i < InternalChildCount(); ++i) { |
| - if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { |
| + for (size_t i = 0; i < GetOwner()->InternalChildCount(); ++i) { |
| + if (GetOwner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { |
| selected->vt = VT_DISPATCH; |
| selected->pdispVal = |
| - ToBrowserAccessibilityWin(InternalGetChild(i))->NewReference(); |
| + ToBrowserAccessibilityComWin(GetOwner()->InternalGetChild(i)) |
| + ->NewReference(); |
| return S_OK; |
| } |
| } |
| @@ -821,11 +846,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { |
| new base::win::EnumVariant(selected_count); |
| enum_variant->AddRef(); |
| unsigned long index = 0; |
| - for (size_t i = 0; i < InternalChildCount(); ++i) { |
| - if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { |
| + for (size_t i = 0; i < GetOwner()->InternalChildCount(); ++i) { |
| + if (GetOwner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { |
| enum_variant->ItemAt(index)->vt = VT_DISPATCH; |
| enum_variant->ItemAt(index)->pdispVal = |
| - ToBrowserAccessibilityWin(InternalGetChild(i))->NewReference(); |
| + ToBrowserAccessibilityComWin(GetOwner()->InternalGetChild(i)) |
| + ->NewReference(); |
| ++index; |
| } |
| } |
| @@ -835,14 +861,18 @@ STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::accSelect( |
| - LONG flags_sel, VARIANT var_id) { |
| +STDMETHODIMP BrowserAccessibilityComWin::accSelect(LONG flags_sel, |
| + VARIANT var_id) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| + auto* manager = GetOwner()->manager(); |
| + if (!manager) |
| return E_FAIL; |
| if (flags_sel & SELFLAG_TAKEFOCUS) { |
| - manager_->SetFocus(*this); |
| + manager->SetFocus(*GetOwner()); |
| return S_OK; |
| } |
| @@ -850,11 +880,11 @@ STDMETHODIMP BrowserAccessibilityWin::accSelect( |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::put_accName(VARIANT var_id, BSTR put_name) { |
| +BrowserAccessibilityComWin::put_accName(VARIANT var_id, BSTR put_name) { |
| return E_NOTIMPL; |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::put_accValue(VARIANT var_id, BSTR put_val) { |
| +BrowserAccessibilityComWin::put_accValue(VARIANT var_id, BSTR put_val) { |
| return E_NOTIMPL; |
| } |
| @@ -862,9 +892,9 @@ BrowserAccessibilityWin::put_accValue(VARIANT var_id, BSTR put_val) { |
| // IAccessible2 methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) { |
| +STDMETHODIMP BrowserAccessibilityComWin::role(LONG* role) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ROLE); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!role) |
| @@ -874,14 +904,16 @@ STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_attributes(BSTR* attributes) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_GET_ATTRIBUTES); |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| if (!attributes) |
| return E_INVALIDARG; |
| *attributes = nullptr; |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| base::string16 str; |
| @@ -896,11 +928,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_states(AccessibleStates* states) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_STATES); |
| - AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| + AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| if (!states) |
| return E_INVALIDARG; |
| @@ -910,50 +942,53 @@ STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_uniqueID(LONG* unique_id) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNIQUE_ID); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!unique_id) |
| return E_INVALIDARG; |
| - *unique_id = -this->unique_id(); |
| + *unique_id = -GetOwner()->unique_id(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_windowHandle(HWND* window_handle) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_windowHandle(HWND* window_handle) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_WINDOW_HANDLE); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!window_handle) |
| return E_INVALIDARG; |
| - *window_handle = |
| - manager_->ToBrowserAccessibilityManagerWin()->GetParentHWND(); |
| + *window_handle = GetOwner() |
| + ->manager() |
| + ->ToBrowserAccessibilityManagerWin() |
|
dmazzoni
2017/05/08 04:45:24
Optional:
Since GetOwner()->manager() is used a lo
dougt
2017/05/08 16:53:36
Acknowledged. Good follow up. Noted.
|
| + ->GetParentHWND(); |
| if (!*window_handle) |
| return E_FAIL; |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_indexInParent(LONG* index_in_parent) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_indexInParent( |
| + LONG* index_in_parent) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INDEX_IN_PARENT); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!index_in_parent) |
| return E_INVALIDARG; |
| - *index_in_parent = this->GetIndexInParent(); |
| + *index_in_parent = GetIndexInParent(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_nRelations(LONG* n_relations) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_nRelations(LONG* n_relations) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_RELATIONS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!n_relations) |
| @@ -963,12 +998,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_nRelations(LONG* n_relations) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_relation( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_relation( |
| LONG relation_index, |
| IAccessibleRelation** relation) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATION); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (relation_index < 0 || |
| @@ -984,13 +1019,13 @@ STDMETHODIMP BrowserAccessibilityWin::get_relation( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_relations( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_relations( |
| LONG max_relations, |
| IAccessibleRelation** relations, |
| LONG* n_relations) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATIONS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!relations || !n_relations) |
| @@ -1009,84 +1044,96 @@ STDMETHODIMP BrowserAccessibilityWin::get_relations( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::scrollTo(IA2ScrollType scroll_type) { |
| +STDMETHODIMP BrowserAccessibilityComWin::scrollTo(IA2ScrollType scroll_type) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_SCROLL_TO); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| + auto* manager = GetOwner()->manager(); |
| + |
| + if (!manager) |
| return E_FAIL; |
| - gfx::Rect r = GetFrameBoundsRect(); |
| - switch(scroll_type) { |
| + gfx::Rect r = GetOwner()->GetFrameBoundsRect(); |
| + switch (scroll_type) { |
| case IA2_SCROLL_TYPE_TOP_LEFT: |
| - manager_->ScrollToMakeVisible(*this, gfx::Rect(r.x(), r.y(), 0, 0)); |
| + manager->ScrollToMakeVisible(*GetOwner(), gfx::Rect(r.x(), r.y(), 0, 0)); |
| break; |
| case IA2_SCROLL_TYPE_BOTTOM_RIGHT: |
| - manager_->ScrollToMakeVisible(*this, |
| - gfx::Rect(r.right(), r.bottom(), 0, 0)); |
| + manager->ScrollToMakeVisible(*GetOwner(), |
| + gfx::Rect(r.right(), r.bottom(), 0, 0)); |
| break; |
| case IA2_SCROLL_TYPE_TOP_EDGE: |
| - manager_->ScrollToMakeVisible(*this, |
| - gfx::Rect(r.x(), r.y(), r.width(), 0)); |
| + manager->ScrollToMakeVisible(*GetOwner(), |
| + gfx::Rect(r.x(), r.y(), r.width(), 0)); |
| break; |
| case IA2_SCROLL_TYPE_BOTTOM_EDGE: |
| - manager_->ScrollToMakeVisible(*this, |
| - gfx::Rect(r.x(), r.bottom(), r.width(), 0)); |
| + manager->ScrollToMakeVisible(*GetOwner(), |
| + gfx::Rect(r.x(), r.bottom(), r.width(), 0)); |
| break; |
| case IA2_SCROLL_TYPE_LEFT_EDGE: |
| - manager_->ScrollToMakeVisible(*this, |
| - gfx::Rect(r.x(), r.y(), 0, r.height())); |
| + manager->ScrollToMakeVisible(*GetOwner(), |
| + gfx::Rect(r.x(), r.y(), 0, r.height())); |
| break; |
| case IA2_SCROLL_TYPE_RIGHT_EDGE: |
| - manager_->ScrollToMakeVisible(*this, |
| - gfx::Rect(r.right(), r.y(), 0, r.height())); |
| + manager->ScrollToMakeVisible(*GetOwner(), |
| + gfx::Rect(r.right(), r.y(), 0, r.height())); |
| break; |
| case IA2_SCROLL_TYPE_ANYWHERE: |
| default: |
| - manager_->ScrollToMakeVisible(*this, r); |
| + manager->ScrollToMakeVisible(*GetOwner(), r); |
| break; |
| } |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::scrollToPoint( |
| +STDMETHODIMP BrowserAccessibilityComWin::scrollToPoint( |
| IA2CoordinateType coordinate_type, |
| LONG x, |
| LONG y) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_POINT); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| + auto* manager = GetOwner()->manager(); |
| + if (!manager) |
| return E_FAIL; |
| gfx::Point scroll_to(x, y); |
| if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
| - scroll_to -= manager_->GetViewBounds().OffsetFromOrigin(); |
| + scroll_to -= manager->GetViewBounds().OffsetFromOrigin(); |
| } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| - if (PlatformGetParent()) |
| - scroll_to += PlatformGetParent()->GetFrameBoundsRect().OffsetFromOrigin(); |
| + if (GetOwner()->PlatformGetParent()) |
| + scroll_to += GetOwner() |
| + ->PlatformGetParent() |
|
dmazzoni
2017/05/08 04:45:24
I think we want braces for readability since this
dougt
2017/05/08 16:53:36
Done. Two places fixed.
|
| + ->GetFrameBoundsRect() |
| + .OffsetFromOrigin(); |
| } else { |
| return E_INVALIDARG; |
| } |
| - manager_->ScrollToPoint(*this, scroll_to); |
| + manager->ScrollToPoint(*GetOwner(), scroll_to); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_groupPosition( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_groupPosition( |
| LONG* group_level, |
| LONG* similar_items_in_group, |
| LONG* position_in_group) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_GROUP_POSITION); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!group_level || !similar_items_in_group || !position_in_group) |
| return E_INVALIDARG; |
| - *group_level = GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL); |
| - *similar_items_in_group = GetIntAttribute(ui::AX_ATTR_SET_SIZE); |
| - *position_in_group = GetIntAttribute(ui::AX_ATTR_POS_IN_SET); |
| + *group_level = GetOwner()->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL); |
| + *similar_items_in_group = GetOwner()->GetIntAttribute(ui::AX_ATTR_SET_SIZE); |
| + *position_in_group = GetOwner()->GetIntAttribute(ui::AX_ATTR_POS_IN_SET); |
| if (*group_level == *similar_items_in_group == *position_in_group == 0) |
| return S_FALSE; |
| @@ -1094,46 +1141,45 @@ STDMETHODIMP BrowserAccessibilityWin::get_groupPosition( |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::get_localizedExtendedRole( |
| +BrowserAccessibilityComWin::get_localizedExtendedRole( |
| BSTR* localized_extended_role) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_EXTENDED_ROLE); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!localized_extended_role) |
| return E_INVALIDARG; |
| - return GetStringAttributeAsBstr( |
| - ui::AX_ATTR_ROLE_DESCRIPTION, localized_extended_role); |
| + return GetStringAttributeAsBstr(ui::AX_ATTR_ROLE_DESCRIPTION, |
| + localized_extended_role); |
| } |
| // |
| // IAccessible2 methods not implemented. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::get_extendedRole(BSTR* extended_role) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_extendedRole(BSTR* extended_role) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_EXTENDED_ROLE); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::get_nExtendedStates(LONG* n_extended_states) { |
| +BrowserAccessibilityComWin::get_nExtendedStates(LONG* n_extended_states) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_EXTENDED_STATES); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::get_extendedStates(LONG max_extended_states, |
| - BSTR** extended_states, |
| - LONG* n_extended_states) { |
| +BrowserAccessibilityComWin::get_extendedStates(LONG max_extended_states, |
| + BSTR** extended_states, |
| + LONG* n_extended_states) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_EXTENDED_STATES); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::get_localizedExtendedStates( |
| +BrowserAccessibilityComWin::get_localizedExtendedStates( |
| LONG max_localized_extended_states, |
| BSTR** localized_extended_states, |
| LONG* n_localized_extended_states) { |
| @@ -1141,7 +1187,7 @@ BrowserAccessibilityWin::get_localizedExtendedStates( |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_locale(IA2Locale* locale) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_locale(IA2Locale* locale) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALE); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| @@ -1151,19 +1197,19 @@ STDMETHODIMP BrowserAccessibilityWin::get_locale(IA2Locale* locale) { |
| // IAccessibleApplication methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::get_appName(BSTR* app_name) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_appName(BSTR* app_name) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_APP_NAME); |
| - // No need to check |instance_active()| because this interface is |
| - // global, and doesn't depend on any local state. |
| + // No need to check |GetOwner()| or |GetOwner->manager()| because this |
| + // interface is global, and doesn't depend on any local state. |
| if (!app_name) |
| return E_INVALIDARG; |
| // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out |
| // the part before the "/". |
| - std::vector<std::string> product_components = base::SplitString( |
| - GetContentClient()->GetProduct(), "/", |
| - base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| + std::vector<std::string> product_components = |
| + base::SplitString(GetContentClient()->GetProduct(), "/", |
| + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| DCHECK_EQ(2U, product_components.size()); |
| if (product_components.size() != 2) |
| return E_FAIL; |
| @@ -1172,9 +1218,9 @@ STDMETHODIMP BrowserAccessibilityWin::get_appName(BSTR* app_name) { |
| return *app_name ? S_OK : E_FAIL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_appVersion(BSTR* app_version) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_APP_VERSION); |
| - // No need to check |instance_active()| because this interface is |
| + // No need to check |GetOwner()->manager()| because this interface is |
| // global, and doesn't depend on any local state. |
| if (!app_version) |
| @@ -1182,9 +1228,9 @@ STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) { |
| // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out |
| // the part after the "/". |
| - std::vector<std::string> product_components = base::SplitString( |
| - GetContentClient()->GetProduct(), "/", |
| - base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| + std::vector<std::string> product_components = |
| + base::SplitString(GetContentClient()->GetProduct(), "/", |
| + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| DCHECK_EQ(2U, product_components.size()); |
| if (product_components.size() != 2) |
| return E_FAIL; |
| @@ -1194,9 +1240,9 @@ STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) { |
| return *app_version ? S_OK : E_FAIL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_toolkitName(BSTR* toolkit_name) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TOOLKIT_NAME); |
| - // No need to check |instance_active()| because this interface is |
| + // No need to check |GetOwner()->manager()| because this interface is |
|
dmazzoni
2017/05/08 04:45:24
This is slightly confusing, how about just |GetOwn
dougt
2017/05/08 16:53:36
yeah, this comment is useless.
Basically what it'
|
| // global, and doesn't depend on any local state. |
| if (!toolkit_name) |
| @@ -1210,10 +1256,10 @@ STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) { |
| return *toolkit_name ? S_OK : E_FAIL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_toolkitVersion( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_toolkitVersion( |
| BSTR* toolkit_version) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TOOLKIT_VERSION); |
| - // No need to check |instance_active()| because this interface is |
| + // No need to check |GetOwner()->manager()| because this interface is |
| // global, and doesn't depend on any local state. |
| if (!toolkit_version) |
| @@ -1229,9 +1275,9 @@ STDMETHODIMP BrowserAccessibilityWin::get_toolkitVersion( |
| // IAccessibleImage methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_description(BSTR* desc) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DESCRIPTION); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!desc) |
| @@ -1246,26 +1292,27 @@ STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_imagePosition( |
| IA2CoordinateType coordinate_type, |
| LONG* x, |
| LONG* y) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IMAGE_POSITION); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!x || !y) |
| return E_INVALIDARG; |
| if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
| - gfx::Rect bounds = GetScreenBoundsRect(); |
| + gfx::Rect bounds = GetOwner()->GetScreenBoundsRect(); |
| *x = bounds.x(); |
| *y = bounds.y(); |
| } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| - gfx::Rect bounds = GetPageBoundsRect(); |
| - gfx::Rect parent_bounds = PlatformGetParent() |
| - ? PlatformGetParent()->GetPageBoundsRect() |
| - : gfx::Rect(); |
| + gfx::Rect bounds = GetOwner()->GetPageBoundsRect(); |
| + gfx::Rect parent_bounds = |
| + GetOwner()->PlatformGetParent() |
| + ? GetOwner()->PlatformGetParent()->GetPageBoundsRect() |
| + : gfx::Rect(); |
| *x = bounds.x() - parent_bounds.x(); |
| *y = bounds.y() - parent_bounds.y(); |
| } else { |
| @@ -1275,16 +1322,17 @@ STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_imageSize(LONG* height, LONG* width) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_imageSize(LONG* height, |
| + LONG* width) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IMAGE_SIZE); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!height || !width) |
| return E_INVALIDARG; |
| - *height = GetPageBoundsRect().height(); |
| - *width = GetPageBoundsRect().width(); |
| + *height = GetOwner()->GetPageBoundsRect().height(); |
| + *width = GetOwner()->GetPageBoundsRect().width(); |
| return S_OK; |
| } |
| @@ -1292,23 +1340,23 @@ STDMETHODIMP BrowserAccessibilityWin::get_imageSize(LONG* height, LONG* width) { |
| // IAccessibleTable methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::get_accessibleAt( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_accessibleAt( |
| long row, |
| long column, |
| IUnknown** accessible) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACCESSIBLE_AT); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!accessible) |
| return E_INVALIDARG; |
| BrowserAccessibility* cell = |
| - GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| - if (cell && ToBrowserAccessibilityWin(cell)) { |
| + GetOwner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| + if (cell && ToBrowserAccessibilityComWin(cell)) { |
| *accessible = static_cast<IAccessible*>( |
| - ToBrowserAccessibilityWin(cell)->NewReference()); |
| + ToBrowserAccessibilityComWin(cell)->NewReference()); |
| return S_OK; |
| } |
| @@ -1316,10 +1364,10 @@ STDMETHODIMP BrowserAccessibilityWin::get_accessibleAt( |
| return E_INVALIDARG; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_caption(IUnknown** accessible) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_caption(IUnknown** accessible) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CAPTION); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!accessible) |
| @@ -1330,19 +1378,19 @@ STDMETHODIMP BrowserAccessibilityWin::get_caption(IUnknown** accessible) { |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_childIndex(long row, |
| - long column, |
| - long* cell_index) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_childIndex(long row, |
| + long column, |
| + long* cell_index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_INDEX); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!cell_index) |
| return E_INVALIDARG; |
| BrowserAccessibility* cell = |
| - GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| + GetOwner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| if (cell) { |
| *cell_index = static_cast<LONG>(cell->GetTableCellIndex()); |
| return S_OK; |
| @@ -1352,40 +1400,40 @@ STDMETHODIMP BrowserAccessibilityWin::get_childIndex(long row, |
| return E_INVALIDARG; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, |
| - BSTR* description) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_columnDescription( |
| + long column, |
| + BSTR* description) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_DESCRIPTION); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!description) |
| return E_INVALIDARG; |
| - int columns = GetTableColumnCount(); |
| + int columns = GetOwner()->GetTableColumnCount(); |
| if (column < 0 || column >= columns) |
| return E_INVALIDARG; |
| - int rows = GetTableRowCount(); |
| + int rows = GetOwner()->GetTableRowCount(); |
| if (rows <= 0) { |
| *description = nullptr; |
| return S_FALSE; |
| } |
| for (int i = 0; i < rows; ++i) { |
| - const BrowserAccessibility* cell = GetTableCell(i, column); |
| - if (ToBrowserAccessibilityWin(cell) && |
| + BrowserAccessibility* cell = GetOwner()->GetTableCell(i, column); |
| + if (ToBrowserAccessibilityComWin(cell) && |
| cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { |
| - base::string16 cell_name = cell->GetString16Attribute( |
| - ui::AX_ATTR_NAME); |
| + base::string16 cell_name = cell->GetString16Attribute(ui::AX_ATTR_NAME); |
| if (cell_name.size() > 0) { |
| *description = SysAllocString(cell_name.c_str()); |
| return S_OK; |
| } |
| - if (ToBrowserAccessibilityWin(cell)->description().size() > 0) { |
| + if (ToBrowserAccessibilityComWin(cell)->description().size() > 0) { |
| *description = SysAllocString( |
| - ToBrowserAccessibilityWin(cell)->description().c_str()); |
| + ToBrowserAccessibilityComWin(cell)->description().c_str()); |
| return S_OK; |
| } |
| } |
| @@ -1395,20 +1443,20 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_columnExtentAt( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_columnExtentAt( |
| long row, |
| long column, |
| long* n_columns_spanned) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT_AT); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!n_columns_spanned) |
| return E_INVALIDARG; |
| BrowserAccessibility* cell = |
| - GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| + GetOwner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| if (!cell) |
| return E_INVALIDARG; |
| @@ -1416,7 +1464,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnExtentAt( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_columnHeader( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_columnHeader( |
| IAccessibleTable** accessible_table, |
| long* starting_row_index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER); |
| @@ -1425,53 +1473,54 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnHeader( |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, |
| - long* column_index) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_columnIndex(long cell_index, |
| + long* column_index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_INDEX); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!column_index) |
| return E_INVALIDARG; |
| - BrowserAccessibility* cell = GetTableCell(cell_index); |
| + BrowserAccessibility* cell = GetOwner()->GetTableCell(cell_index); |
| if (!cell) |
| return E_INVALIDARG; |
| *column_index = cell->GetTableColumn(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_nColumns(long* column_count) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_nColumns(long* column_count) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_COLUMNS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!column_count) |
| return E_INVALIDARG; |
| - *column_count = GetTableColumnCount(); |
| + *column_count = GetOwner()->GetTableColumnCount(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_nRows(long* row_count) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_nRows(long* row_count) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_ROWS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!row_count) |
| return E_INVALIDARG; |
| - *row_count = GetTableRowCount(); |
| + *row_count = GetOwner()->GetTableRowCount(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_nSelectedChildren(long* cell_count) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedChildren( |
| + long* cell_count) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CHILDREN); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!cell_count) |
| @@ -1482,10 +1531,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_nSelectedChildren(long* cell_count) { |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_nSelectedColumns(long* column_count) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedColumns( |
| + long* column_count) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_COLUMNS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!column_count) |
| @@ -1495,10 +1545,10 @@ STDMETHODIMP BrowserAccessibilityWin::get_nSelectedColumns(long* column_count) { |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_nSelectedRows(long* row_count) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedRows(long* row_count) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_ROWS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!row_count) |
| @@ -1508,39 +1558,38 @@ STDMETHODIMP BrowserAccessibilityWin::get_nSelectedRows(long* row_count) { |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_rowDescription(long row, |
| - BSTR* description) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_rowDescription(long row, |
| + BSTR* description) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_DESCRIPTION); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!description) |
| return E_INVALIDARG; |
| - if (row < 0 || row >= GetTableRowCount()) |
| + if (row < 0 || row >= GetOwner()->GetTableRowCount()) |
| return E_INVALIDARG; |
| - int columns = GetTableColumnCount(); |
| + int columns = GetOwner()->GetTableColumnCount(); |
| if (columns <= 0) { |
| *description = nullptr; |
| return S_FALSE; |
| } |
| for (int i = 0; i < columns; ++i) { |
| - const BrowserAccessibility* cell = GetTableCell(row, i); |
| - if (ToBrowserAccessibilityWin(cell) && |
| + BrowserAccessibility* cell = GetOwner()->GetTableCell(row, i); |
| + if (ToBrowserAccessibilityComWin(cell) && |
| cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { |
| - base::string16 cell_name = cell->GetString16Attribute( |
| - ui::AX_ATTR_NAME); |
| + base::string16 cell_name = cell->GetString16Attribute(ui::AX_ATTR_NAME); |
| if (cell_name.size() > 0) { |
| *description = SysAllocString(cell_name.c_str()); |
| return S_OK; |
| } |
| - if (ToBrowserAccessibilityWin(cell)->description().size() > 0) { |
| + if (ToBrowserAccessibilityComWin(cell)->description().size() > 0) { |
| *description = SysAllocString( |
| - ToBrowserAccessibilityWin(cell)->description().c_str()); |
| + ToBrowserAccessibilityComWin(cell)->description().c_str()); |
| return S_OK; |
| } |
| } |
| @@ -1550,26 +1599,26 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowDescription(long row, |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt(long row, |
| - long column, |
| - long* n_rows_spanned) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_rowExtentAt(long row, |
| + long column, |
| + long* n_rows_spanned) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT_AT); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!n_rows_spanned) |
| return E_INVALIDARG; |
| - BrowserAccessibility* cell = GetTableCell(row, column); |
| + BrowserAccessibility* cell = GetOwner()->GetTableCell(row, column); |
| if (!cell) |
| return E_INVALIDARG; |
| - *n_rows_spanned = GetTableRowSpan(); |
| + *n_rows_spanned = GetOwner()->GetTableRowSpan(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_rowHeader( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_rowHeader( |
| IAccessibleTable** accessible_table, |
| long* starting_column_index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER); |
| @@ -1578,17 +1627,17 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowHeader( |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, |
| - long* row_index) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_rowIndex(long cell_index, |
| + long* row_index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_INDEX); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!row_index) |
| return E_INVALIDARG; |
| - BrowserAccessibility* cell = GetTableCell(cell_index); |
| + BrowserAccessibility* cell = GetOwner()->GetTableCell(cell_index); |
| if (!cell) |
| return E_INVALIDARG; |
| @@ -1596,12 +1645,13 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_selectedChildren(long max_children, |
| - long** children, |
| - long* n_children) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_selectedChildren( |
| + long max_children, |
| + long** children, |
| + long* n_children) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_CHILDREN); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!children || !n_children) |
| @@ -1612,12 +1662,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_selectedChildren(long max_children, |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long max_columns, |
| - long** columns, |
| - long* n_columns) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_selectedColumns(long max_columns, |
| + long** columns, |
| + long* n_columns) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_COLUMNS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!columns || !n_columns) |
| @@ -1628,12 +1678,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long max_columns, |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long max_rows, |
| - long** rows, |
| - long* n_rows) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_selectedRows(long max_rows, |
| + long** rows, |
| + long* n_rows) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_ROWS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!rows || !n_rows) |
| @@ -1644,10 +1694,10 @@ STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long max_rows, |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_summary(IUnknown** accessible) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_summary(IUnknown** accessible) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SUMMARY); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!accessible) |
| @@ -1658,12 +1708,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_summary(IUnknown** accessible) { |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_isColumnSelected( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_isColumnSelected( |
| long column, |
| boolean* is_selected) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_COLUMN_SELECTED); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!is_selected) |
| @@ -1674,11 +1724,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_isColumnSelected( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_isRowSelected(long row, |
| - boolean* is_selected) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_isRowSelected( |
| + long row, |
| + boolean* is_selected) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_ROW_SELECTED); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!is_selected) |
| @@ -1689,12 +1740,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_isRowSelected(long row, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_isSelected(long row, |
| - long column, |
| - boolean* is_selected) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_isSelected(long row, |
| + long column, |
| + boolean* is_selected) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_SELECTED); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!is_selected) |
| @@ -1705,7 +1756,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_isSelected(long row, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtentsAtIndex( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_rowColumnExtentsAtIndex( |
| long index, |
| long* row, |
| long* column, |
| @@ -1714,51 +1765,51 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtentsAtIndex( |
| boolean* is_selected) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_COLUMN_EXTENTS_AT_INDEX); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!row || !column || !row_extents || !column_extents || !is_selected) |
| return E_INVALIDARG; |
| - BrowserAccessibility* cell = GetTableCell(index); |
| + BrowserAccessibility* cell = GetOwner()->GetTableCell(index); |
| if (!cell) |
| return E_INVALIDARG; |
| *row = cell->GetTableRow(); |
| *column = cell->GetTableColumn(); |
| - *row_extents = GetTableRowSpan(); |
| - *column_extents = GetTableColumnSpan(); |
| + *row_extents = GetOwner()->GetTableRowSpan(); |
| + *column_extents = GetOwner()->GetTableColumnSpan(); |
| *is_selected = false; // Not supported. |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::selectRow(long row) { |
| +STDMETHODIMP BrowserAccessibilityComWin::selectRow(long row) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SELECT_ROW); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::selectColumn(long column) { |
| +STDMETHODIMP BrowserAccessibilityComWin::selectColumn(long column) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SELECT_COLUMN); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::unselectRow(long row) { |
| +STDMETHODIMP BrowserAccessibilityComWin::unselectRow(long row) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_UNSELECT_ROW); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::unselectColumn(long column) { |
| +STDMETHODIMP BrowserAccessibilityComWin::unselectColumn(long column) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_UNSELECT_COLUMN); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::get_modelChange(IA2TableModelChange* model_change) { |
| +BrowserAccessibilityComWin::get_modelChange(IA2TableModelChange* model_change) { |
| return E_NOTIMPL; |
| } |
| @@ -1766,21 +1817,21 @@ BrowserAccessibilityWin::get_modelChange(IA2TableModelChange* model_change) { |
| // IAccessibleTable2 methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::get_cellAt(long row, |
| - long column, |
| - IUnknown** cell) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_cellAt(long row, |
| + long column, |
| + IUnknown** cell) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CELL_AT); |
| AddAccessibilityModeFlags(AccessibilityMode::kScreenReader); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!cell) |
| return E_INVALIDARG; |
| BrowserAccessibility* table_cell = |
| - GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| - if (ToBrowserAccessibilityWin(table_cell)) { |
| - return ToBrowserAccessibilityWin(table_cell) |
| + GetOwner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| + if (ToBrowserAccessibilityComWin(table_cell)) { |
| + return ToBrowserAccessibilityComWin(table_cell) |
| ->QueryInterface(IID_IUnknown, reinterpret_cast<void**>(cell)); |
| } |
| @@ -1788,18 +1839,18 @@ STDMETHODIMP BrowserAccessibilityWin::get_cellAt(long row, |
| return E_INVALIDARG; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_nSelectedCells(long* cell_count) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedCells(long* cell_count) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CELLS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return get_nSelectedChildren(cell_count); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_selectedCells( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_selectedCells( |
| IUnknown*** cells, |
| long* n_selected_cells) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_CELLS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!cells || !n_selected_cells) |
| @@ -1810,11 +1861,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_selectedCells( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long** columns, |
| - long* n_columns) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_selectedColumns(long** columns, |
| + long* n_columns) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLE2_GET_SELECTED_COLUMNS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!columns || !n_columns) |
| @@ -1825,11 +1876,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long** columns, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long** rows, |
| - long* n_rows) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_selectedRows(long** rows, |
| + long* n_rows) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLE2_GET_SELECTED_ROWS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!rows || !n_rows) |
| @@ -1840,63 +1891,62 @@ STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long** rows, |
| return S_OK; |
| } |
| - |
| // |
| // IAccessibleTableCell methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::get_columnExtent( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_columnExtent( |
| long* n_columns_spanned) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!n_columns_spanned) |
| return E_INVALIDARG; |
| - *n_columns_spanned = GetTableColumnSpan(); |
| + *n_columns_spanned = GetOwner()->GetTableColumnSpan(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_columnHeaderCells( |
| IUnknown*** cell_accessibles, |
| long* n_column_header_cells) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER_CELLS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!cell_accessibles || !n_column_header_cells) |
| return E_INVALIDARG; |
| *n_column_header_cells = 0; |
| - BrowserAccessibility* table = GetTable(); |
| + BrowserAccessibility* table = GetOwner()->GetTable(); |
| if (!table) { |
| NOTREACHED(); |
| return S_FALSE; |
| } |
| - int column = GetTableColumn(); |
| - int columns = GetTableColumnCount(); |
| - int rows = GetTableRowCount(); |
| + int column = GetOwner()->GetTableColumn(); |
| + int columns = GetOwner()->GetTableColumnCount(); |
| + int rows = GetOwner()->GetTableRowCount(); |
| if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) |
| return S_FALSE; |
| for (int i = 0; i < rows; ++i) { |
| - BrowserAccessibility* cell = GetTableCell(i, column); |
| + BrowserAccessibility* cell = GetOwner()->GetTableCell(i, column); |
| if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) |
| (*n_column_header_cells)++; |
| } |
| - *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( |
| - (*n_column_header_cells) * sizeof(cell_accessibles[0]))); |
| + *cell_accessibles = static_cast<IUnknown**>( |
| + CoTaskMemAlloc((*n_column_header_cells) * sizeof(cell_accessibles[0]))); |
| int index = 0; |
| for (int i = 0; i < rows; ++i) { |
| - BrowserAccessibility* cell = GetTableCell(i, column); |
| + BrowserAccessibility* cell = GetOwner()->GetTableCell(i, column); |
| if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { |
| (*cell_accessibles)[index] = static_cast<IAccessible*>( |
| - ToBrowserAccessibilityWin(cell)->NewReference()); |
| + ToBrowserAccessibilityComWin(cell)->NewReference()); |
| ++index; |
| } |
| } |
| @@ -1904,70 +1954,70 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long* column_index) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_columnIndex(long* column_index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_COLUMN_INDEX); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!column_index) |
| return E_INVALIDARG; |
| - *column_index = GetTableColumn(); |
| + *column_index = GetOwner()->GetTableColumn(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_rowExtent(long* n_rows_spanned) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_rowExtent(long* n_rows_spanned) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!n_rows_spanned) |
| return E_INVALIDARG; |
| - *n_rows_spanned = GetTableRowSpan(); |
| + *n_rows_spanned = GetOwner()->GetTableRowSpan(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_rowHeaderCells( |
| IUnknown*** cell_accessibles, |
| long* n_row_header_cells) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER_CELLS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!cell_accessibles || !n_row_header_cells) |
| return E_INVALIDARG; |
| *n_row_header_cells = 0; |
| - BrowserAccessibility* table = GetTable(); |
| + BrowserAccessibility* table = GetOwner()->GetTable(); |
| if (!table) { |
| NOTREACHED(); |
| return S_FALSE; |
| } |
| - int row = GetTableRow(); |
| - int columns = GetTableColumnCount(); |
| - int rows = GetTableRowCount(); |
| + int row = GetOwner()->GetTableRow(); |
| + int columns = GetOwner()->GetTableColumnCount(); |
| + int rows = GetOwner()->GetTableRowCount(); |
| if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) |
| return S_FALSE; |
| for (int i = 0; i < columns; ++i) { |
| - BrowserAccessibility* cell = GetTableCell(row, i); |
| + BrowserAccessibility* cell = GetOwner()->GetTableCell(row, i); |
| if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) |
| (*n_row_header_cells)++; |
| } |
| - *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( |
| - (*n_row_header_cells) * sizeof(cell_accessibles[0]))); |
| + *cell_accessibles = static_cast<IUnknown**>( |
| + CoTaskMemAlloc((*n_row_header_cells) * sizeof(cell_accessibles[0]))); |
| int index = 0; |
| for (int i = 0; i < columns; ++i) { |
| - BrowserAccessibility* cell = GetTableCell(row, i); |
| + BrowserAccessibility* cell = GetOwner()->GetTableCell(row, i); |
| if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { |
| (*cell_accessibles)[index] = static_cast<IAccessible*>( |
| - ToBrowserAccessibilityWin(cell)->NewReference()); |
| + ToBrowserAccessibilityComWin(cell)->NewReference()); |
| ++index; |
| } |
| } |
| @@ -1975,23 +2025,23 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long* row_index) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_rowIndex(long* row_index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_ROW_INDEX); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!row_index) |
| return E_INVALIDARG; |
| - *row_index = GetTableRow(); |
| + *row_index = GetOwner()->GetTableRow(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_isSelected(boolean* is_selected) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_isSelected(boolean* is_selected) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_IS_SELECTED); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!is_selected) |
| @@ -2001,7 +2051,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_isSelected(boolean* is_selected) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtents( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_rowColumnExtents( |
| long* row_index, |
| long* column_index, |
| long* row_extents, |
| @@ -2009,43 +2059,40 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtents( |
| boolean* is_selected) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_COLUMN_EXTENTS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| - if (!row_index || |
| - !column_index || |
| - !row_extents || |
| - !column_extents || |
| + if (!row_index || !column_index || !row_extents || !column_extents || |
| !is_selected) { |
| return E_INVALIDARG; |
| } |
| - *row_index = GetTableRow(); |
| - *column_index = GetTableColumn(); |
| - *row_extents = GetTableRowSpan(); |
| - *column_extents = GetTableColumnSpan(); |
| + *row_index = GetOwner()->GetTableRow(); |
| + *column_index = GetOwner()->GetTableColumn(); |
| + *row_extents = GetOwner()->GetTableRowSpan(); |
| + *column_extents = GetOwner()->GetTableColumnSpan(); |
| *is_selected = false; // Not supported. |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_table(IUnknown** table) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_table(IUnknown** table) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TABLE); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!table) |
| return E_INVALIDARG; |
| - BrowserAccessibility* find_table = GetTable(); |
| - if (!find_table || !ToBrowserAccessibilityWin(find_table)) { |
| + BrowserAccessibility* find_table = GetOwner()->GetTable(); |
| + if (!find_table || !ToBrowserAccessibilityComWin(find_table)) { |
| *table = nullptr; |
| return S_FALSE; |
| } |
| *table = static_cast<IAccessibleTable*>( |
| - ToBrowserAccessibilityWin(find_table)->NewReference()); |
| + ToBrowserAccessibilityComWin(find_table)->NewReference()); |
| return S_OK; |
| } |
| @@ -2053,30 +2100,30 @@ STDMETHODIMP BrowserAccessibilityWin::get_table(IUnknown** table) { |
| // IAccessibleText methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_nCharacters(LONG* n_characters) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_CHARACTERS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| AccessibilityMode::kInlineTextBoxes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!n_characters) |
| return E_INVALIDARG; |
| - *n_characters = static_cast<LONG>(GetText().size()); |
| + *n_characters = static_cast<LONG>(GetOwner()->GetText().size()); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_caretOffset(LONG* offset) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CARET_OFFSET); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!offset) |
| return E_INVALIDARG; |
| - if (!HasCaret()) |
| + if (!GetOwner()->HasCaret()) |
| return S_FALSE; |
| int selection_start, selection_end; |
| @@ -2089,7 +2136,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_characterExtents( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_characterExtents( |
| LONG offset, |
| IA2CoordinateType coordinate_type, |
| LONG* out_x, |
| @@ -2099,25 +2146,27 @@ STDMETHODIMP BrowserAccessibilityWin::get_characterExtents( |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHARACTER_EXTENTS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| AccessibilityMode::kInlineTextBoxes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!out_x || !out_y || !out_width || !out_height) |
| return E_INVALIDARG; |
| - const base::string16& text_str = GetText(); |
| + const base::string16& text_str = GetOwner()->GetText(); |
| HandleSpecialTextOffset(&offset); |
| if (offset < 0 || offset > static_cast<LONG>(text_str.size())) |
| return E_INVALIDARG; |
| gfx::Rect character_bounds; |
| if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
| - character_bounds = GetScreenBoundsForRange(offset, 1); |
| + character_bounds = GetOwner()->GetScreenBoundsForRange(offset, 1); |
| } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| - character_bounds = GetPageBoundsForRange(offset, 1); |
| - if (PlatformGetParent()) |
| - character_bounds -= |
| - PlatformGetParent()->GetPageBoundsRect().OffsetFromOrigin(); |
| + character_bounds = GetOwner()->GetPageBoundsForRange(offset, 1); |
| + if (GetOwner()->PlatformGetParent()) |
| + character_bounds -= GetOwner() |
| + ->PlatformGetParent() |
| + ->GetPageBoundsRect() |
| + .OffsetFromOrigin(); |
| } else { |
| return E_INVALIDARG; |
| } |
| @@ -2130,10 +2179,10 @@ STDMETHODIMP BrowserAccessibilityWin::get_characterExtents( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_nSelections(LONG* n_selections) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTIONS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!n_selections) |
| @@ -2150,12 +2199,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index, |
| - LONG* start_offset, |
| - LONG* end_offset) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_selection(LONG selection_index, |
| + LONG* start_offset, |
| + LONG* end_offset) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTION); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!start_offset || !end_offset || selection_index != 0) |
| @@ -2182,18 +2231,18 @@ STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index, |
| return E_INVALIDARG; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, |
| - LONG end_offset, |
| - BSTR* text) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_text(LONG start_offset, |
| + LONG end_offset, |
| + BSTR* text) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!text) |
| return E_INVALIDARG; |
| - const base::string16& text_str = GetText(); |
| + const base::string16& text_str = GetOwner()->GetText(); |
| HandleSpecialTextOffset(&start_offset); |
| HandleSpecialTextOffset(&end_offset); |
| @@ -2212,8 +2261,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, |
| if (end_offset > len) |
| return E_INVALIDARG; |
| - base::string16 substr = text_str.substr(start_offset, |
| - end_offset - start_offset); |
| + base::string16 substr = |
| + text_str.substr(start_offset, end_offset - start_offset); |
| if (substr.empty()) |
| return S_FALSE; |
| @@ -2223,7 +2272,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_textAtOffset( |
| LONG offset, |
| IA2TextBoundaryType boundary_type, |
| LONG* start_offset, |
| @@ -2232,7 +2281,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_AT_OFFSET); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| AccessibilityMode::kInlineTextBoxes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!start_offset || !end_offset || !text) |
| @@ -2242,7 +2291,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( |
| if (offset < 0) |
| return E_INVALIDARG; |
| - const base::string16& text_str = GetText(); |
| + const base::string16& text_str = GetOwner()->GetText(); |
| LONG text_len = text_str.length(); |
| if (offset > text_len) |
| return E_INVALIDARG; |
| @@ -2269,14 +2318,14 @@ STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( |
| } |
| } |
| - *start_offset = FindBoundary( |
| - text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
| - *end_offset = FindBoundary( |
| - text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
| + *start_offset = |
| + FindBoundary(text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
| + *end_offset = |
| + FindBoundary(text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
| return get_text(*start_offset, *end_offset, text); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_textBeforeOffset( |
| LONG offset, |
| IA2TextBoundaryType boundary_type, |
| LONG* start_offset, |
| @@ -2285,7 +2334,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_BEFORE_OFFSET); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| AccessibilityMode::kInlineTextBoxes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!start_offset || !end_offset || !text) |
| @@ -2300,15 +2349,15 @@ STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( |
| return S_FALSE; |
| } |
| - const base::string16& text_str = GetText(); |
| + const base::string16& text_str = GetOwner()->GetText(); |
| - *start_offset = FindBoundary( |
| - text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
| + *start_offset = |
| + FindBoundary(text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
| *end_offset = offset; |
| return get_text(*start_offset, *end_offset, text); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_textAfterOffset( |
| LONG offset, |
| IA2TextBoundaryType boundary_type, |
| LONG* start_offset, |
| @@ -2317,7 +2366,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_AFTER_OFFSET); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| AccessibilityMode::kInlineTextBoxes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!start_offset || !end_offset || !text) |
| @@ -2332,18 +2381,18 @@ STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( |
| return S_FALSE; |
| } |
| - const base::string16& text_str = GetText(); |
| + const base::string16& text_str = GetOwner()->GetText(); |
| *start_offset = offset; |
| - *end_offset = FindBoundary( |
| - text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
| + *end_offset = |
| + FindBoundary(text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
| return get_text(*start_offset, *end_offset, text); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_newText(IA2TextSegment* new_text) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEW_TEXT); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!new_text) |
| @@ -2357,17 +2406,17 @@ STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { |
| if (new_len == 0) |
| return E_FAIL; |
| - base::string16 substr = GetText().substr(start, new_len); |
| + base::string16 substr = GetOwner()->GetText().substr(start, new_len); |
| new_text->text = SysAllocString(substr.c_str()); |
| new_text->start = static_cast<long>(start); |
| new_text->end = static_cast<long>(start + new_len); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_oldText(IA2TextSegment* old_text) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OLD_TEXT); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!old_text) |
| @@ -2389,7 +2438,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_offsetAtPoint( |
| LONG x, |
| LONG y, |
| IA2CoordinateType coord_type, |
| @@ -2397,7 +2446,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OFFSET_AT_POINT); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| AccessibilityMode::kInlineTextBoxes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!offset) |
| @@ -2410,7 +2459,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::scrollSubstringTo( |
| +STDMETHODIMP BrowserAccessibilityComWin::scrollSubstringTo( |
| LONG start_index, |
| LONG end_index, |
| IA2ScrollType scroll_type) { |
| @@ -2421,7 +2470,7 @@ STDMETHODIMP BrowserAccessibilityWin::scrollSubstringTo( |
| return scrollTo(scroll_type); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::scrollSubstringToPoint( |
| +STDMETHODIMP BrowserAccessibilityComWin::scrollSubstringToPoint( |
| LONG start_index, |
| LONG end_index, |
| IA2CoordinateType coordinate_type, |
| @@ -2430,24 +2479,28 @@ STDMETHODIMP BrowserAccessibilityWin::scrollSubstringToPoint( |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_SUBSTRING_TO_POINT); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| AccessibilityMode::kInlineTextBoxes); |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| if (start_index > end_index) |
| std::swap(start_index, end_index); |
| LONG length = end_index - start_index + 1; |
| DCHECK_GE(length, 0); |
| - gfx::Rect string_bounds = GetPageBoundsForRange(start_index, length); |
| - string_bounds -= GetPageBoundsRect().OffsetFromOrigin(); |
| + gfx::Rect string_bounds = |
| + GetOwner()->GetPageBoundsForRange(start_index, length); |
| + string_bounds -= GetOwner()->GetPageBoundsRect().OffsetFromOrigin(); |
| x -= string_bounds.x(); |
| y -= string_bounds.y(); |
| return scrollToPoint(coordinate_type, x, y); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset, |
| - LONG end_offset) { |
| +STDMETHODIMP BrowserAccessibilityComWin::addSelection(LONG start_offset, |
| + LONG end_offset) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ADD_SELECTION); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| // We only support one selection. |
| @@ -2455,10 +2508,10 @@ STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) { |
| +STDMETHODIMP BrowserAccessibilityComWin::removeSelection(LONG selection_index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_REMOVE_SELECTION); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (selection_index != 0) |
| @@ -2469,27 +2522,27 @@ STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) { |
| LONG caret_offset = 0; |
| int selection_start, selection_end; |
| GetSelectionOffsets(&selection_start, &selection_end); |
| - if (HasCaret() && selection_end >= 0) |
| + if (GetOwner()->HasCaret() && selection_end >= 0) |
| caret_offset = selection_end; |
| SetIA2HypertextSelection(caret_offset, caret_offset); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::setCaretOffset(LONG offset) { |
| +STDMETHODIMP BrowserAccessibilityComWin::setCaretOffset(LONG offset) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_CARET_OFFSET); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| SetIA2HypertextSelection(offset, offset); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, |
| - LONG start_offset, |
| - LONG end_offset) { |
| +STDMETHODIMP BrowserAccessibilityComWin::setSelection(LONG selection_index, |
| + LONG start_offset, |
| + LONG end_offset) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_SELECTION); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (selection_index != 0) |
| return E_INVALIDARG; |
| @@ -2497,10 +2550,10 @@ STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_attributes(LONG offset, |
| - LONG* start_offset, |
| - LONG* end_offset, |
| - BSTR* text_attributes) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_attributes(LONG offset, |
| + LONG* start_offset, |
| + LONG* end_offset, |
| + BSTR* text_attributes) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IATEXT_GET_ATTRIBUTES); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| if (!start_offset || !end_offset || !text_attributes) |
| @@ -2508,10 +2561,10 @@ STDMETHODIMP BrowserAccessibilityWin::get_attributes(LONG offset, |
| *start_offset = *end_offset = 0; |
| *text_attributes = nullptr; |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| - const base::string16 text = GetText(); |
| + const base::string16 text = GetOwner()->GetText(); |
| HandleSpecialTextOffset(&offset); |
| if (offset < 0 || offset > static_cast<LONG>(text.size())) |
| return E_INVALIDARG; |
| @@ -2539,10 +2592,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_attributes(LONG offset, |
| // IAccessibleHypertext methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::get_nHyperlinks(long* hyperlink_count) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_nHyperlinks( |
| + long* hyperlink_count) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_HYPERLINKS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!hyperlink_count) |
| @@ -2552,23 +2606,22 @@ STDMETHODIMP BrowserAccessibilityWin::get_nHyperlinks(long* hyperlink_count) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_hyperlink( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_hyperlink( |
| long index, |
| IAccessibleHyperlink** hyperlink) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| - if (!hyperlink || |
| - index < 0 || |
| + if (!hyperlink || index < 0 || |
| index >= static_cast<long>(hyperlinks().size())) { |
| return E_INVALIDARG; |
| } |
| int32_t id = hyperlinks()[index]; |
| - BrowserAccessibilityWin* link = |
| - ToBrowserAccessibilityWin(GetFromUniqueID(id)); |
| + BrowserAccessibilityComWin* link = |
| + ToBrowserAccessibilityComWin(GetOwner()->GetFromUniqueID(id)); |
| if (!link) |
| return E_FAIL; |
| @@ -2576,18 +2629,19 @@ STDMETHODIMP BrowserAccessibilityWin::get_hyperlink( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_hyperlinkIndex( |
| long char_index, |
| long* hyperlink_index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK_INDEX); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!hyperlink_index) |
| return E_INVALIDARG; |
| - if (char_index < 0 || char_index >= static_cast<long>(GetText().size())) { |
| + if (char_index < 0 || |
| + char_index >= static_cast<long>(GetOwner()->GetText().size())) { |
| return E_INVALIDARG; |
| } |
| @@ -2607,17 +2661,18 @@ STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( |
| // |
| // Currently, only text links are supported. |
| -STDMETHODIMP BrowserAccessibilityWin::get_anchor(long index, VARIANT* anchor) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_anchor(long index, |
| + VARIANT* anchor) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ANCHOR); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active() || !IsHyperlink()) |
| + if (!GetOwner()->instance_active() || !IsHyperlink()) |
| return E_FAIL; |
| // IA2 text links can have only one anchor, that is the text inside them. |
| if (index != 0 || !anchor) |
| return E_INVALIDARG; |
| - BSTR ia2_hypertext = SysAllocString(GetText().c_str()); |
| + BSTR ia2_hypertext = SysAllocString(GetOwner()->GetText().c_str()); |
| DCHECK(ia2_hypertext); |
| anchor->vt = VT_BSTR; |
| anchor->bstrVal = ia2_hypertext; |
| @@ -2631,11 +2686,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_anchor(long index, VARIANT* anchor) { |
| } |
| // Currently, only text links are supported. |
| -STDMETHODIMP BrowserAccessibilityWin::get_anchorTarget(long index, |
| - VARIANT* anchor_target) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_anchorTarget( |
| + long index, |
| + VARIANT* anchor_target) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ANCHOR_TARGET); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active() || !IsHyperlink()) |
| + if (!GetOwner()->instance_active() || !IsHyperlink()) |
| return E_FAIL; |
| // IA2 text links can have at most one target, that is when they represent an |
| @@ -2660,26 +2716,27 @@ STDMETHODIMP BrowserAccessibilityWin::get_anchorTarget(long index, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_startIndex(long* index) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_startIndex(long* index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_START_INDEX); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active() || !IsHyperlink()) |
| + if (!GetOwner()->instance_active() || !IsHyperlink()) |
| return E_FAIL; |
| if (!index) |
| return E_INVALIDARG; |
| int32_t hypertext_offset = 0; |
| - auto* parent = PlatformGetParent(); |
| + auto* parent = GetOwner()->PlatformGetParent(); |
| if (parent) { |
| hypertext_offset = |
| - ToBrowserAccessibilityWin(parent)->GetHypertextOffsetFromChild(*this); |
| + ToBrowserAccessibilityComWin(parent)->GetHypertextOffsetFromChild( |
| + *this); |
| } |
| *index = static_cast<LONG>(hypertext_offset); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_endIndex(long* index) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_endIndex(long* index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_END_INDEX); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| LONG start_index; |
| @@ -2690,7 +2747,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_endIndex(long* index) { |
| } |
| // This method is deprecated in the IA2 Spec. |
| -STDMETHODIMP BrowserAccessibilityWin::get_valid(boolean* valid) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_valid(boolean* valid) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_VALID); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| @@ -2700,10 +2757,10 @@ STDMETHODIMP BrowserAccessibilityWin::get_valid(boolean* valid) { |
| // IAccessibleAction partly implemented. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::nActions(long* n_actions) { |
| +STDMETHODIMP BrowserAccessibilityComWin::nActions(long* n_actions) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_N_ACTIONS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!n_actions) |
| @@ -2712,7 +2769,7 @@ STDMETHODIMP BrowserAccessibilityWin::nActions(long* n_actions) { |
| // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| |
| // to work properly because the |IAccessibleHyperlink| interface inherits from |
| // |IAccessibleAction|. |
| - if (IsHyperlink() || HasIntAttribute(ui::AX_ATTR_ACTION)) { |
| + if (IsHyperlink() || GetOwner()->HasIntAttribute(ui::AX_ATTR_ACTION)) { |
| *n_actions = 1; |
| } else { |
| *n_actions = 0; |
| @@ -2721,46 +2778,49 @@ STDMETHODIMP BrowserAccessibilityWin::nActions(long* n_actions) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::doAction(long action_index) { |
| +STDMETHODIMP BrowserAccessibilityComWin::doAction(long action_index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_DO_ACTION); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| - if (!HasIntAttribute(ui::AX_ATTR_ACTION) || action_index != 0) |
| + if (!GetOwner()->HasIntAttribute(ui::AX_ATTR_ACTION) || action_index != 0) |
| return E_INVALIDARG; |
| - manager_->DoDefaultAction(*this); |
| + GetOwner()->manager()->DoDefaultAction(*GetOwner()); |
| return S_OK; |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::get_description(long action_index, BSTR* description) { |
| +BrowserAccessibilityComWin::get_description(long action_index, |
| + BSTR* description) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IAACTION_GET_DESCRIPTION); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_keyBinding(long action_index, |
| - long n_max_bindings, |
| - BSTR** key_bindings, |
| - long* n_bindings) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_keyBinding(long action_index, |
| + long n_max_bindings, |
| + BSTR** key_bindings, |
| + long* n_bindings) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_KEY_BINDING); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_name(long action_index, BSTR* name) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_name(long action_index, |
| + BSTR* name) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAME); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!name) |
| return E_INVALIDARG; |
| int action; |
| - if (!GetIntAttribute(ui::AX_ATTR_ACTION, &action) || action_index != 0) { |
| + if (!GetOwner()->GetIntAttribute(ui::AX_ATTR_ACTION, &action) || |
| + action_index != 0) { |
| *name = nullptr; |
| return E_INVALIDARG; |
| } |
| @@ -2778,18 +2838,19 @@ STDMETHODIMP BrowserAccessibilityWin::get_name(long action_index, BSTR* name) { |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::get_localizedName(long action_index, |
| - BSTR* localized_name) { |
| +BrowserAccessibilityComWin::get_localizedName(long action_index, |
| + BSTR* localized_name) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!localized_name) |
| return E_INVALIDARG; |
| int action; |
| - if (!GetIntAttribute(ui::AX_ATTR_ACTION, &action) || action_index != 0) { |
| + if (!GetOwner()->GetIntAttribute(ui::AX_ATTR_ACTION, &action) || |
| + action_index != 0) { |
| *localized_name = nullptr; |
| return E_INVALIDARG; |
| } |
| @@ -2810,18 +2871,17 @@ BrowserAccessibilityWin::get_localizedName(long action_index, |
| // IAccessibleValue methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::get_currentValue(VARIANT* value) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_currentValue(VARIANT* value) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CURRENT_VALUE); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!value) |
| return E_INVALIDARG; |
| float float_val; |
| - if (GetFloatAttribute( |
| - ui::AX_ATTR_VALUE_FOR_RANGE, &float_val)) { |
| + if (GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &float_val)) { |
| value->vt = VT_R8; |
| value->dblVal = float_val; |
| return S_OK; |
| @@ -2831,18 +2891,17 @@ STDMETHODIMP BrowserAccessibilityWin::get_currentValue(VARIANT* value) { |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_minimumValue(VARIANT* value) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_minimumValue(VARIANT* value) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MINIMUM_VALUE); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!value) |
| return E_INVALIDARG; |
| float float_val; |
| - if (GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, |
| - &float_val)) { |
| + if (GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, &float_val)) { |
| value->vt = VT_R8; |
| value->dblVal = float_val; |
| return S_OK; |
| @@ -2852,18 +2911,17 @@ STDMETHODIMP BrowserAccessibilityWin::get_minimumValue(VARIANT* value) { |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_maximumValue(VARIANT* value) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_maximumValue(VARIANT* value) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MAXIMUM_VALUE); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!value) |
| return E_INVALIDARG; |
| float float_val; |
| - if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, |
| - &float_val)) { |
| + if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, &float_val)) { |
| value->vt = VT_R8; |
| value->dblVal = float_val; |
| return S_OK; |
| @@ -2873,7 +2931,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_maximumValue(VARIANT* value) { |
| return S_FALSE; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::setCurrentValue(VARIANT new_value) { |
| +STDMETHODIMP BrowserAccessibilityComWin::setCurrentValue(VARIANT new_value) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_CURRENT_VALUE); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| // TODO(dmazzoni): Implement this. |
| @@ -2884,18 +2942,22 @@ STDMETHODIMP BrowserAccessibilityWin::setCurrentValue(VARIANT new_value) { |
| // ISimpleDOMDocument methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::get_URL(BSTR* url) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_URL(BSTR* url) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_URL); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| + auto* manager = GetOwner()->manager(); |
| + if (!manager) |
| return E_FAIL; |
| if (!url) |
| return E_INVALIDARG; |
| - if (this != manager_->GetRoot()) |
| + if (GetOwner() != manager->GetRoot()) |
| return E_FAIL; |
| - std::string str = manager_->GetTreeData().url; |
| + std::string str = manager->GetTreeData().url; |
| if (str.empty()) |
| return S_FALSE; |
| @@ -2905,15 +2967,19 @@ STDMETHODIMP BrowserAccessibilityWin::get_URL(BSTR* url) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_title(BSTR* title) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_title(BSTR* title) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TITLE); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| + auto* manager = GetOwner()->manager(); |
| + if (!manager) |
| return E_FAIL; |
| if (!title) |
| return E_INVALIDARG; |
| - std::string str = manager_->GetTreeData().title; |
| + std::string str = manager->GetTreeData().title; |
| if (str.empty()) |
| return S_FALSE; |
| @@ -2923,15 +2989,19 @@ STDMETHODIMP BrowserAccessibilityWin::get_title(BSTR* title) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_mimeType(BSTR* mime_type) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_mimeType(BSTR* mime_type) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MIME_TYPE); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| + auto* manager = GetOwner()->manager(); |
| + if (!manager) |
| return E_FAIL; |
| if (!mime_type) |
| return E_INVALIDARG; |
| - std::string str = manager_->GetTreeData().mimetype; |
| + std::string str = manager->GetTreeData().mimetype; |
| if (str.empty()) |
| return S_FALSE; |
| @@ -2941,15 +3011,19 @@ STDMETHODIMP BrowserAccessibilityWin::get_mimeType(BSTR* mime_type) { |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_docType(BSTR* doc_type) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_docType(BSTR* doc_type) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DOC_TYPE); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| + auto* manager = GetOwner()->manager(); |
| + if (!manager) |
| return E_FAIL; |
| if (!doc_type) |
| return E_INVALIDARG; |
| - std::string str = manager_->GetTreeData().doctype; |
| + std::string str = manager->GetTreeData().doctype; |
| if (str.empty()) |
| return S_FALSE; |
| @@ -2960,14 +3034,14 @@ STDMETHODIMP BrowserAccessibilityWin::get_docType(BSTR* doc_type) { |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::get_nameSpaceURIForID(short name_space_id, |
| - BSTR* name_space_uri) { |
| +BrowserAccessibilityComWin::get_nameSpaceURIForID(short name_space_id, |
| + BSTR* name_space_uri) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAMESPACE_URI_FOR_ID); |
| return E_NOTIMPL; |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::put_alternateViewMediaTypes( |
| +BrowserAccessibilityComWin::put_alternateViewMediaTypes( |
| BSTR* comma_separated_media_types) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_PUT_ALTERNATE_VIEW_MEDIA_TYPES); |
| return E_NOTIMPL; |
| @@ -2977,7 +3051,7 @@ BrowserAccessibilityWin::put_alternateViewMediaTypes( |
| // ISimpleDOMNode methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::get_nodeInfo( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_nodeInfo( |
| BSTR* node_name, |
| short* name_space_id, |
| BSTR* node_value, |
| @@ -2986,7 +3060,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nodeInfo( |
| unsigned short* node_type) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NODE_INFO); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!node_name || !name_space_id || !node_value || !num_children || |
| @@ -2995,20 +3069,20 @@ STDMETHODIMP BrowserAccessibilityWin::get_nodeInfo( |
| } |
| base::string16 tag; |
| - if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) |
| + if (GetOwner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) |
| *node_name = SysAllocString(tag.c_str()); |
| else |
| *node_name = nullptr; |
| *name_space_id = 0; |
| *node_value = SysAllocString(value().c_str()); |
| - *num_children = PlatformChildCount(); |
| - *unique_id = -this->unique_id(); |
| + *num_children = GetOwner()->PlatformChildCount(); |
| + *unique_id = -GetOwner()->unique_id(); |
| - if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || |
| - GetRole() == ui::AX_ROLE_WEB_AREA) { |
| + if (GetOwner()->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || |
| + GetOwner()->GetRole() == ui::AX_ROLE_WEB_AREA) { |
| *node_type = NODETYPE_DOCUMENT; |
| - } else if (IsTextOnlyObject()) { |
| + } else if (GetOwner()->IsTextOnlyObject()) { |
| *node_type = NODETYPE_TEXT; |
| } else { |
| *node_type = NODETYPE_ELEMENT; |
| @@ -3017,7 +3091,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nodeInfo( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_attributes( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_attributes( |
| unsigned short max_attribs, |
| BSTR* attrib_names, |
| short* name_space_id, |
| @@ -3025,34 +3099,34 @@ STDMETHODIMP BrowserAccessibilityWin::get_attributes( |
| unsigned short* num_attribs) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ISIMPLEDOMNODE_GET_ATTRIBUTES); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) |
| return E_INVALIDARG; |
| *num_attribs = max_attribs; |
| - if (*num_attribs > GetHtmlAttributes().size()) |
| - *num_attribs = GetHtmlAttributes().size(); |
| + if (*num_attribs > GetOwner()->GetHtmlAttributes().size()) |
| + *num_attribs = GetOwner()->GetHtmlAttributes().size(); |
| for (unsigned short i = 0; i < *num_attribs; ++i) { |
| attrib_names[i] = SysAllocString( |
| - base::UTF8ToUTF16(GetHtmlAttributes()[i].first).c_str()); |
| + base::UTF8ToUTF16(GetOwner()->GetHtmlAttributes()[i].first).c_str()); |
| name_space_id[i] = 0; |
| attrib_values[i] = SysAllocString( |
| - base::UTF8ToUTF16(GetHtmlAttributes()[i].second).c_str()); |
| + base::UTF8ToUTF16(GetOwner()->GetHtmlAttributes()[i].second).c_str()); |
| } |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_attributesForNames( |
| unsigned short num_attribs, |
| BSTR* attrib_names, |
| short* name_space_id, |
| BSTR* attrib_values) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ATTRIBUTES_FOR_NAMES); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!attrib_names || !name_space_id || !attrib_values) |
| @@ -3062,10 +3136,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( |
| name_space_id[i] = 0; |
| bool found = false; |
| std::string name = base::UTF16ToUTF8((LPCWSTR)attrib_names[i]); |
| - for (unsigned int j = 0; j < GetHtmlAttributes().size(); ++j) { |
| - if (GetHtmlAttributes()[j].first == name) { |
| + for (unsigned int j = 0; j < GetOwner()->GetHtmlAttributes().size(); ++j) { |
| + if (GetOwner()->GetHtmlAttributes()[j].first == name) { |
| attrib_values[i] = SysAllocString( |
| - base::UTF8ToUTF16(GetHtmlAttributes()[j].second).c_str()); |
| + base::UTF8ToUTF16(GetOwner()->GetHtmlAttributes()[j].second) |
| + .c_str()); |
| found = true; |
| break; |
| } |
| @@ -3077,15 +3152,15 @@ STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_computedStyle( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_computedStyle( |
| unsigned short max_style_properties, |
| boolean use_alternate_view, |
| BSTR* style_properties, |
| BSTR* style_values, |
| - unsigned short *num_style_properties) { |
| + unsigned short* num_style_properties) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COMPUTED_STYLE); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!style_properties || !style_values) |
| @@ -3095,7 +3170,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_computedStyle( |
| base::string16 display; |
| if (max_style_properties == 0 || |
| - !GetString16Attribute(ui::AX_ATTR_DISPLAY, &display)) { |
| + !GetOwner()->GetString16Attribute(ui::AX_ATTR_DISPLAY, &display)) { |
| *num_style_properties = 0; |
| return S_OK; |
| } |
| @@ -3107,14 +3182,14 @@ STDMETHODIMP BrowserAccessibilityWin::get_computedStyle( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_computedStyleForProperties( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_computedStyleForProperties( |
| unsigned short num_style_properties, |
| boolean use_alternate_view, |
| BSTR* style_properties, |
| BSTR* style_values) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COMPUTED_STYLE_FOR_PROPERTIES); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!style_properties || !style_values) |
| @@ -3126,8 +3201,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_computedStyleForProperties( |
| base::string16 name = base::ToLowerASCII( |
| reinterpret_cast<const base::char16*>(style_properties[i])); |
| if (name == L"display") { |
| - base::string16 display = GetString16Attribute( |
| - ui::AX_ATTR_DISPLAY); |
| + base::string16 display = |
| + GetOwner()->GetString16Attribute(ui::AX_ATTR_DISPLAY); |
| style_values[i] = SysAllocString(display.c_str()); |
| } else { |
| style_values[i] = NULL; |
| @@ -3137,156 +3212,166 @@ STDMETHODIMP BrowserAccessibilityWin::get_computedStyleForProperties( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) { |
| +STDMETHODIMP BrowserAccessibilityComWin::scrollTo(boolean placeTopLeft) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ISIMPLEDOMNODE_SCROLL_TO); |
| - return scrollTo(placeTopLeft ? |
| - IA2_SCROLL_TYPE_TOP_LEFT : IA2_SCROLL_TYPE_ANYWHERE); |
| + return scrollTo(placeTopLeft ? IA2_SCROLL_TYPE_TOP_LEFT |
| + : IA2_SCROLL_TYPE_ANYWHERE); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_parentNode(ISimpleDOMNode** node) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PARENT_NODE); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!node) |
| return E_INVALIDARG; |
| - *node = ToBrowserAccessibilityWin(PlatformGetParent())->NewReference(); |
| + *node = ToBrowserAccessibilityComWin(GetOwner()->PlatformGetParent()) |
| + ->NewReference(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_firstChild(ISimpleDOMNode** node) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FIRST_CHILD); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!node) |
| return E_INVALIDARG; |
| - if (PlatformChildCount() == 0) { |
| + if (GetOwner()->PlatformChildCount() == 0) { |
| *node = NULL; |
| return S_FALSE; |
| } |
| - *node = ToBrowserAccessibilityWin(PlatformGetChild(0))->NewReference(); |
| + *node = ToBrowserAccessibilityComWin(GetOwner()->PlatformGetChild(0)) |
| + ->NewReference(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_lastChild(ISimpleDOMNode** node) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LAST_CHILD); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!node) |
| return E_INVALIDARG; |
| - if (PlatformChildCount() == 0) { |
| + if (GetOwner()->PlatformChildCount() == 0) { |
| *node = NULL; |
| return S_FALSE; |
| } |
| - *node = ToBrowserAccessibilityWin( |
| - PlatformGetChild(PlatformChildCount() - 1))->NewReference(); |
| + *node = |
| + ToBrowserAccessibilityComWin( |
| + GetOwner()->PlatformGetChild(GetOwner()->PlatformChildCount() - 1)) |
| + ->NewReference(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_previousSibling( |
| ISimpleDOMNode** node) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PREVIOUS_SIBLING); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!node) |
| return E_INVALIDARG; |
| - if (!PlatformGetParent() || GetIndexInParent() <= 0) { |
| + if (!GetOwner()->PlatformGetParent() || GetIndexInParent() <= 0) { |
| *node = NULL; |
| return S_FALSE; |
| } |
| - *node = ToBrowserAccessibilityWin( |
| - PlatformGetParent()->InternalGetChild(GetIndexInParent() - 1)) |
| + *node = ToBrowserAccessibilityComWin( |
| + GetOwner()->PlatformGetParent()->InternalGetChild( |
| + GetIndexInParent() - 1)) |
| ->NewReference(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_nextSibling( |
| + ISimpleDOMNode** node) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEXT_SIBLING); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!node) |
| return E_INVALIDARG; |
| - if (!PlatformGetParent() || GetIndexInParent() < 0 || |
| + if (!GetOwner()->PlatformGetParent() || GetIndexInParent() < 0 || |
| GetIndexInParent() >= |
| - static_cast<int>(PlatformGetParent()->InternalChildCount()) - 1) { |
| + static_cast<int>( |
| + GetOwner()->PlatformGetParent()->InternalChildCount()) - |
| + 1) { |
| *node = NULL; |
| return S_FALSE; |
| } |
| - *node = ToBrowserAccessibilityWin( |
| - PlatformGetParent()->InternalGetChild(GetIndexInParent() + 1)) |
| + *node = ToBrowserAccessibilityComWin( |
| + GetOwner()->PlatformGetParent()->InternalGetChild( |
| + GetIndexInParent() + 1)) |
| ->NewReference(); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_childAt( |
| - unsigned int child_index, |
| - ISimpleDOMNode** node) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_childAt(unsigned int child_index, |
| + ISimpleDOMNode** node) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_AT); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!node) |
| return E_INVALIDARG; |
| - if (child_index >= PlatformChildCount()) |
| + if (child_index >= GetOwner()->PlatformChildCount()) |
| return E_INVALIDARG; |
| - BrowserAccessibility* child = PlatformGetChild(child_index); |
| + BrowserAccessibility* child = GetOwner()->PlatformGetChild(child_index); |
| if (!child) { |
| *node = NULL; |
| return S_FALSE; |
| } |
| - *node = ToBrowserAccessibilityWin(child)->NewReference(); |
| + *node = ToBrowserAccessibilityComWin(child)->NewReference(); |
| return S_OK; |
| } |
| // We only support this method for retrieving MathML content. |
| -STDMETHODIMP BrowserAccessibilityWin::get_innerHTML(BSTR* innerHTML) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_innerHTML(BSTR* innerHTML) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INNER_HTML); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (GetRole() != ui::AX_ROLE_MATH) |
| - return E_NOTIMPL; |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| + if (GetOwner()->GetRole() != ui::AX_ROLE_MATH) |
| + return E_NOTIMPL; |
| - base::string16 inner_html = GetString16Attribute(ui::AX_ATTR_INNER_HTML); |
| + base::string16 inner_html = |
| + GetOwner()->GetString16Attribute(ui::AX_ATTR_INNER_HTML); |
| *innerHTML = SysAllocString(inner_html.c_str()); |
| DCHECK(*innerHTML); |
| return S_OK; |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::get_localInterface(void** local_interface) { |
| +BrowserAccessibilityComWin::get_localInterface(void** local_interface) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCAL_INTERFACE); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_language(BSTR* language) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_language(BSTR* language) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LANGUAGE); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| if (!language) |
| return E_INVALIDARG; |
| *language = nullptr; |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| - base::string16 lang = GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE); |
| + base::string16 lang = |
| + GetOwner()->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE); |
| if (lang.empty()) |
| lang = L"en-US"; |
| @@ -3299,20 +3384,19 @@ STDMETHODIMP BrowserAccessibilityWin::get_language(BSTR* language) { |
| // ISimpleDOMText methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_domText(BSTR* dom_text) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DOM_TEXT); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!dom_text) |
| return E_INVALIDARG; |
| - return GetStringAttributeAsBstr( |
| - ui::AX_ATTR_NAME, dom_text); |
| + return GetStringAttributeAsBstr(ui::AX_ATTR_NAME, dom_text); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_clippedSubstringBounds( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_clippedSubstringBounds( |
| unsigned int start_index, |
| unsigned int end_index, |
| int* out_x, |
| @@ -3324,11 +3408,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_clippedSubstringBounds( |
| AccessibilityMode::kInlineTextBoxes); |
| // TODO(dmazzoni): fully support this API by intersecting the |
| // rect with the container's rect. |
| - return get_unclippedSubstringBounds( |
| - start_index, end_index, out_x, out_y, out_width, out_height); |
| + return get_unclippedSubstringBounds(start_index, end_index, out_x, out_y, |
| + out_width, out_height); |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_unclippedSubstringBounds( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_unclippedSubstringBounds( |
| unsigned int start_index, |
| unsigned int end_index, |
| int* out_x, |
| @@ -3338,20 +3422,21 @@ STDMETHODIMP BrowserAccessibilityWin::get_unclippedSubstringBounds( |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNCLIPPED_SUBSTRING_BOUNDS); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| AccessibilityMode::kInlineTextBoxes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (!out_x || !out_y || !out_width || !out_height) |
| return E_INVALIDARG; |
| - unsigned int text_length = static_cast<unsigned int>(GetText().size()); |
| + unsigned int text_length = |
| + static_cast<unsigned int>(GetOwner()->GetText().size()); |
| if (start_index > text_length || end_index > text_length || |
| start_index > end_index) { |
| return E_INVALIDARG; |
| } |
| - gfx::Rect bounds = GetScreenBoundsForRange( |
| - start_index, end_index - start_index); |
| + gfx::Rect bounds = |
| + GetOwner()->GetScreenBoundsForRange(start_index, end_index - start_index); |
| *out_x = bounds.x(); |
| *out_y = bounds.y(); |
| *out_width = bounds.width(); |
| @@ -3359,39 +3444,45 @@ STDMETHODIMP BrowserAccessibilityWin::get_unclippedSubstringBounds( |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring( |
| +STDMETHODIMP BrowserAccessibilityComWin::scrollToSubstring( |
| unsigned int start_index, |
| unsigned int end_index) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_SUBSTRING); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| AccessibilityMode::kInlineTextBoxes); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| - unsigned int text_length = static_cast<unsigned int>(GetText().size()); |
| + auto* manager = GetOwner()->manager(); |
| + if (!manager) |
| + return E_FAIL; |
| + |
| + unsigned int text_length = |
| + static_cast<unsigned int>(GetOwner()->GetText().size()); |
| if (start_index > text_length || end_index > text_length || |
| start_index > end_index) { |
| return E_INVALIDARG; |
| } |
| - manager_->ScrollToMakeVisible( |
| - *this, GetPageBoundsForRange(start_index, end_index - start_index)); |
| + manager->ScrollToMakeVisible( |
| + *GetOwner(), |
| + GetOwner()->GetPageBoundsForRange(start_index, end_index - start_index)); |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_fontFamily(BSTR* font_family) { |
| +STDMETHODIMP BrowserAccessibilityComWin::get_fontFamily(BSTR* font_family) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FONT_FAMILY); |
| AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| if (!font_family) |
| return E_INVALIDARG; |
| *font_family = nullptr; |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| base::string16 family = |
| - GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY); |
| + GetOwner()->GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY); |
| if (family.empty()) |
| return S_FALSE; |
| @@ -3404,26 +3495,25 @@ STDMETHODIMP BrowserAccessibilityWin::get_fontFamily(BSTR* font_family) { |
| // IServiceProvider methods. |
| // |
| -STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guid_service, |
| - REFIID riid, |
| - void** object) { |
| +STDMETHODIMP BrowserAccessibilityComWin::QueryService(REFGUID guid_service, |
| + REFIID riid, |
| + void** object) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_QUERY_SERVICE); |
| - if (!instance_active()) |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return E_FAIL; |
| if (guid_service == GUID_IAccessibleContentDocument) { |
| // Special Mozilla extension: return the accessible for the root document. |
| // Screen readers use this to distinguish between a document loaded event |
| // on the root document vs on an iframe. |
| - BrowserAccessibility* node = this; |
| + BrowserAccessibility* node = GetOwner(); |
| while (node->PlatformGetParent()) |
| node = node->PlatformGetParent()->manager()->GetRoot(); |
| - return ToBrowserAccessibilityWin(node)->QueryInterface( |
| - IID_IAccessible2, object); |
| + return ToBrowserAccessibilityComWin(node)->QueryInterface(IID_IAccessible2, |
| + object); |
| } |
| - if (guid_service == IID_IAccessible || |
| - guid_service == IID_IAccessible2 || |
| + if (guid_service == IID_IAccessible || guid_service == IID_IAccessible2 || |
| guid_service == IID_IAccessibleAction || |
| guid_service == IID_IAccessibleApplication || |
| guid_service == IID_IAccessibleHyperlink || |
| @@ -3436,8 +3526,7 @@ STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guid_service, |
| guid_service == IID_IAccessibleValue || |
| guid_service == IID_ISimpleDOMDocument || |
| guid_service == IID_ISimpleDOMNode || |
| - guid_service == IID_ISimpleDOMText || |
| - guid_service == GUID_ISimpleDOM) { |
| + guid_service == IID_ISimpleDOMText || guid_service == GUID_ISimpleDOM) { |
| return QueryInterface(riid, object); |
| } |
| @@ -3455,52 +3544,61 @@ STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guid_service, |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::GetObjectForChild(long child_id, IAccessibleEx** ret) { |
| +BrowserAccessibilityComWin::GetObjectForChild(long child_id, |
| + IAccessibleEx** ret) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OBJECT_FOR_CHILD); |
| return E_NOTIMPL; |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::GetIAccessiblePair(IAccessible** acc, long* child_id) { |
| +BrowserAccessibilityComWin::GetIAccessiblePair(IAccessible** acc, |
| + long* child_id) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IACCESSIBLE_PAIR); |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::GetRuntimeId(SAFEARRAY** runtime_id) { |
| +STDMETHODIMP BrowserAccessibilityComWin::GetRuntimeId(SAFEARRAY** runtime_id) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RUNTIME_ID); |
| return E_NOTIMPL; |
| } |
| STDMETHODIMP |
| -BrowserAccessibilityWin::ConvertReturnedElement( |
| +BrowserAccessibilityComWin::ConvertReturnedElement( |
| IRawElementProviderSimple* element, |
| IAccessibleEx** acc) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_CONVERT_RETURNED_ELEMENT); |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider(PATTERNID id, |
| - IUnknown** provider) { |
| +STDMETHODIMP BrowserAccessibilityComWin::GetPatternProvider( |
| + PATTERNID id, |
| + IUnknown** provider) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PATTERN_PROVIDER); |
| DVLOG(1) << "In Function: " << __func__ << " for pattern id: " << id; |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { |
| - if (HasState(ui::AX_STATE_EDITABLE)) { |
| + if (GetOwner()->HasState(ui::AX_STATE_EDITABLE)) { |
| DVLOG(1) << "Returning UIA text provider"; |
| - base::win::UIATextProvider::CreateTextProvider( |
| - GetValueText(), true, provider); |
| + base::win::UIATextProvider::CreateTextProvider(GetValueText(), true, |
| + provider); |
| return S_OK; |
| } |
| } |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::GetPropertyValue(PROPERTYID id, |
| - VARIANT* ret) { |
| +STDMETHODIMP BrowserAccessibilityComWin::GetPropertyValue(PROPERTYID id, |
| + VARIANT* ret) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PROPERTY_VALUE); |
| DVLOG(1) << "In Function: " << __func__ << " for property id: " << id; |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| + |
| V_VT(ret) = VT_EMPTY; |
| if (id == UIA_ControlTypePropertyId) { |
| - if (HasState(ui::AX_STATE_EDITABLE)) { |
| + if (GetOwner()->HasState(ui::AX_STATE_EDITABLE)) { |
| V_VT(ret) = VT_I4; |
| ret->lVal = UIA_EditControlTypeId; |
| DVLOG(1) << "Returning Edit control type"; |
| @@ -3511,13 +3609,13 @@ STDMETHODIMP BrowserAccessibilityWin::GetPropertyValue(PROPERTYID id, |
| return S_OK; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_ProviderOptions( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_ProviderOptions( |
| ProviderOptions* ret) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PROVIDER_OPTIONS); |
| return E_NOTIMPL; |
| } |
| -STDMETHODIMP BrowserAccessibilityWin::get_HostRawElementProvider( |
| +STDMETHODIMP BrowserAccessibilityComWin::get_HostRawElementProvider( |
| IRawElementProviderSimple** provider) { |
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HOST_RAW_ELEMENT_PROVIDER); |
| return E_NOTIMPL; |
| @@ -3528,13 +3626,13 @@ STDMETHODIMP BrowserAccessibilityWin::get_HostRawElementProvider( |
| // |
| // static |
| -HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( |
| +HRESULT WINAPI BrowserAccessibilityComWin::InternalQueryInterface( |
| void* this_ptr, |
| const _ATL_INTMAP_ENTRY* entries, |
| REFIID iid, |
| void** object) { |
| - BrowserAccessibilityWin* accessibility = |
| - reinterpret_cast<BrowserAccessibilityWin*>(this_ptr); |
| + BrowserAccessibilityComWin* accessibility = |
| + reinterpret_cast<BrowserAccessibilityComWin*>(this_ptr); |
| int32_t ia_role = accessibility->ia_role(); |
| if (iid == IID_IAccessibleImage) { |
| if (ia_role != ROLE_SYSTEM_GRAPHIC) { |
| @@ -3547,14 +3645,13 @@ HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( |
| return E_NOINTERFACE; |
| } |
| } else if (iid == IID_IAccessibleTableCell) { |
| - if (!accessibility->IsCellOrTableHeaderRole()) { |
| + if (!accessibility->GetOwner()->IsCellOrTableHeaderRole()) { |
| *object = NULL; |
| return E_NOINTERFACE; |
| } |
| } else if (iid == IID_IAccessibleValue) { |
| if (ia_role != ROLE_SYSTEM_PROGRESSBAR && |
| - ia_role != ROLE_SYSTEM_SCROLLBAR && |
| - ia_role != ROLE_SYSTEM_SLIDER) { |
| + ia_role != ROLE_SYSTEM_SCROLLBAR && ia_role != ROLE_SYSTEM_SLIDER) { |
| *object = NULL; |
| return E_NOINTERFACE; |
| } |
| @@ -3565,23 +3662,23 @@ HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( |
| } |
| } else if (iid == IID_IAccessibleHyperlink) { |
| auto* ax_object = |
| - reinterpret_cast<const BrowserAccessibilityWin*>(this_ptr); |
| + reinterpret_cast<const BrowserAccessibilityComWin*>(this_ptr); |
| if (!ax_object || !ax_object->IsHyperlink()) { |
| *object = nullptr; |
| return E_NOINTERFACE; |
| } |
| } |
| - return CComObjectRootBase::InternalQueryInterface( |
| - this_ptr, entries, iid, object); |
| + return CComObjectRootBase::InternalQueryInterface(this_ptr, entries, iid, |
| + object); |
| } |
| -void BrowserAccessibilityWin::ComputeStylesIfNeeded() { |
| +void BrowserAccessibilityComWin::ComputeStylesIfNeeded() { |
| if (!offset_to_text_attributes().empty()) |
| return; |
| std::map<int, std::vector<base::string16>> attributes_map; |
| - if (PlatformIsLeaf() || IsSimpleTextControl()) { |
| + if (GetOwner()->PlatformIsLeaf() || GetOwner()->IsSimpleTextControl()) { |
| attributes_map[0] = ComputeTextAttributes(); |
| std::map<int, std::vector<base::string16>> spelling_attributes = |
| GetSpellingAttributes(); |
| @@ -3612,8 +3709,8 @@ void BrowserAccessibilityWin::ComputeStylesIfNeeded() { |
| } |
| int start_offset = 0; |
| - for (size_t i = 0; i < PlatformChildCount(); ++i) { |
| - auto* child = ToBrowserAccessibilityWin(PlatformGetChild(i)); |
| + for (size_t i = 0; i < GetOwner()->PlatformChildCount(); ++i) { |
| + auto* child = ToBrowserAccessibilityComWin(GetOwner()->PlatformGetChild(i)); |
| DCHECK(child); |
| std::vector<base::string16> attributes(child->ComputeTextAttributes()); |
| @@ -3630,8 +3727,8 @@ void BrowserAccessibilityWin::ComputeStylesIfNeeded() { |
| } |
| } |
| - if (child->IsTextOnlyObject()) |
| - start_offset += child->GetText().length(); |
| + if (child->GetOwner()->IsTextOnlyObject()) |
| + start_offset += child->GetOwner()->GetText().length(); |
| else |
| start_offset += 1; |
| } |
| @@ -3642,19 +3739,20 @@ void BrowserAccessibilityWin::ComputeStylesIfNeeded() { |
| // |offset| could either be a text character or a child index in case of |
| // non-text objects. |
| // TODO(nektar): Remove this function once selection bugs are fixed in Blink. |
| -BrowserAccessibilityWin::AXPlatformPositionInstance |
| -BrowserAccessibilityWin::CreatePositionForSelectionAt(int offset) const { |
| - if (!IsNativeTextControl() && !IsTextOnlyObject()) { |
| - DCHECK(manager_); |
| - const BrowserAccessibilityWin* child = this; |
| +AXPlatformPosition::AXPositionInstance |
| +BrowserAccessibilityComWin::CreatePositionForSelectionAt(int offset) const { |
| + if (!GetOwner()->IsNativeTextControl() && !GetOwner()->IsTextOnlyObject()) { |
| + auto* manager = GetOwner()->manager(); |
| + DCHECK(manager); |
| + const BrowserAccessibilityComWin* child = this; |
| // TODO(nektar): Make parents of text-only objects not include the text of |
| // children in their hypertext. |
| - for (size_t i = 0; i < InternalChildCount(); ++i) { |
| + for (size_t i = 0; i < GetOwner()->InternalChildCount(); ++i) { |
| int new_offset = offset; |
| - child = ToBrowserAccessibilityWin(InternalGetChild(i)); |
| + child = ToBrowserAccessibilityComWin(GetOwner()->InternalGetChild(i)); |
| DCHECK(child); |
| - if (child->IsTextOnlyObject()) { |
| - new_offset -= child->GetText().length(); |
| + if (child->GetOwner()->IsTextOnlyObject()) { |
| + new_offset -= child->GetOwner()->GetText().length(); |
| } else { |
| new_offset -= 1; |
| } |
| @@ -3663,9 +3761,9 @@ BrowserAccessibilityWin::CreatePositionForSelectionAt(int offset) const { |
| offset = new_offset; |
| } |
| AXPlatformPositionInstance position = |
| - AXPlatformPosition::CreateTextPosition(manager_->ax_tree_id(), |
| - child->GetId(), offset, |
| - ui::AX_TEXT_AFFINITY_DOWNSTREAM) |
| + AXPlatformPosition::CreateTextPosition( |
| + manager->ax_tree_id(), child->GetOwner()->GetId(), offset, |
| + ui::AX_TEXT_AFFINITY_DOWNSTREAM) |
| ->AsLeafTextPosition(); |
| if (position->GetAnchor() && |
| position->GetAnchor()->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) { |
| @@ -3673,20 +3771,14 @@ BrowserAccessibilityWin::CreatePositionForSelectionAt(int offset) const { |
| } |
| return position; |
| } |
| - return CreatePositionAt(offset); |
| -} |
| - |
| -base::string16 BrowserAccessibilityWin::GetText() const { |
| - if (PlatformIsChildOfLeaf()) |
| - return BrowserAccessibility::GetText(); |
| - return win_attributes_->hypertext; |
| + return GetOwner()->CreatePositionAt(offset); |
| } |
| // |
| // Private methods. |
| // |
| -void BrowserAccessibilityWin::UpdateStep1ComputeWinAttributes() { |
| +void BrowserAccessibilityComWin::UpdateStep1ComputeWinAttributes() { |
| // Swap win_attributes_ to old_win_attributes_, allowing us to see |
| // exactly what changed and fire appropriate events. Note that |
| // old_win_attributes_ is cleared at the end of UpdateStep3FireEvents. |
| @@ -3729,25 +3821,23 @@ void BrowserAccessibilityWin::UpdateStep1ComputeWinAttributes() { |
| BoolAttributeToIA2(ui::AX_ATTR_LIVE_BUSY, "busy"); |
| // Expose container live region attributes. |
| - StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_STATUS, |
| - "container-live"); |
| + StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_STATUS, "container-live"); |
| StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_RELEVANT, |
| "container-relevant"); |
| - BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC, |
| - "container-atomic"); |
| - BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY, |
| - "container-busy"); |
| + BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC, "container-atomic"); |
| + BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY, "container-busy"); |
| // Expose the non-standard explicit-name IA2 attribute. |
| int name_from; |
| - if (GetIntAttribute(ui::AX_ATTR_NAME_FROM, &name_from) && |
| + if (GetOwner()->GetIntAttribute(ui::AX_ATTR_NAME_FROM, &name_from) && |
| name_from != ui::AX_NAME_FROM_CONTENTS) { |
| win_attributes_->ia2_attributes.push_back(L"explicit-name:true"); |
| } |
| // Expose the aria-current attribute. |
| int32_t aria_current_state; |
| - if (GetIntAttribute(ui::AX_ATTR_ARIA_CURRENT_STATE, &aria_current_state)) { |
| + if (GetOwner()->GetIntAttribute(ui::AX_ATTR_ARIA_CURRENT_STATE, |
| + &aria_current_state)) { |
| switch (static_cast<ui::AXAriaCurrentState>(aria_current_state)) { |
| case ui::AX_ARIA_CURRENT_STATE_NONE: |
| break; |
| @@ -3776,15 +3866,15 @@ void BrowserAccessibilityWin::UpdateStep1ComputeWinAttributes() { |
| } |
| // Expose table cell index. |
| - if (IsCellOrTableHeaderRole()) { |
| - BrowserAccessibility* table = PlatformGetParent(); |
| + if (GetOwner()->IsCellOrTableHeaderRole()) { |
| + BrowserAccessibility* table = GetOwner()->PlatformGetParent(); |
| while (table && !table->IsTableLikeRole()) |
| table = table->PlatformGetParent(); |
| if (table) { |
| const std::vector<int32_t>& unique_cell_ids = |
| table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
| for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |
| - if (unique_cell_ids[i] == GetId()) { |
| + if (unique_cell_ids[i] == GetOwner()->GetId()) { |
| win_attributes_->ia2_attributes.push_back( |
| base::string16(L"table-cell-index:") + base::IntToString16(i)); |
| } |
| @@ -3793,14 +3883,15 @@ void BrowserAccessibilityWin::UpdateStep1ComputeWinAttributes() { |
| } |
| // Expose aria-colcount and aria-rowcount in a table, grid or treegrid. |
| - if (IsTableLikeRole()) { |
| + if (GetOwner()->IsTableLikeRole()) { |
| IntAttributeToIA2(ui::AX_ATTR_ARIA_COLUMN_COUNT, "colcount"); |
| IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_COUNT, "rowcount"); |
| } |
| // Expose aria-colindex and aria-rowindex in a cell or row. |
| - if (IsCellOrTableHeaderRole() || GetRole() == ui::AX_ROLE_ROW) { |
| - if (GetRole() != ui::AX_ROLE_ROW) |
| + if (GetOwner()->IsCellOrTableHeaderRole() || |
| + GetOwner()->GetRole() == ui::AX_ROLE_ROW) { |
| + if (GetOwner()->GetRole() != ui::AX_ROLE_ROW) |
| IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, "colindex"); |
| IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, "rowindex"); |
| } |
| @@ -3808,8 +3899,9 @@ void BrowserAccessibilityWin::UpdateStep1ComputeWinAttributes() { |
| // Expose row or column header sort direction. |
| int32_t sort_direction; |
| if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || |
| - ia_role() == ROLE_SYSTEM_ROWHEADER) && |
| - GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, &sort_direction)) { |
| + ia_role() == ROLE_SYSTEM_ROWHEADER) && |
| + GetOwner()->GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, |
| + &sort_direction)) { |
| switch (static_cast<ui::AXSortDirection>(sort_direction)) { |
| case ui::AX_SORT_DIRECTION_NONE: |
| break; |
| @@ -3828,20 +3920,21 @@ void BrowserAccessibilityWin::UpdateStep1ComputeWinAttributes() { |
| } |
| } |
| - win_attributes_->name = GetString16Attribute(ui::AX_ATTR_NAME); |
| - win_attributes_->description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); |
| + win_attributes_->name = GetOwner()->GetString16Attribute(ui::AX_ATTR_NAME); |
| + win_attributes_->description = |
| + GetOwner()->GetString16Attribute(ui::AX_ATTR_DESCRIPTION); |
| StringAttributeToIA2(ui::AX_ATTR_PLACEHOLDER, "placeholder"); |
| - base::string16 value = GetValue(); |
| + base::string16 value = GetOwner()->GetValue(); |
| // On Windows, the value of a document should be its url. |
| - if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || |
| - GetRole() == ui::AX_ROLE_WEB_AREA) { |
| - value = base::UTF8ToUTF16(manager_->GetTreeData().url); |
| + if (GetOwner()->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || |
| + GetOwner()->GetRole() == ui::AX_ROLE_WEB_AREA) { |
| + value = base::UTF8ToUTF16(GetOwner()->manager()->GetTreeData().url); |
| } |
| // If this doesn't have a value and is linked then set its value to the url |
| // attribute. This allows screen readers to read an empty link's destination. |
| if (value.empty() && (ia_state() & STATE_SYSTEM_LINKED)) |
| - value = GetString16Attribute(ui::AX_ATTR_URL); |
| + value = GetOwner()->GetString16Attribute(ui::AX_ATTR_URL); |
| win_attributes_->value = value; |
| ClearOwnRelations(); |
| @@ -3859,17 +3952,17 @@ void BrowserAccessibilityWin::UpdateStep1ComputeWinAttributes() { |
| ui::AX_ATTR_DETAILS_IDS); |
| int member_of_id; |
| - if (GetIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, &member_of_id)) |
| + if (GetOwner()->GetIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, &member_of_id)) |
| AddRelation(IA2_RELATION_MEMBER_OF, member_of_id); |
| int error_message_id; |
| - if (GetIntAttribute(ui::AX_ATTR_ERRORMESSAGE_ID, &error_message_id)) |
| + if (GetOwner()->GetIntAttribute(ui::AX_ATTR_ERRORMESSAGE_ID, |
| + &error_message_id)) |
| AddRelation(IA2_RELATION_ERROR_MESSAGE, error_message_id); |
| // Expose slider value. |
| if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || |
| - ia_role() == ROLE_SYSTEM_SCROLLBAR || |
| - ia_role() == ROLE_SYSTEM_SLIDER) { |
| + ia_role() == ROLE_SYSTEM_SCROLLBAR || ia_role() == ROLE_SYSTEM_SLIDER) { |
| base::string16 value_text = GetValueText(); |
| SanitizeStringAttributeForIA2(value_text, &value_text); |
| win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text); |
| @@ -3879,20 +3972,20 @@ void BrowserAccessibilityWin::UpdateStep1ComputeWinAttributes() { |
| // If this is a web area for a presentational iframe, give it a role of |
| // something other than DOCUMENT so that the fact that it's a separate doc |
| // is not exposed to AT. |
| - if (IsWebAreaForPresentationalIframe()) { |
| + if (GetOwner()->IsWebAreaForPresentationalIframe()) { |
| win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; |
| win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; |
| } |
| } |
| -void BrowserAccessibilityWin::UpdateStep2ComputeHypertext() { |
| - if (IsSimpleTextControl()) { |
| +void BrowserAccessibilityComWin::UpdateStep2ComputeHypertext() { |
| + if (GetOwner()->IsSimpleTextControl()) { |
| win_attributes_->hypertext = value(); |
| return; |
| } |
| - if (!PlatformChildCount()) { |
| - if (IsRichTextControl()) { |
| + if (!GetOwner()->PlatformChildCount()) { |
| + if (GetOwner()->IsRichTextControl()) { |
| // We don't want to expose any associated label in IA2 Hypertext. |
| return; |
| } |
| @@ -3905,15 +3998,15 @@ void BrowserAccessibilityWin::UpdateStep2ComputeHypertext() { |
| // embedded object character for all the other children. Build up a map from |
| // the character index of each embedded object character to the id of the |
| // child object it points to. |
| - for (unsigned int i = 0; i < PlatformChildCount(); ++i) { |
| - auto* child = ToBrowserAccessibilityWin(PlatformGetChild(i)); |
| + for (unsigned int i = 0; i < GetOwner()->PlatformChildCount(); ++i) { |
| + auto* child = ToBrowserAccessibilityComWin(GetOwner()->PlatformGetChild(i)); |
| DCHECK(child); |
| // Similar to Firefox, we don't expose text-only objects in IA2 hypertext. |
| - if (child->IsTextOnlyObject()) { |
| + if (child->GetOwner()->IsTextOnlyObject()) { |
| win_attributes_->hypertext += child->name(); |
| } else { |
| - int32_t char_offset = static_cast<int32_t>(GetText().size()); |
| - int32_t child_unique_id = child->unique_id(); |
| + int32_t char_offset = static_cast<int32_t>(GetOwner()->GetText().size()); |
| + int32_t child_unique_id = child->GetOwner()->unique_id(); |
| int32_t index = hyperlinks().size(); |
| win_attributes_->hyperlink_offset_to_index[char_offset] = index; |
| win_attributes_->hyperlinks.push_back(child_unique_id); |
| @@ -3922,7 +4015,8 @@ void BrowserAccessibilityWin::UpdateStep2ComputeHypertext() { |
| } |
| } |
| -void BrowserAccessibilityWin::UpdateStep3FireEvents(bool is_subtree_creation) { |
| +void BrowserAccessibilityComWin::UpdateStep3FireEvents( |
| + bool is_subtree_creation) { |
| // Fire an event when a new subtree is created. |
| if (is_subtree_creation) |
| FireNativeEvent(EVENT_OBJECT_SHOW); |
| @@ -3946,8 +4040,9 @@ void BrowserAccessibilityWin::UpdateStep3FireEvents(bool is_subtree_creation) { |
| (old_win_attributes_->ia_state & STATE_SYSTEM_SELECTED) != 0; |
| if (is_selected_now || was_selected_before) { |
| bool multiselect = false; |
| - if (PlatformGetParent() && |
| - PlatformGetParent()->HasState(ui::AX_STATE_MULTISELECTABLE)) |
| + if (GetOwner()->PlatformGetParent() && |
| + GetOwner()->PlatformGetParent()->HasState( |
| + ui::AX_STATE_MULTISELECTABLE)) |
| multiselect = true; |
| if (multiselect) { |
| @@ -3966,8 +4061,8 @@ void BrowserAccessibilityWin::UpdateStep3FireEvents(bool is_subtree_creation) { |
| // Fire an event if this container object has scrolled. |
| int sx = 0; |
| int sy = 0; |
| - if (GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && |
| - GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { |
| + if (GetOwner()->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && |
| + GetOwner()->GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { |
| if (sx != previous_scroll_x_ || sy != previous_scroll_y_) |
| FireNativeEvent(EVENT_SYSTEM_SCROLLINGEND); |
| previous_scroll_x_ = sx; |
| @@ -3990,58 +4085,32 @@ void BrowserAccessibilityWin::UpdateStep3FireEvents(bool is_subtree_creation) { |
| // Changing a static text node can affect the IAccessibleText hypertext |
| // of the parent node, so force an update on the parent. |
| - BrowserAccessibilityWin* parent = |
| - ToBrowserAccessibilityWin(PlatformGetParent()); |
| - if (parent && IsTextOnlyObject() && |
| + BrowserAccessibilityComWin* parent = |
| + ToBrowserAccessibilityComWin(GetOwner()->PlatformGetParent()); |
| + if (parent && GetOwner()->IsTextOnlyObject() && |
| name() != old_win_attributes_->name) { |
| - parent->UpdatePlatformAttributes(); |
| + parent->GetOwner()->UpdatePlatformAttributes(); |
| } |
| } |
| old_win_attributes_.reset(nullptr); |
| } |
| -void BrowserAccessibilityWin::UpdatePlatformAttributes() { |
| - UpdateStep1ComputeWinAttributes(); |
| - UpdateStep2ComputeHypertext(); |
| - UpdateStep3FireEvents(false); |
| -} |
| - |
| -void BrowserAccessibilityWin::OnSubtreeWillBeDeleted() { |
| - FireNativeEvent(EVENT_OBJECT_HIDE); |
| -} |
| - |
| -void BrowserAccessibilityWin::NativeAddReference() { |
| - AddRef(); |
| -} |
| - |
| -void BrowserAccessibilityWin::NativeReleaseReference() { |
| - Release(); |
| -} |
| - |
| -bool BrowserAccessibilityWin::IsNative() const { |
| - return true; |
| -} |
| - |
| -void BrowserAccessibilityWin::OnLocationChanged() { |
| - FireNativeEvent(EVENT_OBJECT_LOCATIONCHANGE); |
| -} |
| - |
| -std::vector<base::string16> BrowserAccessibilityWin::ComputeTextAttributes() |
| +std::vector<base::string16> BrowserAccessibilityComWin::ComputeTextAttributes() |
| const { |
| std::vector<base::string16> attributes; |
| // We include list markers for now, but there might be other objects that are |
| // auto generated. |
| // TODO(nektar): Compute what objects are auto-generated in Blink. |
| - if (GetRole() == ui::AX_ROLE_LIST_MARKER) |
| + if (GetOwner()->GetRole() == ui::AX_ROLE_LIST_MARKER) |
| attributes.push_back(L"auto-generated:true"); |
| else |
| attributes.push_back(L"auto-generated:false"); |
| int color; |
| base::string16 color_value(L"transparent"); |
| - if (GetIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, &color)) { |
| + if (GetOwner()->GetIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, &color)) { |
| unsigned int alpha = SkColorGetA(color); |
| unsigned int red = SkColorGetR(color); |
| unsigned int green = SkColorGetG(color); |
| @@ -4055,7 +4124,7 @@ std::vector<base::string16> BrowserAccessibilityWin::ComputeTextAttributes() |
| SanitizeStringAttributeForIA2(color_value, &color_value); |
| attributes.push_back(L"background-color:" + color_value); |
| - if (GetIntAttribute(ui::AX_ATTR_COLOR, &color)) { |
| + if (GetOwner()->GetIntAttribute(ui::AX_ATTR_COLOR, &color)) { |
| unsigned int red = SkColorGetR(color); |
| unsigned int green = SkColorGetG(color); |
| unsigned int blue = SkColorGetB(color); |
| @@ -4069,7 +4138,7 @@ std::vector<base::string16> BrowserAccessibilityWin::ComputeTextAttributes() |
| attributes.push_back(L"color:" + color_value); |
| base::string16 font_family( |
| - GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY)); |
| + GetOwner()->GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY)); |
| // Attribute has no default value. |
| if (!font_family.empty()) { |
| SanitizeStringAttributeForIA2(font_family, &font_family); |
| @@ -4089,8 +4158,8 @@ std::vector<base::string16> BrowserAccessibilityWin::ComputeTextAttributes() |
| L"pt"); |
| } |
| - auto text_style = |
| - static_cast<ui::AXTextStyle>(GetIntAttribute(ui::AX_ATTR_TEXT_STYLE)); |
| + auto text_style = static_cast<ui::AXTextStyle>( |
| + GetOwner()->GetIntAttribute(ui::AX_ATTR_TEXT_STYLE)); |
| if (text_style == ui::AX_TEXT_STYLE_NONE) { |
| attributes.push_back(L"font-style:normal"); |
| attributes.push_back(L"font-weight:normal"); |
| @@ -4109,7 +4178,7 @@ std::vector<base::string16> BrowserAccessibilityWin::ComputeTextAttributes() |
| } |
| auto invalid_state = static_cast<ui::AXInvalidState>( |
| - GetIntAttribute(ui::AX_ATTR_INVALID_STATE)); |
| + GetOwner()->GetIntAttribute(ui::AX_ATTR_INVALID_STATE)); |
| switch (invalid_state) { |
| case ui::AX_INVALID_STATE_NONE: |
| case ui::AX_INVALID_STATE_FALSE: |
| @@ -4132,8 +4201,8 @@ std::vector<base::string16> BrowserAccessibilityWin::ComputeTextAttributes() |
| } |
| case ui::AX_INVALID_STATE_OTHER: { |
| base::string16 aria_invalid_value; |
| - if (GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, |
| - &aria_invalid_value)) { |
| + if (GetOwner()->GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, |
| + &aria_invalid_value)) { |
| SanitizeStringAttributeForIA2(aria_invalid_value, &aria_invalid_value); |
| attributes.push_back(L"invalid:" + aria_invalid_value); |
| } else { |
| @@ -4144,7 +4213,8 @@ std::vector<base::string16> BrowserAccessibilityWin::ComputeTextAttributes() |
| } |
| } |
| - base::string16 language(GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE)); |
| + base::string16 language( |
| + GetOwner()->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE)); |
| // Default value should be L"en-US". |
| if (language.empty()) { |
| attributes.push_back(L"language:en-US"); |
| @@ -4186,7 +4256,7 @@ std::vector<base::string16> BrowserAccessibilityWin::ComputeTextAttributes() |
| attributes.push_back(L"text-underline-width:auto"); |
| auto text_direction = static_cast<ui::AXTextDirection>( |
| - GetIntAttribute(ui::AX_ATTR_TEXT_DIRECTION)); |
| + GetOwner()->GetIntAttribute(ui::AX_ATTR_TEXT_DIRECTION)); |
| switch (text_direction) { |
| case ui::AX_TEXT_DIRECTION_NONE: |
| case ui::AX_TEXT_DIRECTION_LTR: |
| @@ -4207,21 +4277,21 @@ std::vector<base::string16> BrowserAccessibilityWin::ComputeTextAttributes() |
| return attributes; |
| } |
| -BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { |
| +BrowserAccessibilityComWin* BrowserAccessibilityComWin::NewReference() { |
| AddRef(); |
| return this; |
| } |
| std::map<int, std::vector<base::string16>> |
| -BrowserAccessibilityWin::GetSpellingAttributes() const { |
| +BrowserAccessibilityComWin::GetSpellingAttributes() { |
| std::map<int, std::vector<base::string16>> spelling_attributes; |
| - if (IsTextOnlyObject()) { |
| + if (GetOwner()->IsTextOnlyObject()) { |
| const std::vector<int32_t>& marker_types = |
| - GetIntListAttribute(ui::AX_ATTR_MARKER_TYPES); |
| + GetOwner()->GetIntListAttribute(ui::AX_ATTR_MARKER_TYPES); |
| const std::vector<int>& marker_starts = |
| - GetIntListAttribute(ui::AX_ATTR_MARKER_STARTS); |
| + GetOwner()->GetIntListAttribute(ui::AX_ATTR_MARKER_STARTS); |
| const std::vector<int>& marker_ends = |
| - GetIntListAttribute(ui::AX_ATTR_MARKER_ENDS); |
| + GetOwner()->GetIntListAttribute(ui::AX_ATTR_MARKER_ENDS); |
| for (size_t i = 0; i < marker_types.size(); ++i) { |
| if (!(static_cast<ui::AXMarkerType>(marker_types[i]) & |
| ui::AX_MARKER_TYPE_SPELLING)) |
| @@ -4236,13 +4306,13 @@ BrowserAccessibilityWin::GetSpellingAttributes() const { |
| spelling_attributes[end_offset] = end_attributes; |
| } |
| } |
| - if (IsSimpleTextControl()) { |
| + if (GetOwner()->IsSimpleTextControl()) { |
| int start_offset = 0; |
| - for (const BrowserAccessibility* static_text = |
| + for (BrowserAccessibility* static_text = |
| BrowserAccessibilityManager::NextTextOnlyObject( |
| - InternalGetChild(0)); |
| + GetOwner()->InternalGetChild(0)); |
| static_text; static_text = static_text->GetNextSibling()) { |
| - auto* text_win = ToBrowserAccessibilityWin(static_text); |
| + auto* text_win = ToBrowserAccessibilityComWin(static_text); |
| if (text_win) { |
| std::map<int, std::vector<base::string16>> text_spelling_attributes = |
| text_win->GetSpellingAttributes(); |
| @@ -4250,15 +4320,19 @@ BrowserAccessibilityWin::GetSpellingAttributes() const { |
| spelling_attributes[start_offset + attribute.first] = |
| std::move(attribute.second); |
| } |
| - start_offset += static_cast<int>(text_win->GetText().length()); |
| + start_offset += |
| + static_cast<int>(text_win->GetOwner()->GetText().length()); |
| } |
| } |
| } |
| return spelling_attributes; |
| } |
| -BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( |
| +BrowserAccessibilityComWin* BrowserAccessibilityComWin::GetTargetFromChildID( |
| const VARIANT& var_id) { |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return nullptr; |
| + |
| if (var_id.vt != VT_I4) |
| return nullptr; |
| @@ -4266,23 +4340,27 @@ BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( |
| if (child_id == CHILDID_SELF) |
| return this; |
| - if (child_id >= 1 && child_id <= static_cast<LONG>(PlatformChildCount())) |
| - return ToBrowserAccessibilityWin(PlatformGetChild(child_id - 1)); |
| + if (child_id >= 1 && |
| + child_id <= static_cast<LONG>(GetOwner()->PlatformChildCount())) |
| + return ToBrowserAccessibilityComWin( |
| + GetOwner()->PlatformGetChild(child_id - 1)); |
| - BrowserAccessibilityWin* child = ToBrowserAccessibilityWin( |
| + BrowserAccessibilityComWin* child = ToBrowserAccessibilityComWin( |
| BrowserAccessibility::GetFromUniqueID(-child_id)); |
| - if (child && child->IsDescendantOf(this)) |
| + if (child && child->GetOwner()->IsDescendantOf(GetOwner())) |
| return child; |
| return nullptr; |
| } |
| -HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( |
| +HRESULT BrowserAccessibilityComWin::GetStringAttributeAsBstr( |
| ui::AXStringAttribute attribute, |
| BSTR* value_bstr) { |
| base::string16 str; |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| + return E_FAIL; |
| - if (!GetString16Attribute(attribute, &str)) |
| + if (!GetOwner()->GetString16Attribute(attribute, &str)) |
| return S_FALSE; |
| *value_bstr = SysAllocString(str.c_str()); |
| @@ -4292,7 +4370,7 @@ HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( |
| } |
| // Static |
| -void BrowserAccessibilityWin::SanitizeStringAttributeForIA2( |
| +void BrowserAccessibilityComWin::SanitizeStringAttributeForIA2( |
| const base::string16& input, |
| base::string16* output) { |
| DCHECK(output); |
| @@ -4306,57 +4384,54 @@ void BrowserAccessibilityWin::SanitizeStringAttributeForIA2( |
| base::ReplaceChars(*output, L";", L"\\;", output); |
| } |
| -void BrowserAccessibilityWin::SetIA2HypertextSelection(LONG start_offset, |
| - LONG end_offset) { |
| +void BrowserAccessibilityComWin::SetIA2HypertextSelection(LONG start_offset, |
| + LONG end_offset) { |
| HandleSpecialTextOffset(&start_offset); |
| HandleSpecialTextOffset(&end_offset); |
| AXPlatformPositionInstance start_position = |
| CreatePositionForSelectionAt(static_cast<int>(start_offset)); |
| AXPlatformPositionInstance end_position = |
| CreatePositionForSelectionAt(static_cast<int>(end_offset)); |
| - manager_->SetSelection(AXPlatformRange(start_position->AsTextPosition(), |
| - end_position->AsTextPosition())); |
| + GetOwner()->manager()->SetSelection(AXPlatformRange( |
| + start_position->AsTextPosition(), end_position->AsTextPosition())); |
| } |
| -void BrowserAccessibilityWin::StringAttributeToIA2( |
| +void BrowserAccessibilityComWin::StringAttributeToIA2( |
| ui::AXStringAttribute attribute, |
| const char* ia2_attr) { |
| base::string16 value; |
| - if (GetString16Attribute(attribute, &value)) { |
| + if (GetOwner()->GetString16Attribute(attribute, &value)) { |
| SanitizeStringAttributeForIA2(value, &value); |
| - win_attributes_->ia2_attributes.push_back( |
| - base::ASCIIToUTF16(ia2_attr) + L":" + value); |
| + win_attributes_->ia2_attributes.push_back(base::ASCIIToUTF16(ia2_attr) + |
| + L":" + value); |
| } |
| } |
| -void BrowserAccessibilityWin::BoolAttributeToIA2( |
| +void BrowserAccessibilityComWin::BoolAttributeToIA2( |
| ui::AXBoolAttribute attribute, |
| const char* ia2_attr) { |
| bool value; |
| - if (GetBoolAttribute(attribute, &value)) { |
| + if (GetOwner()->GetBoolAttribute(attribute, &value)) { |
| win_attributes_->ia2_attributes.push_back( |
| - (base::ASCIIToUTF16(ia2_attr) + L":") + |
| - (value ? L"true" : L"false")); |
| + (base::ASCIIToUTF16(ia2_attr) + L":") + (value ? L"true" : L"false")); |
| } |
| } |
| -void BrowserAccessibilityWin::IntAttributeToIA2( |
| - ui::AXIntAttribute attribute, |
| - const char* ia2_attr) { |
| +void BrowserAccessibilityComWin::IntAttributeToIA2(ui::AXIntAttribute attribute, |
| + const char* ia2_attr) { |
| int value; |
| - if (GetIntAttribute(attribute, &value)) { |
| + if (GetOwner()->GetIntAttribute(attribute, &value)) { |
| win_attributes_->ia2_attributes.push_back( |
| - base::ASCIIToUTF16(ia2_attr) + L":" + |
| - base::IntToString16(value)); |
| + base::ASCIIToUTF16(ia2_attr) + L":" + base::IntToString16(value)); |
| } |
| } |
| -bool BrowserAccessibilityWin::IsHyperlink() const { |
| +bool BrowserAccessibilityComWin::IsHyperlink() const { |
| int32_t hyperlink_index = -1; |
| - auto* parent = PlatformGetParent(); |
| + auto* parent = GetOwner()->PlatformGetParent(); |
| if (parent) { |
| hyperlink_index = |
| - ToBrowserAccessibilityWin(parent)->GetHyperlinkIndexFromChild(*this); |
| + ToBrowserAccessibilityComWin(parent)->GetHyperlinkIndexFromChild(*this); |
| } |
| if (hyperlink_index >= 0) |
| @@ -4364,8 +4439,8 @@ bool BrowserAccessibilityWin::IsHyperlink() const { |
| return false; |
| } |
| -BrowserAccessibilityWin* |
| -BrowserAccessibilityWin::GetHyperlinkFromHypertextOffset(int offset) const { |
| +BrowserAccessibilityComWin* |
| +BrowserAccessibilityComWin::GetHyperlinkFromHypertextOffset(int offset) const { |
| std::map<int32_t, int32_t>::iterator iterator = |
| hyperlink_offset_to_index().find(offset); |
| if (iterator == hyperlink_offset_to_index().end()) |
| @@ -4375,27 +4450,27 @@ BrowserAccessibilityWin::GetHyperlinkFromHypertextOffset(int offset) const { |
| DCHECK_GE(index, 0); |
| DCHECK_LT(index, static_cast<int32_t>(hyperlinks().size())); |
| int32_t id = hyperlinks()[index]; |
| - BrowserAccessibilityWin* hyperlink = |
| - ToBrowserAccessibilityWin(GetFromUniqueID(id)); |
| + BrowserAccessibilityComWin* hyperlink = |
| + ToBrowserAccessibilityComWin(GetOwner()->GetFromUniqueID(id)); |
| if (!hyperlink) |
| return nullptr; |
| return hyperlink; |
| } |
| -int32_t BrowserAccessibilityWin::GetHyperlinkIndexFromChild( |
| - const BrowserAccessibilityWin& child) const { |
| +int32_t BrowserAccessibilityComWin::GetHyperlinkIndexFromChild( |
| + const BrowserAccessibilityComWin& child) const { |
| if (hyperlinks().empty()) |
| return -1; |
| - auto iterator = |
| - std::find(hyperlinks().begin(), hyperlinks().end(), child.unique_id()); |
| + auto iterator = std::find(hyperlinks().begin(), hyperlinks().end(), |
| + child.GetOwner()->unique_id()); |
| if (iterator == hyperlinks().end()) |
| return -1; |
| return static_cast<int32_t>(iterator - hyperlinks().begin()); |
| } |
| -int32_t BrowserAccessibilityWin::GetHypertextOffsetFromHyperlinkIndex( |
| +int32_t BrowserAccessibilityComWin::GetHypertextOffsetFromHyperlinkIndex( |
| int32_t hyperlink_index) const { |
| for (auto& offset_index : hyperlink_offset_to_index()) { |
| if (offset_index.second == hyperlink_index) |
| @@ -4405,26 +4480,27 @@ int32_t BrowserAccessibilityWin::GetHypertextOffsetFromHyperlinkIndex( |
| return -1; |
| } |
| -int32_t BrowserAccessibilityWin::GetHypertextOffsetFromChild( |
| - const BrowserAccessibilityWin& child) const { |
| - DCHECK(child.PlatformGetParent() == this); |
| +int32_t BrowserAccessibilityComWin::GetHypertextOffsetFromChild( |
| + BrowserAccessibilityComWin& child) { |
| + DCHECK(child.GetOwner()->PlatformGetParent() == GetOwner()); |
| // Handle the case when we are dealing with a direct text-only child. |
| // (Note that this object might be a platform leaf, e.g. an ARIA searchbox, |
| - // and so |InternalChild...| functions need to be used. Also, direct text-only |
| - // children should not be present at tree roots and so no cross-tree traversal |
| - // is necessary.) |
| - if (child.IsTextOnlyObject()) { |
| + // and so |GetOwner()->InternalChild...| functions need to be used. Also, |
| + // direct text-only children should not be present at tree roots and so no |
| + // cross-tree traversal is necessary.) |
| + if (child.GetOwner()->IsTextOnlyObject()) { |
| int32_t hypertextOffset = 0; |
| int32_t index_in_parent = child.GetIndexInParent(); |
| DCHECK_GE(index_in_parent, 0); |
| - DCHECK_LT(index_in_parent, static_cast<int32_t>(InternalChildCount())); |
| + DCHECK_LT(index_in_parent, |
| + static_cast<int32_t>(GetOwner()->InternalChildCount())); |
| for (uint32_t i = 0; i < static_cast<uint32_t>(index_in_parent); ++i) { |
| - const BrowserAccessibilityWin* sibling = |
| - ToBrowserAccessibilityWin(InternalGetChild(i)); |
| + const BrowserAccessibilityComWin* sibling = |
| + ToBrowserAccessibilityComWin(GetOwner()->InternalGetChild(i)); |
| DCHECK(sibling); |
| - if (sibling->IsTextOnlyObject()) |
| - hypertextOffset += sibling->GetText().size(); |
| + if (sibling->GetOwner()->IsTextOnlyObject()) |
| + hypertextOffset += sibling->GetOwner()->GetText().size(); |
| else |
| ++hypertextOffset; |
| } |
| @@ -4438,15 +4514,15 @@ int32_t BrowserAccessibilityWin::GetHypertextOffsetFromChild( |
| return GetHypertextOffsetFromHyperlinkIndex(hyperlink_index); |
| } |
| -int32_t BrowserAccessibilityWin::GetHypertextOffsetFromDescendant( |
| - const BrowserAccessibilityWin& descendant) const { |
| +int32_t BrowserAccessibilityComWin::GetHypertextOffsetFromDescendant( |
| + const BrowserAccessibilityComWin& descendant) const { |
| auto* parent_object = |
| - ToBrowserAccessibilityWin(descendant.PlatformGetParent()); |
| - auto* current_object = const_cast<BrowserAccessibilityWin*>(&descendant); |
| + ToBrowserAccessibilityComWin(descendant.GetOwner()->PlatformGetParent()); |
| + auto* current_object = const_cast<BrowserAccessibilityComWin*>(&descendant); |
| while (parent_object && parent_object != this) { |
| current_object = parent_object; |
| - parent_object = |
| - ToBrowserAccessibilityWin(current_object->PlatformGetParent()); |
| + parent_object = ToBrowserAccessibilityComWin( |
| + current_object->GetOwner()->PlatformGetParent()); |
| } |
| if (!parent_object) |
| return -1; |
| @@ -4454,8 +4530,8 @@ int32_t BrowserAccessibilityWin::GetHypertextOffsetFromDescendant( |
| return parent_object->GetHypertextOffsetFromChild(*current_object); |
| } |
| -int BrowserAccessibilityWin::GetHypertextOffsetFromEndpoint( |
| - const BrowserAccessibilityWin& endpoint_object, |
| +int BrowserAccessibilityComWin::GetHypertextOffsetFromEndpoint( |
| + const BrowserAccessibilityComWin& endpoint_object, |
| int endpoint_offset) const { |
| // There are three cases: |
| // 1. Either the selection endpoint is inside this object or is an ancestor of |
| @@ -4470,12 +4546,13 @@ int BrowserAccessibilityWin::GetHypertextOffsetFromEndpoint( |
| // Case 1. |
| // |
| // IsDescendantOf includes the case when endpoint_object == this. |
| - if (IsDescendantOf(&endpoint_object)) |
| + if (GetOwner()->IsDescendantOf(endpoint_object.GetOwner())) |
| return endpoint_offset; |
| - const BrowserAccessibility* common_parent = this; |
| - int32_t index_in_common_parent = GetIndexInParent(); |
| - while (common_parent && !endpoint_object.IsDescendantOf(common_parent)) { |
| + const BrowserAccessibility* common_parent = GetOwner(); |
| + int32_t index_in_common_parent = GetOwner()->GetIndexInParent(); |
| + while (common_parent && |
| + !endpoint_object.GetOwner()->IsDescendantOf(common_parent)) { |
| index_in_common_parent = common_parent->GetIndexInParent(); |
| common_parent = common_parent->PlatformGetParent(); |
| } |
| @@ -4490,11 +4567,11 @@ int BrowserAccessibilityWin::GetHypertextOffsetFromEndpoint( |
| // We already checked in case 1 if our endpoint is inside this object. |
| // We can safely assume that it is a descendant or in a completely different |
| // part of the tree. |
| - if (common_parent == this) { |
| + if (common_parent == GetOwner()) { |
| int32_t hypertext_offset = |
| GetHypertextOffsetFromDescendant(endpoint_object); |
| - if (endpoint_object.PlatformGetParent() == this && |
| - endpoint_object.IsTextOnlyObject()) { |
| + if (endpoint_object.GetOwner()->PlatformGetParent() == GetOwner() && |
| + endpoint_object.GetOwner()->IsTextOnlyObject()) { |
| hypertext_offset += endpoint_offset; |
| } |
| @@ -4509,7 +4586,7 @@ int BrowserAccessibilityWin::GetHypertextOffsetFromEndpoint( |
| for (uint32_t i = 0; i < common_parent->InternalChildCount(); ++i) { |
| const BrowserAccessibility* child = common_parent->InternalGetChild(i); |
| DCHECK(child); |
| - if (endpoint_object.IsDescendantOf(child)) { |
| + if (endpoint_object.GetOwner()->IsDescendantOf(child)) { |
| endpoint_index_in_common_parent = child->GetIndexInParent(); |
| break; |
| } |
| @@ -4519,39 +4596,40 @@ int BrowserAccessibilityWin::GetHypertextOffsetFromEndpoint( |
| if (endpoint_index_in_common_parent < index_in_common_parent) |
| return 0; |
| if (endpoint_index_in_common_parent > index_in_common_parent) |
| - return GetText().size(); |
| + return GetOwner()->GetText().size(); |
| NOTREACHED(); |
| return -1; |
| } |
| -int BrowserAccessibilityWin::GetSelectionAnchor() const { |
| - int32_t anchor_id = manager_->GetTreeData().sel_anchor_object_id; |
| - const BrowserAccessibilityWin* anchor_object = GetFromID(anchor_id); |
| +int BrowserAccessibilityComWin::GetSelectionAnchor() const { |
| + int32_t anchor_id = GetOwner()->manager()->GetTreeData().sel_anchor_object_id; |
| + const BrowserAccessibilityComWin* anchor_object = GetFromID(anchor_id); |
| if (!anchor_object) |
| return -1; |
| - int anchor_offset = manager_->GetTreeData().sel_anchor_offset; |
| + int anchor_offset = GetOwner()->manager()->GetTreeData().sel_anchor_offset; |
| return GetHypertextOffsetFromEndpoint(*anchor_object, anchor_offset); |
| } |
| -int BrowserAccessibilityWin::GetSelectionFocus() const { |
| - int32_t focus_id = manager_->GetTreeData().sel_focus_object_id; |
| - const BrowserAccessibilityWin* focus_object = GetFromID(focus_id); |
| +int BrowserAccessibilityComWin::GetSelectionFocus() const { |
| + int32_t focus_id = GetOwner()->manager()->GetTreeData().sel_focus_object_id; |
| + const BrowserAccessibilityComWin* focus_object = GetFromID(focus_id); |
| if (!focus_object) |
| return -1; |
| - int focus_offset = manager_->GetTreeData().sel_focus_offset; |
| + int focus_offset = GetOwner()->manager()->GetTreeData().sel_focus_offset; |
| return GetHypertextOffsetFromEndpoint(*focus_object, focus_offset); |
| } |
| -void BrowserAccessibilityWin::GetSelectionOffsets( |
| - int* selection_start, int* selection_end) const { |
| +void BrowserAccessibilityComWin::GetSelectionOffsets(int* selection_start, |
| + int* selection_end) const { |
| DCHECK(selection_start && selection_end); |
| - if (IsSimpleTextControl() && |
| - GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, selection_start) && |
| - GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, selection_end)) { |
| + if (GetOwner()->IsSimpleTextControl() && |
| + GetOwner()->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, |
| + selection_start) && |
| + GetOwner()->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, selection_end)) { |
| return; |
| } |
| @@ -4572,7 +4650,7 @@ void BrowserAccessibilityWin::GetSelectionOffsets( |
| // outside this object in their entirety. |
| // Selections that span more than one character are by definition inside this |
| // object, so checking them is not necessary. |
| - if (*selection_start == *selection_end && !HasCaret()) { |
| + if (*selection_start == *selection_end && !GetOwner()->HasCaret()) { |
| *selection_start = -1; |
| *selection_end = -1; |
| return; |
| @@ -4586,7 +4664,7 @@ void BrowserAccessibilityWin::GetSelectionOffsets( |
| // the selection. |
| int* largest_offset = |
| (*selection_start <= *selection_end) ? selection_end : selection_start; |
| - BrowserAccessibilityWin* hyperlink = |
| + BrowserAccessibilityComWin* hyperlink = |
| GetHyperlinkFromHypertextOffset(*largest_offset); |
| if (!hyperlink) |
| return; |
| @@ -4598,19 +4676,19 @@ void BrowserAccessibilityWin::GetSelectionOffsets( |
| ++(*largest_offset); |
| } |
| -base::string16 BrowserAccessibilityWin::GetValueText() { |
| +base::string16 BrowserAccessibilityComWin::GetValueText() { |
| float fval; |
| - base::string16 value = this->value(); |
| + base::string16 result = value(); |
| - if (value.empty() && |
| - GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) { |
| - value = base::UTF8ToUTF16(base::DoubleToString(fval)); |
| + if (result.empty() && GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) { |
| + result = base::UTF8ToUTF16(base::DoubleToString(fval)); |
| } |
| - return value; |
| + return result; |
| } |
| -bool BrowserAccessibilityWin::IsSameHypertextCharacter(size_t old_char_index, |
| - size_t new_char_index) { |
| +bool BrowserAccessibilityComWin::IsSameHypertextCharacter( |
| + size_t old_char_index, |
| + size_t new_char_index) { |
| CHECK(old_win_attributes_); |
| // For anything other than the "embedded character", we just compare the |
| @@ -4631,8 +4709,9 @@ bool BrowserAccessibilityWin::IsSameHypertextCharacter(size_t old_char_index, |
| std::map<int32_t, int32_t>::iterator iter; |
| iter = old_offset_to_index.find(old_char_index); |
| int old_index = (iter != old_offset_to_index.end()) ? iter->second : -1; |
| - int old_child_id = (old_index >= 0 && old_index < old_hyperlinks_count) ? |
| - old_hyperlinks[old_index] : -1; |
| + int old_child_id = (old_index >= 0 && old_index < old_hyperlinks_count) |
| + ? old_hyperlinks[old_index] |
| + : -1; |
| std::map<int32_t, int32_t>& new_offset_to_index = |
| win_attributes_->hyperlink_offset_to_index; |
| @@ -4640,14 +4719,17 @@ bool BrowserAccessibilityWin::IsSameHypertextCharacter(size_t old_char_index, |
| int32_t new_hyperlinks_count = static_cast<int32_t>(new_hyperlinks.size()); |
| iter = new_offset_to_index.find(new_char_index); |
| int new_index = (iter != new_offset_to_index.end()) ? iter->second : -1; |
| - int new_child_id = (new_index >= 0 && new_index < new_hyperlinks_count) ? |
| - new_hyperlinks[new_index] : -1; |
| + int new_child_id = (new_index >= 0 && new_index < new_hyperlinks_count) |
| + ? new_hyperlinks[new_index] |
| + : -1; |
| return old_child_id == new_child_id; |
| } |
| -void BrowserAccessibilityWin::ComputeHypertextRemovedAndInserted( |
| - int* start, int* old_len, int* new_len) { |
| +void BrowserAccessibilityComWin::ComputeHypertextRemovedAndInserted( |
| + int* start, |
| + int* old_len, |
| + int* new_len) { |
| CHECK(old_win_attributes_); |
| *start = 0; |
| @@ -4655,11 +4737,10 @@ void BrowserAccessibilityWin::ComputeHypertextRemovedAndInserted( |
| *new_len = 0; |
| const base::string16& old_text = old_win_attributes_->hypertext; |
| - const base::string16& new_text = GetText(); |
| + const base::string16& new_text = GetOwner()->GetText(); |
| size_t common_prefix = 0; |
| - while (common_prefix < old_text.size() && |
| - common_prefix < new_text.size() && |
| + while (common_prefix < old_text.size() && common_prefix < new_text.size() && |
| IsSameHypertextCharacter(common_prefix, common_prefix)) { |
| ++common_prefix; |
| } |
| @@ -4667,9 +4748,8 @@ void BrowserAccessibilityWin::ComputeHypertextRemovedAndInserted( |
| size_t common_suffix = 0; |
| while (common_prefix + common_suffix < old_text.size() && |
| common_prefix + common_suffix < new_text.size() && |
| - IsSameHypertextCharacter( |
| - old_text.size() - common_suffix - 1, |
| - new_text.size() - common_suffix - 1)) { |
| + IsSameHypertextCharacter(old_text.size() - common_suffix - 1, |
| + new_text.size() - common_suffix - 1)) { |
| ++common_suffix; |
| } |
| @@ -4678,9 +4758,9 @@ void BrowserAccessibilityWin::ComputeHypertextRemovedAndInserted( |
| *new_len = new_text.size() - common_prefix - common_suffix; |
| } |
| -void BrowserAccessibilityWin::HandleSpecialTextOffset(LONG* offset) { |
| +void BrowserAccessibilityComWin::HandleSpecialTextOffset(LONG* offset) { |
| if (*offset == IA2_TEXT_OFFSET_LENGTH) { |
| - *offset = static_cast<LONG>(GetText().length()); |
| + *offset = static_cast<LONG>(GetOwner()->GetText().length()); |
| } else if (*offset == IA2_TEXT_OFFSET_CARET) { |
| // We shouldn't call |get_caretOffset| here as it affects UMA counts. |
| int selection_start, selection_end; |
| @@ -4689,9 +4769,9 @@ void BrowserAccessibilityWin::HandleSpecialTextOffset(LONG* offset) { |
| } |
| } |
| -ui::TextBoundaryType BrowserAccessibilityWin::IA2TextBoundaryToTextBoundary( |
| +ui::TextBoundaryType BrowserAccessibilityComWin::IA2TextBoundaryToTextBoundary( |
| IA2TextBoundaryType ia2_boundary) { |
| - switch(ia2_boundary) { |
| + switch (ia2_boundary) { |
| case IA2_TEXT_BOUNDARY_CHAR: |
| return ui::CHAR_BOUNDARY; |
| case IA2_TEXT_BOUNDARY_WORD: |
| @@ -4709,36 +4789,37 @@ ui::TextBoundaryType BrowserAccessibilityWin::IA2TextBoundaryToTextBoundary( |
| return ui::CHAR_BOUNDARY; |
| } |
| -LONG BrowserAccessibilityWin::FindBoundary( |
| +LONG BrowserAccessibilityComWin::FindBoundary( |
| const base::string16& text, |
| IA2TextBoundaryType ia2_boundary, |
| LONG start_offset, |
| ui::TextBoundaryDirection direction) { |
| // If the boundary is relative to the caret, use the selection |
| // affinity, otherwise default to downstream affinity. |
| - ui::AXTextAffinity affinity = start_offset == IA2_TEXT_OFFSET_CARET |
| - ? manager_->GetTreeData().sel_focus_affinity |
| - : ui::AX_TEXT_AFFINITY_DOWNSTREAM; |
| + ui::AXTextAffinity affinity = |
| + start_offset == IA2_TEXT_OFFSET_CARET |
| + ? GetOwner()->manager()->GetTreeData().sel_focus_affinity |
| + : ui::AX_TEXT_AFFINITY_DOWNSTREAM; |
| HandleSpecialTextOffset(&start_offset); |
| if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD) { |
| switch (direction) { |
| case ui::FORWARDS_DIRECTION: { |
| - AXPlatformPositionInstance position = |
| - CreatePositionAt(static_cast<int>(start_offset), affinity); |
| + AXPlatformPositionInstance position = GetOwner()->CreatePositionAt( |
| + static_cast<int>(start_offset), affinity); |
| AXPlatformPositionInstance next_word = |
| position->CreateNextWordStartPosition(); |
| - if (next_word->anchor_id() != GetId()) |
| + if (next_word->anchor_id() != GetOwner()->GetId()) |
| next_word = position->CreatePositionAtEndOfAnchor(); |
| return next_word->text_offset(); |
| } |
| case ui::BACKWARDS_DIRECTION: { |
| - AXPlatformPositionInstance position = |
| - CreatePositionAt(static_cast<int>(start_offset), affinity); |
| + AXPlatformPositionInstance position = GetOwner()->CreatePositionAt( |
| + static_cast<int>(start_offset), affinity); |
| AXPlatformPositionInstance previous_word; |
| if (!position->AtStartOfWord()) { |
| previous_word = position->CreatePreviousWordStartPosition(); |
| - if (previous_word->anchor_id() != GetId()) |
| + if (previous_word->anchor_id() != GetOwner()->GetId()) |
| previous_word = position->CreatePositionAtStartOfAnchor(); |
| } else { |
| previous_word = std::move(position); |
| @@ -4751,21 +4832,21 @@ LONG BrowserAccessibilityWin::FindBoundary( |
| if (ia2_boundary == IA2_TEXT_BOUNDARY_LINE) { |
| switch (direction) { |
| case ui::FORWARDS_DIRECTION: { |
| - AXPlatformPositionInstance position = |
| - CreatePositionAt(static_cast<int>(start_offset), affinity); |
| + AXPlatformPositionInstance position = GetOwner()->CreatePositionAt( |
| + static_cast<int>(start_offset), affinity); |
| AXPlatformPositionInstance next_line = |
| position->CreateNextLineStartPosition(); |
| - if (next_line->anchor_id() != GetId()) |
| + if (next_line->anchor_id() != GetOwner()->GetId()) |
| next_line = position->CreatePositionAtEndOfAnchor(); |
| return next_line->text_offset(); |
| } |
| case ui::BACKWARDS_DIRECTION: { |
| - AXPlatformPositionInstance position = |
| - CreatePositionAt(static_cast<int>(start_offset), affinity); |
| + AXPlatformPositionInstance position = GetOwner()->CreatePositionAt( |
| + static_cast<int>(start_offset), affinity); |
| AXPlatformPositionInstance previous_line; |
| if (!position->AtStartOfLine()) { |
| previous_line = position->CreatePreviousLineStartPosition(); |
| - if (previous_line->anchor_id() != GetId()) |
| + if (previous_line->anchor_id() != GetOwner()->GetId()) |
| previous_line = position->CreatePositionAtStartOfAnchor(); |
| } else { |
| previous_line = std::move(position); |
| @@ -4777,14 +4858,15 @@ LONG BrowserAccessibilityWin::FindBoundary( |
| // TODO(nektar): |AXPosition| can handle other types of boundaries as well. |
| ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); |
| - return ui::FindAccessibleTextBoundary(text, GetLineStartOffsets(), boundary, |
| - start_offset, direction, affinity); |
| + return ui::FindAccessibleTextBoundary(text, GetOwner()->GetLineStartOffsets(), |
| + boundary, start_offset, direction, |
| + affinity); |
| } |
| -LONG BrowserAccessibilityWin::FindStartOfStyle( |
| +LONG BrowserAccessibilityComWin::FindStartOfStyle( |
| LONG start_offset, |
| ui::TextBoundaryDirection direction) const { |
| - LONG text_length = static_cast<LONG>(GetText().length()); |
| + LONG text_length = static_cast<LONG>(GetOwner()->GetText().length()); |
| DCHECK_GE(start_offset, 0); |
| DCHECK_LE(start_offset, text_length); |
| @@ -4810,18 +4892,19 @@ LONG BrowserAccessibilityWin::FindStartOfStyle( |
| return start_offset; |
| } |
| -BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32_t id) const { |
| - if (!instance_active()) |
| +BrowserAccessibilityComWin* BrowserAccessibilityComWin::GetFromID( |
| + int32_t id) const { |
| + if (!GetOwner() || !GetOwner()->instance_active()) |
| return nullptr; |
| - return ToBrowserAccessibilityWin(manager_->GetFromID(id)); |
| + return ToBrowserAccessibilityComWin(GetOwner()->manager()->GetFromID(id)); |
| } |
| -bool BrowserAccessibilityWin::IsListBoxOptionOrMenuListOption() { |
| - if (!PlatformGetParent()) |
| +bool BrowserAccessibilityComWin::IsListBoxOptionOrMenuListOption() { |
| + if (!GetOwner()->PlatformGetParent()) |
| return false; |
| - int32_t role = GetRole(); |
| - int32_t parent_role = PlatformGetParent()->GetRole(); |
| + int32_t role = GetOwner()->GetRole(); |
| + int32_t parent_role = GetOwner()->PlatformGetParent()->GetRole(); |
| if (role == ui::AX_ROLE_LIST_BOX_OPTION && |
| parent_role == ui::AX_ROLE_LIST_BOX) { |
| @@ -4836,10 +4919,11 @@ bool BrowserAccessibilityWin::IsListBoxOptionOrMenuListOption() { |
| return false; |
| } |
| -void BrowserAccessibilityWin::AddRelation(const base::string16& relation_type, |
| - int target_id) { |
| +void BrowserAccessibilityComWin::AddRelation( |
| + const base::string16& relation_type, |
| + int target_id) { |
| // Reflexive relations don't need to be exposed through IA2. |
| - if (target_id == GetId()) |
| + if (target_id == GetOwner()->GetId()) |
| return; |
| CComObject<BrowserAccessibilityRelation>* relation; |
| @@ -4852,17 +4936,18 @@ void BrowserAccessibilityWin::AddRelation(const base::string16& relation_type, |
| relations_.push_back(relation); |
| } |
| -void BrowserAccessibilityWin::AddBidirectionalRelations( |
| +void BrowserAccessibilityComWin::AddBidirectionalRelations( |
| const base::string16& relation_type, |
| const base::string16& reverse_relation_type, |
| ui::AXIntListAttribute attribute) { |
| - if (!HasIntListAttribute(attribute)) |
| + if (!GetOwner()->HasIntListAttribute(attribute)) |
| return; |
| - const std::vector<int32_t>& target_ids = GetIntListAttribute(attribute); |
| + const std::vector<int32_t>& target_ids = |
| + GetOwner()->GetIntListAttribute(attribute); |
| // Reflexive relations don't need to be exposed through IA2. |
| std::vector<int32_t> filtered_target_ids; |
| - int32_t current_id = GetId(); |
| + int32_t current_id = GetOwner()->GetId(); |
| std::copy_if(target_ids.begin(), target_ids.end(), |
| std::back_inserter(filtered_target_ids), |
| [current_id](int32_t id) { return id != current_id; }); |
| @@ -4877,12 +4962,12 @@ void BrowserAccessibilityWin::AddBidirectionalRelations( |
| relation->Initialize(this, relation_type); |
| for (int target_id : filtered_target_ids) { |
| - BrowserAccessibilityWin* target = |
| + BrowserAccessibilityComWin* target = |
| GetFromID(static_cast<int32_t>(target_id)); |
| - if (!target || !target->instance_active()) |
| + if (!target || !target->GetOwner()->instance_active()) |
| continue; |
| relation->AddTarget(target_id); |
| - target->AddRelation(reverse_relation_type, GetId()); |
| + target->AddRelation(reverse_relation_type, GetOwner()->GetId()); |
| } |
| relations_.push_back(relation); |
| @@ -4891,7 +4976,7 @@ void BrowserAccessibilityWin::AddBidirectionalRelations( |
| // Clears all the forward relations from this object to any other object and the |
| // associated reverse relations on the other objects, but leaves any reverse |
| // relations on this object alone. |
| -void BrowserAccessibilityWin::ClearOwnRelations() { |
| +void BrowserAccessibilityComWin::ClearOwnRelations() { |
| RemoveBidirectionalRelationsOfType(IA2_RELATION_CONTROLLER_FOR, |
| IA2_RELATION_CONTROLLED_BY); |
| RemoveBidirectionalRelationsOfType(IA2_RELATION_DESCRIBED_BY, |
| @@ -4913,7 +4998,7 @@ void BrowserAccessibilityWin::ClearOwnRelations() { |
| relations_.end()); |
| } |
| -void BrowserAccessibilityWin::RemoveBidirectionalRelationsOfType( |
| +void BrowserAccessibilityComWin::RemoveBidirectionalRelationsOfType( |
| const base::string16& relation_type, |
| const base::string16& reverse_relation_type) { |
| for (auto iter = relations_.begin(); iter != relations_.end();) { |
| @@ -4921,12 +5006,13 @@ void BrowserAccessibilityWin::RemoveBidirectionalRelationsOfType( |
| DCHECK(relation); |
| if (relation->get_type() == relation_type) { |
| for (int target_id : relation->get_target_ids()) { |
| - BrowserAccessibilityWin* target = |
| + BrowserAccessibilityComWin* target = |
| GetFromID(static_cast<int32_t>(target_id)); |
| - if (!target || !target->instance_active()) |
| + if (!target || !target->GetOwner()->instance_active()) |
| continue; |
| DCHECK_NE(target, this); |
| - target->RemoveTargetFromRelation(reverse_relation_type, GetId()); |
| + target->RemoveTargetFromRelation(reverse_relation_type, |
| + GetOwner()->GetId()); |
| } |
| iter = relations_.erase(iter); |
| relation->Release(); |
| @@ -4936,7 +5022,7 @@ void BrowserAccessibilityWin::RemoveBidirectionalRelationsOfType( |
| } |
| } |
| -void BrowserAccessibilityWin::RemoveTargetFromRelation( |
| +void BrowserAccessibilityComWin::RemoveTargetFromRelation( |
| const base::string16& relation_type, |
| int target_id) { |
| for (auto iter = relations_.begin(); iter != relations_.end();) { |
| @@ -4955,17 +5041,17 @@ void BrowserAccessibilityWin::RemoveTargetFromRelation( |
| } |
| } |
| -void BrowserAccessibilityWin::UpdateRequiredAttributes() { |
| - if (IsCellOrTableHeaderRole()) { |
| +void BrowserAccessibilityComWin::UpdateRequiredAttributes() { |
| + if (GetOwner()->IsCellOrTableHeaderRole()) { |
| // Expose colspan attribute. |
| base::string16 colspan; |
| - if (GetHtmlAttribute("aria-colspan", &colspan)) { |
| + if (GetOwner()->GetHtmlAttribute("aria-colspan", &colspan)) { |
| SanitizeStringAttributeForIA2(colspan, &colspan); |
| win_attributes_->ia2_attributes.push_back(L"colspan:" + colspan); |
| } |
| // Expose rowspan attribute. |
| base::string16 rowspan; |
| - if (GetHtmlAttribute("aria-rowspan", &rowspan)) { |
| + if (GetOwner()->GetHtmlAttribute("aria-rowspan", &rowspan)) { |
| SanitizeStringAttributeForIA2(rowspan, &rowspan); |
| win_attributes_->ia2_attributes.push_back(L"rowspan:" + rowspan); |
| } |
| @@ -4973,82 +5059,78 @@ void BrowserAccessibilityWin::UpdateRequiredAttributes() { |
| // Expose dropeffect attribute. |
| base::string16 drop_effect; |
| - if (GetHtmlAttribute("aria-dropeffect", &drop_effect)) { |
| + if (GetOwner()->GetHtmlAttribute("aria-dropeffect", &drop_effect)) { |
| SanitizeStringAttributeForIA2(drop_effect, &drop_effect); |
| win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect); |
| } |
| // Expose grabbed attribute. |
| base::string16 grabbed; |
| - if (GetHtmlAttribute("aria-grabbed", &grabbed)) { |
| + if (GetOwner()->GetHtmlAttribute("aria-grabbed", &grabbed)) { |
| SanitizeStringAttributeForIA2(grabbed, &grabbed); |
| win_attributes_->ia2_attributes.push_back(L"grabbed:" + grabbed); |
| } |
| // Expose class attribute. |
| base::string16 class_attr; |
| - if (GetHtmlAttribute("class", &class_attr)) { |
| + if (GetOwner()->GetHtmlAttribute("class", &class_attr)) { |
| SanitizeStringAttributeForIA2(class_attr, &class_attr); |
| win_attributes_->ia2_attributes.push_back(L"class:" + class_attr); |
| } |
| // Expose datetime attribute. |
| base::string16 datetime; |
| - if (GetRole() == ui::AX_ROLE_TIME && |
| - GetHtmlAttribute("datetime", &datetime)) { |
| + if (GetOwner()->GetRole() == ui::AX_ROLE_TIME && |
| + GetOwner()->GetHtmlAttribute("datetime", &datetime)) { |
| SanitizeStringAttributeForIA2(datetime, &datetime); |
| win_attributes_->ia2_attributes.push_back(L"datetime:" + datetime); |
| } |
| // Expose id attribute. |
| base::string16 id; |
| - if (GetHtmlAttribute("id", &id)) { |
| + if (GetOwner()->GetHtmlAttribute("id", &id)) { |
| SanitizeStringAttributeForIA2(id, &id); |
| win_attributes_->ia2_attributes.push_back(L"id:" + id); |
| } |
| // Expose src attribute. |
| base::string16 src; |
| - if (GetRole() == ui::AX_ROLE_IMAGE && GetHtmlAttribute("src", &src)) { |
| + if (GetOwner()->GetRole() == ui::AX_ROLE_IMAGE && |
| + GetOwner()->GetHtmlAttribute("src", &src)) { |
| SanitizeStringAttributeForIA2(src, &src); |
| win_attributes_->ia2_attributes.push_back(L"src:" + src); |
| } |
| // Expose input-text type attribute. |
| base::string16 type; |
| - base::string16 html_tag = GetString16Attribute(ui::AX_ATTR_HTML_TAG); |
| - if (IsSimpleTextControl() && html_tag == L"input" && |
| - GetHtmlAttribute("type", &type)) { |
| + base::string16 html_tag = |
| + GetOwner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); |
| + if (GetOwner()->IsSimpleTextControl() && html_tag == L"input" && |
| + GetOwner()->GetHtmlAttribute("type", &type)) { |
| SanitizeStringAttributeForIA2(type, &type); |
| win_attributes_->ia2_attributes.push_back(L"text-input-type:" + type); |
| } |
| } |
| -void BrowserAccessibilityWin::FireNativeEvent(LONG win_event_type) const { |
| - (new BrowserAccessibilityEventWin( |
| - BrowserAccessibilityEvent::FromTreeChange, |
| - ui::AX_EVENT_NONE, |
| - win_event_type, |
| - this))->Fire(); |
| -} |
| - |
| -ui::AXPlatformNodeWin* BrowserAccessibilityWin::GetPlatformNodeWin() const { |
| - DCHECK(platform_node_); |
| - return static_cast<ui::AXPlatformNodeWin*>(platform_node_); |
| +void BrowserAccessibilityComWin::FireNativeEvent(LONG win_event_type) const { |
| + (new BrowserAccessibilityEventWin(BrowserAccessibilityEvent::FromTreeChange, |
| + ui::AX_EVENT_NONE, win_event_type, |
| + GetOwner())) |
| + ->Fire(); |
| } |
| -void BrowserAccessibilityWin::InitRoleAndState() { |
| +void BrowserAccessibilityComWin::InitRoleAndState() { |
| int32_t ia_role = 0; |
| int32_t ia_state = 0; |
| base::string16 role_name; |
| int32_t ia2_role = 0; |
| int32_t ia2_state = IA2_STATE_OPAQUE; |
| - if (HasState(ui::AX_STATE_BUSY)) |
| + if (GetOwner()->HasState(ui::AX_STATE_BUSY)) |
| ia_state |= STATE_SYSTEM_BUSY; |
| const auto checked_state = static_cast<ui::AXCheckedState>( |
| - GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); |
| + GetOwner()->GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); |
| switch (checked_state) { |
| case ui::AX_CHECKED_STATE_TRUE: |
| ia_state |= STATE_SYSTEM_CHECKED; |
| @@ -5060,47 +5142,48 @@ void BrowserAccessibilityWin::InitRoleAndState() { |
| break; |
| } |
| - if (HasState(ui::AX_STATE_COLLAPSED)) |
| + if (GetOwner()->HasState(ui::AX_STATE_COLLAPSED)) |
| ia_state |= STATE_SYSTEM_COLLAPSED; |
| - if (HasState(ui::AX_STATE_EXPANDED)) |
| + if (GetOwner()->HasState(ui::AX_STATE_EXPANDED)) |
| ia_state |= STATE_SYSTEM_EXPANDED; |
| - if (HasState(ui::AX_STATE_FOCUSABLE)) |
| + if (GetOwner()->HasState(ui::AX_STATE_FOCUSABLE)) |
| ia_state |= STATE_SYSTEM_FOCUSABLE; |
| - if (HasState(ui::AX_STATE_HASPOPUP)) |
| + if (GetOwner()->HasState(ui::AX_STATE_HASPOPUP)) |
| ia_state |= STATE_SYSTEM_HASPOPUP; |
| - if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && |
| - GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != ui::AX_INVALID_STATE_FALSE) |
| + if (GetOwner()->HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && |
| + GetOwner()->GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != |
| + ui::AX_INVALID_STATE_FALSE) |
| ia2_state |= IA2_STATE_INVALID_ENTRY; |
| - if (HasState(ui::AX_STATE_INVISIBLE)) |
| + if (GetOwner()->HasState(ui::AX_STATE_INVISIBLE)) |
| ia_state |= STATE_SYSTEM_INVISIBLE; |
| - if (HasState(ui::AX_STATE_LINKED)) |
| + if (GetOwner()->HasState(ui::AX_STATE_LINKED)) |
| ia_state |= STATE_SYSTEM_LINKED; |
| - if (HasState(ui::AX_STATE_MULTISELECTABLE)) { |
| + if (GetOwner()->HasState(ui::AX_STATE_MULTISELECTABLE)) { |
| ia_state |= STATE_SYSTEM_EXTSELECTABLE; |
| ia_state |= STATE_SYSTEM_MULTISELECTABLE; |
| } |
| // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. |
| - if (HasState(ui::AX_STATE_OFFSCREEN)) |
| + if (GetOwner()->HasState(ui::AX_STATE_OFFSCREEN)) |
| ia_state |= STATE_SYSTEM_OFFSCREEN; |
| - if (HasState(ui::AX_STATE_PRESSED)) |
| + if (GetOwner()->HasState(ui::AX_STATE_PRESSED)) |
| ia_state |= STATE_SYSTEM_PRESSED; |
| - if (HasState(ui::AX_STATE_PROTECTED)) |
| + if (GetOwner()->HasState(ui::AX_STATE_PROTECTED)) |
| ia_state |= STATE_SYSTEM_PROTECTED; |
| - if (HasState(ui::AX_STATE_REQUIRED)) |
| + if (GetOwner()->HasState(ui::AX_STATE_REQUIRED)) |
| ia2_state |= IA2_STATE_REQUIRED; |
| - if (HasState(ui::AX_STATE_SELECTABLE)) |
| + if (GetOwner()->HasState(ui::AX_STATE_SELECTABLE)) |
| ia_state |= STATE_SYSTEM_SELECTABLE; |
| - if (HasState(ui::AX_STATE_SELECTED)) |
| + if (GetOwner()->HasState(ui::AX_STATE_SELECTED)) |
| ia_state |= STATE_SYSTEM_SELECTED; |
| - if (HasState(ui::AX_STATE_VISITED)) |
| + if (GetOwner()->HasState(ui::AX_STATE_VISITED)) |
| ia_state |= STATE_SYSTEM_TRAVERSED; |
| - if (HasState(ui::AX_STATE_DISABLED)) |
| + if (GetOwner()->HasState(ui::AX_STATE_DISABLED)) |
| ia_state |= STATE_SYSTEM_UNAVAILABLE; |
| - if (HasState(ui::AX_STATE_VERTICAL)) |
| + if (GetOwner()->HasState(ui::AX_STATE_VERTICAL)) |
| ia2_state |= IA2_STATE_VERTICAL; |
| - if (HasState(ui::AX_STATE_HORIZONTAL)) |
| + if (GetOwner()->HasState(ui::AX_STATE_HORIZONTAL)) |
| ia2_state |= IA2_STATE_HORIZONTAL; |
| - if (HasState(ui::AX_STATE_VISITED)) |
| + if (GetOwner()->HasState(ui::AX_STATE_VISITED)) |
| ia_state |= STATE_SYSTEM_TRAVERSED; |
| // Expose whether or not the mouse is over an element, but suppress |
| @@ -5109,25 +5192,25 @@ void BrowserAccessibilityWin::InitRoleAndState() { |
| BrowserAccessibilityStateImpl* accessibility_state = |
| BrowserAccessibilityStateImpl::GetInstance(); |
| if (!accessibility_state->disable_hot_tracking_for_testing()) { |
| - if (HasState(ui::AX_STATE_HOVERED)) |
| + if (GetOwner()->HasState(ui::AX_STATE_HOVERED)) |
| ia_state |= STATE_SYSTEM_HOTTRACKED; |
| } |
| - if (HasState(ui::AX_STATE_EDITABLE)) |
| + if (GetOwner()->HasState(ui::AX_STATE_EDITABLE)) |
| ia2_state |= IA2_STATE_EDITABLE; |
| - if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) |
| + if (GetOwner()->GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) |
| ia2_state |= IA2_STATE_EDITABLE; |
| - if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) |
| + if (!GetOwner()->GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) |
| ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; |
| - if (GetBoolAttribute(ui::AX_ATTR_MODAL)) |
| + if (GetOwner()->GetBoolAttribute(ui::AX_ATTR_MODAL)) |
| ia2_state |= IA2_STATE_MODAL; |
| - base::string16 html_tag = GetString16Attribute( |
| - ui::AX_ATTR_HTML_TAG); |
| - switch (GetRole()) { |
| + base::string16 html_tag = |
| + GetOwner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); |
| + switch (GetOwner()->GetRole()) { |
| case ui::AX_ROLE_ALERT: |
| ia_role = ROLE_SYSTEM_ALERT; |
| break; |
| @@ -5163,7 +5246,7 @@ void BrowserAccessibilityWin::InitRoleAndState() { |
| ia_role = ROLE_SYSTEM_PUSHBUTTON; |
| break; |
| case ui::AX_ROLE_CANVAS: |
| - if (GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { |
| + if (GetOwner()->GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { |
| role_name = L"canvas"; |
| ia2_role = IA2_ROLE_CANVAS; |
| } else { |
| @@ -5249,7 +5332,7 @@ void BrowserAccessibilityWin::InitRoleAndState() { |
| ia_state |= STATE_SYSTEM_FOCUSABLE; |
| break; |
| case ui::AX_ROLE_EMBEDDED_OBJECT: |
| - if (PlatformChildCount()) { |
| + if (GetOwner()->PlatformChildCount()) { |
| // Windows screen readers assume that IA2_ROLE_EMBEDDED_OBJECT |
| // doesn't have any children, but it may be something like a |
| // browser plugin that has a document inside. |
| @@ -5285,8 +5368,8 @@ void BrowserAccessibilityWin::InitRoleAndState() { |
| // ia_state |= STATE_SYSTEM_READONLY; |
| break; |
| case ui::AX_ROLE_GROUP: { |
| - base::string16 aria_role = GetString16Attribute( |
| - ui::AX_ATTR_ROLE); |
| + base::string16 aria_role = |
| + GetOwner()->GetString16Attribute(ui::AX_ATTR_ROLE); |
| if (aria_role == L"group" || html_tag == L"fieldset") { |
| ia_role = ROLE_SYSTEM_GROUPING; |
| } else if (html_tag == L"li") { |
| @@ -5455,7 +5538,8 @@ void BrowserAccessibilityWin::InitRoleAndState() { |
| case ui::AX_ROLE_ROW: { |
| // Role changes depending on whether row is inside a treegrid |
| // https://www.w3.org/TR/core-aam-1.1/#role-map-row |
| - ia_role = IsInTreeGrid(this) ? ROLE_SYSTEM_OUTLINEITEM : ROLE_SYSTEM_ROW; |
| + ia_role = |
| + IsInTreeGrid(GetOwner()) ? ROLE_SYSTEM_OUTLINEITEM : ROLE_SYSTEM_ROW; |
| break; |
| } |
| case ui::AX_ROLE_ROW_HEADER: |
| @@ -5538,12 +5622,12 @@ void BrowserAccessibilityWin::InitRoleAndState() { |
| case ui::AX_ROLE_TEXT_FIELD: |
| case ui::AX_ROLE_SEARCH_BOX: |
| ia_role = ROLE_SYSTEM_TEXT; |
| - if (HasState(ui::AX_STATE_MULTILINE)) { |
| + if (GetOwner()->HasState(ui::AX_STATE_MULTILINE)) { |
| ia2_state |= IA2_STATE_MULTI_LINE; |
| } else { |
| ia2_state |= IA2_STATE_SINGLE_LINE; |
| } |
| - if (HasState(ui::AX_STATE_READ_ONLY)) |
| + if (GetOwner()->HasState(ui::AX_STATE_READ_ONLY)) |
| ia_state |= STATE_SYSTEM_READONLY; |
| ia2_state |= IA2_STATE_SELECTABLE_TEXT; |
| break; |
| @@ -5602,13 +5686,13 @@ void BrowserAccessibilityWin::InitRoleAndState() { |
| // aria-readonly attribute and for a few roles (in the switch above), |
| // including read-only text fields. |
| // The majority of focusable controls should not have the read-only state set. |
| - if (HasState(ui::AX_STATE_FOCUSABLE) && ia_role != ROLE_SYSTEM_DOCUMENT && |
| - ia_role != ROLE_SYSTEM_TEXT) { |
| + if (GetOwner()->HasState(ui::AX_STATE_FOCUSABLE) && |
| + ia_role != ROLE_SYSTEM_DOCUMENT && ia_role != ROLE_SYSTEM_TEXT) { |
| ia_state &= ~(STATE_SYSTEM_READONLY); |
| } |
| - if (!HasState(ui::AX_STATE_READ_ONLY)) |
| + if (!GetOwner()->HasState(ui::AX_STATE_READ_ONLY)) |
| ia_state &= ~(STATE_SYSTEM_READONLY); |
| - if (GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) |
| + if (GetOwner()->GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) |
| ia_state |= STATE_SYSTEM_READONLY; |
| // The role should always be set. |
| @@ -5626,7 +5710,8 @@ void BrowserAccessibilityWin::InitRoleAndState() { |
| win_attributes_->ia2_state = ia2_state; |
| } |
| -bool BrowserAccessibilityWin::IsInTreeGrid(const BrowserAccessibility* item) { |
| +bool BrowserAccessibilityComWin::IsInTreeGrid( |
| + const BrowserAccessibility* item) { |
| BrowserAccessibility* container = item->PlatformGetParent(); |
| if (container && container->GetRole() == ui::AX_ROLE_GROUP) { |
| // If parent was a rowgroup, we need to look at the grandparent |
| @@ -5640,15 +5725,12 @@ bool BrowserAccessibilityWin::IsInTreeGrid(const BrowserAccessibility* item) { |
| return container->GetRole() == ui::AX_ROLE_TREE_GRID; |
| } |
| -BrowserAccessibilityWin* ToBrowserAccessibilityWin(BrowserAccessibility* obj) { |
| - DCHECK(!obj || obj->IsNative()); |
| - return static_cast<BrowserAccessibilityWin*>(obj); |
| -} |
| - |
| -const BrowserAccessibilityWin* |
| -ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { |
| - DCHECK(!obj || obj->IsNative()); |
| - return static_cast<const BrowserAccessibilityWin*>(obj); |
| +BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( |
| + BrowserAccessibility* obj) { |
| + if (!obj || !obj->IsNative()) |
| + return nullptr; |
| + auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); |
| + return result; |
| } |
| } // namespace content |