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

Side by Side Diff: ash/system/web_notification/ash_popup_alignment_delegate_unittest.cc

Issue 2643853003: ash: fix multiple stack-use-after-scope issues with GetPrimaryDisplay use. (Closed)
Patch Set: Created 3 years, 11 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" 5 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 if (!delegate.get()) { 64 if (!delegate.get()) {
65 alignment_delegate_.reset(); 65 alignment_delegate_.reset();
66 return; 66 return;
67 } 67 }
68 alignment_delegate_ = std::move(delegate); 68 alignment_delegate_ = std::move(delegate);
69 UpdateWorkArea(alignment_delegate_.get(), 69 UpdateWorkArea(alignment_delegate_.get(),
70 display::Screen::GetScreen()->GetPrimaryDisplay()); 70 display::Screen::GetScreen()->GetPrimaryDisplay());
71 } 71 }
72 72
73 Position GetPositionInDisplay(const gfx::Point& point) { 73 Position GetPositionInDisplay(const gfx::Point& point) {
74 const gfx::Rect& work_area = 74 const gfx::Rect work_area =
sky 2017/01/18 23:33:45 Why do you need the copy here? I can't see how thi
krasin1 2017/01/19 17:36:38 What happens here (before the fix) is the followin
75 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); 75 display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
76 const gfx::Point center_point = work_area.CenterPoint(); 76 const gfx::Point center_point = work_area.CenterPoint();
77 if (work_area.x() > point.x() || work_area.y() > point.y() || 77 if (work_area.x() > point.x() || work_area.y() > point.y() ||
78 work_area.right() < point.x() || work_area.bottom() < point.y()) { 78 work_area.right() < point.x() || work_area.bottom() < point.y()) {
79 return OUTSIDE; 79 return OUTSIDE;
80 } 80 }
81 81
82 if (center_point.x() < point.x()) 82 if (center_point.x() < point.x())
83 return (center_point.y() < point.y()) ? BOTTOM_RIGHT : TOP_RIGHT; 83 return (center_point.y() < point.y()) ? BOTTOM_RIGHT : TOP_RIGHT;
84 else 84 else
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 shelf->SetVirtualKeyboardBoundsForTesting(keyboard_bounds); 283 shelf->SetVirtualKeyboardBoundsForTesting(keyboard_bounds);
284 int keyboard_baseline = alignment_delegate()->GetBaseLine(); 284 int keyboard_baseline = alignment_delegate()->GetBaseLine();
285 EXPECT_NE(baseline, keyboard_baseline); 285 EXPECT_NE(baseline, keyboard_baseline);
286 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); 286 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline);
287 287
288 shelf->SetVirtualKeyboardBoundsForTesting(gfx::Rect()); 288 shelf->SetVirtualKeyboardBoundsForTesting(gfx::Rect());
289 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); 289 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine());
290 } 290 }
291 291
292 } // namespace ash 292 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698