| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversion_utils.h" | 9 #include "base/strings/utf_string_conversion_utils.h" |
| 10 #include "components/pdf/renderer/pdf_accessibility_tree.h" | 10 #include "components/pdf/renderer/pdf_accessibility_tree.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 ui::AXNodeData* page_node = CreateNode(ui::AX_ROLE_REGION); | 84 ui::AXNodeData* page_node = CreateNode(ui::AX_ROLE_REGION); |
| 85 page_node->AddStringAttribute( | 85 page_node->AddStringAttribute( |
| 86 ui::AX_ATTR_NAME, | 86 ui::AX_ATTR_NAME, |
| 87 l10n_util::GetPluralStringFUTF8( | 87 l10n_util::GetPluralStringFUTF8( |
| 88 IDS_PDF_PAGE_INDEX, page_index + 1)); | 88 IDS_PDF_PAGE_INDEX, page_index + 1)); |
| 89 | 89 |
| 90 gfx::RectF page_bounds = ToRectF(page_info.bounds); | 90 gfx::RectF page_bounds = ToRectF(page_info.bounds); |
| 91 page_bounds += offset_; | 91 page_bounds += offset_; |
| 92 page_bounds -= scroll_; | 92 page_bounds -= scroll_; |
| 93 page_bounds.Scale(zoom_ / GetDeviceScaleFactor()); | 93 page_bounds.Scale(zoom_ / GetDeviceScaleFactor()); |
| 94 page_node->location = gfx::ToEnclosingRect(page_bounds); | 94 page_node->location = page_bounds; |
| 95 doc_node_->location.Union(page_node->location); | 95 doc_node_->location.Union(page_node->location); |
| 96 doc_node_->child_ids.push_back(page_node->id); | 96 doc_node_->child_ids.push_back(page_node->id); |
| 97 | 97 |
| 98 double heading_font_size_threshold = 0; | 98 double heading_font_size_threshold = 0; |
| 99 double line_spacing_threshold = 0; | 99 double line_spacing_threshold = 0; |
| 100 ComputeParagraphAndHeadingThresholds(text_runs, | 100 ComputeParagraphAndHeadingThresholds(text_runs, |
| 101 &heading_font_size_threshold, | 101 &heading_font_size_threshold, |
| 102 &line_spacing_threshold); | 102 &line_spacing_threshold); |
| 103 | 103 |
| 104 ui::AXNodeData* para_node = nullptr; | 104 ui::AXNodeData* para_node = nullptr; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 134 | 134 |
| 135 // Add this text run to the current static text node. | 135 // Add this text run to the current static text node. |
| 136 ui::AXNodeData* inline_text_box_node = CreateNode( | 136 ui::AXNodeData* inline_text_box_node = CreateNode( |
| 137 ui::AX_ROLE_INLINE_TEXT_BOX); | 137 ui::AX_ROLE_INLINE_TEXT_BOX); |
| 138 static_text_node->child_ids.push_back(inline_text_box_node->id); | 138 static_text_node->child_ids.push_back(inline_text_box_node->id); |
| 139 | 139 |
| 140 inline_text_box_node->AddStringAttribute(ui::AX_ATTR_NAME, chars_utf8); | 140 inline_text_box_node->AddStringAttribute(ui::AX_ATTR_NAME, chars_utf8); |
| 141 gfx::RectF text_run_bounds = ToGfxRectF(text_run.bounds); | 141 gfx::RectF text_run_bounds = ToGfxRectF(text_run.bounds); |
| 142 text_run_bounds.Scale(zoom_ / GetDeviceScaleFactor()); | 142 text_run_bounds.Scale(zoom_ / GetDeviceScaleFactor()); |
| 143 text_run_bounds += page_bounds.OffsetFromOrigin(); | 143 text_run_bounds += page_bounds.OffsetFromOrigin(); |
| 144 inline_text_box_node->location = gfx::ToEnclosingRect(text_run_bounds); | 144 inline_text_box_node->location = text_run_bounds; |
| 145 inline_text_box_node->AddIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS, | 145 inline_text_box_node->AddIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS, |
| 146 char_offsets); | 146 char_offsets); |
| 147 | 147 |
| 148 para_node->location.Union(inline_text_box_node->location); | 148 para_node->location.Union(inline_text_box_node->location); |
| 149 static_text_node->location.Union(inline_text_box_node->location); | 149 static_text_node->location.Union(inline_text_box_node->location); |
| 150 | 150 |
| 151 if (i == text_runs.size() - 1) { | 151 if (i == text_runs.size() - 1) { |
| 152 static_text_node->AddStringAttribute(ui::AX_ATTR_NAME, static_text); | 152 static_text_node->AddStringAttribute(ui::AX_ATTR_NAME, static_text); |
| 153 break; | 153 break; |
| 154 } | 154 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 const ui::AXNode* PdfAccessibilityTree::GetNull() const { | 319 const ui::AXNode* PdfAccessibilityTree::GetNull() const { |
| 320 return nullptr; | 320 return nullptr; |
| 321 } | 321 } |
| 322 | 322 |
| 323 void PdfAccessibilityTree::SerializeNode( | 323 void PdfAccessibilityTree::SerializeNode( |
| 324 const ui::AXNode* node, ui::AXNodeData* out_data) const { | 324 const ui::AXNode* node, ui::AXNodeData* out_data) const { |
| 325 *out_data = node->data(); | 325 *out_data = node->data(); |
| 326 } | 326 } |
| 327 | 327 |
| 328 } // namespace pdf | 328 } // namespace pdf |
| OLD | NEW |