Tweak PDF getThumbnail message and related code
- Change PluginController.requestThumbnail() to take a page index. Adjust its 2 callers. - Rename the getThumbnail message's "page" key to "pageIndex". Change-Id: Ib9b52cc1f67dae332a624ee8575516be0142429e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5789329 Reviewed-by: Andy Phan <andyphan@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#1343016}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
35b1f31064
commit
acd4a7344a
chrome
pdf
@ -330,11 +330,10 @@ export class PluginController implements ContentController {
|
||||
* Post a thumbnail request message to the plugin.
|
||||
* @return A promise holding the thumbnail response from the plugin.
|
||||
*/
|
||||
requestThumbnail(page: number): Promise<ThumbnailMessageData> {
|
||||
requestThumbnail(pageIndex: number): Promise<ThumbnailMessageData> {
|
||||
return this.postMessageWithReply_({
|
||||
type: 'getThumbnail',
|
||||
// The plugin references pages using zero-based indices.
|
||||
page: page - 1,
|
||||
pageIndex: pageIndex,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,8 @@ export class ViewerThumbnailBarElement extends CrLitElement {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pluginController_.requestThumbnail(thumbnail.pageNumber)
|
||||
// Convert to zero-based page index.
|
||||
this.pluginController_.requestThumbnail(thumbnail.pageNumber - 1)
|
||||
.then(response => {
|
||||
const array = new Uint8ClampedArray(response.imageData);
|
||||
const imageData = new ImageData(array, response.width);
|
||||
|
@ -6,7 +6,7 @@ import {PluginController} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgieh
|
||||
|
||||
const tests = [
|
||||
async function testRequestThumbnail() {
|
||||
const data = await PluginController.getInstance().requestThumbnail(1);
|
||||
const data = await PluginController.getInstance().requestThumbnail(0);
|
||||
|
||||
const expectedWidth = 108 * window.devicePixelRatio;
|
||||
const expectedHeight = 140 * window.devicePixelRatio;
|
||||
|
@ -1482,7 +1482,7 @@ void PdfViewWebPlugin::HandleGetSelectedTextMessage(
|
||||
|
||||
void PdfViewWebPlugin::HandleGetThumbnailMessage(
|
||||
const base::Value::Dict& message) {
|
||||
const int page_index = message.FindInt("page").value();
|
||||
const int page_index = message.FindInt("pageIndex").value();
|
||||
base::Value::Dict reply = PrepareReplyMessage("getThumbnailReply", message);
|
||||
|
||||
engine_->RequestThumbnail(
|
||||
|
Reference in New Issue
Block a user