Commit 80973ba8 authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Consolidate two calls to WebAXObject::GetRelativeBounds

One call had some extra logic that was missing from the other
call. Most likely it didn't trigger a bug because it's unlikely we'd
ever have a scenario where the root object's AXRelativeBounds changes
but the root isn't serialized. Still, this is definitely the right
thing to do, and it makes the code in RenderAccessibilityImpl
simpler and more readable.

Bug: 1109081
Change-Id: If4ccb9d5dab5393c9b965af48943161c549fd272
AX-Relnotes: N/A
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2314874
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791454}
parent cbcb7be8
...@@ -414,6 +414,34 @@ void BlinkAXTreeSource::SetLoadInlineTextBoxesForId(int32_t id) { ...@@ -414,6 +414,34 @@ void BlinkAXTreeSource::SetLoadInlineTextBoxesForId(int32_t id) {
load_inline_text_boxes_ids_.insert(id); load_inline_text_boxes_ids_.insert(id);
} }
void BlinkAXTreeSource::PopulateAXRelativeBounds(WebAXObject obj,
ui::AXRelativeBounds* bounds,
bool* clips_children) const {
WebAXObject offset_container;
WebFloatRect bounds_in_container;
SkMatrix44 web_container_transform;
obj.GetRelativeBounds(offset_container, bounds_in_container,
web_container_transform, clips_children);
bounds->bounds = bounds_in_container;
if (!offset_container.IsDetached())
bounds->offset_container_id = offset_container.AxID();
if (content::AXShouldIncludePageScaleFactorInRoot() && obj.Equals(root())) {
const WebView* web_view = render_frame_->GetRenderView()->GetWebView();
std::unique_ptr<gfx::Transform> container_transform =
std::make_unique<gfx::Transform>(web_container_transform);
container_transform->Scale(web_view->PageScaleFactor(),
web_view->PageScaleFactor());
container_transform->Translate(
-web_view->VisualViewportOffset().OffsetFromOrigin());
if (!container_transform->IsIdentity())
bounds->transform = std::move(container_transform);
} else if (!web_container_transform.isIdentity()) {
bounds->transform =
base::WrapUnique(new gfx::Transform(web_container_transform));
}
}
bool BlinkAXTreeSource::GetTreeData(ui::AXTreeData* tree_data) const { bool BlinkAXTreeSource::GetTreeData(ui::AXTreeData* tree_data) const {
CHECK(frozen_); CHECK(frozen_);
tree_data->doctype = "html"; tree_data->doctype = "html";
...@@ -652,29 +680,8 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, ...@@ -652,29 +680,8 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src,
void BlinkAXTreeSource::SerializeBoundingBoxAttributes( void BlinkAXTreeSource::SerializeBoundingBoxAttributes(
WebAXObject src, WebAXObject src,
ui::AXNodeData* dst) const { ui::AXNodeData* dst) const {
WebAXObject offset_container;
WebFloatRect bounds_in_container;
SkMatrix44 container_transform;
bool clips_children = false; bool clips_children = false;
src.GetRelativeBounds(offset_container, bounds_in_container, PopulateAXRelativeBounds(src, &dst->relative_bounds, &clips_children);
container_transform, &clips_children);
dst->relative_bounds.bounds = bounds_in_container;
if (content::AXShouldIncludePageScaleFactorInRoot() && src.Equals(root())) {
WebView* web_view = render_frame_->GetRenderView()->GetWebView();
std::unique_ptr<gfx::Transform> container_transform_gfx =
std::make_unique<gfx::Transform>(container_transform);
container_transform_gfx->Scale(web_view->PageScaleFactor(),
web_view->PageScaleFactor());
container_transform_gfx->Translate(
-web_view->VisualViewportOffset().OffsetFromOrigin());
if (!container_transform_gfx->IsIdentity())
dst->relative_bounds.transform = std::move(container_transform_gfx);
} else if (!container_transform.isIdentity()) {
dst->relative_bounds.transform =
base::WrapUnique(new gfx::Transform(container_transform));
}
if (!offset_container.IsDetached())
dst->relative_bounds.offset_container_id = offset_container.AxID();
if (clips_children) if (clips_children)
dst->AddBoolAttribute(ax::mojom::BoolAttribute::kClipsChildren, true); dst->AddBoolAttribute(ax::mojom::BoolAttribute::kClipsChildren, true);
......
...@@ -91,6 +91,10 @@ class CONTENT_EXPORT BlinkAXTreeSource ...@@ -91,6 +91,10 @@ class CONTENT_EXPORT BlinkAXTreeSource
bool ShouldLoadInlineTextBoxes(const blink::WebAXObject& obj) const; bool ShouldLoadInlineTextBoxes(const blink::WebAXObject& obj) const;
void SetLoadInlineTextBoxesForId(int32_t id); void SetLoadInlineTextBoxesForId(int32_t id);
void PopulateAXRelativeBounds(blink::WebAXObject obj,
ui::AXRelativeBounds* bounds,
bool* clips_children = nullptr) const;
// AXTreeSource implementation. // AXTreeSource implementation.
bool GetTreeData(ui::AXTreeData* tree_data) const override; bool GetTreeData(ui::AXTreeData* tree_data) const override;
blink::WebAXObject GetRoot() const override; blink::WebAXObject GetRoot() const override;
......
...@@ -996,17 +996,8 @@ void RenderAccessibilityImpl::SendLocationChanges() { ...@@ -996,17 +996,8 @@ void RenderAccessibilityImpl::SendLocationChanges() {
continue; continue;
// If the location has changed, append it to the IPC message. // If the location has changed, append it to the IPC message.
WebAXObject offset_container;
WebFloatRect bounds_in_container;
SkMatrix44 container_transform;
obj.GetRelativeBounds(offset_container, bounds_in_container,
container_transform);
ui::AXRelativeBounds new_location; ui::AXRelativeBounds new_location;
new_location.offset_container_id = offset_container.AxID(); tree_source_->PopulateAXRelativeBounds(obj, &new_location);
new_location.bounds = bounds_in_container;
if (!container_transform.isIdentity())
new_location.transform = base::WrapUnique(
new gfx::Transform(container_transform));
if (iter->second != new_location) if (iter->second != new_location)
changes.push_back(mojom::LocationChanges::New(id, new_location)); changes.push_back(mojom::LocationChanges::New(id, new_location));
......
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