Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: pdf/instance.cc

Issue 530363002: Prevent the in-process PDF plugin re-entering into JS during blink layout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pdf/instance.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/instance.cc
diff --git a/pdf/instance.cc b/pdf/instance.cc
index acf19fc816cf5060621b57126b2275d9a12ddca5..d700be8757d679f00d98f86329a649308e64bfef 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() {
« no previous file with comments | « pdf/instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698