OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "pdf/pdfium/pdfium_page.h" | 5 #include "pdf/pdfium/pdfium_page.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <memory> | 11 #include <memory> |
| 12 #include <utility> |
12 | 13 |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "pdf/pdfium/pdfium_api_string_buffer_adapter.h" | 19 #include "pdf/pdfium/pdfium_api_string_buffer_adapter.h" |
19 #include "pdf/pdfium/pdfium_engine.h" | 20 #include "pdf/pdfium/pdfium_engine.h" |
20 #include "printing/units.h" | 21 #include "printing/units.h" |
21 | 22 |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 302 } |
302 } | 303 } |
303 | 304 |
304 if (is_intraword_linebreak || IsEol(character)) { | 305 if (is_intraword_linebreak || IsEol(character)) { |
305 if (!line_rect.IsEmpty()) { | 306 if (!line_rect.IsEmpty()) { |
306 if (is_intraword_linebreak) { | 307 if (is_intraword_linebreak) { |
307 // Add a 0-width hyphen. | 308 // Add a 0-width hyphen. |
308 line.push_back('-'); | 309 line.push_back('-'); |
309 } | 310 } |
310 | 311 |
311 base::DictionaryValue* text_node = new base::DictionaryValue(); | 312 std::unique_ptr<base::DictionaryValue> text_node( |
| 313 new base::DictionaryValue()); |
312 text_node->SetString(kTextNodeType, kTextNodeTypeText); | 314 text_node->SetString(kTextNodeType, kTextNodeTypeText); |
313 text_node->SetString(kTextNodeText, line); | 315 text_node->SetString(kTextNodeText, line); |
314 | 316 |
315 base::ListValue* text_nodes = new base::ListValue(); | 317 base::ListValue* text_nodes = new base::ListValue(); |
316 text_nodes->Append(text_node); | 318 text_nodes->Append(std::move(text_node)); |
317 | 319 |
318 base::DictionaryValue* line_node = new base::DictionaryValue(); | 320 std::unique_ptr<base::DictionaryValue> line_node( |
| 321 new base::DictionaryValue()); |
319 line_node->SetDouble(kTextBoxLeft, line_rect.x()); | 322 line_node->SetDouble(kTextBoxLeft, line_rect.x()); |
320 line_node->SetDouble(kTextBoxTop, line_rect.y()); | 323 line_node->SetDouble(kTextBoxTop, line_rect.y()); |
321 line_node->SetDouble(kTextBoxWidth, line_rect.width()); | 324 line_node->SetDouble(kTextBoxWidth, line_rect.width()); |
322 line_node->SetDouble(kTextBoxHeight, line_rect.height()); | 325 line_node->SetDouble(kTextBoxHeight, line_rect.height()); |
323 line_node->SetDouble(kTextBoxFontSize, | 326 line_node->SetDouble(kTextBoxFontSize, |
324 FPDFText_GetFontSize(text_page, i)); | 327 FPDFText_GetFontSize(text_page, i)); |
325 line_node->Set(kTextBoxNodes, text_nodes); | 328 line_node->Set(kTextBoxNodes, text_nodes); |
326 text->Append(line_node); | 329 text->Append(std::move(line_node)); |
327 | 330 |
328 line.clear(); | 331 line.clear(); |
329 line_rect = pp::Rect(); | 332 line_rect = pp::Rect(); |
330 word_rect = pp::Rect(); | 333 word_rect = pp::Rect(); |
331 seen_literal_text_in_word = false; | 334 seen_literal_text_in_word = false; |
332 } | 335 } |
333 continue; | 336 continue; |
334 } | 337 } |
335 seen_literal_text_in_word = seen_literal_text_in_word || | 338 seen_literal_text_in_word = seen_literal_text_in_word || |
336 !base::IsUnicodeWhitespace(character); | 339 !base::IsUnicodeWhitespace(character); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 page_->loading_count_--; | 674 page_->loading_count_--; |
672 } | 675 } |
673 | 676 |
674 PDFiumPage::Link::Link() { | 677 PDFiumPage::Link::Link() { |
675 } | 678 } |
676 | 679 |
677 PDFiumPage::Link::~Link() { | 680 PDFiumPage::Link::~Link() { |
678 } | 681 } |
679 | 682 |
680 } // namespace chrome_pdf | 683 } // namespace chrome_pdf |
OLD | NEW |