Commit 212f8f9b authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Fix WebViewImpl::SetZoomLevel to not be a no-op if a plugin is focused.

Bug: 735358
Change-Id: Ibe2a98bd93c1e6288e7c8e9a3633f21e3433350a
Reviewed-on: https://chromium-review.googlesource.com/577390Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarStuart Langley <slangley@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488110}
parent 24652e9f
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "core/editing/FrameSelection.h" #include "core/editing/FrameSelection.h"
#include "core/editing/InputMethodController.h" #include "core/editing/InputMethodController.h"
#include "core/editing/markers/DocumentMarkerController.h" #include "core/editing/markers/DocumentMarkerController.h"
#include "core/exported/FakeWebPlugin.h"
#include "core/exported/WebSettingsImpl.h" #include "core/exported/WebSettingsImpl.h"
#include "core/exported/WebViewBase.h" #include "core/exported/WebViewBase.h"
#include "core/frame/EventHandlerRegistry.h" #include "core/frame/EventHandlerRegistry.h"
...@@ -55,6 +56,7 @@ ...@@ -55,6 +56,7 @@
#include "core/fullscreen/Fullscreen.h" #include "core/fullscreen/Fullscreen.h"
#include "core/html/HTMLIFrameElement.h" #include "core/html/HTMLIFrameElement.h"
#include "core/html/HTMLInputElement.h" #include "core/html/HTMLInputElement.h"
#include "core/html/HTMLObjectElement.h"
#include "core/html/HTMLTextAreaElement.h" #include "core/html/HTMLTextAreaElement.h"
#include "core/inspector/DevToolsEmulator.h" #include "core/inspector/DevToolsEmulator.h"
#include "core/layout/api/LayoutViewItem.h" #include "core/layout/api/LayoutViewItem.h"
...@@ -4399,4 +4401,37 @@ TEST_P(WebViewTest, DeviceEmulationResetScrollbars) { ...@@ -4399,4 +4401,37 @@ TEST_P(WebViewTest, DeviceEmulationResetScrollbars) {
} }
} }
TEST_P(WebViewTest, SetZoomLevelWhilePluginFocused) {
class PluginCreatingWebFrameClient
: public FrameTestHelpers::TestWebFrameClient {
public:
// WebFrameClient overrides:
WebPlugin* CreatePlugin(const WebPluginParams& params) override {
return new FakeWebPlugin(params);
}
};
PluginCreatingWebFrameClient frame_client;
WebViewBase* web_view = web_view_helper_.Initialize(&frame_client);
WebURL base_url = URLTestHelpers::ToKURL("https://example.com/");
FrameTestHelpers::LoadHTMLString(
web_view->MainFrameImpl(),
"<!DOCTYPE html><html><body>"
"<object type='application/x-webkit-test-plugin'></object>"
"</body></html>",
base_url);
// Verify the plugin is loaded.
LocalFrame* main_frame = web_view->MainFrameImpl()->GetFrame();
HTMLObjectElement* plugin_element =
toHTMLObjectElement(main_frame->GetDocument()->body()->firstChild());
EXPECT_TRUE(plugin_element->OwnedPlugin());
// Focus the plugin element, and then change the zoom level on the WebView.
plugin_element->focus();
EXPECT_FLOAT_EQ(1.0f, main_frame->PageZoomFactor());
web_view->SetZoomLevel(-1.0);
// Even though the plugin is focused, the entire frame's zoom factor should
// still be updated.
EXPECT_FLOAT_EQ(5.0f / 6.0f, main_frame->PageZoomFactor());
web_view_helper_.Reset(); // Remove dependency on locally scoped client.
}
} // namespace blink } // namespace blink
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
#include "core/html/HTMLMediaElement.h" #include "core/html/HTMLMediaElement.h"
#include "core/html/HTMLPlugInElement.h" #include "core/html/HTMLPlugInElement.h"
#include "core/html/HTMLTextAreaElement.h" #include "core/html/HTMLTextAreaElement.h"
#include "core/html/PluginDocument.h"
#include "core/input/ContextMenuAllowedScope.h" #include "core/input/ContextMenuAllowedScope.h"
#include "core/input/EventHandler.h" #include "core/input/EventHandler.h"
#include "core/input/TouchActionUtil.h" #include "core/input/TouchActionUtil.h"
...@@ -2840,8 +2841,12 @@ void WebViewImpl::PropagateZoomFactorToLocalFrameRoots(Frame* frame, ...@@ -2840,8 +2841,12 @@ void WebViewImpl::PropagateZoomFactorToLocalFrameRoots(Frame* frame,
float zoom_factor) { float zoom_factor) {
if (frame->IsLocalRoot()) { if (frame->IsLocalRoot()) {
LocalFrame* local_frame = ToLocalFrame(frame); LocalFrame* local_frame = ToLocalFrame(frame);
if (!local_frame->GetWebPluginContainer()) if (Document* document = local_frame->GetDocument()) {
local_frame->SetPageZoomFactor(zoom_factor); if (!document->IsPluginDocument() ||
!ToPluginDocument(document)->GetPluginView()) {
local_frame->SetPageZoomFactor(zoom_factor);
}
}
} }
for (Frame* child = frame->Tree().FirstChild(); child; for (Frame* child = frame->Tree().FirstChild(); child;
......
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