OLD | NEW |
---|---|
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/controls/label.h" | 5 #include "ui/views/controls/label.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
448 render_text->SetText(text); | 448 render_text->SetText(text); |
449 return render_text; | 449 return render_text; |
450 } | 450 } |
451 | 451 |
452 void Label::PaintText(gfx::Canvas* canvas) { | 452 void Label::PaintText(gfx::Canvas* canvas) { |
453 MaybeBuildRenderTextLines(); | 453 MaybeBuildRenderTextLines(); |
454 | 454 |
455 for (size_t i = 0; i < lines_.size(); ++i) | 455 for (size_t i = 0; i < lines_.size(); ++i) |
456 lines_[i]->Draw(canvas); | 456 lines_[i]->Draw(canvas); |
457 | 457 |
458 #if DCHECK_IS_ON() | |
sky
2017/03/03 19:15:39
Why ar eyou removing the DCHECK_IS_ON conditional?
Qiang(Joe) Xu
2017/03/03 19:29:54
Done. I thought we were going to remove the follow
| |
459 // Attempt to ensure that if we're using subpixel rendering, we're painting | 458 // Attempt to ensure that if we're using subpixel rendering, we're painting |
460 // to an opaque background. What we don't want to find is an ancestor in the | 459 // to an opaque background. What we don't want to find is an ancestor in the |
461 // hierarchy that paints to a non-opaque layer. | 460 // hierarchy that paints to a non-opaque layer. |
462 if (lines_.empty() || lines_[0]->subpixel_rendering_suppressed()) | 461 if (lines_.empty() || lines_[0]->subpixel_rendering_suppressed()) |
463 return; | 462 return; |
464 | 463 |
465 for (View* view = this; view; view = view->parent()) { | 464 for (View* view = this; view; view = view->parent()) { |
466 if (view->background() && | 465 if (view->background() && |
467 SkColorGetA(view->background()->get_color()) == SK_AlphaOPAQUE) | 466 SkColorGetA(view->background()->get_color()) == SK_AlphaOPAQUE) |
468 break; | 467 break; |
469 | 468 |
470 if (view->layer()) { | 469 if (view->layer() && view->layer()->fills_bounds_opaquely()) { |
471 DCHECK(view->layer()->fills_bounds_opaquely()) | 470 LOG(WARNING) << "Ancestor view has a non-opaque layer: " |
sky
2017/03/03 19:15:39
DLOG at best.
Qiang(Joe) Xu
2017/03/03 19:29:54
Done.
| |
472 << " Ancestor view has a non-opaque layer: " << view->GetClassName() | 471 << view->GetClassName() << " with ID " << view->id(); |
473 << " with ID " << view->id(); | |
474 break; | 472 break; |
475 } | 473 } |
476 } | 474 } |
477 #endif | |
478 } | 475 } |
479 | 476 |
480 void Label::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 477 void Label::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
481 if (previous_bounds.size() != size()) | 478 if (previous_bounds.size() != size()) |
482 InvalidateLayout(); | 479 InvalidateLayout(); |
483 } | 480 } |
484 | 481 |
485 void Label::OnPaint(gfx::Canvas* canvas) { | 482 void Label::OnPaint(gfx::Canvas* canvas) { |
486 View::OnPaint(canvas); | 483 View::OnPaint(canvas); |
487 if (is_first_paint_text_) { | 484 if (is_first_paint_text_) { |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1056 .WriteText(GetSelectedText()); | 1053 .WriteText(GetSelectedText()); |
1057 } | 1054 } |
1058 | 1055 |
1059 void Label::BuildContextMenuContents() { | 1056 void Label::BuildContextMenuContents() { |
1060 context_menu_contents_.AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); | 1057 context_menu_contents_.AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); |
1061 context_menu_contents_.AddItemWithStringId(IDS_APP_SELECT_ALL, | 1058 context_menu_contents_.AddItemWithStringId(IDS_APP_SELECT_ALL, |
1062 IDS_APP_SELECT_ALL); | 1059 IDS_APP_SELECT_ALL); |
1063 } | 1060 } |
1064 | 1061 |
1065 } // namespace views | 1062 } // namespace views |
OLD | NEW |