Commit 1260858e authored by Meredith Lane's avatar Meredith Lane Committed by Chromium LUCI CQ

[AXOnionSoup] Move scroll serialization to AXObject

This patch has no functional difference, it is just a refactor.

AX-Relnotes: N/A
Bug: 1068668
Change-Id: Iedaefa7d8b06ac80d7155739e134978bdb674d29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2577389
Commit-Queue: Meredith Lane <meredithl@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841259}
parent 262bc78e
...@@ -552,10 +552,6 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, ...@@ -552,10 +552,6 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src,
indirect_child_ids); indirect_child_ids);
} }
if (src.IsScrollableContainer()) {
SerializeScrollAttributes(src, dst);
}
if (dst->id == image_data_node_id_) { if (dst->id == image_data_node_id_) {
// In general, string attributes should be truncated using // In general, string attributes should be truncated using
// TruncateAndAddStringAttribute, but ImageDataUrl contains a data url // TruncateAndAddStringAttribute, but ImageDataUrl contains a data url
...@@ -705,30 +701,6 @@ void BlinkAXTreeSource::SerializeLiveRegionAttributes( ...@@ -705,30 +701,6 @@ void BlinkAXTreeSource::SerializeLiveRegionAttributes(
src.ContainerLiveRegionRelevant().Utf8()); src.ContainerLiveRegionRelevant().Utf8());
} }
void BlinkAXTreeSource::SerializeScrollAttributes(WebAXObject src,
ui::AXNodeData* dst) const {
// Only mark as scrollable if user has actual scrollbars to use.
dst->AddBoolAttribute(ax::mojom::BoolAttribute::kScrollable,
src.IsUserScrollable());
// Provide x,y scroll info if scrollable in any way (programmatically or via
// user).
const gfx::Point& scroll_offset = src.GetScrollOffset();
dst->AddIntAttribute(ax::mojom::IntAttribute::kScrollX, scroll_offset.x());
dst->AddIntAttribute(ax::mojom::IntAttribute::kScrollY, scroll_offset.y());
const gfx::Point& min_scroll_offset = src.MinimumScrollOffset();
dst->AddIntAttribute(ax::mojom::IntAttribute::kScrollXMin,
min_scroll_offset.x());
dst->AddIntAttribute(ax::mojom::IntAttribute::kScrollYMin,
min_scroll_offset.y());
const gfx::Point& max_scroll_offset = src.MaximumScrollOffset();
dst->AddIntAttribute(ax::mojom::IntAttribute::kScrollXMax,
max_scroll_offset.x());
dst->AddIntAttribute(ax::mojom::IntAttribute::kScrollYMax,
max_scroll_offset.y());
}
void BlinkAXTreeSource::SerializeChooserPopupAttributes( void BlinkAXTreeSource::SerializeChooserPopupAttributes(
WebAXObject src, WebAXObject src,
ui::AXNodeData* dst) const { ui::AXNodeData* dst) const {
......
...@@ -144,8 +144,6 @@ class CONTENT_EXPORT BlinkAXTreeSource ...@@ -144,8 +144,6 @@ class CONTENT_EXPORT BlinkAXTreeSource
ui::AXNodeData* dst) const; ui::AXNodeData* dst) const;
void SerializeLiveRegionAttributes(blink::WebAXObject src, void SerializeLiveRegionAttributes(blink::WebAXObject src,
ui::AXNodeData* dst) const; ui::AXNodeData* dst) const;
void SerializeScrollAttributes(blink::WebAXObject src,
ui::AXNodeData* dst) const;
void SerializeChooserPopupAttributes(blink::WebAXObject src, void SerializeChooserPopupAttributes(blink::WebAXObject src,
ui::AXNodeData* dst) const; ui::AXNodeData* dst) const;
void SerializeOtherScreenReaderAttributes(blink::WebAXObject src, void SerializeOtherScreenReaderAttributes(blink::WebAXObject src,
......
...@@ -1459,12 +1459,12 @@ void WebAXObjectProxy::ScrollToGlobalPoint(int x, int y) { ...@@ -1459,12 +1459,12 @@ void WebAXObjectProxy::ScrollToGlobalPoint(int x, int y) {
int WebAXObjectProxy::ScrollX() { int WebAXObjectProxy::ScrollX() {
UpdateLayout(); UpdateLayout();
return accessibility_object_.GetScrollOffset().x(); return GetAXNodeData().GetIntAttribute(ax::mojom::IntAttribute::kScrollX);
} }
int WebAXObjectProxy::ScrollY() { int WebAXObjectProxy::ScrollY() {
UpdateLayout(); UpdateLayout();
return accessibility_object_.GetScrollOffset().y(); return GetAXNodeData().GetIntAttribute(ax::mojom::IntAttribute::kScrollY);
} }
std::string WebAXObjectProxy::ToString() { std::string WebAXObjectProxy::ToString() {
......
...@@ -333,7 +333,6 @@ class WebAXObject { ...@@ -333,7 +333,6 @@ class WebAXObject {
// Programmatically scrollable. // Programmatically scrollable.
BLINK_EXPORT bool IsScrollableContainer() const; BLINK_EXPORT bool IsScrollableContainer() const;
// Also scrollable by user. // Also scrollable by user.
BLINK_EXPORT bool IsUserScrollable() const;
BLINK_EXPORT gfx::Point GetScrollOffset() const; BLINK_EXPORT gfx::Point GetScrollOffset() const;
BLINK_EXPORT gfx::Point MinimumScrollOffset() const; BLINK_EXPORT gfx::Point MinimumScrollOffset() const;
BLINK_EXPORT gfx::Point MaximumScrollOffset() const; BLINK_EXPORT gfx::Point MaximumScrollOffset() const;
......
...@@ -961,6 +961,9 @@ void AXObject::Serialize(ui::AXNodeData* node_data, ...@@ -961,6 +961,9 @@ void AXObject::Serialize(ui::AXNodeData* node_data,
} }
} }
} }
if (IsScrollableContainer())
SerializeScrollAttributes(node_data);
} }
void AXObject::SerializeTableAttributes(ui::AXNodeData* node_data) { void AXObject::SerializeTableAttributes(ui::AXNodeData* node_data) {
...@@ -1018,6 +1021,31 @@ void AXObject::SerializeTableAttributes(ui::AXNodeData* node_data) { ...@@ -1018,6 +1021,31 @@ void AXObject::SerializeTableAttributes(ui::AXNodeData* node_data) {
} }
} }
void AXObject::SerializeScrollAttributes(ui::AXNodeData* node_data) {
// Only mark as scrollable if user has actual scrollbars to use.
node_data->AddBoolAttribute(ax::mojom::blink::BoolAttribute::kScrollable,
IsUserScrollable());
// Provide x,y scroll info if scrollable in any way (programmatically or via
// user).
const gfx::Point& scroll_offset = GetScrollOffset();
node_data->AddIntAttribute(ax::mojom::blink::IntAttribute::kScrollX,
scroll_offset.x());
node_data->AddIntAttribute(ax::mojom::blink::IntAttribute::kScrollY,
scroll_offset.y());
const gfx::Point& min_scroll_offset = MinimumScrollOffset();
node_data->AddIntAttribute(ax::mojom::blink::IntAttribute::kScrollXMin,
min_scroll_offset.x());
node_data->AddIntAttribute(ax::mojom::blink::IntAttribute::kScrollYMin,
min_scroll_offset.y());
const gfx::Point& max_scroll_offset = MaximumScrollOffset();
node_data->AddIntAttribute(ax::mojom::blink::IntAttribute::kScrollXMax,
max_scroll_offset.x());
node_data->AddIntAttribute(ax::mojom::blink::IntAttribute::kScrollYMax,
max_scroll_offset.y());
}
void AXObject::SerializeStyleAttributes(ui::AXNodeData* node_data) { void AXObject::SerializeStyleAttributes(ui::AXNodeData* node_data) {
// Text attributes. // Text attributes.
if (BackgroundColor()) { if (BackgroundColor()) {
......
...@@ -1316,6 +1316,7 @@ class MODULES_EXPORT AXObject : public GarbageCollected<AXObject> { ...@@ -1316,6 +1316,7 @@ class MODULES_EXPORT AXObject : public GarbageCollected<AXObject> {
void SerializeSparseAttributes(ui::AXNodeData* node_data); void SerializeSparseAttributes(ui::AXNodeData* node_data);
void SerializeTableAttributes(ui::AXNodeData* node_data); void SerializeTableAttributes(ui::AXNodeData* node_data);
void SerializeListAttributes(ui::AXNodeData* node_data); void SerializeListAttributes(ui::AXNodeData* node_data);
void SerializeScrollAttributes(ui::AXNodeData* node_data);
private: private:
void UpdateDistributionForFlatTreeTraversal() const; void UpdateDistributionForFlatTreeTraversal() const;
......
...@@ -1238,12 +1238,6 @@ bool WebAXObject::IsScrollableContainer() const { ...@@ -1238,12 +1238,6 @@ bool WebAXObject::IsScrollableContainer() const {
return private_->IsScrollableContainer(); return private_->IsScrollableContainer();
} }
bool WebAXObject::IsUserScrollable() const {
if (IsDetached())
return false;
return private_->IsUserScrollable();
}
gfx::Point WebAXObject::GetScrollOffset() const { gfx::Point WebAXObject::GetScrollOffset() const {
if (IsDetached()) if (IsDetached())
return gfx::Point(); return gfx::Point();
......
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