diff options
author | raymes <raymes@chromium.org> | 2014-09-03 21:24:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-04 04:31:10 +0000 |
commit | 8410df4f4a7c54f2d669b6cc717ec9a09b76ad79 (patch) | |
tree | c074243f608c618dc472d1e0d123bbec88bc395a /pdf/instance.cc | |
parent | 972bc39f4a28fa510bfb8c61f94e2e9b1897790f (diff) | |
download | chromium_src-8410df4f4a7c54f2d669b6cc717ec9a09b76ad79.zip chromium_src-8410df4f4a7c54f2d669b6cc717ec9a09b76ad79.tar.gz chromium_src-8410df4f4a7c54f2d669b6cc717ec9a09b76ad79.tar.bz2 |
Prevent the in-process PDF plugin re-entering into JS during blink layout
Layout changes trigger view changes which get sent to the plugin. With the
in process plugin (PDF), the plugin is notified synchronously of the view
change. It then might execute scripts synchronously in the plugin but
scripts are not meant to be executed during layout changes. This change
runs the scripts asynchronously. I tested print preview to ensure that it
still works correctly.
Note that once we remove in-process plugins this won't be an issue because
view changes happen asynchronously out of process (besides the fact that
synchronous script execution is limited to private plugins).
BUG=351636
Review URL: https://codereview.chromium.org/530363002
Cr-Commit-Position: refs/heads/master@{#293256}
Diffstat (limited to 'pdf/instance.cc')
-rw-r--r-- | pdf/instance.cc | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/pdf/instance.cc b/pdf/instance.cc index acf19fc..d700be8 100644 --- a/pdf/instance.cc +++ b/pdf/instance.cc @@ -295,7 +295,7 @@ Instance::Instance(PP_Instance instance) loader_factory_.Initialize(this); timer_factory_.Initialize(this); form_factory_.Initialize(this); - print_callback_factory_.Initialize(this); + callback_factory_.Initialize(this); engine_.reset(PDFEngine::Create(this)); pp::Module::Get()->AddPluginInterface(kPPPPdfInterface, &ppp_private); AddPerInstanceObject(kPPPPdfInterface, this); @@ -1132,8 +1132,12 @@ void Instance::Scroll(const pp::Point& point) { if (page_indicator_.visible()) paint_manager_.InvalidateRect(page_indicator_.rect()); - if (on_scroll_callback_.is_string()) - ExecuteScript(on_scroll_callback_); + // Run the scroll callback asynchronously. This function can be invoked by a + // layout change which should not re-enter into JS synchronously. + pp::CompletionCallback callback = + callback_factory_.NewCallback(&Instance::RunCallback, + on_scroll_callback_); + pp::Module::Get()->core()->CallOnMainThread(0, callback); } void Instance::ScrollToX(int position) { @@ -1374,7 +1378,7 @@ void Instance::Print() { } pp::CompletionCallback callback = - print_callback_factory_.NewCallback(&Instance::OnPrint); + callback_factory_.NewCallback(&Instance::OnPrint); pp::Module::Get()->core()->CallOnMainThread(0, callback); } @@ -2117,8 +2121,17 @@ void Instance::OnGeometryChanged(double old_zoom, float old_device_scale) { return; paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); - if (on_plugin_size_changed_callback_.is_string()) - ExecuteScript(on_plugin_size_changed_callback_); + // Run the plugin size change callback asynchronously. This function can be + // invoked by a layout change which should not re-enter into JS synchronously. + pp::CompletionCallback callback = + callback_factory_.NewCallback(&Instance::RunCallback, + on_plugin_size_changed_callback_); + pp::Module::Get()->core()->CallOnMainThread(0, callback); +} + +void Instance::RunCallback(int32_t, pp::Var callback) { + if (callback.is_string()) + ExecuteScript(callback); } void Instance::CreateHorizontalScrollbar() { |