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 "pdf/pdfium/pdfium_engine.h" | 5 #include "pdf/pdfium/pdfium_engine.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 3272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3283 for (auto& old_selection : old_selections_) { | 3283 for (auto& old_selection : old_selections_) { |
3284 if (!old_selection.IsEmpty() && new_selection == old_selection) { | 3284 if (!old_selection.IsEmpty() && new_selection == old_selection) { |
3285 // Rectangle was selected before and after, so no need to invalidate it. | 3285 // Rectangle was selected before and after, so no need to invalidate it. |
3286 // Mark the rectangles by setting them to empty. | 3286 // Mark the rectangles by setting them to empty. |
3287 new_selection = old_selection = pp::Rect(); | 3287 new_selection = old_selection = pp::Rect(); |
3288 break; | 3288 break; |
3289 } | 3289 } |
3290 } | 3290 } |
3291 } | 3291 } |
3292 | 3292 |
| 3293 bool selection_changed = false; |
3293 for (const auto& old_selection : old_selections_) { | 3294 for (const auto& old_selection : old_selections_) { |
3294 if (!old_selection.IsEmpty()) | 3295 if (!old_selection.IsEmpty()) { |
3295 engine_->client_->Invalidate(old_selection); | 3296 engine_->client_->Invalidate(old_selection); |
| 3297 selection_changed = true; |
| 3298 } |
3296 } | 3299 } |
3297 for (const auto& new_selection : new_selections) { | 3300 for (const auto& new_selection : new_selections) { |
3298 if (!new_selection.IsEmpty()) | 3301 if (!new_selection.IsEmpty()) { |
3299 engine_->client_->Invalidate(new_selection); | 3302 engine_->client_->Invalidate(new_selection); |
| 3303 selection_changed = true; |
| 3304 } |
3300 } | 3305 } |
3301 engine_->OnSelectionChanged(); | 3306 if (selection_changed) |
| 3307 engine_->OnSelectionChanged(); |
3302 } | 3308 } |
3303 | 3309 |
3304 void PDFiumEngine::SelectionChangeInvalidator::GetVisibleSelectionsScreenRects( | 3310 void PDFiumEngine::SelectionChangeInvalidator::GetVisibleSelectionsScreenRects( |
3305 std::vector<pp::Rect>* rects) { | 3311 std::vector<pp::Rect>* rects) { |
3306 pp::Rect visible_rect = engine_->GetVisibleRect(); | 3312 pp::Rect visible_rect = engine_->GetVisibleRect(); |
3307 for (auto& range : engine_->selection_) { | 3313 for (auto& range : engine_->selection_) { |
3308 int page_index = range.page_index(); | 3314 int page_index = range.page_index(); |
3309 if (!engine_->IsPageVisible(page_index)) | 3315 if (!engine_->IsPageVisible(page_index)) |
3310 continue; // This selection is on a page that's not currently visible. | 3316 continue; // This selection is on a page that's not currently visible. |
3311 | 3317 |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4186 FPDF_DOCUMENT doc = | 4192 FPDF_DOCUMENT doc = |
4187 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); | 4193 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); |
4188 if (!doc) | 4194 if (!doc) |
4189 return false; | 4195 return false; |
4190 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 4196 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
4191 FPDF_CloseDocument(doc); | 4197 FPDF_CloseDocument(doc); |
4192 return success; | 4198 return success; |
4193 } | 4199 } |
4194 | 4200 |
4195 } // namespace chrome_pdf | 4201 } // namespace chrome_pdf |
OLD | NEW |