| OLD | NEW |
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 const char kChromePrint[] = "chrome://print/"; | 58 const char kChromePrint[] = "chrome://print/"; |
| 59 const char kChromeExtension[] = | 59 const char kChromeExtension[] = |
| 60 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"; | 60 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"; |
| 61 | 61 |
| 62 // Dictionary Value key names for the document accessibility info | 62 // Dictionary Value key names for the document accessibility info |
| 63 const char kAccessibleNumberOfPages[] = "numberOfPages"; | 63 const char kAccessibleNumberOfPages[] = "numberOfPages"; |
| 64 const char kAccessibleLoaded[] = "loaded"; | 64 const char kAccessibleLoaded[] = "loaded"; |
| 65 const char kAccessibleCopyable[] = "copyable"; | 65 const char kAccessibleCopyable[] = "copyable"; |
| 66 | 66 |
| 67 // Constants used in handling postMessage() messages. | 67 // Constants used in handling postMessage() messages. |
| 68 const char* kType = "type"; | 68 const char kType[] = "type"; |
| 69 // Viewport message arguments. (Page -> Plugin). | 69 // Viewport message arguments. (Page -> Plugin). |
| 70 const char* kJSViewportType = "viewport"; | 70 const char kJSViewportType[] = "viewport"; |
| 71 const char* kJSXOffset = "xOffset"; | 71 const char kJSXOffset[] = "xOffset"; |
| 72 const char* kJSYOffset = "yOffset"; | 72 const char kJSYOffset[] = "yOffset"; |
| 73 const char* kJSZoom = "zoom"; | 73 const char kJSZoom[] = "zoom"; |
| 74 // Stop scrolling message (Page -> Plugin) | 74 // Stop scrolling message (Page -> Plugin) |
| 75 const char* kJSStopScrollingType = "stopScrolling"; | 75 const char kJSStopScrollingType[] = "stopScrolling"; |
| 76 // Document dimension arguments (Plugin -> Page). | 76 // Document dimension arguments (Plugin -> Page). |
| 77 const char* kJSDocumentDimensionsType = "documentDimensions"; | 77 const char kJSDocumentDimensionsType[] = "documentDimensions"; |
| 78 const char* kJSDocumentWidth = "width"; | 78 const char kJSDocumentWidth[] = "width"; |
| 79 const char* kJSDocumentHeight = "height"; | 79 const char kJSDocumentHeight[] = "height"; |
| 80 const char* kJSPageDimensions = "pageDimensions"; | 80 const char kJSPageDimensions[] = "pageDimensions"; |
| 81 const char* kJSPageX = "x"; | 81 const char kJSPageX[] = "x"; |
| 82 const char* kJSPageY = "y"; | 82 const char kJSPageY[] = "y"; |
| 83 const char* kJSPageWidth = "width"; | 83 const char kJSPageWidth[] = "width"; |
| 84 const char* kJSPageHeight = "height"; | 84 const char kJSPageHeight[] = "height"; |
| 85 // Document load progress arguments (Plugin -> Page) | 85 // Document load progress arguments (Plugin -> Page) |
| 86 const char* kJSLoadProgressType = "loadProgress"; | 86 const char kJSLoadProgressType[] = "loadProgress"; |
| 87 const char* kJSProgressPercentage = "progress"; | 87 const char kJSProgressPercentage[] = "progress"; |
| 88 // Get password arguments (Plugin -> Page) | 88 // Get password arguments (Plugin -> Page) |
| 89 const char* kJSGetPasswordType = "getPassword"; | 89 const char kJSGetPasswordType[] = "getPassword"; |
| 90 // Get password complete arguments (Page -> Plugin) | 90 // Get password complete arguments (Page -> Plugin) |
| 91 const char* kJSGetPasswordCompleteType = "getPasswordComplete"; | 91 const char kJSGetPasswordCompleteType[] = "getPasswordComplete"; |
| 92 const char* kJSPassword = "password"; | 92 const char kJSPassword[] = "password"; |
| 93 // Print (Page -> Plugin) | 93 // Print (Page -> Plugin) |
| 94 const char* kJSPrintType = "print"; | 94 const char kJSPrintType[] = "print"; |
| 95 // Go to page (Plugin -> Page) | 95 // Go to page (Plugin -> Page) |
| 96 const char* kJSGoToPageType = "goToPage"; | 96 const char kJSGoToPageType[] = "goToPage"; |
| 97 const char* kJSPageNumber = "page"; | 97 const char kJSPageNumber[] = "page"; |
| 98 // Reset print preview mode (Page -> Plugin) | 98 // Reset print preview mode (Page -> Plugin) |
| 99 const char* kJSResetPrintPreviewModeType = "resetPrintPreviewMode"; | 99 const char kJSResetPrintPreviewModeType[] = "resetPrintPreviewMode"; |
| 100 const char* kJSPrintPreviewUrl = "url"; | 100 const char kJSPrintPreviewUrl[] = "url"; |
| 101 const char* kJSPrintPreviewGrayscale = "grayscale"; | 101 const char kJSPrintPreviewGrayscale[] = "grayscale"; |
| 102 const char* kJSPrintPreviewPageCount = "pageCount"; | 102 const char kJSPrintPreviewPageCount[] = "pageCount"; |
| 103 // Load preview page (Page -> Plugin) | 103 // Load preview page (Page -> Plugin) |
| 104 const char* kJSLoadPreviewPageType = "loadPreviewPage"; | 104 const char kJSLoadPreviewPageType[] = "loadPreviewPage"; |
| 105 const char* kJSPreviewPageUrl = "url"; | 105 const char kJSPreviewPageUrl[] = "url"; |
| 106 const char* kJSPreviewPageIndex = "index"; | 106 const char kJSPreviewPageIndex[] = "index"; |
| 107 // Set scroll position (Plugin -> Page) | 107 // Set scroll position (Plugin -> Page) |
| 108 const char* kJSSetScrollPositionType = "setScrollPosition"; | 108 const char kJSSetScrollPositionType[] = "setScrollPosition"; |
| 109 const char* kJSPositionX = "x"; | 109 const char kJSPositionX[] = "x"; |
| 110 const char* kJSPositionY = "y"; | 110 const char kJSPositionY[] = "y"; |
| 111 // Set translated strings (Plugin -> Page) | 111 // Set translated strings (Plugin -> Page) |
| 112 const char* kJSSetTranslatedStringsType = "setTranslatedStrings"; | 112 const char kJSSetTranslatedStringsType[] = "setTranslatedStrings"; |
| 113 const char* kJSGetPasswordString = "getPasswordString"; | 113 const char kJSGetPasswordString[] = "getPasswordString"; |
| 114 const char* kJSLoadingString = "loadingString"; | 114 const char kJSLoadingString[] = "loadingString"; |
| 115 const char* kJSLoadFailedString = "loadFailedString"; | 115 const char kJSLoadFailedString[] = "loadFailedString"; |
| 116 // Request accessibility JSON data (Page -> Plugin) | 116 // Request accessibility JSON data (Page -> Plugin) |
| 117 const char* kJSGetAccessibilityJSONType = "getAccessibilityJSON"; | 117 const char kJSGetAccessibilityJSONType[] = "getAccessibilityJSON"; |
| 118 const char* kJSAccessibilityPageNumber = "page"; | 118 const char kJSAccessibilityPageNumber[] = "page"; |
| 119 // Reply with accessibility JSON data (Plugin -> Page) | 119 // Reply with accessibility JSON data (Plugin -> Page) |
| 120 const char* kJSGetAccessibilityJSONReplyType = "getAccessibilityJSONReply"; | 120 const char kJSGetAccessibilityJSONReplyType[] = "getAccessibilityJSONReply"; |
| 121 const char* kJSAccessibilityJSON = "json"; | 121 const char kJSAccessibilityJSON[] = "json"; |
| 122 // Cancel the stream URL request (Plugin -> Page) | 122 // Cancel the stream URL request (Plugin -> Page) |
| 123 const char* kJSCancelStreamUrlType = "cancelStreamUrl"; | 123 const char kJSCancelStreamUrlType[] = "cancelStreamUrl"; |
| 124 // Navigate to the given URL (Plugin -> Page) | 124 // Navigate to the given URL (Plugin -> Page) |
| 125 const char* kJSNavigateType = "navigate"; | 125 const char kJSNavigateType[] = "navigate"; |
| 126 const char* kJSNavigateUrl = "url"; | 126 const char kJSNavigateUrl[] = "url"; |
| 127 const char* kJSNavigateNewTab = "newTab"; | 127 const char kJSNavigateNewTab[] = "newTab"; |
| 128 // Open the email editor with the given parameters (Plugin -> Page) | 128 // Open the email editor with the given parameters (Plugin -> Page) |
| 129 const char* kJSEmailType = "email"; | 129 const char kJSEmailType[] = "email"; |
| 130 const char* kJSEmailTo = "to"; | 130 const char kJSEmailTo[] = "to"; |
| 131 const char* kJSEmailCc = "cc"; | 131 const char kJSEmailCc[] = "cc"; |
| 132 const char* kJSEmailBcc = "bcc"; | 132 const char kJSEmailBcc[] = "bcc"; |
| 133 const char* kJSEmailSubject = "subject"; | 133 const char kJSEmailSubject[] = "subject"; |
| 134 const char* kJSEmailBody = "body"; | 134 const char kJSEmailBody[] = "body"; |
| 135 | 135 |
| 136 const int kFindResultCooldownMs = 100; | 136 const int kFindResultCooldownMs = 100; |
| 137 | 137 |
| 138 const double kMinZoom = 0.01; | 138 const double kMinZoom = 0.01; |
| 139 | 139 |
| 140 namespace { | 140 namespace { |
| 141 | 141 |
| 142 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; | 142 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; |
| 143 | 143 |
| 144 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { | 144 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { |
| (...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument( | 1417 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument( |
| 1418 const pp::Point& scroll_offset) { | 1418 const pp::Point& scroll_offset) { |
| 1419 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1419 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1420 int x = std::max(std::min(scroll_offset.x(), max_x), 0); | 1420 int x = std::max(std::min(scroll_offset.x(), max_x), 0); |
| 1421 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1421 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1422 int y = std::max(std::min(scroll_offset.y(), max_y), 0); | 1422 int y = std::max(std::min(scroll_offset.y(), max_y), 0); |
| 1423 return pp::Point(x, y); | 1423 return pp::Point(x, y); |
| 1424 } | 1424 } |
| 1425 | 1425 |
| 1426 } // namespace chrome_pdf | 1426 } // namespace chrome_pdf |
| OLD | NEW |