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

Side by Side Diff: ui/views/controls/label.cc

Issue 960203004: tracing for RenderTextMac::GetDisplayText() eliding goo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20150129-MacViews-Bringup5-RTHB-in-Label
Patch Set: fix upstream Created 5 years, 9 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
« no previous file with comments | « ui/gfx/render_text_unittest.cc ('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/controls/label.h" 5 #include "ui/views/controls/label.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <vector> 10 #include <vector>
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 } 438 }
439 439
440 // Text eliding is not supported for multi-lined Labels. 440 // Text eliding is not supported for multi-lined Labels.
441 // TODO(mukai): Add multi-lined elided text support. 441 // TODO(mukai): Add multi-lined elided text support.
442 gfx::ElideBehavior elide_behavior = 442 gfx::ElideBehavior elide_behavior =
443 multi_line() ? gfx::NO_ELIDE : elide_behavior_; 443 multi_line() ? gfx::NO_ELIDE : elide_behavior_;
444 if (!multi_line() || 444 if (!multi_line() ||
445 (render_text_->MultilineSupported() && !allow_character_break_)) { 445 (render_text_->MultilineSupported() && !allow_character_break_)) {
446 scoped_ptr<gfx::RenderText> render_text = 446 scoped_ptr<gfx::RenderText> render_text =
447 CreateRenderText(text(), alignment, directionality, elide_behavior); 447 CreateRenderText(text(), alignment, directionality, elide_behavior);
448 render_text->SetMultiline(multi_line());
448 render_text->SetDisplayRect(rect); 449 render_text->SetDisplayRect(rect);
449 render_text->SetMultiline(multi_line());
450 lines_.push_back(render_text.release()); 450 lines_.push_back(render_text.release());
451 // lines_.back()->SetText(lines_[0]->GetDisplayText());
451 } else { 452 } else {
452 std::vector<base::string16> lines = GetLinesForWidth(rect.width()); 453 std::vector<base::string16> lines = GetLinesForWidth(rect.width());
453 if (lines.size() > 1) 454 if (lines.size() > 1)
454 rect.set_height(std::max(line_height(), font_list().GetHeight())); 455 rect.set_height(std::max(line_height(), font_list().GetHeight()));
455 456
456 const int bottom = GetContentsBounds().bottom(); 457 const int bottom = GetContentsBounds().bottom();
457 for (size_t i = 0; i < lines.size() && rect.y() <= bottom; ++i) { 458 for (size_t i = 0; i < lines.size() && rect.y() <= bottom; ++i) {
458 scoped_ptr<gfx::RenderText> line = 459 scoped_ptr<gfx::RenderText> line =
459 CreateRenderText(lines[i], alignment, directionality, elide_behavior); 460 CreateRenderText(lines[i], alignment, directionality, elide_behavior);
460 line->SetDisplayRect(rect); 461 line->SetDisplayRect(rect);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 544 }
544 545
545 bool Label::ShouldShowDefaultTooltip() const { 546 bool Label::ShouldShowDefaultTooltip() const {
546 const gfx::Size text_size = GetTextSize(); 547 const gfx::Size text_size = GetTextSize();
547 const gfx::Size size = GetContentsBounds().size(); 548 const gfx::Size size = GetContentsBounds().size();
548 return !obscured() && (text_size.width() > size.width() || 549 return !obscured() && (text_size.width() > size.width() ||
549 (multi_line() && text_size.height() > size.height())); 550 (multi_line() && text_size.height() > size.height()));
550 } 551 }
551 552
552 } // namespace views 553 } // namespace views
OLDNEW
« no previous file with comments | « ui/gfx/render_text_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698