Commit 5e4e0c98 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

AX Onion soup: migrate serialization of child's AXTreeID to Blink

Following the lead of crrev.com/c/2140593, this CL moves the logic
that serializes a child frame's AXTreeID from //content/renderer
into Blink itself, and removes WebElement::GetEmbeddingToken() from
Blink's public API.

Bug: 1094150, 1068668
Change-Id: I7ea4def5c65be6135e7e3c956f4a25071831d506
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302890
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789609}
parent 72ff6c2d
...@@ -1248,19 +1248,6 @@ void BlinkAXTreeSource::SerializeElementAttributes(WebAXObject src, ...@@ -1248,19 +1248,6 @@ void BlinkAXTreeSource::SerializeElementAttributes(WebAXObject src,
TruncateAndAddStringAttribute(dst, ax::mojom::StringAttribute::kRole, TruncateAndAddStringAttribute(dst, ax::mojom::StringAttribute::kRole,
role); role);
} }
// Frames and iframes:
// If there are children, the fallback content has been rendered and should
// be used instead. For example, the fallback content may be rendered if
// there was an error loading an <object>. In that case, only expose the
// children. A node should not have both children and a child tree.
base::Optional<base::UnguessableToken> child_embedding_token =
element.GetEmbeddingToken();
if (child_embedding_token && !src.ChildCount()) {
TruncateAndAddStringAttribute(dst, ax::mojom::StringAttribute::kChildTreeId,
child_embedding_token->ToString());
}
} }
void BlinkAXTreeSource::SerializeHTMLAttributes(WebAXObject src, void BlinkAXTreeSource::SerializeHTMLAttributes(WebAXObject src,
......
...@@ -33,14 +33,9 @@ ...@@ -33,14 +33,9 @@
#include <vector> #include <vector>
#include "base/optional.h"
#include "third_party/blink/public/web/web_node.h" #include "third_party/blink/public/web/web_node.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
namespace base {
class UnguessableToken;
}
namespace gfx { namespace gfx {
class Size; class Size;
} }
...@@ -120,11 +115,6 @@ class BLINK_EXPORT WebElement : public WebNode { ...@@ -120,11 +115,6 @@ class BLINK_EXPORT WebElement : public WebNode {
// /public/web interfaces. // /public/web interfaces.
WebString GetComputedValue(const WebString& property_name); WebString GetComputedValue(const WebString& property_name);
// Returns the EmbeddingToken associated to this WebElement, or base::nullopt
// if there isn't one set. Currently, this can only return actual values for
// elements wrapping instances of an blink::HTMLFrameOwnerElement.
base::Optional<base::UnguessableToken> GetEmbeddingToken() const;
#if INSIDE_BLINK #if INSIDE_BLINK
WebElement(Element*); WebElement(Element*);
WebElement& operator=(Element*); WebElement& operator=(Element*);
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "third_party/blink/public/web/web_element.h" #include "third_party/blink/public/web/web_element.h"
#include "base/unguessable_token.h"
#include "third_party/blink/public/platform/web_rect.h" #include "third_party/blink/public/platform/web_rect.h"
#include "third_party/blink/renderer/core/css/css_computed_style_declaration.h" #include "third_party/blink/renderer/core/css/css_computed_style_declaration.h"
#include "third_party/blink/renderer/core/css/css_property_names.h" #include "third_party/blink/renderer/core/css/css_property_names.h"
...@@ -41,7 +40,6 @@ ...@@ -41,7 +40,6 @@
#include "third_party/blink/renderer/core/html/custom/v0_custom_element.h" #include "third_party/blink/renderer/core/html/custom/v0_custom_element.h"
#include "third_party/blink/renderer/core/html/custom/v0_custom_element_processing_stack.h" #include "third_party/blink/renderer/core/html/custom/v0_custom_element_processing_stack.h"
#include "third_party/blink/renderer/core/html/forms/text_control_element.h" #include "third_party/blink/renderer/core/html/forms/text_control_element.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/html_names.h" #include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/graphics/image.h" #include "third_party/blink/renderer/platform/graphics/image.h"
...@@ -202,13 +200,6 @@ WebString WebElement::GetComputedValue(const WebString& property_name) { ...@@ -202,13 +200,6 @@ WebString WebElement::GetComputedValue(const WebString& property_name) {
return computed_style->GetPropertyCSSValue(property_id)->CssText(); return computed_style->GetPropertyCSSValue(property_id)->CssText();
} }
base::Optional<base::UnguessableToken> WebElement::GetEmbeddingToken() const {
if (auto* owner = DynamicTo<HTMLFrameOwnerElement>(ConstUnwrap<Element>()))
return owner->GetEmbeddingToken();
return base::nullopt;
}
WebElement::WebElement(Element* elem) : WebNode(elem) {} WebElement::WebElement(Element* elem) : WebNode(elem) {}
DEFINE_WEB_NODE_TYPE_CASTS(WebElement, IsElementNode()) DEFINE_WEB_NODE_TYPE_CASTS(WebElement, IsElementNode())
......
...@@ -800,6 +800,25 @@ void AXObject::Serialize(ui::AXNodeData* node_data) { ...@@ -800,6 +800,25 @@ void AXObject::Serialize(ui::AXNodeData* node_data) {
if (GetTextAlign() != ax::mojom::blink::TextAlign::kNone) { if (GetTextAlign() != ax::mojom::blink::TextAlign::kNone) {
node_data->SetTextAlign(GetTextAlign()); node_data->SetTextAlign(GetTextAlign());
} }
// If this is an HTMLFrameOwnerElement (such as an iframe), we may need
// to embed the ID of the child frame.
if (auto* html_frame_owner_element =
DynamicTo<HTMLFrameOwnerElement>(GetElement())) {
base::Optional<base::UnguessableToken> child_token =
html_frame_owner_element->GetEmbeddingToken();
// Only add the attribute for the embedding token if there aren't children,
// because if there are children, the fallback content has been rendered
// and should be used instead. For example, the fallback content may be
// rendered if there was an error loading an <object>. The AXNodeData
// should not have both children and a child tree.
if (child_token && !(IsDetached() || ChildCountIncludingIgnored())) {
node_data->AddStringAttribute(
ax::mojom::blink::StringAttribute::kChildTreeId,
child_token->ToString());
}
}
} }
bool AXObject::IsAXNodeObject() const { bool AXObject::IsAXNodeObject() const {
......
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