Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 2959813003: PDF: Selection Invalidation should compensate for rounding errors. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3273 matching lines...) Expand 10 before | Expand all | Expand 10 after
3284 // Mark the rectangles by setting them to empty. 3284 // Mark the rectangles by setting them to empty.
3285 new_selection = old_selection = pp::Rect(); 3285 new_selection = old_selection = pp::Rect();
3286 break; 3286 break;
3287 } 3287 }
3288 } 3288 }
3289 } 3289 }
3290 3290
3291 bool selection_changed = false; 3291 bool selection_changed = false;
3292 for (const auto& old_selection : old_selections_) { 3292 for (const auto& old_selection : old_selections_) {
3293 if (!old_selection.IsEmpty()) { 3293 if (!old_selection.IsEmpty()) {
3294 engine_->client_->Invalidate(old_selection); 3294 Invalidate(old_selection);
3295 selection_changed = true; 3295 selection_changed = true;
3296 } 3296 }
3297 } 3297 }
3298 for (const auto& new_selection : new_selections) { 3298 for (const auto& new_selection : new_selections) {
3299 if (!new_selection.IsEmpty()) { 3299 if (!new_selection.IsEmpty()) {
3300 engine_->client_->Invalidate(new_selection); 3300 Invalidate(new_selection);
3301 selection_changed = true; 3301 selection_changed = true;
3302 } 3302 }
3303 } 3303 }
3304 if (selection_changed) 3304 if (selection_changed)
3305 engine_->OnSelectionChanged(); 3305 engine_->OnSelectionChanged();
3306 } 3306 }
3307 3307
3308 std::vector<pp::Rect> 3308 std::vector<pp::Rect>
3309 PDFiumEngine::SelectionChangeInvalidator::GetVisibleSelections() const { 3309 PDFiumEngine::SelectionChangeInvalidator::GetVisibleSelections() const {
3310 std::vector<pp::Rect> rects; 3310 std::vector<pp::Rect> rects;
3311 pp::Point visible_point = engine_->GetVisibleRect().point(); 3311 pp::Point visible_point = engine_->GetVisibleRect().point();
3312 for (auto& range : engine_->selection_) { 3312 for (auto& range : engine_->selection_) {
3313 // Exclude selections on pages that's not currently visible. 3313 // Exclude selections on pages that's not currently visible.
3314 if (!engine_->IsPageVisible(range.page_index())) 3314 if (!engine_->IsPageVisible(range.page_index()))
3315 continue; 3315 continue;
3316 3316
3317 std::vector<pp::Rect> selection_rects = range.GetScreenRects( 3317 std::vector<pp::Rect> selection_rects = range.GetScreenRects(
3318 visible_point, engine_->current_zoom_, engine_->current_rotation_); 3318 visible_point, engine_->current_zoom_, engine_->current_rotation_);
3319 rects.insert(rects.end(), selection_rects.begin(), selection_rects.end()); 3319 rects.insert(rects.end(), selection_rects.begin(), selection_rects.end());
3320 } 3320 }
3321 return rects; 3321 return rects;
3322 } 3322 }
3323 3323
3324 void PDFiumEngine::SelectionChangeInvalidator::Invalidate(
3325 const pp::Rect& selection) {
3326 pp::Rect expanded_selection = selection;
3327 expanded_selection.Inset(-1, -1);
3328 engine_->client_->Invalidate(expanded_selection);
3329 }
3330
3324 PDFiumEngine::MouseDownState::MouseDownState( 3331 PDFiumEngine::MouseDownState::MouseDownState(
3325 const PDFiumPage::Area& area, 3332 const PDFiumPage::Area& area,
3326 const PDFiumPage::LinkTarget& target) 3333 const PDFiumPage::LinkTarget& target)
3327 : area_(area), target_(target) {} 3334 : area_(area), target_(target) {}
3328 3335
3329 PDFiumEngine::MouseDownState::~MouseDownState() {} 3336 PDFiumEngine::MouseDownState::~MouseDownState() {}
3330 3337
3331 void PDFiumEngine::MouseDownState::Set(const PDFiumPage::Area& area, 3338 void PDFiumEngine::MouseDownState::Set(const PDFiumPage::Area& area,
3332 const PDFiumPage::LinkTarget& target) { 3339 const PDFiumPage::LinkTarget& target) {
3333 area_ = area; 3340 area_ = area;
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
4191 FPDF_DOCUMENT doc = 4198 FPDF_DOCUMENT doc =
4192 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 4199 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
4193 if (!doc) 4200 if (!doc)
4194 return false; 4201 return false;
4195 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 4202 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
4196 FPDF_CloseDocument(doc); 4203 FPDF_CloseDocument(doc);
4197 return success; 4204 return success;
4198 } 4205 }
4199 4206
4200 } // namespace chrome_pdf 4207 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698