Skip to content

Commit f1457e8

Browse files
Daniel HosseinianChromium LUCI CQ
authored andcommitted
[unseasoned-pdf] Implement content rotation through the context menu
Meanwhile, change blink::WebPlugin::RotationType to an enum class. Change-Id: Iccd2782c5d57efa242c4364afd60d6efaa790f36 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3021686 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Bill Budge <bbudge@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Commit-Queue: Daniel Hosseinian <dhoss@chromium.org> Cr-Commit-Position: refs/heads/master@{#901326}
1 parent bcb2e4d commit f1457e8

File tree

7 files changed

+25
-9
lines changed

7 files changed

+25
-9
lines changed

content/renderer/pepper/pepper_plugin_instance_impl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,7 @@ void PepperPluginInstanceImpl::RotateView(WebPlugin::RotationType type) {
19451945
if (!LoadPdfInterface())
19461946
return;
19471947
PP_PrivatePageTransformType transform_type =
1948-
type == WebPlugin::kRotationType90Clockwise
1948+
type == WebPlugin::RotationType::k90Clockwise
19491949
? PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW
19501950
: PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW;
19511951
plugin_pdf_interface_->Transform(pp_instance(), transform_type);

content/renderer/pepper/pepper_webplugin_impl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ bool PepperWebPluginImpl::CanRotateView() {
461461
return instance_->CanRotateView();
462462
}
463463

464-
void PepperWebPluginImpl::RotateView(RotationType type) {
464+
void PepperWebPluginImpl::RotateView(blink::WebPlugin::RotationType type) {
465465
// Re-entrancy may cause JS to try to execute script on the plugin before it
466466
// is fully initialized. See: crbug.com/715747.
467467
if (instance_)

content/renderer/pepper/pepper_webplugin_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class PepperWebPluginImpl : public blink::WebPlugin {
8181
void PrintEnd() override;
8282

8383
bool CanRotateView() override;
84-
void RotateView(RotationType type) override;
84+
void RotateView(blink::WebPlugin::RotationType type) override;
8585
bool IsPlaceholder() override;
8686
void DidLoseMouseLock() override;
8787
void DidReceiveMouseLockResult(bool success) override;

pdf/pdf_view_web_plugin.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,23 @@ void PdfViewWebPlugin::StopFind() {
496496
// dismissed.
497497
}
498498

499+
bool PdfViewWebPlugin::CanRotateView() {
500+
return !IsPrintPreview();
501+
}
502+
503+
void PdfViewWebPlugin::RotateView(blink::WebPlugin::RotationType type) {
504+
DCHECK(CanRotateView());
505+
506+
switch (type) {
507+
case blink::WebPlugin::RotationType::k90Clockwise:
508+
engine()->RotateClockwise();
509+
break;
510+
case blink::WebPlugin::RotationType::k90Counterclockwise:
511+
engine()->RotateCounterclockwise();
512+
break;
513+
}
514+
}
515+
499516
blink::WebTextInputType PdfViewWebPlugin::GetPluginTextInputType() {
500517
return text_input_type_;
501518
}

pdf/pdf_view_web_plugin.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,
167167
int identifier) override;
168168
void SelectFindResult(bool forward, int identifier) override;
169169
void StopFind() override;
170+
bool CanRotateView() override;
171+
void RotateView(blink::WebPlugin::RotationType type) override;
170172
blink::WebTextInputType GetPluginTextInputType() override;
171173

172174
// PdfViewPluginBase:

third_party/blink/public/web/web_plugin.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,7 @@ class WebPlugin {
236236
virtual void StopFind() {}
237237

238238
// View rotation types.
239-
enum RotationType {
240-
kRotationType90Clockwise,
241-
kRotationType90Counterclockwise
242-
};
239+
enum class RotationType { k90Clockwise, k90Counterclockwise };
243240
// Whether the plugin can rotate the view of its content.
244241
virtual bool CanRotateView() { return false; }
245242
// Rotates the plugin's view of its content.

third_party/blink/renderer/core/frame/local_frame_mojo_receiver.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ void LocalFrameMojoReceiver::PluginActionAt(
205205

206206
switch (action) {
207207
case mojom::blink::PluginActionType::kRotate90Clockwise:
208-
plugin_view->Plugin()->RotateView(WebPlugin::kRotationType90Clockwise);
208+
plugin_view->Plugin()->RotateView(WebPlugin::RotationType::k90Clockwise);
209209
return;
210210
case mojom::blink::PluginActionType::kRotate90Counterclockwise:
211211
plugin_view->Plugin()->RotateView(
212-
WebPlugin::kRotationType90Counterclockwise);
212+
WebPlugin::RotationType::k90Counterclockwise);
213213
return;
214214
}
215215
NOTREACHED();

0 commit comments

Comments
 (0)