Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Unified Diff: ui/chromeos/ime/candidate_window_view.cc

Issue 2474163003: Remove stl_util's deletion function use from ui/. (Closed)
Patch Set: braces Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/chromeos/ime/candidate_window_view.h ('k') | ui/chromeos/ime/candidate_window_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/chromeos/ime/candidate_window_view.cc
diff --git a/ui/chromeos/ime/candidate_window_view.cc b/ui/chromeos/ime/candidate_window_view.cc
index dcfd35893f39218af53bce378c8ecccd5dba4483..7182c361c2791c1a37d076c1557f3b8c2433827c 100644
--- a/ui/chromeos/ime/candidate_window_view.cc
+++ b/ui/chromeos/ime/candidate_window_view.cc
@@ -9,6 +9,7 @@
#include <string>
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/chromeos/ime/candidate_view.h"
#include "ui/chromeos/ime/candidate_window_constants.h"
@@ -280,7 +281,7 @@ void CandidateWindowView::UpdateCandidates(
for (size_t i = 0; i < candidate_views_.size(); ++i) {
const size_t index_in_page = i;
const size_t candidate_index = start_from + index_in_page;
- CandidateView* candidate_view = candidate_views_[index_in_page];
+ CandidateView* candidate_view = candidate_views_[index_in_page].get();
// Set the candidate text.
if (candidate_index < new_candidate_window.candidates().size()) {
const ui::CandidateWindow::Entry& entry =
@@ -304,8 +305,8 @@ void CandidateWindowView::UpdateCandidates(
}
}
if (new_candidate_window.orientation() == ui::CandidateWindow::VERTICAL) {
- for (size_t i = 0; i < candidate_views_.size(); ++i)
- candidate_views_[i]->SetWidths(max_shortcut_width, max_candidate_width);
+ for (const auto& view : candidate_views_)
+ view->SetWidths(max_shortcut_width, max_candidate_width);
}
CandidateWindowBorder* border = static_cast<CandidateWindowBorder*>(
@@ -359,16 +360,16 @@ void CandidateWindowView::MaybeInitializeCandidateViews(
// Reset all candidate_views_ when orientation changes.
if (orientation != candidate_window_.orientation())
- base::STLDeleteElements(&candidate_views_);
+ candidate_views_.clear();
- while (page_size < candidate_views_.size()) {
- delete candidate_views_.back();
+ while (page_size < candidate_views_.size())
candidate_views_.pop_back();
- }
+
while (page_size > candidate_views_.size()) {
- CandidateView* new_candidate = new CandidateView(this, orientation);
- candidate_area_->AddChildView(new_candidate);
- candidate_views_.push_back(new_candidate);
+ std::unique_ptr<CandidateView> new_candidate =
+ base::MakeUnique<CandidateView>(this, orientation);
+ candidate_area_->AddChildView(new_candidate.get());
+ candidate_views_.push_back(std::move(new_candidate));
}
}
@@ -408,7 +409,7 @@ int CandidateWindowView::GetDialogButtons() const {
void CandidateWindowView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
for (size_t i = 0; i < candidate_views_.size(); ++i) {
- if (sender == candidate_views_[i]) {
+ if (sender == candidate_views_[i].get()) {
for (Observer& observer : observers_)
observer.OnCandidateCommitted(i);
return;
« no previous file with comments | « ui/chromeos/ime/candidate_window_view.h ('k') | ui/chromeos/ime/candidate_window_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698