| 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 | 7 |
| 8 #if defined(OS_WIN) | 8 #if defined(OS_WIN) |
| 9 #include <atlbase.h> // NOLINT | 9 #include <atlbase.h> // NOLINT |
| 10 #include <atlwin.h> // NOLINT | 10 #include <atlwin.h> // NOLINT |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 23 #include "chrome/browser/ui/layout_constants.h" | 23 #include "chrome/browser/ui/layout_constants.h" |
| 24 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" | 24 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" |
| 25 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 25 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 26 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" | 26 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" |
| 27 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
| 28 #include "components/grit/components_scaled_resources.h" | 28 #include "components/grit/components_scaled_resources.h" |
| 29 #include "components/omnibox/browser/omnibox_popup_model.h" | 29 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 30 #include "third_party/skia/include/core/SkColor.h" | 30 #include "third_party/skia/include/core/SkColor.h" |
| 31 #include "ui/accessibility/ax_view_state.h" | 31 #include "ui/accessibility/ax_node_data.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
| 34 #include "ui/base/theme_provider.h" | 34 #include "ui/base/theme_provider.h" |
| 35 #include "ui/gfx/canvas.h" | 35 #include "ui/gfx/canvas.h" |
| 36 #include "ui/gfx/color_palette.h" | 36 #include "ui/gfx/color_palette.h" |
| 37 #include "ui/gfx/color_utils.h" | 37 #include "ui/gfx/color_utils.h" |
| 38 #include "ui/gfx/image/image.h" | 38 #include "ui/gfx/image/image.h" |
| 39 #include "ui/gfx/paint_vector_icon.h" | 39 #include "ui/gfx/paint_vector_icon.h" |
| 40 #include "ui/gfx/range/range.h" | 40 #include "ui/gfx/range/range.h" |
| 41 #include "ui/gfx/render_text.h" | 41 #include "ui/gfx/render_text.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 separator_rendertext_.reset(); | 262 separator_rendertext_.reset(); |
| 263 keyword_contents_rendertext_.reset(); | 263 keyword_contents_rendertext_.reset(); |
| 264 keyword_description_rendertext_.reset(); | 264 keyword_description_rendertext_.reset(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void OmniboxResultView::OnSelected() { | 267 void OmniboxResultView::OnSelected() { |
| 268 DCHECK_EQ(SELECTED, GetState()); | 268 DCHECK_EQ(SELECTED, GetState()); |
| 269 | 269 |
| 270 // Notify assistive technology when results with answers attached are | 270 // Notify assistive technology when results with answers attached are |
| 271 // selected. The non-answer text is already accessible as a consequence of | 271 // selected. The non-answer text is already accessible as a consequence of |
| 272 // updating the text in the omnibox but this alert and GetAccessibleState | 272 // updating the text in the omnibox but this alert and GetAccessibleNodeData |
| 273 // below make the answer contents accessible. | 273 // below make the answer contents accessible. |
| 274 if (match_.answer) | 274 if (match_.answer) |
| 275 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 275 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 276 } | 276 } |
| 277 | 277 |
| 278 gfx::Size OmniboxResultView::GetPreferredSize() const { | 278 gfx::Size OmniboxResultView::GetPreferredSize() const { |
| 279 if (!match_.answer) | 279 if (!match_.answer) |
| 280 return gfx::Size(0, GetContentLineHeight()); | 280 return gfx::Size(0, GetContentLineHeight()); |
| 281 // An answer implies a match and a description in a large font. | 281 // An answer implies a match and a description in a large font. |
| 282 if (match_.answer->second_line().num_text_lines() == 1) | 282 if (match_.answer->second_line().num_text_lines() == 1) |
| 283 return gfx::Size(0, GetContentLineHeight() + GetAnswerLineHeight()); | 283 return gfx::Size(0, GetContentLineHeight() + GetAnswerLineHeight()); |
| 284 if (!description_rendertext_) { | 284 if (!description_rendertext_) { |
| 285 description_rendertext_ = | 285 description_rendertext_ = |
| 286 CreateAnswerLine(match_.answer->second_line(), font_list_); | 286 CreateAnswerLine(match_.answer->second_line(), font_list_); |
| 287 } | 287 } |
| 288 description_rendertext_->SetDisplayRect( | 288 description_rendertext_->SetDisplayRect( |
| 289 gfx::Rect(text_bounds_.width(), 0)); | 289 gfx::Rect(text_bounds_.width(), 0)); |
| 290 description_rendertext_->GetStringSize(); | 290 description_rendertext_->GetStringSize(); |
| 291 return gfx::Size( | 291 return gfx::Size( |
| 292 0, GetContentLineHeight() + | 292 0, GetContentLineHeight() + |
| 293 GetAnswerLineHeight() * description_rendertext_->GetNumLines()); | 293 GetAnswerLineHeight() * description_rendertext_->GetNumLines()); |
| 294 } | 294 } |
| 295 | 295 |
| 296 void OmniboxResultView::GetAccessibleState(ui::AXViewState* state) { | 296 void OmniboxResultView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 297 state->name = match_.answer | 297 node_data->SetName(match_.answer |
| 298 ? l10n_util::GetStringFUTF16( | 298 ? l10n_util::GetStringFUTF16( |
| 299 IDS_OMNIBOX_ACCESSIBLE_ANSWER, match_.contents, | 299 IDS_OMNIBOX_ACCESSIBLE_ANSWER, match_.contents, |
| 300 match_.answer->second_line().AccessibleText()) | 300 match_.answer->second_line().AccessibleText()) |
| 301 : match_.contents; | 301 : match_.contents); |
| 302 } | 302 } |
| 303 | 303 |
| 304 //////////////////////////////////////////////////////////////////////////////// | 304 //////////////////////////////////////////////////////////////////////////////// |
| 305 // OmniboxResultView, protected: | 305 // OmniboxResultView, protected: |
| 306 | 306 |
| 307 OmniboxResultView::ResultViewState OmniboxResultView::GetState() const { | 307 OmniboxResultView::ResultViewState OmniboxResultView::GetState() const { |
| 308 if (model_->IsSelectedIndex(model_index_)) | 308 if (model_->IsSelectedIndex(model_index_)) |
| 309 return SELECTED; | 309 return SELECTED; |
| 310 return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL; | 310 return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL; |
| 311 } | 311 } |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 destination->AppendText(text); | 765 destination->AppendText(text); |
| 766 const TextStyle& text_style = GetTextStyle(text_type); | 766 const TextStyle& text_style = GetTextStyle(text_type); |
| 767 // TODO(dschuyler): follow up on the problem of different font sizes within | 767 // TODO(dschuyler): follow up on the problem of different font sizes within |
| 768 // one RenderText. Maybe with destination->SetFontList(...). | 768 // one RenderText. Maybe with destination->SetFontList(...). |
| 769 destination->ApplyWeight( | 769 destination->ApplyWeight( |
| 770 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); | 770 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); |
| 771 destination->ApplyColor( | 771 destination->ApplyColor( |
| 772 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); | 772 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); |
| 773 destination->ApplyBaselineStyle(text_style.baseline, range); | 773 destination->ApplyBaselineStyle(text_style.baseline, range); |
| 774 } | 774 } |
| OLD | NEW |