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

Side by Side Diff: chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc

Issue 6469074: AutocompletePopupContentsView must override View::PaintChildren to prevent views (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 10 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h" 5 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" 9 #include "chrome/browser/autocomplete/autocomplete_edit_view.h"
10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 // 376 //
377 // Because the border of this view creates an anti-aliased round-rect region 377 // Because the border of this view creates an anti-aliased round-rect region
378 // for the contents, we need to render our rectangular result child views into 378 // for the contents, we need to render our rectangular result child views into
379 // this round rect region. We can't use a simple clip because clipping is 379 // this round rect region. We can't use a simple clip because clipping is
380 // 1-bit and we get nasty jagged edges. 380 // 1-bit and we get nasty jagged edges.
381 // 381 //
382 // Instead, we paint all our children into a second canvas and use that as a 382 // Instead, we paint all our children into a second canvas and use that as a
383 // shader to fill a path representing the round-rect clipping region. This 383 // shader to fill a path representing the round-rect clipping region. This
384 // yields a nice anti-aliased edge. 384 // yields a nice anti-aliased edge.
385 gfx::CanvasSkia contents_canvas(width(), height(), true); 385 gfx::CanvasSkia contents_canvas(width(), height(), true);
386 PaintChildren(&contents_canvas); 386 PaintResultViews(&contents_canvas);
387 387
388 // We want the contents background to be slightly transparent so we can see 388 // We want the contents background to be slightly transparent so we can see
389 // the blurry glass effect on DWM systems behind. We do this _after_ we paint 389 // the blurry glass effect on DWM systems behind. We do this _after_ we paint
390 // the children since they paint text, and GDI will reset this alpha data if 390 // the children since they paint text, and GDI will reset this alpha data if
391 // we paint text after this call. 391 // we paint text after this call.
392 MakeCanvasTransparent(&contents_canvas); 392 MakeCanvasTransparent(&contents_canvas);
393 393
394 // Now paint the contents of the contents canvas into the actual canvas. 394 // Now paint the contents of the contents canvas into the actual canvas.
395 SkPaint paint; 395 SkPaint paint;
396 paint.setAntiAlias(true); 396 paint.setAntiAlias(true);
397 397
398 SkShader* shader = SkShader::CreateBitmapShader( 398 SkShader* shader = SkShader::CreateBitmapShader(
399 contents_canvas.getDevice()->accessBitmap(false), 399 contents_canvas.getDevice()->accessBitmap(false),
400 SkShader::kClamp_TileMode, 400 SkShader::kClamp_TileMode,
401 SkShader::kClamp_TileMode); 401 SkShader::kClamp_TileMode);
402 paint.setShader(shader); 402 paint.setShader(shader);
403 shader->unref(); 403 shader->unref();
404 404
405 gfx::Path path; 405 gfx::Path path;
406 MakeContentsPath(&path, GetContentsBounds()); 406 MakeContentsPath(&path, GetContentsBounds());
407 canvas->AsCanvasSkia()->drawPath(path, paint); 407 canvas->AsCanvasSkia()->drawPath(path, paint);
408 408
409 // Now we paint the border, so it will be alpha-blended atop the contents. 409 // Now we paint the border, so it will be alpha-blended atop the contents.
410 // This looks slightly better in the corners than drawing the contents atop 410 // This looks slightly better in the corners than drawing the contents atop
411 // the border. 411 // the border.
412 OnPaintBorder(canvas); 412 OnPaintBorder(canvas);
413 } 413 }
414 414
415 void AutocompletePopupContentsView::PaintChildren(gfx::CanvasSkia* canvas) {
416 canvas->drawColor(AutocompleteResultView::GetColor(
417 AutocompleteResultView::NORMAL, AutocompleteResultView::BACKGROUND));
418 View::PaintChildren(canvas);
419 }
420
421 void AutocompletePopupContentsView::Layout() { 415 void AutocompletePopupContentsView::Layout() {
422 UpdateBlurRegion(); 416 UpdateBlurRegion();
423 417
424 // Size our children to the available content area. 418 // Size our children to the available content area.
425 LayoutChildren(); 419 LayoutChildren();
426 420
427 // We need to manually schedule a paint here since we are a layered window and 421 // We need to manually schedule a paint here since we are a layered window and
428 // won't implicitly require painting until we ask for one. 422 // won't implicitly require painting until we ask for one.
429 SchedulePaint(); 423 SchedulePaint();
430 } 424 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 views::View* child = views::View::GetViewForPoint(point); 499 views::View* child = views::View::GetViewForPoint(point);
506 views::View* ancestor = child; 500 views::View* ancestor = child;
507 while (ancestor && ancestor != opt_in_view_) 501 while (ancestor && ancestor != opt_in_view_)
508 ancestor = ancestor->parent(); 502 ancestor = ancestor->parent();
509 return ancestor ? child : this; 503 return ancestor ? child : this;
510 } 504 }
511 505
512 //////////////////////////////////////////////////////////////////////////////// 506 ////////////////////////////////////////////////////////////////////////////////
513 // AutocompletePopupContentsView, protected: 507 // AutocompletePopupContentsView, protected:
514 508
509 void AutocompletePopupContentsView::PaintResultViews(gfx::CanvasSkia* canvas) {
510 canvas->drawColor(AutocompleteResultView::GetColor(
511 AutocompleteResultView::NORMAL, AutocompleteResultView::BACKGROUND));
512 View::PaintChildren(canvas);
513 }
514
515 int AutocompletePopupContentsView::CalculatePopupHeight() { 515 int AutocompletePopupContentsView::CalculatePopupHeight() {
516 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size()); 516 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size());
517 int popup_height = 0; 517 int popup_height = 0;
518 for (size_t i = 0; i < model_->result().size(); ++i) 518 for (size_t i = 0; i < model_->result().size(); ++i)
519 popup_height += GetChildViewAt(i)->GetPreferredSize().height(); 519 popup_height += GetChildViewAt(i)->GetPreferredSize().height();
520 return popup_height + 520 return popup_height +
521 (opt_in_view_ ? opt_in_view_->GetPreferredSize().height() : 0); 521 (opt_in_view_ ? opt_in_view_->GetPreferredSize().height() : 0);
522 } 522 }
523 523
524 AutocompleteResultView* AutocompletePopupContentsView::CreateResultView( 524 AutocompleteResultView* AutocompletePopupContentsView::CreateResultView(
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 opt_in_view_ = NULL; 654 opt_in_view_ = NULL;
655 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); 655 PromoCounter* counter = model_->profile()->GetInstantPromoCounter();
656 DCHECK(counter); 656 DCHECK(counter);
657 counter->Hide(); 657 counter->Hide();
658 if (opt_in) { 658 if (opt_in) {
659 browser::ShowInstantConfirmDialogIfNecessary( 659 browser::ShowInstantConfirmDialogIfNecessary(
660 location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); 660 location_bar_->GetWindow()->GetNativeWindow(), model_->profile());
661 } 661 }
662 UpdatePopupAppearance(); 662 UpdatePopupAppearance();
663 } 663 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698