diff options
author | raymes <raymes@chromium.org> | 2015-08-05 00:05:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-05 07:09:02 +0000 |
commit | bd82a94bbc1738c60459dec25f4d9aa73f7baeab (patch) | |
tree | 20b89ede12a9abc6452d80446d5838d732ebbf11 /pdf/pdfium | |
parent | fa9f7f47739724fe1cba8ad17668edcabe9e213c (diff) | |
download | chromium_src-bd82a94bbc1738c60459dec25f4d9aa73f7baeab.zip chromium_src-bd82a94bbc1738c60459dec25f4d9aa73f7baeab.tar.gz chromium_src-bd82a94bbc1738c60459dec25f4d9aa73f7baeab.tar.bz2 |
Add a scroll offset to PDF documents to account for the top material design toolbar.
Previously the toolbar in the material design PDF UI would always cover the top
of pages when it was first loaded or when a page was navigated to using the
page selector. Now we ensure that a blank region is left at the very top of
the document when it is first loaded. This is the region that the toolbar
covers, so the document is not obscured at all. When pages are navigated to, we
ensure that the top of the selected page is always underneath the toolbar
so that it is not obscured. The one exception to this is when in fit-to-page
mode which causes the page to be zoomed to cover the entire screen, ignoring
the toolbar. This is so that users can take advantaging of filling all of the
screen real-estate with a page when that is what they want.
This is implemented by initially scrolling the document to a negative offset
(which is equal to the toolbar height). All subsequent scrolls are relative
to this initial scroll. A few small bugs that assumed there was no blank space
above the first page have also been fixed.
BUG=439114
Committed: https://crrev.com/daad0f1f879b13c8b55797ae5ce106d382283047
Cr-Commit-Position: refs/heads/master@{#341685}
Review URL: https://codereview.chromium.org/1255403002
Cr-Commit-Position: refs/heads/master@{#341861}
Diffstat (limited to 'pdf/pdfium')
-rw-r--r-- | pdf/pdfium/pdfium_engine.cc | 9 | ||||
-rw-r--r-- | pdf/pdfium/pdfium_engine.h | 5 |
2 files changed, 10 insertions, 4 deletions
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc index 89fa7eb..fc36c1e 100644 --- a/pdf/pdfium/pdfium_engine.cc +++ b/pdf/pdfium/pdfium_engine.cc @@ -1071,6 +1071,15 @@ void PDFiumEngine::Paint(const pp::Rect& rect, if (dirty_in_screen.IsEmpty()) continue; + // Compute the leftover dirty region. The first page may have blank space + // above it, in which case we also need to subtract that space from the + // dirty region. + if (i == 0) { + pp::Rect blank_space_in_screen = dirty_in_screen; + blank_space_in_screen.set_y(0); + blank_space_in_screen.set_height(dirty_in_screen.y()); + leftover = leftover.Subtract(blank_space_in_screen); + } leftover = leftover.Subtract(dirty_in_screen); if (pages_[index]->available()) { diff --git a/pdf/pdfium/pdfium_engine.h b/pdf/pdfium/pdfium_engine.h index ff45f45..c8ee6bd 100644 --- a/pdf/pdfium/pdfium_engine.h +++ b/pdf/pdfium/pdfium_engine.h @@ -84,6 +84,7 @@ class PDFiumEngine : public PDFEngine, virtual int GetMostVisiblePage(); virtual pp::Rect GetPageRect(int index); virtual pp::Rect GetPageContentsRect(int index); + virtual pp::Rect GetPageScreenRect(int page_index) const; virtual int GetVerticalScrollbarYPosition() { return position_.y(); } virtual void PaintThumbnail(pp::ImageData* image_data, int index); virtual void SetGrayscale(bool grayscale); @@ -373,10 +374,6 @@ class PDFiumEngine : public PDFEngine, // Returns the currently visible rectangle in document coordinates. pp::Rect GetVisibleRect() const; - // Returns a page's rect in screen coordinates, as well as its surrounding - // border areas and bottom separator. - pp::Rect GetPageScreenRect(int page_index) const; - // Given a rectangle in document coordinates, returns the rectange into screen // coordinates (i.e. 0,0 is top left corner of plugin area). If it's not // visible, an empty rectangle is returned. |