0

Rename ScrollIntoView() to ScrollAnnotationIntoView()

This CL renames method ScrollIntoView() to ScrollAnnotationIntoView()
and changes the input params to take an annotation and a page index
instead of a rect. This change was needed as we have another caller
for ScrollAnnotationIntoView().

Bug: 1085614
Change-Id: I8cc6725944ab3e870865c3d47942721ea4e1c97d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2228430
Reviewed-by: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Ankit Kumar 🌪️ <ankk@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#775734}
This commit is contained in:
Ankit Kumar
2020-06-05 20:25:06 +00:00
committed by Commit Bot
parent cf67368fcd
commit e2f8aa9278
3 changed files with 18 additions and 15 deletions

@ -3668,7 +3668,20 @@ void PDFiumEngine::SetSelection(
}
}
void PDFiumEngine::ScrollIntoView(const pp::Rect& rect) {
void PDFiumEngine::ScrollAnnotationIntoView(FPDF_ANNOTATION annot,
int page_index) {
if (!PageIndexInBounds(page_index))
return;
FS_RECTF annot_rect;
if (!FPDFAnnot_GetRect(annot, &annot_rect))
return;
pp::Rect rect = pages_[page_index]->PageToScreen(
pp::Point(), /*zoom=*/1.0, annot_rect.left, annot_rect.top,
annot_rect.right, annot_rect.bottom,
layout_.options().default_page_orientation());
pp::Rect visible_rect = GetVisibleRect();
if (visible_rect.Contains(rect))
return;

@ -583,9 +583,8 @@ class PDFiumEngine : public PDFEngine,
void SetSelection(const PP_PdfPageCharacterIndex& selection_start_index,
const PP_PdfPageCharacterIndex& selection_end_index);
// Given |rect| in document coordinates, scroll the |rect| into view if not
// already in view.
void ScrollIntoView(const pp::Rect& rect);
// Given |annot|, scroll the |annot| into view if not already in view.
void ScrollAnnotationIntoView(FPDF_ANNOTATION annot, int page_index);
void OnFocusedAnnotationUpdated(FPDF_ANNOTATION annot, int page_index);

@ -285,17 +285,8 @@ void PDFiumFormFiller::Form_OnFocusChange(FPDF_FORMFILLINFO* param,
// Maintain viewport if we are updating focus. This is to ensure that we don't
// scroll the focused annotation into view when focus is regained.
if (!engine->updating_focus_) {
FS_RECTF annot_rect;
if (!FPDFAnnot_GetRect(annot, &annot_rect))
return;
pp::Rect screen_rect = engine->pages_[page_index]->PageToScreen(
pp::Point(), /*zoom=*/1.0, annot_rect.left, annot_rect.top,
annot_rect.right, annot_rect.bottom,
engine->layout_.options().default_page_orientation());
engine->ScrollIntoView(screen_rect);
}
if (!engine->updating_focus_)
engine->ScrollAnnotationIntoView(annot, page_index);
engine->OnFocusedAnnotationUpdated(annot, page_index);
}