Commit e2f8aa92 authored by Ankit Kumar's avatar Ankit Kumar Committed by Commit Bot

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/+/2228430Reviewed-by: default avatarKevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Ankit Kumar 🌪️ <ankk@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#775734}
parent cf67368f
...@@ -3668,7 +3668,20 @@ void PDFiumEngine::SetSelection( ...@@ -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(); pp::Rect visible_rect = GetVisibleRect();
if (visible_rect.Contains(rect)) if (visible_rect.Contains(rect))
return; return;
......
...@@ -583,9 +583,8 @@ class PDFiumEngine : public PDFEngine, ...@@ -583,9 +583,8 @@ class PDFiumEngine : public PDFEngine,
void SetSelection(const PP_PdfPageCharacterIndex& selection_start_index, void SetSelection(const PP_PdfPageCharacterIndex& selection_start_index,
const PP_PdfPageCharacterIndex& selection_end_index); const PP_PdfPageCharacterIndex& selection_end_index);
// Given |rect| in document coordinates, scroll the |rect| into view if not // Given |annot|, scroll the |annot| into view if not already in view.
// already in view. void ScrollAnnotationIntoView(FPDF_ANNOTATION annot, int page_index);
void ScrollIntoView(const pp::Rect& rect);
void OnFocusedAnnotationUpdated(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, ...@@ -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 // 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. // scroll the focused annotation into view when focus is regained.
if (!engine->updating_focus_) { if (!engine->updating_focus_)
FS_RECTF annot_rect; engine->ScrollAnnotationIntoView(annot, page_index);
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);
}
engine->OnFocusedAnnotationUpdated(annot, page_index); engine->OnFocusedAnnotationUpdated(annot, page_index);
} }
......
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