Commit ca43e451 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

PDF: Avoid doing work with empty rects.

Change-Id: I0d97bb34d9f04c4e2ece07d1f773c17f2ffb2c9f
Reviewed-on: https://chromium-review.googlesource.com/749678Reviewed-by: default avatardsinclair <dsinclair@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516045}
parent 8ee053cd
...@@ -4004,6 +4004,9 @@ void PDFiumEngine::Form_OutputSelectedRect(FPDF_FORMFILLINFO* param, ...@@ -4004,6 +4004,9 @@ void PDFiumEngine::Form_OutputSelectedRect(FPDF_FORMFILLINFO* param,
pp::Rect rect = engine->pages_[page_index]->PageToScreen( pp::Rect rect = engine->pages_[page_index]->PageToScreen(
engine->GetVisibleRect().point(), engine->current_zoom_, left, top, right, engine->GetVisibleRect().point(), engine->current_zoom_, left, top, right,
bottom, engine->current_rotation_); bottom, engine->current_rotation_);
if (rect.IsEmpty())
return;
engine->form_highlights_.push_back(rect); engine->form_highlights_.push_back(rect);
} }
......
...@@ -501,10 +501,16 @@ void PDFiumPage::CalculateLinks() { ...@@ -501,10 +501,16 @@ void PDFiumPage::CalculateLinks() {
int rect_count = FPDFLink_CountRects(links, i); int rect_count = FPDFLink_CountRects(links, i);
for (int j = 0; j < rect_count; ++j) { for (int j = 0; j < rect_count; ++j) {
double left, top, right, bottom; double left;
double top;
double right;
double bottom;
FPDFLink_GetRect(links, i, j, &left, &top, &right, &bottom); FPDFLink_GetRect(links, i, j, &left, &top, &right, &bottom);
link.rects.push_back( pp::Rect rect =
PageToScreen(pp::Point(), 1.0, left, top, right, bottom, 0)); PageToScreen(pp::Point(), 1.0, left, top, right, bottom, 0);
if (rect.IsEmpty())
continue;
link.rects.push_back(rect);
} }
links_.push_back(link); links_.push_back(link);
} }
......
...@@ -54,8 +54,11 @@ const std::vector<pp::Rect>& PDFiumRange::GetScreenRects( ...@@ -54,8 +54,11 @@ const std::vector<pp::Rect>& PDFiumRange::GetScreenRects(
double right; double right;
double bottom; double bottom;
FPDFText_GetRect(page_->GetTextPage(), i, &left, &top, &right, &bottom); FPDFText_GetRect(page_->GetTextPage(), i, &left, &top, &right, &bottom);
cached_screen_rects_.push_back( pp::Rect rect =
page_->PageToScreen(offset, zoom, left, top, right, bottom, rotation)); page_->PageToScreen(offset, zoom, left, top, right, bottom, rotation);
if (rect.IsEmpty())
continue;
cached_screen_rects_.push_back(rect);
} }
return cached_screen_rects_; return cached_screen_rects_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment