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

Side by Side Diff: ui/views/bubble/bubble_delegate.cc

Issue 24469006: Fixing crash Report - Magic Signature: views::View::ConvertPointToScreen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/bubble/bubble_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/bubble/bubble_delegate.h" 5 #include "ui/views/bubble/bubble_delegate.h"
6 6
7 #include "ui/gfx/animation/slide_animation.h" 7 #include "ui/gfx/animation/slide_animation.h"
8 #include "ui/gfx/color_utils.h" 8 #include "ui/gfx/color_utils.h"
9 #include "ui/gfx/rect.h" 9 #include "ui/gfx/rect.h"
10 #include "ui/native_theme/native_theme.h" 10 #include "ui/native_theme/native_theme.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 use_focusless_(false), 163 use_focusless_(false),
164 accept_events_(true), 164 accept_events_(true),
165 border_accepts_events_(true), 165 border_accepts_events_(true),
166 adjust_if_offscreen_(true), 166 adjust_if_offscreen_(true),
167 parent_window_(NULL) { 167 parent_window_(NULL) {
168 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); 168 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
169 UpdateColorsFromTheme(GetNativeTheme()); 169 UpdateColorsFromTheme(GetNativeTheme());
170 } 170 }
171 171
172 BubbleDelegateView::~BubbleDelegateView() { 172 BubbleDelegateView::~BubbleDelegateView() {
173 if (anchor_widget() != NULL) 173 DetachFromAnchor();
174 anchor_widget()->RemoveObserver(this);
175 anchor_widget_ = NULL;
176 anchor_view_ = NULL;
177 } 174 }
178 175
179 // static 176 // static
180 Widget* BubbleDelegateView::CreateBubble(BubbleDelegateView* bubble_delegate) { 177 Widget* BubbleDelegateView::CreateBubble(BubbleDelegateView* bubble_delegate) {
181 bubble_delegate->Init(); 178 bubble_delegate->Init();
182 // Determine the anchor widget from the anchor view at bubble creation time. 179 // Determine the anchor widget from the anchor view at bubble creation time.
183 bubble_delegate->anchor_widget_ = bubble_delegate->anchor_view() ? 180 bubble_delegate->anchor_widget_ = bubble_delegate->anchor_view() ?
184 bubble_delegate->anchor_view()->GetWidget() : NULL; 181 bubble_delegate->anchor_view()->GetWidget() : NULL;
185 if (bubble_delegate->anchor_widget()) 182 if (bubble_delegate->anchor_widget())
186 bubble_delegate->anchor_widget()->AddObserver(bubble_delegate); 183 bubble_delegate->anchor_widget()->AddObserver(bubble_delegate);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView( 221 NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView(
225 Widget* widget) { 222 Widget* widget) {
226 BubbleFrameView* frame = new BubbleFrameView(margins()); 223 BubbleFrameView* frame = new BubbleFrameView(margins());
227 const BubbleBorder::Arrow adjusted_arrow = base::i18n::IsRTL() ? 224 const BubbleBorder::Arrow adjusted_arrow = base::i18n::IsRTL() ?
228 BubbleBorder::horizontal_mirror(arrow()) : arrow(); 225 BubbleBorder::horizontal_mirror(arrow()) : arrow();
229 frame->SetBubbleBorder(new BubbleBorder(adjusted_arrow, shadow(), color())); 226 frame->SetBubbleBorder(new BubbleBorder(adjusted_arrow, shadow(), color()));
230 return frame; 227 return frame;
231 } 228 }
232 229
233 void BubbleDelegateView::OnWidgetDestroying(Widget* widget) { 230 void BubbleDelegateView::OnWidgetDestroying(Widget* widget) {
234 if (anchor_widget() == widget) { 231 if (anchor_widget() == widget)
235 anchor_widget_->RemoveObserver(this); 232 DetachFromAnchor();
236 anchor_view_ = NULL;
237 anchor_widget_ = NULL;
238 }
239 } 233 }
240 234
241 void BubbleDelegateView::OnWidgetVisibilityChanging(Widget* widget, 235 void BubbleDelegateView::OnWidgetVisibilityChanging(Widget* widget,
242 bool visible) { 236 bool visible) {
243 #if defined(OS_WIN) 237 #if defined(OS_WIN)
244 // On Windows we need to handle this before the bubble is visible or hidden. 238 // On Windows we need to handle this before the bubble is visible or hidden.
245 // Please see the comment on the OnWidgetVisibilityChanging function. On 239 // Please see the comment on the OnWidgetVisibilityChanging function. On
246 // other platforms it is fine to handle it after the bubble is shown/hidden. 240 // other platforms it is fine to handle it after the bubble is shown/hidden.
247 HandleVisibilityChanged(widget, visible); 241 HandleVisibilityChanged(widget, visible);
248 #endif 242 #endif
249 } 243 }
250 244
251 void BubbleDelegateView::OnWidgetVisibilityChanged(Widget* widget, 245 void BubbleDelegateView::OnWidgetVisibilityChanged(Widget* widget,
252 bool visible) { 246 bool visible) {
253 #if !defined(OS_WIN) 247 #if !defined(OS_WIN)
254 HandleVisibilityChanged(widget, visible); 248 HandleVisibilityChanged(widget, visible);
255 #endif 249 #endif
256 } 250 }
257 251
258 void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget, 252 void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget,
259 bool active) { 253 bool active) {
260 if (close_on_deactivate() && widget == GetWidget() && !active) 254 if (close_on_deactivate() && widget == GetWidget() && !active) {
255 // At this point the original anchor view could be gone and we should make
256 // sure that we do not query it anymore for screen locations.
257 DetachFromAnchor();
261 GetWidget()->Close(); 258 GetWidget()->Close();
259 }
262 } 260 }
263 261
264 void BubbleDelegateView::OnWidgetBoundsChanged(Widget* widget, 262 void BubbleDelegateView::OnWidgetBoundsChanged(Widget* widget,
265 const gfx::Rect& new_bounds) { 263 const gfx::Rect& new_bounds) {
266 if (move_with_anchor() && anchor_widget() == widget) 264 if (move_with_anchor() && anchor_widget() == widget)
267 SizeToContents(); 265 SizeToContents();
268 } 266 }
269 267
270 gfx::Rect BubbleDelegateView::GetAnchorRect() { 268 gfx::Rect BubbleDelegateView::GetAnchorRect() {
271 if (!anchor_view()) 269 if (!anchor_view())
272 return anchor_rect_; 270 return anchor_rect_;
273 gfx::Rect anchor_bounds = anchor_view()->GetBoundsInScreen(); 271 gfx::Rect anchor_bounds = anchor_view()->GetBoundsInScreen();
274 anchor_bounds.Inset(anchor_view_insets_); 272 anchor_bounds.Inset(anchor_view_insets_);
275 return anchor_bounds; 273 return anchor_bounds;
276 } 274 }
277 275
278 void BubbleDelegateView::StartFade(bool fade_in) { 276 void BubbleDelegateView::StartFade(bool fade_in) {
279 #if defined(USE_AURA) 277 #if defined(USE_AURA)
280 // Use AURA's window layer animation instead of fading. This ensures that 278 // Use AURA's window layer animation instead of fading. This ensures that
281 // hosts which rely on the layer animation callbacks to close the window 279 // hosts which rely on the layer animation callbacks to close the window
282 // work correctly. 280 // work correctly.
283 if (fade_in) 281 if (fade_in) {
284 GetWidget()->Show(); 282 GetWidget()->Show();
285 else 283 } else {
284 // At this point the original anchor view could be gone and we should make
285 // sure that we do not query it anymore for screen locations.
286 DetachFromAnchor();
286 GetWidget()->Close(); 287 GetWidget()->Close();
288 }
287 #else 289 #else
288 fade_animation_.reset(new gfx::SlideAnimation(this)); 290 fade_animation_.reset(new gfx::SlideAnimation(this));
289 fade_animation_->SetSlideDuration(GetFadeDuration()); 291 fade_animation_->SetSlideDuration(GetFadeDuration());
290 fade_animation_->Reset(fade_in ? 0.0 : 1.0); 292 fade_animation_->Reset(fade_in ? 0.0 : 1.0);
291 if (fade_in) { 293 if (fade_in) {
292 original_opacity_ = 0; 294 original_opacity_ = 0;
293 if (border_widget_) 295 if (border_widget_)
294 border_widget_->SetOpacity(original_opacity_); 296 border_widget_->SetOpacity(original_opacity_);
295 GetWidget()->SetOpacity(original_opacity_); 297 GetWidget()->SetOpacity(original_opacity_);
296 GetWidget()->Show(); 298 GetWidget()->Show();
297 fade_animation_->Show(); 299 fade_animation_->Show();
298 } else { 300 } else {
299 original_opacity_ = 255; 301 original_opacity_ = 255;
300 fade_animation_->Hide(); 302 fade_animation_->Hide();
303 // At this point the original anchor view could be gone and we should make
304 // sure that we do not query it anymore for screen locations.
305 DetachFromAnchor();
301 } 306 }
302 #endif 307 #endif
303 } 308 }
304 309
305 void BubbleDelegateView::ResetFade() { 310 void BubbleDelegateView::ResetFade() {
306 fade_animation_.reset(); 311 fade_animation_.reset();
307 if (border_widget_) 312 if (border_widget_)
308 border_widget_->SetOpacity(original_opacity_); 313 border_widget_->SetOpacity(original_opacity_);
309 GetWidget()->SetOpacity(original_opacity_); 314 GetWidget()->SetOpacity(original_opacity_);
310 } 315 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 if (border_widget_) 435 if (border_widget_)
431 border_widget_->ShowInactive(); 436 border_widget_->ShowInactive();
432 if (anchor_widget() && anchor_widget()->GetTopLevelWidget()) 437 if (anchor_widget() && anchor_widget()->GetTopLevelWidget())
433 anchor_widget()->GetTopLevelWidget()->DisableInactiveRendering(); 438 anchor_widget()->GetTopLevelWidget()->DisableInactiveRendering();
434 } else { 439 } else {
435 if (border_widget_) 440 if (border_widget_)
436 border_widget_->Hide(); 441 border_widget_->Hide();
437 } 442 }
438 } 443 }
439 444
445 void BubbleDelegateView::DetachFromAnchor() {
446 if (!anchor_widget_)
447 return
msw 2013/09/26 22:17:19 This statement needs a semicolon. Have you tested
Mr4D (OOO till 08-26) 2013/09/27 17:22:50 I told you to send a patch within 10 minutes so th
448 anchor_widget_->RemoveObserver(this);
msw 2013/09/26 22:17:19 Do this in an if (anchor_widget) block, and set |a
Mr4D (OOO till 08-26) 2013/09/27 17:22:50 Done.
449 anchor_view_ = NULL;
450 anchor_widget_ = NULL;
451 }
452
440 } // namespace views 453 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698