Commit b35a59e1 authored by Chris Hall's avatar Chris Hall Committed by Commit Bot

Moving AXNode.language_info_ from raw pointer to unique_ptr

R=dmazzoni,aboxhall
BUG=889370

Change-Id: Ic3cb08d971a387fe55fe9b6c527eaab09db18dd5
Reviewed-on: https://chromium-review.googlesource.com/c/1354734
Commit-Queue: Chris Hall <chrishall@chromium.org>
Reviewed-by: default avatarAlice Boxhall <aboxhall@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612992}
parent 2014176e
...@@ -28,10 +28,7 @@ AXNode::AXNode(AXNode::OwnerTree* tree, ...@@ -28,10 +28,7 @@ AXNode::AXNode(AXNode::OwnerTree* tree,
data_.id = id; data_.id = id;
} }
AXNode::~AXNode() { AXNode::~AXNode() = default;
if (language_info_)
delete language_info_;
}
int AXNode::GetUnignoredChildCount() const { int AXNode::GetUnignoredChildCount() const {
int count = 0; int count = 0;
...@@ -184,15 +181,15 @@ base::string16 AXNode::GetInheritedString16Attribute( ...@@ -184,15 +181,15 @@ base::string16 AXNode::GetInheritedString16Attribute(
const AXLanguageInfo* AXNode::GetLanguageInfo() { const AXLanguageInfo* AXNode::GetLanguageInfo() {
if (language_info_) if (language_info_)
return language_info_; return language_info_.get();
const auto& lang_attr = const auto& lang_attr =
GetStringAttribute(ax::mojom::StringAttribute::kLanguage); GetStringAttribute(ax::mojom::StringAttribute::kLanguage);
// Promote language attribute to LanguageInfo. // Promote language attribute to LanguageInfo.
if (!lang_attr.empty()) { if (!lang_attr.empty()) {
language_info_ = new AXLanguageInfo(this, lang_attr); language_info_.reset(new AXLanguageInfo(this, lang_attr));
return language_info_; return language_info_.get();
} }
// Try search for language through parent instead. // Try search for language through parent instead.
...@@ -204,8 +201,8 @@ const AXLanguageInfo* AXNode::GetLanguageInfo() { ...@@ -204,8 +201,8 @@ const AXLanguageInfo* AXNode::GetLanguageInfo() {
return nullptr; return nullptr;
// Cache the results on this node. // Cache the results on this node.
language_info_ = new AXLanguageInfo(parent_lang_info, this); language_info_.reset(new AXLanguageInfo(parent_lang_info, this));
return language_info_; return language_info_.get();
} }
std::string AXNode::GetLanguage() { std::string AXNode::GetLanguage() {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <stdint.h> #include <stdint.h>
#include <memory>
#include <ostream> #include <ostream>
#include <vector> #include <vector>
...@@ -283,7 +284,7 @@ class AX_EXPORT AXNode final { ...@@ -283,7 +284,7 @@ class AX_EXPORT AXNode final {
std::vector<AXNode*> children_; std::vector<AXNode*> children_;
AXNodeData data_; AXNodeData data_;
AXLanguageInfo* language_info_; std::unique_ptr<AXLanguageInfo> language_info_;
// Return an object containing information about the languages used. // Return an object containing information about the languages used.
// Will walk up tree if needed to determine language. // Will walk up tree if needed to determine language.
......
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