| 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 // For WinDDK ATL compatibility, these ATL headers must come first. | 5 // For WinDDK ATL compatibility, these ATL headers must come first. |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <atlbase.h> // NOLINT | 8 #include <atlbase.h> // NOLINT |
| 9 #include <atlwin.h> // NOLINT | 9 #include <atlwin.h> // NOLINT |
| 10 #endif | 10 #endif |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 // Draw the runs. | 464 // Draw the runs. |
| 465 for (Runs::iterator i(runs.begin()); i != runs.end(); ++i) { | 465 for (Runs::iterator i(runs.begin()); i != runs.end(); ++i) { |
| 466 const bool reverse_visible_order = (i->is_rtl != base::i18n::IsRTL()); | 466 const bool reverse_visible_order = (i->is_rtl != base::i18n::IsRTL()); |
| 467 if (reverse_visible_order) | 467 if (reverse_visible_order) |
| 468 std::reverse(i->classifications.begin(), i->classifications.end()); | 468 std::reverse(i->classifications.begin(), i->classifications.end()); |
| 469 for (Classifications::const_iterator j(i->classifications.begin()); | 469 for (Classifications::const_iterator j(i->classifications.begin()); |
| 470 j != i->classifications.end(); ++j) { | 470 j != i->classifications.end(); ++j) { |
| 471 const gfx::Size size = (*j)->GetStringSize(); | 471 const gfx::Size size = (*j)->GetStringSize(); |
| 472 // Align the text runs to a common baseline. | 472 // Align the text runs to a common baseline. |
| 473 const gfx::Rect rect( | 473 const gfx::Rect rect( |
| 474 mirroring_context_->mirrored_left_coord(x, x + size.width()), | 474 mirroring_context_->mirrored_left_coord(x, x + size.width()), y, |
| 475 y + font_list_.GetBaseline() - (*j)->GetBaseline(), | 475 size.width(), height()); |
| 476 size.width(), size.height()); | |
| 477 (*j)->SetDisplayRect(rect); | 476 (*j)->SetDisplayRect(rect); |
| 478 (*j)->Draw(canvas); | 477 (*j)->Draw(canvas); |
| 479 x += size.width(); | 478 x += size.width(); |
| 480 } | 479 } |
| 481 } | 480 } |
| 482 | 481 |
| 483 return x; | 482 return x; |
| 484 } | 483 } |
| 485 | 484 |
| 486 void OmniboxResultView::Elide(Runs* runs, int remaining_width) const { | 485 void OmniboxResultView::Elide(Runs* runs, int remaining_width) const { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 | 566 |
| 568 void OmniboxResultView::Layout() { | 567 void OmniboxResultView::Layout() { |
| 569 const gfx::ImageSkia icon = GetIcon(); | 568 const gfx::ImageSkia icon = GetIcon(); |
| 570 | 569 |
| 571 icon_bounds_.SetRect(edge_item_padding_ + | 570 icon_bounds_.SetRect(edge_item_padding_ + |
| 572 ((icon.width() == default_icon_size_) ? | 571 ((icon.width() == default_icon_size_) ? |
| 573 0 : LocationBarView::kIconInternalPadding), | 572 0 : LocationBarView::kIconInternalPadding), |
| 574 (height() - icon.height()) / 2, icon.width(), icon.height()); | 573 (height() - icon.height()) / 2, icon.width(), icon.height()); |
| 575 | 574 |
| 576 int text_x = edge_item_padding_ + default_icon_size_ + item_padding_; | 575 int text_x = edge_item_padding_ + default_icon_size_ + item_padding_; |
| 577 int text_height = GetTextHeight(); | |
| 578 int text_width; | 576 int text_width; |
| 579 | 577 |
| 580 if (match_.associated_keyword.get()) { | 578 if (match_.associated_keyword.get()) { |
| 581 const int kw_collapsed_size = | 579 const int kw_collapsed_size = |
| 582 keyword_icon_->width() + edge_item_padding_; | 580 keyword_icon_->width() + edge_item_padding_; |
| 583 const int max_kw_x = width() - kw_collapsed_size; | 581 const int max_kw_x = width() - kw_collapsed_size; |
| 584 const int kw_x = | 582 const int kw_x = |
| 585 animation_->CurrentValueBetween(max_kw_x, edge_item_padding_); | 583 animation_->CurrentValueBetween(max_kw_x, edge_item_padding_); |
| 586 const int kw_text_x = kw_x + keyword_icon_->width() + item_padding_; | 584 const int kw_text_x = kw_x + keyword_icon_->width() + item_padding_; |
| 587 | 585 |
| 588 text_width = kw_x - text_x - item_padding_; | 586 text_width = kw_x - text_x - item_padding_; |
| 589 keyword_text_bounds_.SetRect(kw_text_x, 0, | 587 keyword_text_bounds_.SetRect( |
| 590 std::max(width() - kw_text_x - edge_item_padding_, 0), text_height); | 588 kw_text_x, 0, |
| 591 keyword_icon_->SetPosition(gfx::Point(kw_x, | 589 std::max(width() - kw_text_x - edge_item_padding_, 0), height()); |
| 592 (height() - keyword_icon_->height()) / 2)); | 590 keyword_icon_->SetPosition( |
| 591 gfx::Point(kw_x, (height() - keyword_icon_->height()) / 2)); |
| 593 } else { | 592 } else { |
| 594 text_width = width() - text_x - edge_item_padding_; | 593 text_width = width() - text_x - edge_item_padding_; |
| 595 } | 594 } |
| 596 | 595 |
| 597 text_bounds_.SetRect(text_x, std::max(0, (height() - text_height) / 2), | 596 text_bounds_.SetRect(text_x, 0, std::max(text_width, 0), height()); |
| 598 std::max(text_width, 0), text_height); | |
| 599 } | 597 } |
| 600 | 598 |
| 601 void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 599 void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 602 animation_->SetSlideDuration(width() / 4); | 600 animation_->SetSlideDuration(width() / 4); |
| 603 } | 601 } |
| 604 | 602 |
| 605 void OmniboxResultView::OnPaint(gfx::Canvas* canvas) { | 603 void OmniboxResultView::OnPaint(gfx::Canvas* canvas) { |
| 606 const ResultViewState state = GetState(); | 604 const ResultViewState state = GetState(); |
| 607 if (state != NORMAL) | 605 if (state != NORMAL) |
| 608 canvas->DrawColor(GetColor(state, BACKGROUND)); | 606 canvas->DrawColor(GetColor(state, BACKGROUND)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 624 int x = GetMirroredXForRect(keyword_text_bounds_); | 622 int x = GetMirroredXForRect(keyword_text_bounds_); |
| 625 mirroring_context_->Initialize(x, keyword_text_bounds_.width()); | 623 mirroring_context_->Initialize(x, keyword_text_bounds_.width()); |
| 626 PaintMatch(canvas, *match_.associated_keyword.get(), x); | 624 PaintMatch(canvas, *match_.associated_keyword.get(), x); |
| 627 } | 625 } |
| 628 } | 626 } |
| 629 | 627 |
| 630 void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) { | 628 void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) { |
| 631 Layout(); | 629 Layout(); |
| 632 SchedulePaint(); | 630 SchedulePaint(); |
| 633 } | 631 } |
| OLD | NEW |