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

Revert: Free up accessibility tree resources from hidden frames.

It was causing too many problems like being unable to inspect background
tabs in chrome://accessibility and losing your place when switching tabs.
We should come up with a better fix.

Original change: crrev.com/c/1107207

TBR=nektar@chromium.org

Bug: 854411, 856163, 856160
Change-Id: Iaef9b8ccbd47defba02e4e887f8219d00e77a808
Reviewed-on: https://chromium-review.googlesource.com/1131846Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573876}
parent aafcd73a
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function createTabInNewInactiveWindow(url, callback) {
function createBackgroundTab(url, callback) {
chrome.tabs.query({ active: true }, function(tabs) {
chrome.test.assertEq(1, tabs.length);
var originalActiveTab = tabs[0];
chrome.windows.create({"url": url, "focused": false}, function(win) {
createTab(url, function(tab) {
chrome.tabs.update(originalActiveTab.id, { active: true }, function() {
callback(win.tabs[0]);
callback(tab);
});
})
});
......@@ -25,7 +26,7 @@ var allTests = [
getUrlFromConfig('index.html', function(url) {
// Keep the NTP as the active tab so that we know we're requesting the
// tab by ID rather than just getting the active tab still.
createTabInNewInactiveWindow(url, function(tab) {
createBackgroundTab(url, function(tab) {
chrome.automation.getTree(tab.id, function(rootNode) {
if (rootNode.docLoaded) {
assertCorrectTab(rootNode);
......
......@@ -215,22 +215,11 @@ ScopedFreezeBlinkAXTreeSource::~ScopedFreezeBlinkAXTreeSource() {
BlinkAXTreeSource::BlinkAXTreeSource(RenderFrameImpl* render_frame,
ui::AXMode mode)
: render_frame_(render_frame),
accessibility_mode_(mode),
frozen_(false),
hidden_(false) {}
: render_frame_(render_frame), accessibility_mode_(mode), frozen_(false) {}
BlinkAXTreeSource::~BlinkAXTreeSource() {
}
void BlinkAXTreeSource::WasHidden() {
hidden_ = true;
}
void BlinkAXTreeSource::WasShown() {
hidden_ = false;
}
void BlinkAXTreeSource::Freeze() {
CHECK(!frozen_);
frozen_ = true;
......@@ -384,9 +373,6 @@ void BlinkAXTreeSource::GetChildren(
std::vector<WebAXObject>* out_children) const {
CHECK(frozen_);
if (hidden_)
return;
if ((parent.Role() == blink::kWebAXRoleStaticText ||
parent.Role() == blink::kWebAXRoleLineBreak) &&
ShouldLoadInlineTextBoxes(parent)) {
......@@ -424,9 +410,6 @@ void BlinkAXTreeSource::GetChildren(
WebAXObject BlinkAXTreeSource::GetParent(WebAXObject node) const {
CHECK(frozen_);
if (hidden_)
return WebAXObject();
// Blink returns ignored objects when walking up the parent chain,
// we have to skip those here. Also, stop when we get to the root
// element.
......@@ -440,9 +423,6 @@ WebAXObject BlinkAXTreeSource::GetParent(WebAXObject node) const {
}
bool BlinkAXTreeSource::IsValid(WebAXObject node) const {
if (hidden_ && !node.Equals(root()))
return false;
return !node.IsDetached(); // This also checks if it's null.
}
......
......@@ -42,11 +42,6 @@ class BlinkAXTreeSource
BlinkAXTreeSource(RenderFrameImpl* render_frame, ui::AXMode mode);
~BlinkAXTreeSource() override;
// If the frame is hidden, expose only the root node and skip the
// rest of the tree.
void WasHidden();
void WasShown();
// Freeze caches the document, accessibility root, and current focused
// object for fast retrieval during a batch of operations. Use
// ScopedFreezeBlinkAXTreeSource on the stack rather than calling
......@@ -140,10 +135,6 @@ class BlinkAXTreeSource
blink::WebDocument document_;
blink::WebAXObject root_;
blink::WebAXObject focus_;
// If the page is hidden, we eliminate everything other than the
// root node.
bool hidden_;
};
} // namespace content
......
......@@ -125,9 +125,6 @@ RenderAccessibilityImpl::RenderAccessibilityImpl(RenderFrameImpl* render_frame,
settings->SetInlineTextBoxAccessibilityEnabled(true);
#endif
if (render_frame_->IsHidden())
tree_source_.WasHidden();
const WebDocument& document = GetMainDocument();
if (!document.IsNull()) {
// It's possible that the webview has already loaded a webpage without
......@@ -197,22 +194,8 @@ bool RenderAccessibilityImpl::OnMessageReceived(const IPC::Message& message) {
return handled;
}
void RenderAccessibilityImpl::WasHidden() {
pending_events_.clear();
tree_source_.WasHidden();
HandleAXEvent(tree_source_.GetRoot(), ax::mojom::Event::kNone);
}
void RenderAccessibilityImpl::WasShown() {
pending_events_.clear();
tree_source_.WasShown();
HandleAXEvent(tree_source_.GetRoot(), ax::mojom::Event::kNone);
}
void RenderAccessibilityImpl::HandleWebAccessibilityEvent(
const blink::WebAXObject& obj, blink::WebAXEvent event) {
if (render_frame_->IsHidden())
return;
HandleAXEvent(obj, AXEventFromBlink(event));
}
......
......@@ -75,8 +75,6 @@ class CONTENT_EXPORT RenderAccessibilityImpl
// RenderFrameObserver implementation.
void AccessibilityModeChanged() override;
bool OnMessageReceived(const IPC::Message& message) override;
void WasHidden() override;
void WasShown() override;
// Called when an accessibility notification occurs in Blink.
void HandleWebAccessibilityEvent(const blink::WebAXObject& obj,
......
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