| 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/table/table_view.h" | 5 #include "ui/views/controls/table/table_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/auto_reset.h" | 13 #include "base/auto_reset.h" |
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "ui/accessibility/ax_view_state.h" | 17 #include "ui/accessibility/ax_node_data.h" |
| 18 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
| 19 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 20 #include "ui/gfx/geometry/rect_conversions.h" | 20 #include "ui/gfx/geometry/rect_conversions.h" |
| 21 #include "ui/gfx/image/image_skia.h" | 21 #include "ui/gfx/image/image_skia.h" |
| 22 #include "ui/gfx/skia_util.h" | 22 #include "ui/gfx/skia_util.h" |
| 23 #include "ui/gfx/text_utils.h" | 23 #include "ui/gfx/text_utils.h" |
| 24 #include "ui/native_theme/native_theme.h" | 24 #include "ui/native_theme/native_theme.h" |
| 25 #include "ui/views/controls/scroll_view.h" | 25 #include "ui/views/controls/scroll_view.h" |
| 26 #include "ui/views/controls/table/table_grouper.h" | 26 #include "ui/views/controls/table/table_grouper.h" |
| 27 #include "ui/views/controls/table/table_header.h" | 27 #include "ui/views/controls/table/table_header.h" |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 bool TableView::GetTooltipText(const gfx::Point& p, | 436 bool TableView::GetTooltipText(const gfx::Point& p, |
| 437 base::string16* tooltip) const { | 437 base::string16* tooltip) const { |
| 438 return GetTooltipImpl(p, tooltip, NULL); | 438 return GetTooltipImpl(p, tooltip, NULL); |
| 439 } | 439 } |
| 440 | 440 |
| 441 bool TableView::GetTooltipTextOrigin(const gfx::Point& p, | 441 bool TableView::GetTooltipTextOrigin(const gfx::Point& p, |
| 442 gfx::Point* loc) const { | 442 gfx::Point* loc) const { |
| 443 return GetTooltipImpl(p, NULL, loc); | 443 return GetTooltipImpl(p, NULL, loc); |
| 444 } | 444 } |
| 445 | 445 |
| 446 void TableView::GetAccessibleState(ui::AXViewState* state) { | 446 void TableView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 447 state->role = ui::AX_ROLE_TABLE; | 447 node_data->role = ui::AX_ROLE_TABLE; |
| 448 state->AddStateFlag(ui::AX_STATE_READ_ONLY); | 448 node_data->AddStateFlag(ui::AX_STATE_READ_ONLY); |
| 449 state->count = RowCount(); | 449 node_data->AddIntAttribute(ui::AX_ATTR_SET_SIZE, RowCount()); |
| 450 | 450 |
| 451 if (selection_model_.active() != ui::ListSelectionModel::kUnselectedIndex) { | 451 if (selection_model_.active() != ui::ListSelectionModel::kUnselectedIndex) { |
| 452 // Get information about the active item, this is not the same as the set | 452 // Get information about the active item, this is not the same as the set |
| 453 // of selected items (of which there could be more than one). | 453 // of selected items (of which there could be more than one). |
| 454 state->role = ui::AX_ROLE_ROW; | 454 node_data->role = ui::AX_ROLE_ROW; |
| 455 state->index = selection_model_.active(); | 455 node_data->AddIntAttribute(ui::AX_ATTR_POS_IN_SET, |
| 456 selection_model_.active()); |
| 456 if (selection_model_.IsSelected(selection_model_.active())) { | 457 if (selection_model_.IsSelected(selection_model_.active())) { |
| 457 state->AddStateFlag(ui::AX_STATE_SELECTED); | 458 node_data->AddStateFlag(ui::AX_STATE_SELECTED); |
| 458 } | 459 } |
| 459 | 460 |
| 460 std::vector<base::string16> name_parts; | 461 std::vector<base::string16> name_parts; |
| 461 for (const VisibleColumn& visible_column : visible_columns_) { | 462 for (const VisibleColumn& visible_column : visible_columns_) { |
| 462 base::string16 value = model_->GetText( | 463 base::string16 value = model_->GetText( |
| 463 selection_model_.active(), visible_column.column.id); | 464 selection_model_.active(), visible_column.column.id); |
| 464 if (!value.empty()) { | 465 if (!value.empty()) { |
| 465 name_parts.push_back(visible_column.column.title); | 466 name_parts.push_back(visible_column.column.title); |
| 466 name_parts.push_back(value); | 467 name_parts.push_back(value); |
| 467 } | 468 } |
| 468 } | 469 } |
| 469 state->name = base::JoinString(name_parts, base::ASCIIToUTF16(", ")); | 470 node_data->SetName(base::JoinString(name_parts, base::ASCIIToUTF16(", "))); |
| 470 } | 471 } |
| 471 } | 472 } |
| 472 | 473 |
| 473 void TableView::OnModelChanged() { | 474 void TableView::OnModelChanged() { |
| 474 selection_model_.Clear(); | 475 selection_model_.Clear(); |
| 475 NumRowsChanged(); | 476 NumRowsChanged(); |
| 476 } | 477 } |
| 477 | 478 |
| 478 void TableView::OnItemsChanged(int start, int length) { | 479 void TableView::OnItemsChanged(int start, int length) { |
| 479 SortItemsAndUpdateMapping(); | 480 SortItemsAndUpdateMapping(); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 if (tooltip) | 958 if (tooltip) |
| 958 *tooltip = text; | 959 *tooltip = text; |
| 959 if (tooltip_origin) { | 960 if (tooltip_origin) { |
| 960 tooltip_origin->SetPoint(cell_bounds.x(), | 961 tooltip_origin->SetPoint(cell_bounds.x(), |
| 961 cell_bounds.y() + kTextVerticalPadding); | 962 cell_bounds.y() + kTextVerticalPadding); |
| 962 } | 963 } |
| 963 return true; | 964 return true; |
| 964 } | 965 } |
| 965 | 966 |
| 966 } // namespace views | 967 } // namespace views |
| OLD | NEW |