[PDF Ink Signatures] Account for device scale in Ink zoom
PdfInkModule relies upon a client query to know the scale factor to apply when transforming points. This has included the zoom factor within the PDF viewer plugin, but has been missing any extra screen scaling for OS-level display scaling. HiRes on some macOS devices or Windows devices with display scale settings set to something other than 100% could cause a significant shift in stroke placement. Update the PdfViewWebPlugin::PdfInkModuleClientImpl to incorporate the device scale when providing zoom for Ink strokes. Bug: 378623808 Change-Id: Ic4bc2b89eaa0de99d38345249552986e9aeb17f3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6017318 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Alan Screen <awscreen@chromium.org> Cr-Commit-Position: refs/heads/main@{#1382514}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
a6544a1d16
commit
bac0a0770b
@ -293,7 +293,9 @@ class PdfViewWebPlugin::PdfInkModuleClientImpl : public PdfInkModuleClient {
|
||||
return plugin_->available_area_.OffsetFromOrigin();
|
||||
}
|
||||
|
||||
float GetZoom() const override { return plugin_->zoom_; }
|
||||
float GetZoom() const override {
|
||||
return plugin_->zoom_ * plugin_->client_->DeviceScaleFactor();
|
||||
}
|
||||
|
||||
void Invalidate(const gfx::Rect& rect) override {
|
||||
return plugin_->Invalidate(rect);
|
||||
|
@ -230,6 +230,7 @@ class FakePdfViewWebPluginClient : public PdfViewWebPlugin::Client {
|
||||
return associated_loader;
|
||||
});
|
||||
ON_CALL(*this, GetIsolate).WillByDefault(Return(GetBlinkIsolate()));
|
||||
ON_CALL(*this, DeviceScaleFactor).WillByDefault(Return(1.0f));
|
||||
ON_CALL(*this, GetEmbedderOriginString)
|
||||
.WillByDefault(
|
||||
Return("chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/"));
|
||||
@ -2716,6 +2717,36 @@ TEST_F(PdfViewWebPluginInkTest, UpdateCursor) {
|
||||
EXPECT_EQ(ui::mojom::CursorType::kPointer, cursor.type());
|
||||
}
|
||||
|
||||
TEST_F(PdfViewWebPluginInkTest, GetZoom) {
|
||||
// Demonstrate that default zoom is identity.
|
||||
EXPECT_EQ(1.0f, plugin_->ink_module_client_for_testing()->GetZoom());
|
||||
|
||||
// Verify that changing the plugin zoom shows effect.
|
||||
EXPECT_CALL(*engine_ptr_, ZoomUpdated(2.0f));
|
||||
plugin_->OnMessage(ParseMessage(R"({
|
||||
"type": "viewport",
|
||||
"userInitiated": false,
|
||||
"zoom": 2,
|
||||
"layoutOptions": {
|
||||
"direction": 0,
|
||||
"defaultPageOrientation": 0,
|
||||
"twoUpViewEnabled": false,
|
||||
},
|
||||
"xOffset": 0,
|
||||
"yOffset": 0,
|
||||
"pinchPhase": 0,
|
||||
})"));
|
||||
EXPECT_EQ(2.0f, plugin_->ink_module_client_for_testing()->GetZoom());
|
||||
|
||||
// Verify that changing the platform device scale shows effect.
|
||||
ON_CALL(*client_ptr_, DeviceScaleFactor).WillByDefault(Return(1.25f));
|
||||
EXPECT_CALL(*engine_ptr_, ZoomUpdated(2.5f));
|
||||
constexpr gfx::Rect kWindowRect(12, 24, 36, 48);
|
||||
plugin_->UpdateGeometry(kWindowRect, kWindowRect, kWindowRect,
|
||||
/*is_visible=*/true);
|
||||
EXPECT_EQ(2.5f, plugin_->ink_module_client_for_testing()->GetZoom());
|
||||
}
|
||||
|
||||
TEST_F(PdfViewWebPluginInkTest, UpdateThumbnail) {
|
||||
SetUpWithTrivialInkStrokes();
|
||||
|
||||
|
Reference in New Issue
Block a user