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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « pdf/instance.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/instance.h" 5 #include "pdf/instance.h"
6 6
7 #include <algorithm> // for min() 7 #include <algorithm> // for min()
8 #define _USE_MATH_DEFINES // for M_PI 8 #define _USE_MATH_DEFINES // for M_PI
9 #include <cmath> // for log() and pow() 9 #include <cmath> // for log() and pow()
10 #include <math.h> 10 #include <math.h>
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 first_paint_(true), 288 first_paint_(true),
289 painted_first_page_(false), 289 painted_first_page_(false),
290 show_page_indicator_(false), 290 show_page_indicator_(false),
291 document_load_state_(LOAD_STATE_LOADING), 291 document_load_state_(LOAD_STATE_LOADING),
292 preview_document_load_state_(LOAD_STATE_COMPLETE), 292 preview_document_load_state_(LOAD_STATE_COMPLETE),
293 told_browser_about_unsupported_feature_(false), 293 told_browser_about_unsupported_feature_(false),
294 print_preview_page_count_(0) { 294 print_preview_page_count_(0) {
295 loader_factory_.Initialize(this); 295 loader_factory_.Initialize(this);
296 timer_factory_.Initialize(this); 296 timer_factory_.Initialize(this);
297 form_factory_.Initialize(this); 297 form_factory_.Initialize(this);
298 print_callback_factory_.Initialize(this); 298 callback_factory_.Initialize(this);
299 engine_.reset(PDFEngine::Create(this)); 299 engine_.reset(PDFEngine::Create(this));
300 pp::Module::Get()->AddPluginInterface(kPPPPdfInterface, &ppp_private); 300 pp::Module::Get()->AddPluginInterface(kPPPPdfInterface, &ppp_private);
301 AddPerInstanceObject(kPPPPdfInterface, this); 301 AddPerInstanceObject(kPPPPdfInterface, this);
302 302
303 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_MOUSE); 303 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
304 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_WHEEL); 304 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_WHEEL);
305 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); 305 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD);
306 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_TOUCH); 306 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_TOUCH);
307 } 307 }
308 308
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 paint_manager_.InvalidateRect(autoscroll_rect_); 1125 paint_manager_.InvalidateRect(autoscroll_rect_);
1126 1126
1127 if (show_page_indicator_) { 1127 if (show_page_indicator_) {
1128 page_indicator_.set_current_page(GetPageNumberToDisplay()); 1128 page_indicator_.set_current_page(GetPageNumberToDisplay());
1129 page_indicator_.Splash(); 1129 page_indicator_.Splash();
1130 } 1130 }
1131 1131
1132 if (page_indicator_.visible()) 1132 if (page_indicator_.visible())
1133 paint_manager_.InvalidateRect(page_indicator_.rect()); 1133 paint_manager_.InvalidateRect(page_indicator_.rect());
1134 1134
1135 if (on_scroll_callback_.is_string()) 1135 // Run the scroll callback asynchronously. This function can be invoked by a
1136 ExecuteScript(on_scroll_callback_); 1136 // layout change which should not re-enter into JS synchronously.
1137 pp::CompletionCallback callback =
1138 callback_factory_.NewCallback(&Instance::RunCallback,
1139 on_scroll_callback_);
1140 pp::Module::Get()->core()->CallOnMainThread(0, callback);
1137 } 1141 }
1138 1142
1139 void Instance::ScrollToX(int position) { 1143 void Instance::ScrollToX(int position) {
1140 if (!h_scrollbar_.get()) { 1144 if (!h_scrollbar_.get()) {
1141 NOTREACHED(); 1145 NOTREACHED();
1142 return; 1146 return;
1143 } 1147 }
1144 int position_dip = static_cast<int>(position / device_scale_); 1148 int position_dip = static_cast<int>(position / device_scale_);
1145 h_scrollbar_->SetValue(position_dip); 1149 h_scrollbar_->SetValue(position_dip);
1146 } 1150 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 } 1371 }
1368 1372
1369 void Instance::Print() { 1373 void Instance::Print() {
1370 if (!printing_enabled_ || 1374 if (!printing_enabled_ ||
1371 (!engine_->HasPermission(PDFEngine::PERMISSION_PRINT_LOW_QUALITY) && 1375 (!engine_->HasPermission(PDFEngine::PERMISSION_PRINT_LOW_QUALITY) &&
1372 !engine_->HasPermission(PDFEngine::PERMISSION_PRINT_HIGH_QUALITY))) { 1376 !engine_->HasPermission(PDFEngine::PERMISSION_PRINT_HIGH_QUALITY))) {
1373 return; 1377 return;
1374 } 1378 }
1375 1379
1376 pp::CompletionCallback callback = 1380 pp::CompletionCallback callback =
1377 print_callback_factory_.NewCallback(&Instance::OnPrint); 1381 callback_factory_.NewCallback(&Instance::OnPrint);
1378 pp::Module::Get()->core()->CallOnMainThread(0, callback); 1382 pp::Module::Get()->core()->CallOnMainThread(0, callback);
1379 } 1383 }
1380 1384
1381 void Instance::OnPrint(int32_t) { 1385 void Instance::OnPrint(int32_t) {
1382 pp::PDF::Print(this); 1386 pp::PDF::Print(this);
1383 } 1387 }
1384 1388
1385 void Instance::SaveAs() { 1389 void Instance::SaveAs() {
1386 pp::PDF::SaveAs(this); 1390 pp::PDF::SaveAs(this);
1387 } 1391 }
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 #endif 2114 #endif
2111 2115
2112 CalculateBackgroundParts(); 2116 CalculateBackgroundParts();
2113 engine_->PageOffsetUpdated(available_area_.point()); 2117 engine_->PageOffsetUpdated(available_area_.point());
2114 engine_->PluginSizeUpdated(available_area_.size()); 2118 engine_->PluginSizeUpdated(available_area_.size());
2115 2119
2116 if (!document_size_.GetArea()) 2120 if (!document_size_.GetArea())
2117 return; 2121 return;
2118 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); 2122 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_));
2119 2123
2120 if (on_plugin_size_changed_callback_.is_string()) 2124 // Run the plugin size change callback asynchronously. This function can be
2121 ExecuteScript(on_plugin_size_changed_callback_); 2125 // invoked by a layout change which should not re-enter into JS synchronously.
2126 pp::CompletionCallback callback =
2127 callback_factory_.NewCallback(&Instance::RunCallback,
2128 on_plugin_size_changed_callback_);
2129 pp::Module::Get()->core()->CallOnMainThread(0, callback);
2130 }
2131
2132 void Instance::RunCallback(int32_t, pp::Var callback) {
2133 if (callback.is_string())
2134 ExecuteScript(callback);
2122 } 2135 }
2123 2136
2124 void Instance::CreateHorizontalScrollbar() { 2137 void Instance::CreateHorizontalScrollbar() {
2125 if (h_scrollbar_.get()) 2138 if (h_scrollbar_.get())
2126 return; 2139 return;
2127 2140
2128 h_scrollbar_.reset(new pp::Scrollbar_Dev(this, false)); 2141 h_scrollbar_.reset(new pp::Scrollbar_Dev(this, false));
2129 } 2142 }
2130 2143
2131 void Instance::CreateVerticalScrollbar() { 2144 void Instance::CreateVerticalScrollbar() {
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
2726 return instance_->HasScriptableMethod(name, exception); 2739 return instance_->HasScriptableMethod(name, exception);
2727 } 2740 }
2728 2741
2729 pp::Var PDFScriptableObject::Call(const pp::Var& method, 2742 pp::Var PDFScriptableObject::Call(const pp::Var& method,
2730 const std::vector<pp::Var>& args, 2743 const std::vector<pp::Var>& args,
2731 pp::Var* exception) { 2744 pp::Var* exception) {
2732 return instance_->CallScriptableMethod(method, args, exception); 2745 return instance_->CallScriptableMethod(method, args, exception);
2733 } 2746 }
2734 2747
2735 } // namespace chrome_pdf 2748 } // namespace chrome_pdf
OLDNEW
« 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