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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 814573004: Fix for Multipage selection by dragging mouse in OOP case in PDF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nit. Created 5 years, 10 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
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/out_of_process_instance.h" 5 #include "pdf/out_of_process_instance.h"
6 6
7 #include <algorithm> // for min/max() 7 #include <algorithm> // for min/max()
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Get the selected text in the document (Page -> Plugin) 137 // Get the selected text in the document (Page -> Plugin)
138 const char kJSGetSelectedTextType[] = "getSelectedText"; 138 const char kJSGetSelectedTextType[] = "getSelectedText";
139 // Reply with selected text (Plugin -> Page) 139 // Reply with selected text (Plugin -> Page)
140 const char kJSGetSelectedTextReplyType[] = "getSelectedTextReply"; 140 const char kJSGetSelectedTextReplyType[] = "getSelectedTextReply";
141 const char kJSSelectedText[] = "selectedText"; 141 const char kJSSelectedText[] = "selectedText";
142 142
143 // List of named destinations (Plugin -> Page) 143 // List of named destinations (Plugin -> Page)
144 const char kJSSetNamedDestinationsType[] = "setNamedDestinations"; 144 const char kJSSetNamedDestinationsType[] = "setNamedDestinations";
145 const char kJSNamedDestinations[] = "namedDestinations"; 145 const char kJSNamedDestinations[] = "namedDestinations";
146 146
147 // Selecting text in document (Plugin -> Page)
148 const char kJSSetIsSelectingType[] = "setIsSelecting";
149 const char kJSIsSelecting[] = "isSelecting";
150
147 const int kFindResultCooldownMs = 100; 151 const int kFindResultCooldownMs = 100;
148 152
149 const double kMinZoom = 0.01; 153 const double kMinZoom = 0.01;
150 154
151 namespace { 155 namespace {
152 156
153 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; 157 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1;
154 158
155 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { 159 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) {
156 pp::Var var; 160 pp::Var var;
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 return; 1344 return;
1341 engine_->AppendBlankPages(print_preview_page_count_); 1345 engine_->AppendBlankPages(print_preview_page_count_);
1342 if (preview_pages_info_.size() > 0) 1346 if (preview_pages_info_.size() > 0)
1343 LoadAvailablePreviewPage(); 1347 LoadAvailablePreviewPage();
1344 } 1348 }
1345 1349
1346 bool OutOfProcessInstance::IsPrintPreview() { 1350 bool OutOfProcessInstance::IsPrintPreview() {
1347 return IsPrintPreviewUrl(url_); 1351 return IsPrintPreviewUrl(url_);
1348 } 1352 }
1349 1353
1354 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) {
1355 pp::VarDictionary message;
1356 message.Set(kType, kJSSetIsSelectingType);
1357 message.Set(kJSIsSelecting, pp::Var(is_selecting));
1358 PostMessage(message);
1359 }
1360
1350 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url, 1361 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url,
1351 int dst_page_index) { 1362 int dst_page_index) {
1352 if (!IsPrintPreview()) 1363 if (!IsPrintPreview())
1353 return; 1364 return;
1354 1365
1355 int src_page_index = ExtractPrintPreviewPageIndex(url); 1366 int src_page_index = ExtractPrintPreviewPageIndex(url);
1356 if (src_page_index < 1) 1367 if (src_page_index < 1)
1357 return; 1368 return;
1358 1369
1359 preview_pages_info_.push(std::make_pair(url, dst_page_index)); 1370 preview_pages_info_.push(std::make_pair(url, dst_page_index));
(...skipping 28 matching lines...) Expand all
1388 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( 1399 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument(
1389 const pp::FloatPoint& scroll_offset) { 1400 const pp::FloatPoint& scroll_offset) {
1390 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1401 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1391 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); 1402 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1392 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1403 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1393 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); 1404 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f);
1394 return pp::FloatPoint(x, y); 1405 return pp::FloatPoint(x, y);
1395 } 1406 }
1396 1407
1397 } // namespace chrome_pdf 1408 } // namespace chrome_pdf
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698