Made AXMode a required argument to WebAXContext
This follows http://crrev.com/c/2894726 and now ensures that Blink accessibility always has the minimal accessibility mode possible set, which will enable future optimizations. Bug: 1208912 Change-Id: I761bb848e27d36cdd62ede0ae524ed30dc99264d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2911953 Reviewed-by: Aaron Leventhal <aleventhal@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org> Cr-Commit-Position: refs/heads/master@{#886344}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
a08cb7aae5
commit
db04a10121
components/printing/renderer
content
public
renderer
renderer
accessibility
aom_content_ax_tree.ccax_tree_snapshotter_impl.ccax_tree_snapshotter_impl.hrender_accessibility_impl.cc
render_frame_impl.ccrender_frame_impl.hweb_test
renderer
third_party/blink
public
renderer
core
accessibility
aom
dom
frame
inspector
modules
DEPS
accessibility
canvas
exported
tools
blinkpy
presubmit
@ -2025,9 +2025,8 @@ bool PrintRenderFrameHelper::PrintPagesNative(blink::WebLocalFrame* frame,
|
||||
// is enabled.
|
||||
std::unique_ptr<content::AXTreeSnapshotter> snapshotter;
|
||||
if (delegate_->ShouldGenerateTaggedPDF()) {
|
||||
snapshotter = render_frame()->CreateAXTreeSnapshotter();
|
||||
snapshotter->Snapshot(ui::AXMode::kPDF,
|
||||
/* exclude_offscreen= */ false,
|
||||
snapshotter = render_frame()->CreateAXTreeSnapshotter(ui::AXMode::kPDF);
|
||||
snapshotter->Snapshot(/* exclude_offscreen= */ false,
|
||||
/* max_node_count= */ 0,
|
||||
/* timeout= */ {}, &metafile.accessibility_tree());
|
||||
}
|
||||
@ -2435,7 +2434,7 @@ void PrintRenderFrameHelper::RequestPrintPreview(PrintPreviewRequestType type) {
|
||||
// the scope of printing, because text drawing commands are only annotated
|
||||
// with a DOMNodeId if accessibility is enabled.
|
||||
if (delegate_->ShouldGenerateTaggedPDF())
|
||||
snapshotter_ = render_frame()->CreateAXTreeSnapshotter();
|
||||
snapshotter_ = render_frame()->CreateAXTreeSnapshotter(ui::AXMode::kPDF);
|
||||
|
||||
auto params = mojom::RequestPrintPreviewParams::New();
|
||||
params->is_from_arc = is_from_arc;
|
||||
@ -2566,8 +2565,7 @@ bool PrintRenderFrameHelper::PreviewPageRendered(
|
||||
// http://crbug.com/1039817
|
||||
if (snapshotter_ && page_number == 0) {
|
||||
ui::AXTreeUpdate accessibility_tree;
|
||||
snapshotter_->Snapshot(ui::AXMode::kPDF,
|
||||
/* exclude_offscreen= */ false,
|
||||
snapshotter_->Snapshot(/* exclude_offscreen= */ false,
|
||||
/* max_node_count= */ 0,
|
||||
/* timeout= */ {}, &accessibility_tree);
|
||||
GetPrintManagerHost()->SetAccessibilityTree(
|
||||
|
@ -73,8 +73,6 @@ class AXTreeSnapshotter {
|
||||
// Return in |accessibility_tree| a snapshot of the accessibility tree
|
||||
// for the frame with the given accessibility mode.
|
||||
//
|
||||
// - |ax_mode| is the accessibility mode to use, which determines which
|
||||
// fields of AXNodeData are populated.
|
||||
// - |exclude_offscreen| excludes a subtree if a node is entirely offscreen,
|
||||
// but note that this heuristic is imperfect, and an aboslute-positioned
|
||||
// node that's visible, but whose ancestors are entirely offscreen, may
|
||||
@ -87,8 +85,7 @@ class AXTreeSnapshotter {
|
||||
// (per frame), specified in milliseconds. Like max_node_count, this is not
|
||||
// a hard limit, and once this/ limit is reached a few more nodes may
|
||||
// be added in order to ensure a well-formed tree. Use 0 for no timeout.
|
||||
virtual void Snapshot(ui::AXMode ax_mode,
|
||||
bool exclude_offscreen,
|
||||
virtual void Snapshot(bool exclude_offscreen,
|
||||
size_t max_node_count,
|
||||
base::TimeDelta timeout,
|
||||
ui::AXTreeUpdate* accessibility_tree) = 0;
|
||||
@ -147,7 +144,10 @@ class CONTENT_EXPORT RenderFrame : public IPC::Listener,
|
||||
virtual RenderAccessibility* GetRenderAccessibility() = 0;
|
||||
|
||||
// Return an object that can take a snapshot of the accessibility tree.
|
||||
virtual std::unique_ptr<AXTreeSnapshotter> CreateAXTreeSnapshotter() = 0;
|
||||
// |ax_mode| is the accessibility mode to use, which determines which
|
||||
// fields of AXNodeData are populated when you make a snapshot.
|
||||
virtual std::unique_ptr<AXTreeSnapshotter> CreateAXTreeSnapshotter(
|
||||
ui::AXMode ax_mode) = 0;
|
||||
|
||||
// Get the routing ID of the frame.
|
||||
virtual int GetRoutingID() = 0;
|
||||
|
@ -128,9 +128,8 @@ AomContentAxTree::AomContentAxTree(RenderFrameImpl* render_frame)
|
||||
|
||||
bool AomContentAxTree::ComputeAccessibilityTree() {
|
||||
ui::AXTreeUpdate tree_update;
|
||||
AXTreeSnapshotterImpl snapshotter(render_frame_);
|
||||
snapshotter.Snapshot(ui::kAXModeComplete,
|
||||
/* exclude_offscreen= */ false,
|
||||
AXTreeSnapshotterImpl snapshotter(render_frame_, ui::kAXModeComplete);
|
||||
snapshotter.Snapshot(/* exclude_offscreen= */ false,
|
||||
/* max_node_count= */ 0,
|
||||
/* timeout= */ {}, &tree_update);
|
||||
CHECK(tree_.Unserialize(tree_update)) << tree_.error();
|
||||
|
@ -20,17 +20,17 @@ using BlinkAXTreeSerializer = ui::AXTreeSerializer<blink::WebAXObject>;
|
||||
|
||||
namespace content {
|
||||
|
||||
AXTreeSnapshotterImpl::AXTreeSnapshotterImpl(RenderFrameImpl* render_frame)
|
||||
AXTreeSnapshotterImpl::AXTreeSnapshotterImpl(RenderFrameImpl* render_frame,
|
||||
ui::AXMode ax_mode)
|
||||
: render_frame_(render_frame) {
|
||||
DCHECK(render_frame->GetWebFrame());
|
||||
blink::WebDocument document_ = render_frame->GetWebFrame()->GetDocument();
|
||||
context_ = std::make_unique<WebAXContext>(document_);
|
||||
context_ = std::make_unique<WebAXContext>(document_, ax_mode);
|
||||
}
|
||||
|
||||
AXTreeSnapshotterImpl::~AXTreeSnapshotterImpl() = default;
|
||||
|
||||
void AXTreeSnapshotterImpl::Snapshot(ui::AXMode ax_mode,
|
||||
bool exclude_offscreen,
|
||||
void AXTreeSnapshotterImpl::Snapshot(bool exclude_offscreen,
|
||||
size_t max_node_count,
|
||||
base::TimeDelta timeout,
|
||||
ui::AXTreeUpdate* response) {
|
||||
@ -41,7 +41,7 @@ void AXTreeSnapshotterImpl::Snapshot(ui::AXMode ax_mode,
|
||||
return;
|
||||
WebAXObject root = context_->Root();
|
||||
|
||||
BlinkAXTreeSource tree_source(render_frame_, ax_mode);
|
||||
BlinkAXTreeSource tree_source(render_frame_, context_->GetAXMode());
|
||||
tree_source.SetRoot(root);
|
||||
tree_source.set_exclude_offscreen(exclude_offscreen);
|
||||
ScopedFreezeBlinkAXTreeSource freeze(&tree_source);
|
||||
|
@ -19,12 +19,11 @@ class RenderFrameImpl;
|
||||
|
||||
class AXTreeSnapshotterImpl : public AXTreeSnapshotter {
|
||||
public:
|
||||
explicit AXTreeSnapshotterImpl(RenderFrameImpl* render_frame);
|
||||
AXTreeSnapshotterImpl(RenderFrameImpl* render_frame, ui::AXMode ax_mode);
|
||||
~AXTreeSnapshotterImpl() override;
|
||||
|
||||
// AXTreeSnapshotter implementation.
|
||||
void Snapshot(ui::AXMode ax_mode,
|
||||
bool exclude_offscreen,
|
||||
void Snapshot(bool exclude_offscreen,
|
||||
size_t max_node_count,
|
||||
base::TimeDelta timeout,
|
||||
ui::AXTreeUpdate* accessibility_tree) override;
|
||||
|
@ -157,7 +157,7 @@ RenderAccessibilityImpl::RenderAccessibilityImpl(
|
||||
|
||||
const WebDocument& document = GetMainDocument();
|
||||
if (!document.IsNull()) {
|
||||
ax_context_ = std::make_unique<WebAXContext>(document);
|
||||
ax_context_ = std::make_unique<WebAXContext>(document, mode);
|
||||
StartOrStopLabelingImages(ui::AXMode(), mode);
|
||||
|
||||
// It's possible that the webview has already loaded a webpage without
|
||||
@ -177,7 +177,8 @@ RenderAccessibilityImpl::~RenderAccessibilityImpl() = default;
|
||||
void RenderAccessibilityImpl::DidCreateNewDocument() {
|
||||
const WebDocument& document = GetMainDocument();
|
||||
if (!document.IsNull())
|
||||
ax_context_ = std::make_unique<WebAXContext>(document);
|
||||
ax_context_ =
|
||||
std::make_unique<WebAXContext>(document, GetAccessibilityMode());
|
||||
}
|
||||
|
||||
void RenderAccessibilityImpl::DidCommitProvisionalLoad(
|
||||
|
@ -2212,9 +2212,9 @@ void RenderFrameImpl::SnapshotAccessibilityTree(
|
||||
mojom::SnapshotAccessibilityTreeParamsPtr params,
|
||||
SnapshotAccessibilityTreeCallback callback) {
|
||||
ui::AXTreeUpdate response;
|
||||
AXTreeSnapshotterImpl snapshotter(this);
|
||||
snapshotter.Snapshot(ui::AXMode(params->ax_mode), params->exclude_offscreen,
|
||||
params->max_nodes, params->timeout, &response);
|
||||
AXTreeSnapshotterImpl snapshotter(this, ui::AXMode(params->ax_mode));
|
||||
snapshotter.Snapshot(params->exclude_offscreen, params->max_nodes,
|
||||
params->timeout, &response);
|
||||
std::move(callback).Run(response);
|
||||
}
|
||||
|
||||
@ -2269,8 +2269,9 @@ RenderAccessibility* RenderFrameImpl::GetRenderAccessibility() {
|
||||
return render_accessibility_manager_->GetRenderAccessibilityImpl();
|
||||
}
|
||||
|
||||
std::unique_ptr<AXTreeSnapshotter> RenderFrameImpl::CreateAXTreeSnapshotter() {
|
||||
return std::make_unique<AXTreeSnapshotterImpl>(this);
|
||||
std::unique_ptr<AXTreeSnapshotter> RenderFrameImpl::CreateAXTreeSnapshotter(
|
||||
ui::AXMode ax_mode) {
|
||||
return std::make_unique<AXTreeSnapshotterImpl>(this, ax_mode);
|
||||
}
|
||||
|
||||
int RenderFrameImpl::GetRoutingID() {
|
||||
|
@ -334,7 +334,8 @@ class CONTENT_EXPORT RenderFrameImpl
|
||||
// RenderFrame implementation:
|
||||
RenderView* GetRenderView() override;
|
||||
RenderAccessibility* GetRenderAccessibility() override;
|
||||
std::unique_ptr<AXTreeSnapshotter> CreateAXTreeSnapshotter() override;
|
||||
std::unique_ptr<AXTreeSnapshotter> CreateAXTreeSnapshotter(
|
||||
ui::AXMode ax_mode) override;
|
||||
int GetRoutingID() override;
|
||||
blink::WebLocalFrame* GetWebFrame() override;
|
||||
const blink::WebLocalFrame* GetWebFrame() const override;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
#include "third_party/blink/public/web/web_settings.h"
|
||||
#include "third_party/blink/public/web/web_view.h"
|
||||
#include "ui/accessibility/ax_mode.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
@ -167,7 +168,8 @@ void AccessibilityController::Reset() {
|
||||
}
|
||||
|
||||
void AccessibilityController::Install(blink::WebLocalFrame* frame) {
|
||||
ax_context_ = std::make_unique<blink::WebAXContext>(frame->GetDocument());
|
||||
ax_context_ = std::make_unique<blink::WebAXContext>(frame->GetDocument(),
|
||||
ui::kAXModeComplete);
|
||||
frame->View()->GetSettings()->SetInlineTextBoxAccessibilityEnabled(true);
|
||||
|
||||
AccessibilityControllerBindings::Install(weak_factory_.GetWeakPtr(), frame);
|
||||
|
@ -8,6 +8,10 @@
|
||||
#include "third_party/blink/public/web/web_ax_object.h"
|
||||
#include "third_party/blink/public/web/web_document.h"
|
||||
|
||||
namespace ui {
|
||||
class AXMode;
|
||||
} // namespace ui
|
||||
|
||||
namespace blink {
|
||||
|
||||
class AXContext;
|
||||
@ -16,12 +20,15 @@ class AXContext;
|
||||
// support for the given document.
|
||||
class WebAXContext {
|
||||
public:
|
||||
BLINK_EXPORT explicit WebAXContext(WebDocument document);
|
||||
BLINK_EXPORT explicit WebAXContext(WebDocument document,
|
||||
const ui::AXMode& mode);
|
||||
BLINK_EXPORT ~WebAXContext();
|
||||
|
||||
// Returns the root element of the document's accessibility tree.
|
||||
BLINK_EXPORT WebAXObject Root() const;
|
||||
|
||||
BLINK_EXPORT const ui::AXMode& GetAXMode() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<AXContext> private_;
|
||||
};
|
||||
|
@ -22,8 +22,7 @@ class CORE_EXPORT AXContext {
|
||||
USING_FAST_MALLOC(AXContext);
|
||||
|
||||
public:
|
||||
explicit AXContext(Document& document,
|
||||
const ui::AXMode& mode = ui::kAXModeComplete);
|
||||
AXContext(Document& document, const ui::AXMode& mode);
|
||||
AXContext(const AXContext&) = delete;
|
||||
AXContext& operator=(const AXContext&) = delete;
|
||||
virtual ~AXContext();
|
||||
@ -38,7 +37,7 @@ class CORE_EXPORT AXContext {
|
||||
|
||||
Document* GetDocument();
|
||||
|
||||
ui::AXMode GetAXMode() { return ax_mode_; }
|
||||
const ui::AXMode& GetAXMode() { return ax_mode_; }
|
||||
|
||||
protected:
|
||||
WeakPersistent<Document> document_;
|
||||
|
@ -12,13 +12,14 @@
|
||||
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/vector.h"
|
||||
#include "ui/accessibility/ax_enums.mojom-blink.h"
|
||||
#include "ui/accessibility/ax_mode.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
using ScopedBlinkAXEventIntentTest = RenderingTest;
|
||||
|
||||
TEST_F(ScopedBlinkAXEventIntentTest, SingleIntent) {
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
AXObjectCache* cache = GetDocument().ExistingAXObjectCache();
|
||||
ASSERT_NE(nullptr, cache);
|
||||
|
||||
@ -38,7 +39,7 @@ TEST_F(ScopedBlinkAXEventIntentTest, SingleIntent) {
|
||||
}
|
||||
|
||||
TEST_F(ScopedBlinkAXEventIntentTest, MultipleIdenticalIntents) {
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
AXObjectCache* cache = GetDocument().ExistingAXObjectCache();
|
||||
ASSERT_NE(nullptr, cache);
|
||||
|
||||
@ -63,7 +64,7 @@ TEST_F(ScopedBlinkAXEventIntentTest, MultipleIdenticalIntents) {
|
||||
}
|
||||
|
||||
TEST_F(ScopedBlinkAXEventIntentTest, NestedIndividualIntents) {
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
AXObjectCache* cache = GetDocument().ExistingAXObjectCache();
|
||||
ASSERT_NE(nullptr, cache);
|
||||
|
||||
@ -101,7 +102,7 @@ TEST_F(ScopedBlinkAXEventIntentTest, NestedIndividualIntents) {
|
||||
}
|
||||
|
||||
TEST_F(ScopedBlinkAXEventIntentTest, NestedMultipleIntents) {
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
AXObjectCache* cache = GetDocument().ExistingAXObjectCache();
|
||||
ASSERT_NE(nullptr, cache);
|
||||
|
||||
@ -155,7 +156,7 @@ TEST_F(ScopedBlinkAXEventIntentTest, NestedMultipleIntents) {
|
||||
}
|
||||
|
||||
TEST_F(ScopedBlinkAXEventIntentTest, NestedIdenticalIntents) {
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
AXObjectCache* cache = GetDocument().ExistingAXObjectCache();
|
||||
ASSERT_NE(nullptr, cache);
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "third_party/blink/renderer/platform/bindings/script_state.h"
|
||||
#include "third_party/blink/renderer/platform/heap/handle.h"
|
||||
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
|
||||
#include "ui/accessibility/ax_mode.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
@ -50,7 +51,8 @@ ComputedAccessibleNodePromiseResolver::ComputedAccessibleNodePromiseResolver(
|
||||
: element_(element),
|
||||
resolver_(MakeGarbageCollected<ScriptPromiseResolver>(script_state)),
|
||||
resolve_with_node_(false),
|
||||
ax_context_(std::make_unique<AXContext>(element_->GetDocument())) {}
|
||||
ax_context_(std::make_unique<AXContext>(element_->GetDocument(),
|
||||
ui::kAXModeComplete)) {}
|
||||
|
||||
ScriptPromise ComputedAccessibleNodePromiseResolver::Promise() {
|
||||
return resolver_->Promise();
|
||||
@ -106,11 +108,11 @@ void ComputedAccessibleNodePromiseResolver::UpdateTreeAndResolve() {
|
||||
|
||||
// ComputedAccessibleNode ------------------------------------------------------
|
||||
|
||||
ComputedAccessibleNode::ComputedAccessibleNode(AXID ax_id,
|
||||
Document* document)
|
||||
ComputedAccessibleNode::ComputedAccessibleNode(AXID ax_id, Document* document)
|
||||
: ax_id_(ax_id),
|
||||
document_(document),
|
||||
ax_context_(std::make_unique<AXContext>(*document)) {}
|
||||
ax_context_(std::make_unique<AXContext>(*document, ui::kAXModeComplete)) {
|
||||
}
|
||||
|
||||
absl::optional<bool> ComputedAccessibleNode::atomic() const {
|
||||
return GetBoolAttribute(WebAOMBoolAttribute::AOM_ATTR_ATOMIC);
|
||||
|
@ -169,6 +169,7 @@
|
||||
#include "third_party/blink/renderer/platform/wtf/hash_functions.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/text/text_position.h"
|
||||
#include "ui/accessibility/ax_mode.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
@ -2133,7 +2134,7 @@ const AtomicString& Element::computedRole() {
|
||||
document.View()->UpdateAllLifecyclePhasesExceptPaint(
|
||||
DocumentUpdateReason::kJavaScript);
|
||||
}
|
||||
AXContext ax_context(document);
|
||||
AXContext ax_context(document, ui::kAXModeBasic);
|
||||
return ax_context.GetAXObjectCache().ComputedRoleForNode(this);
|
||||
}
|
||||
|
||||
@ -2147,7 +2148,7 @@ String Element::computedName() {
|
||||
document.View()->UpdateAllLifecyclePhasesExceptPaint(
|
||||
DocumentUpdateReason::kJavaScript);
|
||||
}
|
||||
AXContext ax_context(document);
|
||||
AXContext ax_context(document, ui::kAXModeBasic);
|
||||
return ax_context.GetAXObjectCache().ComputedNameForNode(this);
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h"
|
||||
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
|
||||
#include "third_party/blink/renderer/platform/testing/url_test_helpers.h"
|
||||
#include "ui/accessibility/ax_mode.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -1963,7 +1964,7 @@ TEST_P(VisualViewportTest, AccessibilityHitTestWhileZoomedIn) {
|
||||
WebDocument web_doc = WebView()->MainFrameImpl()->GetDocument();
|
||||
LocalFrameView& frame_view = *WebView()->MainFrameImpl()->GetFrameView();
|
||||
|
||||
WebAXContext ax_context(web_doc);
|
||||
WebAXContext ax_context(web_doc, ui::kAXModeComplete);
|
||||
|
||||
WebView()->SetPageScaleFactor(2);
|
||||
WebView()->SetVisualViewportOffset(gfx::PointF(200, 230));
|
||||
|
@ -83,6 +83,7 @@
|
||||
#include "third_party/blink/renderer/platform/heap/heap.h"
|
||||
#include "third_party/blink/renderer/platform/keyboard_codes.h"
|
||||
#include "third_party/inspector_protocol/crdtp/json.h"
|
||||
#include "ui/accessibility/ax_mode.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
||||
using crdtp::SpanFrom;
|
||||
@ -436,7 +437,7 @@ Response InspectorOverlayAgent::enable() {
|
||||
void InspectorOverlayAgent::EnsureAXContext(Node* node) {
|
||||
Document& document = node->GetDocument();
|
||||
if (!document_to_ax_context_.Contains(&document)) {
|
||||
auto context = std::make_unique<AXContext>(document);
|
||||
auto context = std::make_unique<AXContext>(document, ui::kAXModeComplete);
|
||||
document_to_ax_context_.Set(&document, std::move(context));
|
||||
}
|
||||
}
|
||||
|
1
third_party/blink/renderer/modules/DEPS
vendored
1
third_party/blink/renderer/modules/DEPS
vendored
@ -20,6 +20,7 @@ include_rules = [
|
||||
"!third_party/blink/renderer/core/frame/web_local_frame_impl.h",
|
||||
"!third_party/blink/renderer/core/frame/web_remote_frame_impl.h",
|
||||
"+third_party/blink/renderer/modules",
|
||||
"+ui/accessibility/ax_mode.h",
|
||||
"+ui/gfx/geometry",
|
||||
"-web",
|
||||
]
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.h"
|
||||
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
|
||||
#include "ui/accessibility/ax_mode.h"
|
||||
|
||||
namespace blink {
|
||||
namespace test {
|
||||
@ -36,7 +37,7 @@ TEST_F(AccessibilityObjectModelTest, DOMElementsHaveAnAccessibleNode) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
LoadURL("https://example.com/");
|
||||
main_resource.Complete("<button id=button>Click me</button>");
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
auto* button = GetDocument().getElementById("button");
|
||||
EXPECT_NE(nullptr, button->accessibleNode());
|
||||
@ -52,7 +53,7 @@ TEST_F(AccessibilityObjectModelTest, SetAccessibleNodeRole) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
LoadURL("https://example.com/");
|
||||
main_resource.Complete("<button id=button>Click me</button>");
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
auto* cache = AXObjectCache();
|
||||
ASSERT_NE(nullptr, cache);
|
||||
@ -78,7 +79,7 @@ TEST_F(AccessibilityObjectModelTest, AOMDoesNotReflectARIA) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
LoadURL("https://example.com/");
|
||||
main_resource.Complete("<input id=textbox>");
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
// Set ARIA attributes.
|
||||
auto* textbox = GetDocument().getElementById("textbox");
|
||||
@ -107,7 +108,7 @@ TEST_F(AccessibilityObjectModelTest, AOMPropertiesCanBeCleared) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
LoadURL("https://example.com/");
|
||||
main_resource.Complete("<input type=button id=button>");
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
// Set ARIA attributes.
|
||||
auto* button = GetDocument().getElementById("button");
|
||||
@ -159,7 +160,7 @@ TEST_F(AccessibilityObjectModelTest, RangeProperties) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
LoadURL("https://example.com/");
|
||||
main_resource.Complete("<div role=slider id=slider>");
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
auto* slider = GetDocument().getElementById("slider");
|
||||
ASSERT_NE(nullptr, slider);
|
||||
@ -185,7 +186,7 @@ TEST_F(AccessibilityObjectModelTest, Level) {
|
||||
SimRequest main_resource("https://example.com/", "text/html");
|
||||
LoadURL("https://example.com/");
|
||||
main_resource.Complete("<div role=heading id=heading>");
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
auto* heading = GetDocument().getElementById("heading");
|
||||
ASSERT_NE(nullptr, heading);
|
||||
@ -202,7 +203,7 @@ TEST_F(AccessibilityObjectModelTest, ListItem) {
|
||||
LoadURL("https://example.com/");
|
||||
main_resource.Complete(
|
||||
"<div role=list><div role=listitem id=listitem></div></div>");
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
auto* listitem = GetDocument().getElementById("listitem");
|
||||
ASSERT_NE(nullptr, listitem);
|
||||
@ -227,7 +228,7 @@ TEST_F(AccessibilityObjectModelTest, Grid) {
|
||||
</div>
|
||||
</div>
|
||||
)HTML");
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
auto* grid = GetDocument().getElementById("grid");
|
||||
ASSERT_NE(nullptr, grid);
|
||||
@ -282,7 +283,7 @@ TEST_F(AccessibilityObjectModelTest, SparseAttributes) {
|
||||
<div id=error role=article>Error</div>
|
||||
<div id=error2 role=banner>Error 2</div>
|
||||
)HTML");
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
auto* target = GetDocument().getElementById("target");
|
||||
auto* cache = AXObjectCache();
|
||||
@ -361,7 +362,7 @@ TEST_F(AccessibilityObjectModelTest, LabeledBy) {
|
||||
<label id=l2>Label 2</label>
|
||||
<label id=l3>Label 3</label>
|
||||
)HTML");
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
auto* target = GetDocument().getElementById("target");
|
||||
auto* l1 = GetDocument().getElementById("l1");
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.h"
|
||||
#include "third_party/blink/renderer/modules/accessibility/testing/accessibility_test.h"
|
||||
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
|
||||
#include "ui/accessibility/ax_mode.h"
|
||||
|
||||
namespace blink {
|
||||
namespace test {
|
||||
@ -954,7 +955,7 @@ TEST_F(AccessibilityTest, InitRelationCacheLabelFor) {
|
||||
|
||||
// Now recreate an AXContext, simulating what happens if accessibility
|
||||
// is enabled after the document is loaded.
|
||||
ax_context_ = std::make_unique<AXContext>(GetDocument());
|
||||
ax_context_ = std::make_unique<AXContext>(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
const AXObject* root = GetAXRootObject();
|
||||
ASSERT_NE(nullptr, root);
|
||||
@ -980,7 +981,7 @@ TEST_F(AccessibilityTest, InitRelationCacheAriaOwns) {
|
||||
|
||||
// Now recreate an AXContext, simulating what happens if accessibility
|
||||
// is enabled after the document is loaded.
|
||||
ax_context_ = std::make_unique<AXContext>(GetDocument());
|
||||
ax_context_ = std::make_unique<AXContext>(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
const AXObject* root = GetAXRootObject();
|
||||
ASSERT_NE(nullptr, root);
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.h"
|
||||
#include "third_party/blink/renderer/modules/accessibility/inspector_type_builder_helper.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/deque.h"
|
||||
#include "ui/accessibility/ax_mode.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
@ -547,7 +548,7 @@ Response InspectorAccessibilityAgent::getPartialAXTree(
|
||||
LocalFrame* local_frame = document.GetFrame();
|
||||
if (!local_frame)
|
||||
return Response::ServerError("Frame is detached.");
|
||||
AXContext ax_context(document);
|
||||
AXContext ax_context(document, ui::kAXModeComplete);
|
||||
auto& cache = To<AXObjectCacheImpl>(ax_context.GetAXObjectCache());
|
||||
|
||||
AXObject* inspected_ax_object = cache.GetOrCreate(dom_node);
|
||||
@ -757,7 +758,7 @@ InspectorAccessibilityAgent::WalkAXNodesToDepth(Document* document,
|
||||
std::unique_ptr<protocol::Array<AXNode>> nodes =
|
||||
std::make_unique<protocol::Array<protocol::Accessibility::AXNode>>();
|
||||
|
||||
AXContext ax_context(*document);
|
||||
AXContext ax_context(*document, ui::kAXModeComplete);
|
||||
auto& cache = To<AXObjectCacheImpl>(ax_context.GetAXObjectCache());
|
||||
|
||||
Deque<std::pair<AXID, int>> id_depths;
|
||||
@ -961,7 +962,7 @@ Response InspectorAccessibilityAgent::queryAXTree(
|
||||
document.UpdateStyleAndLayout(DocumentUpdateReason::kInspector);
|
||||
DocumentLifecycle::DisallowTransitionScope disallow_transition(
|
||||
document.Lifecycle());
|
||||
AXContext ax_context(document);
|
||||
AXContext ax_context(document, ui::kAXModeComplete);
|
||||
|
||||
*nodes = std::make_unique<protocol::Array<protocol::Accessibility::AXNode>>();
|
||||
auto& cache = To<AXObjectCacheImpl>(ax_context.GetAXObjectCache());
|
||||
@ -1051,7 +1052,7 @@ void InspectorAccessibilityAgent::ProvideTo(LocalFrame* frame) {
|
||||
void InspectorAccessibilityAgent::CreateAXContext() {
|
||||
Document* document = inspected_frames_->Root()->GetDocument();
|
||||
if (document)
|
||||
context_ = std::make_unique<AXContext>(*document);
|
||||
context_ = std::make_unique<AXContext>(*document, ui::kAXModeComplete);
|
||||
}
|
||||
|
||||
void InspectorAccessibilityAgent::Trace(Visitor* visitor) const {
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "third_party/blink/renderer/core/layout/layout_view.h"
|
||||
#include "third_party/blink/renderer/modules/accessibility/ax_object.h"
|
||||
#include "third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.h"
|
||||
#include "ui/accessibility/ax_mode.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
@ -19,7 +20,7 @@ AccessibilityTest::AccessibilityTest(LocalFrameClient* local_frame_client)
|
||||
|
||||
void AccessibilityTest::SetUp() {
|
||||
RenderingTest::SetUp();
|
||||
ax_context_ = std::make_unique<AXContext>(GetDocument());
|
||||
ax_context_ = std::make_unique<AXContext>(GetDocument(), ui::kAXModeComplete);
|
||||
}
|
||||
|
||||
AXObjectCacheImpl& AccessibilityTest::GetAXObjectCache() const {
|
||||
|
5
third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_api_test.cc
vendored
5
third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_api_test.cc
vendored
@ -26,6 +26,7 @@
|
||||
#include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_gradient.h"
|
||||
#include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_pattern.h"
|
||||
#include "third_party/blink/renderer/modules/webgl/webgl_rendering_context.h"
|
||||
#include "ui/accessibility/ax_mode.h"
|
||||
|
||||
using testing::Mock;
|
||||
|
||||
@ -344,7 +345,7 @@ void ResetCanvasForAccessibilityRectTest(Document& document) {
|
||||
|
||||
TEST_F(CanvasRenderingContext2DAPITest, AccessibilityRectTestForAddHitRegion) {
|
||||
ResetCanvasForAccessibilityRectTest(GetDocument());
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
Element* button_element = GetDocument().getElementById("button");
|
||||
auto* canvas = To<HTMLCanvasElement>(GetDocument().getElementById("canvas"));
|
||||
@ -373,7 +374,7 @@ TEST_F(CanvasRenderingContext2DAPITest, AccessibilityRectTestForAddHitRegion) {
|
||||
TEST_F(CanvasRenderingContext2DAPITest,
|
||||
AccessibilityRectTestForDrawFocusIfNeeded) {
|
||||
ResetCanvasForAccessibilityRectTest(GetDocument());
|
||||
AXContext ax_context(GetDocument());
|
||||
AXContext ax_context(GetDocument(), ui::kAXModeComplete);
|
||||
|
||||
Element* button_element = GetDocument().getElementById("button");
|
||||
auto* canvas = To<HTMLCanvasElement>(GetDocument().getElementById("canvas"));
|
||||
|
@ -9,11 +9,12 @@
|
||||
#include "third_party/blink/renderer/core/accessibility/ax_object_cache.h"
|
||||
#include "third_party/blink/renderer/core/dom/document.h"
|
||||
#include "third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.h"
|
||||
#include "ui/accessibility/ax_mode.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
WebAXContext::WebAXContext(WebDocument root_document)
|
||||
: private_(new AXContext(*root_document.Unwrap<Document>())) {}
|
||||
WebAXContext::WebAXContext(WebDocument root_document, const ui::AXMode& mode)
|
||||
: private_(new AXContext(*root_document.Unwrap<Document>(), mode)) {}
|
||||
|
||||
WebAXContext::~WebAXContext() {}
|
||||
|
||||
@ -31,4 +32,8 @@ WebAXObject WebAXContext::Root() const {
|
||||
static_cast<AXObjectCacheImpl*>(&private_->GetAXObjectCache())->Root());
|
||||
}
|
||||
|
||||
const ui::AXMode& WebAXContext::GetAXMode() const {
|
||||
return private_->GetAXMode();
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
|
@ -512,6 +512,8 @@ _CONFIG = [
|
||||
'ui::AXMode',
|
||||
'ui::AXNodeData',
|
||||
'ui::AXTreeID',
|
||||
'ui::kAXModeBasic',
|
||||
'ui::kAXModeComplete',
|
||||
'ax::mojom::BoolAttribute',
|
||||
'ax::mojom::HasPopup',
|
||||
'ax::mojom::State',
|
||||
|
Reference in New Issue
Block a user