Commit d5bb8272 authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Use const LayoutObject* in AXObjectCache where possible.

We can't use const LayoutObject* throughout, because sometimes we do
call non-const methods, for example to scroll a LayoutObject in
response to an accessibility action.

What this change does is make it so that to create a new
AXObject from a LayoutObject*, you need a non-const pointer,
but to just retrieve an existing AXObject, it's okay if you just
have a const LayoutObject*. I think that logically makes sense.

This is a pure refactoring that shouldn't have any side effects.
I'm making this change because it will make landing a future change
I'm working on a bit easier.

Bug: 1109081
Change-Id: Ic03525b4faee20e7d8c7d3cb9c6141281036a982
AX-Relnotes: N/A
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315822
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791395}
parent 61125f99
...@@ -68,15 +68,15 @@ class CORE_EXPORT AXObjectCache : public GarbageCollected<AXObjectCache> { ...@@ -68,15 +68,15 @@ class CORE_EXPORT AXObjectCache : public GarbageCollected<AXObjectCache> {
virtual void SelectionChanged(Node*) = 0; virtual void SelectionChanged(Node*) = 0;
virtual void ChildrenChanged(Node*) = 0; virtual void ChildrenChanged(Node*) = 0;
virtual void ChildrenChanged(LayoutObject*) = 0; virtual void ChildrenChanged(const LayoutObject*) = 0;
virtual void ChildrenChanged(AccessibleNode*) = 0; virtual void ChildrenChanged(AccessibleNode*) = 0;
virtual void CheckedStateChanged(Node*) = 0; virtual void CheckedStateChanged(Node*) = 0;
virtual void ListboxOptionStateChanged(HTMLOptionElement*) = 0; virtual void ListboxOptionStateChanged(HTMLOptionElement*) = 0;
virtual void ListboxSelectedChildrenChanged(HTMLSelectElement*) = 0; virtual void ListboxSelectedChildrenChanged(HTMLSelectElement*) = 0;
virtual void ListboxActiveIndexChanged(HTMLSelectElement*) = 0; virtual void ListboxActiveIndexChanged(HTMLSelectElement*) = 0;
virtual void LocationChanged(LayoutObject*) = 0; virtual void LocationChanged(const LayoutObject*) = 0;
virtual void RadiobuttonRemovedFromGroup(HTMLInputElement*) = 0; virtual void RadiobuttonRemovedFromGroup(HTMLInputElement*) = 0;
virtual void ImageLoaded(LayoutObject*) = 0; virtual void ImageLoaded(const LayoutObject*) = 0;
virtual void Remove(AccessibleNode*) = 0; virtual void Remove(AccessibleNode*) = 0;
virtual void Remove(LayoutObject*) = 0; virtual void Remove(LayoutObject*) = 0;
...@@ -86,11 +86,11 @@ class CORE_EXPORT AXObjectCache : public GarbageCollected<AXObjectCache> { ...@@ -86,11 +86,11 @@ class CORE_EXPORT AXObjectCache : public GarbageCollected<AXObjectCache> {
virtual const Element* RootAXEditableElement(const Node*) = 0; virtual const Element* RootAXEditableElement(const Node*) = 0;
// Called when aspects of the style (e.g. color, alignment) change. // Called when aspects of the style (e.g. color, alignment) change.
virtual void StyleChanged(LayoutObject*) = 0; virtual void StyleChanged(const LayoutObject*) = 0;
// Called by a node when text or a text equivalent (e.g. alt) attribute is // Called by a node when text or a text equivalent (e.g. alt) attribute is
// changed. // changed.
virtual void TextChanged(LayoutObject*) = 0; virtual void TextChanged(const LayoutObject*) = 0;
virtual void DocumentTitleChanged() = 0; virtual void DocumentTitleChanged() = 0;
// Called when a node has just been attached, so we can make sure we have the // Called when a node has just been attached, so we can make sure we have the
// right subclass of AXObject. // right subclass of AXObject.
......
...@@ -117,7 +117,7 @@ namespace blink { ...@@ -117,7 +117,7 @@ namespace blink {
namespace { namespace {
// Return a node for the current layout object or ancestor layout object. // Return a node for the current layout object or ancestor layout object.
Node* GetClosestNodeForLayoutObject(LayoutObject* layout_object) { Node* GetClosestNodeForLayoutObject(const LayoutObject* layout_object) {
if (!layout_object) if (!layout_object)
return nullptr; return nullptr;
Node* node = layout_object->GetNode(); Node* node = layout_object->GetNode();
...@@ -262,7 +262,7 @@ AXObject* AXObjectCacheImpl::FocusedObject() { ...@@ -262,7 +262,7 @@ AXObject* AXObjectCacheImpl::FocusedObject() {
return GetOrCreateFocusedObjectFromNode(this->FocusedElement()); return GetOrCreateFocusedObjectFromNode(this->FocusedElement());
} }
AXObject* AXObjectCacheImpl::Get(LayoutObject* layout_object) { AXObject* AXObjectCacheImpl::Get(const LayoutObject* layout_object) {
if (!layout_object) if (!layout_object)
return nullptr; return nullptr;
...@@ -957,7 +957,7 @@ void AXObjectCacheImpl::UpdateReverseRelations( ...@@ -957,7 +957,7 @@ void AXObjectCacheImpl::UpdateReverseRelations(
relation_cache_->UpdateReverseRelations(relation_source, target_ids); relation_cache_->UpdateReverseRelations(relation_source, target_ids);
} }
void AXObjectCacheImpl::StyleChanged(LayoutObject* layout_object) { void AXObjectCacheImpl::StyleChanged(const LayoutObject* layout_object) {
// There is a ton of style change notifications coming from newly-opened // There is a ton of style change notifications coming from newly-opened
// calendar popups for pickers. Solving that problem is what inspired the // calendar popups for pickers. Solving that problem is what inspired the
// approach below, which is likely true for all elements. // approach below, which is likely true for all elements.
...@@ -988,7 +988,7 @@ void AXObjectCacheImpl::TextChanged(Node* node) { ...@@ -988,7 +988,7 @@ void AXObjectCacheImpl::TextChanged(Node* node) {
DeferTreeUpdate(&AXObjectCacheImpl::TextChangedWithCleanLayout, node); DeferTreeUpdate(&AXObjectCacheImpl::TextChangedWithCleanLayout, node);
} }
void AXObjectCacheImpl::TextChanged(LayoutObject* layout_object) { void AXObjectCacheImpl::TextChanged(const LayoutObject* layout_object) {
if (!layout_object) if (!layout_object)
return; return;
...@@ -1101,7 +1101,7 @@ void AXObjectCacheImpl::ChildrenChanged(Node* node) { ...@@ -1101,7 +1101,7 @@ void AXObjectCacheImpl::ChildrenChanged(Node* node) {
DeferTreeUpdate(&AXObjectCacheImpl::ChildrenChangedWithCleanLayout, node); DeferTreeUpdate(&AXObjectCacheImpl::ChildrenChangedWithCleanLayout, node);
} }
void AXObjectCacheImpl::ChildrenChanged(LayoutObject* layout_object) { void AXObjectCacheImpl::ChildrenChanged(const LayoutObject* layout_object) {
if (!layout_object) if (!layout_object)
return; return;
...@@ -1250,7 +1250,7 @@ void AXObjectCacheImpl::PostNotifications(Document& document) { ...@@ -1250,7 +1250,7 @@ void AXObjectCacheImpl::PostNotifications(Document& document) {
} }
} }
void AXObjectCacheImpl::PostNotification(LayoutObject* layout_object, void AXObjectCacheImpl::PostNotification(const LayoutObject* layout_object,
ax::mojom::blink::Event notification) { ax::mojom::blink::Event notification) {
if (!layout_object) if (!layout_object)
return; return;
...@@ -1426,7 +1426,7 @@ void AXObjectCacheImpl::ListboxActiveIndexChanged(HTMLSelectElement* select) { ...@@ -1426,7 +1426,7 @@ void AXObjectCacheImpl::ListboxActiveIndexChanged(HTMLSelectElement* select) {
ax_object->ActiveIndexChanged(); ax_object->ActiveIndexChanged();
} }
void AXObjectCacheImpl::LocationChanged(LayoutObject* layout_object) { void AXObjectCacheImpl::LocationChanged(const LayoutObject* layout_object) {
// No need to send this notification if the object is aria-hidden. // No need to send this notification if the object is aria-hidden.
// Note that if the node is ignored for other reasons, it still might // Note that if the node is ignored for other reasons, it still might
// be important to send this notification if any of its children are // be important to send this notification if any of its children are
...@@ -1459,7 +1459,7 @@ void AXObjectCacheImpl::RadiobuttonRemovedFromGroup( ...@@ -1459,7 +1459,7 @@ void AXObjectCacheImpl::RadiobuttonRemovedFromGroup(
ax_first_obj->RequestUpdateToNextNode(true); ax_first_obj->RequestUpdateToNextNode(true);
} }
void AXObjectCacheImpl::ImageLoaded(LayoutObject* layout_object) { void AXObjectCacheImpl::ImageLoaded(const LayoutObject* layout_object) {
AXObject* obj = Get(layout_object); AXObject* obj = Get(layout_object);
MarkAXObjectDirty(obj, false); MarkAXObjectDirty(obj, false);
} }
......
...@@ -90,15 +90,15 @@ class MODULES_EXPORT AXObjectCacheImpl ...@@ -90,15 +90,15 @@ class MODULES_EXPORT AXObjectCacheImpl
void UpdateReverseRelations(const AXObject* relation_source, void UpdateReverseRelations(const AXObject* relation_source,
const Vector<String>& target_ids); const Vector<String>& target_ids);
void ChildrenChanged(Node*) override; void ChildrenChanged(Node*) override;
void ChildrenChanged(LayoutObject*) override; void ChildrenChanged(const LayoutObject*) override;
void ChildrenChanged(AccessibleNode*) override; void ChildrenChanged(AccessibleNode*) override;
void CheckedStateChanged(Node*) override; void CheckedStateChanged(Node*) override;
void ListboxOptionStateChanged(HTMLOptionElement*) override; void ListboxOptionStateChanged(HTMLOptionElement*) override;
void ListboxSelectedChildrenChanged(HTMLSelectElement*) override; void ListboxSelectedChildrenChanged(HTMLSelectElement*) override;
void ListboxActiveIndexChanged(HTMLSelectElement*) override; void ListboxActiveIndexChanged(HTMLSelectElement*) override;
void LocationChanged(LayoutObject*) override; void LocationChanged(const LayoutObject*) override;
void RadiobuttonRemovedFromGroup(HTMLInputElement*) override; void RadiobuttonRemovedFromGroup(HTMLInputElement*) override;
void ImageLoaded(LayoutObject*) override; void ImageLoaded(const LayoutObject*) override;
void Remove(AccessibleNode*) override; void Remove(AccessibleNode*) override;
void Remove(LayoutObject*) override; void Remove(LayoutObject*) override;
...@@ -108,11 +108,11 @@ class MODULES_EXPORT AXObjectCacheImpl ...@@ -108,11 +108,11 @@ class MODULES_EXPORT AXObjectCacheImpl
const Element* RootAXEditableElement(const Node*) override; const Element* RootAXEditableElement(const Node*) override;
// Called when aspects of the style (e.g. color, alignment) change. // Called when aspects of the style (e.g. color, alignment) change.
void StyleChanged(LayoutObject*) override; void StyleChanged(const LayoutObject*) override;
// Called by a node when text or a text equivalent (e.g. alt) attribute is // Called by a node when text or a text equivalent (e.g. alt) attribute is
// changed. // changed.
void TextChanged(LayoutObject*) override; void TextChanged(const LayoutObject*) override;
void TextChangedWithCleanLayout(Node* optional_node, AXObject*); void TextChangedWithCleanLayout(Node* optional_node, AXObject*);
void FocusableChangedWithCleanLayout(Element* element); void FocusableChangedWithCleanLayout(Element* element);
void DocumentTitleChanged() override; void DocumentTitleChanged() override;
...@@ -185,7 +185,7 @@ class MODULES_EXPORT AXObjectCacheImpl ...@@ -185,7 +185,7 @@ class MODULES_EXPORT AXObjectCacheImpl
// will only return the AXObject if it already exists // will only return the AXObject if it already exists
AXObject* Get(AccessibleNode*); AXObject* Get(AccessibleNode*);
AXObject* Get(const Node*) override; AXObject* Get(const Node*) override;
AXObject* Get(LayoutObject*); AXObject* Get(const LayoutObject*);
AXObject* Get(AbstractInlineTextBox*); AXObject* Get(AbstractInlineTextBox*);
AXObject* FirstAccessibleObjectFromNode(const Node*); AXObject* FirstAccessibleObjectFromNode(const Node*);
...@@ -215,7 +215,7 @@ class MODULES_EXPORT AXObjectCacheImpl ...@@ -215,7 +215,7 @@ class MODULES_EXPORT AXObjectCacheImpl
// values are cached as long as the modification count hasn't changed. // values are cached as long as the modification count hasn't changed.
int ModificationCount() const { return modification_count_; } int ModificationCount() const { return modification_count_; }
void PostNotification(LayoutObject*, ax::mojom::blink::Event); void PostNotification(const LayoutObject*, ax::mojom::blink::Event);
void PostNotification(Node*, ax::mojom::Event); void PostNotification(Node*, ax::mojom::Event);
void PostNotification(AXObject*, ax::mojom::blink::Event); void PostNotification(AXObject*, ax::mojom::blink::Event);
void MarkAXObjectDirty(AXObject*, bool subtree); void MarkAXObjectDirty(AXObject*, bool subtree);
...@@ -349,7 +349,7 @@ class MODULES_EXPORT AXObjectCacheImpl ...@@ -349,7 +349,7 @@ class MODULES_EXPORT AXObjectCacheImpl
// LayoutObject and AbstractInlineTextBox are not on the Oilpan heap so we // LayoutObject and AbstractInlineTextBox are not on the Oilpan heap so we
// do not use HeapHashMap for those mappings. // do not use HeapHashMap for those mappings.
HeapHashMap<Member<AccessibleNode>, AXID> accessible_node_mapping_; HeapHashMap<Member<AccessibleNode>, AXID> accessible_node_mapping_;
HashMap<LayoutObject*, AXID> layout_object_mapping_; HashMap<const LayoutObject*, AXID> layout_object_mapping_;
HeapHashMap<Member<const Node>, AXID> node_object_mapping_; HeapHashMap<Member<const Node>, AXID> node_object_mapping_;
HashMap<AbstractInlineTextBox*, AXID> inline_text_box_object_mapping_; HashMap<AbstractInlineTextBox*, AXID> inline_text_box_object_mapping_;
int modification_count_; int modification_count_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment