summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/Plugins/PDF
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/WebProcess/Plugins/PDF')
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h158
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h325
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/PDFAnnotationTextWidgetDetails.h31
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h172
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h323
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginAnnotation.h119
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.h66
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginPasswordField.h57
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.h73
9 files changed, 1324 insertions, 0 deletions
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h b/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h
new file mode 100644
index 000000000..18042e213
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2012, 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DeprecatedPDFLayerControllerSPI_h
+#define DeprecatedPDFLayerControllerSPI_h
+
+#if ENABLE(PDFKIT_PLUGIN) && USE(DEPRECATED_PDF_PLUGIN)
+
+#import <PDFKit/PDFKit.h>
+
+@class CPReadingModel;
+@class PDFViewLayout;
+
+@protocol PDFLayerControllerDelegate <NSObject>
+
+- (void)updateScrollPosition:(CGPoint)newPosition;
+- (void)writeItemsToPasteboard:(NSArray *)items withTypes:(NSArray *)types;
+- (void)showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point;
+- (void)performWebSearch:(NSString *)string;
+- (void)performSpotlightSearch:(NSString *)string;
+- (void)openWithNativeApplication;
+- (void)saveToPDF;
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeActiveAnnotation:(PDFAnnotation *)annotation;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController clickedLinkWithURL:(NSURL *)url;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeContentScaleFactor:(CGFloat)scaleFactor;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeDisplayMode:(int)mode;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeSelection:(PDFSelection *)selection;
+
+@end
+
+@interface PDFLayerController : NSObject
+@end
+
+@interface PDFLayerController ()
+
+@property (retain) CALayer *parentLayer;
+@property (retain) PDFDocument *document;
+@property (retain) id<PDFLayerControllerDelegate> delegate;
+
+- (void)setFrameSize:(CGSize)size;
+
+- (PDFDisplayMode)displayMode;
+- (void)setDisplayMode:(PDFDisplayMode)mode;
+- (void)setDisplaysPageBreaks:(BOOL)pageBreaks;
+
+- (CGFloat)contentScaleFactor;
+- (void)setContentScaleFactor:(CGFloat)scaleFactor;
+
+- (CGFloat)deviceScaleFactor;
+- (void)setDeviceScaleFactor:(CGFloat)scaleFactor;
+
+- (CGSize)contentSize;
+- (CGSize)contentSizeRespectingZoom;
+
+- (void)snapshotInContext:(CGContextRef)context;
+
+- (void)magnifyWithMagnification:(CGFloat)magnification atPoint:(CGPoint)point immediately:(BOOL)immediately;
+
+- (CGPoint)scrollPosition;
+- (void)setScrollPosition:(CGPoint)newPosition;
+- (void)scrollWithDelta:(CGSize)delta;
+
+- (void)mouseDown:(NSEvent *)event;
+- (void)rightMouseDown:(NSEvent *)event;
+- (void)mouseMoved:(NSEvent *)event;
+- (void)mouseUp:(NSEvent *)event;
+- (void)mouseDragged:(NSEvent *)event;
+- (void)mouseEntered:(NSEvent *)event;
+- (void)mouseExited:(NSEvent *)event;
+
+- (NSMenu *)menuForEvent:(NSEvent *)event;
+
+- (NSArray *)findString:(NSString *)string caseSensitive:(BOOL)isCaseSensitive highlightMatches:(BOOL)shouldHighlightMatches;
+
+- (PDFSelection *)currentSelection;
+- (void)setCurrentSelection:(PDFSelection *)selection;
+- (PDFSelection *)searchSelection;
+- (void)setSearchSelection:(PDFSelection *)selection;
+- (void)gotoSelection:(PDFSelection *)selection;
+- (PDFSelection *)getSelectionForWordAtPoint:(CGPoint)point;
+- (NSArray *)rectsForSelectionInLayoutSpace:(PDFSelection *)selection;
+- (NSArray *)rectsForAnnotationInLayoutSpace:(PDFAnnotation *)annotation;
+- (PDFViewLayout *)layout;
+- (NSRect)frame;
+
+- (PDFPage *)currentPage;
+- (NSUInteger)lastPageIndex;
+- (NSUInteger)currentPageIndex;
+- (void)gotoNextPage;
+- (void)gotoPreviousPage;
+
+- (void)copySelection;
+- (void)selectAll;
+
+- (bool)keyDown:(NSEvent *)event;
+
+- (void)setHUDEnabled:(BOOL)enabled;
+- (BOOL)hudEnabled;
+
+- (CGRect)boundsForAnnotation:(PDFAnnotation *)annotation;
+- (void)activateNextAnnotation:(BOOL)previous;
+
+- (void)attemptToUnlockWithPassword:(NSString *)password;
+
+- (void)searchInDictionaryWithSelection:(PDFSelection *)selection;
+
+// Accessibility
+
+- (CPReadingModel *)readingModel;
+- (id)accessibilityFocusedUIElement;
+- (NSArray *)accessibilityAttributeNames;
+- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute;
+- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute;
+- (NSArray *)accessibilityParameterizedAttributeNames;
+- (NSString *)accessibilityRoleAttribute;
+- (NSString *)accessibilityRoleDescriptionAttribute;
+- (NSString *)accessibilityValueAttribute;
+- (BOOL)accessibilityIsValueAttributeSettable;
+- (NSString *)accessibilitySelectedTextAttribute;
+- (BOOL)accessibilityIsSelectedTextAttributeSettable;
+- (NSValue *)accessibilitySelectedTextRangeAttribute;
+- (NSNumber *)accessibilityNumberOfCharactersAttribute;
+- (BOOL)accessibilityIsNumberOfCharactersAttributeSettable;
+- (NSValue *)accessibilityVisibleCharacterRangeAttribute;
+- (BOOL)accessibilityIsVisibleCharacterRangeAttributeSettable;
+- (NSNumber *)accessibilityLineForIndexAttributeForParameter:(id)parameter;
+- (NSValue *)accessibilityRangeForLineAttributeForParameter:(id)parameter;
+- (NSString *)accessibilityStringForRangeAttributeForParameter:(id)parameter;
+- (NSValue *)accessibilityBoundsForRangeAttributeForParameter:(id)parameter;
+
+@end
+
+#endif
+
+#endif // DeprecatedPDFLayerControllerSPI_h
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h b/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h
new file mode 100644
index 000000000..1456a5198
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h
@@ -0,0 +1,325 @@
+/*
+ * Copyright (C) 2011, 2012, 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DeprecatedPDFPlugin_h
+#define DeprecatedPDFPlugin_h
+
+#include "PDFKitImports.h"
+
+#if ENABLE(PDFKIT_PLUGIN) && USE(DEPRECATED_PDF_PLUGIN)
+
+#include "Plugin.h"
+#include "WebEvent.h"
+#include "WebHitTestResultData.h"
+#include <WebCore/AffineTransform.h>
+#include <WebCore/FindOptions.h>
+#include <WebCore/ScrollableArea.h>
+#include <wtf/RetainPtr.h>
+
+typedef const struct OpaqueJSContext* JSContextRef;
+typedef struct OpaqueJSValue* JSObjectRef;
+typedef const struct OpaqueJSValue* JSValueRef;
+
+OBJC_CLASS NSArray;
+OBJC_CLASS NSAttributedString;
+OBJC_CLASS NSData;
+OBJC_CLASS NSString;
+OBJC_CLASS PDFAnnotation;
+OBJC_CLASS PDFLayerController;
+OBJC_CLASS PDFSelection;
+OBJC_CLASS WKPDFPluginAccessibilityObject;
+OBJC_CLASS WKPDFLayerControllerDelegate;
+
+namespace IPC {
+class DataReference;
+}
+
+namespace WebCore {
+class Element;
+struct PluginInfo;
+}
+
+namespace WebKit {
+
+class PDFPluginAnnotation;
+class PDFPluginPasswordField;
+class PluginView;
+class WebFrame;
+
+class PDFPlugin final : public Plugin, private WebCore::ScrollableArea {
+public:
+ static Ref<PDFPlugin> create(WebFrame*);
+ ~PDFPlugin();
+
+ static WebCore::PluginInfo pluginInfo();
+
+ WebCore::IntSize size() const { return m_size; }
+
+ void didMutatePDFDocument() { m_pdfDocumentWasMutated = true; }
+
+ void paintControlForLayerInContext(CALayer *, CGContextRef);
+ void setActiveAnnotation(PDFAnnotation *);
+
+ using ScrollableArea::notifyScrollPositionChanged;
+ void notifyContentScaleFactorChanged(CGFloat scaleFactor);
+ void notifyDisplayModeChanged(int);
+
+ void notifySelectionChanged(PDFSelection *);
+
+ void clickedLink(NSURL *);
+ void saveToPDF();
+ void openWithNativeApplication();
+ void writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types);
+ void showDefinitionForAttributedString(NSAttributedString *, CGPoint);
+ void performWebSearch(NSString *);
+ void performSpotlightSearch(NSString *);
+
+ void focusNextAnnotation();
+ void focusPreviousAnnotation();
+
+ void attemptToUnlockPDF(const String& password);
+
+ WebCore::FloatRect convertFromPDFViewToScreen(const WebCore::FloatRect&) const;
+ WebCore::IntRect boundsOnScreen() const;
+
+ bool showContextMenuAtPoint(const WebCore::IntPoint&);
+
+ String lookupTextAtLocation(const WebCore::FloatPoint&, WebHitTestResultData&, PDFSelection **, NSDictionary **) const;
+ WebCore::FloatRect rectForSelectionInRootView(PDFSelection *) const;
+
+ CGFloat scaleFactor() const;
+
+ bool shouldPlaceBlockDirectionScrollbarOnLeft() const override { return false; }
+
+private:
+ explicit PDFPlugin(WebFrame*);
+
+ // Plugin functions.
+ bool initialize(const Parameters&) override;
+ void destroy() override;
+ void paint(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRectInWindowCoordinates) override { }
+ void updateControlTints(WebCore::GraphicsContext&) override;
+ bool supportsSnapshotting() const override { return true; }
+ RefPtr<ShareableBitmap> snapshot() override;
+ PlatformLayer* pluginLayer() override;
+ bool isTransparent() override { return false; }
+ bool wantsWheelEvents() override { return true; }
+ void geometryDidChange(const WebCore::IntSize& pluginSize, const WebCore::IntRect& clipRect, const WebCore::AffineTransform& pluginToRootViewTransform) override;
+ void contentsScaleFactorChanged(float) override;
+ void visibilityDidChange(bool) override { }
+ void frameDidFinishLoading(uint64_t requestID) override;
+ void frameDidFail(uint64_t requestID, bool wasCancelled) override;
+ void didEvaluateJavaScript(uint64_t requestID, const String& result) override;
+ void streamWillSendRequest(uint64_t streamID, const WebCore::URL& requestURL, const WebCore::URL& responseURL, int responseStatus) override { }
+ void streamDidReceiveResponse(uint64_t streamID, const WebCore::URL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers, const String& suggestedFileName) override;
+ void streamDidReceiveData(uint64_t streamID, const char* bytes, int length) override;
+ void streamDidFinishLoading(uint64_t streamID) override;
+ void streamDidFail(uint64_t streamID, bool wasCancelled) override;
+ void manualStreamDidReceiveResponse(const WebCore::URL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const WTF::String& mimeType, const WTF::String& headers, const String& suggestedFileName) override;
+ void manualStreamDidReceiveData(const char* bytes, int length) override;
+ void manualStreamDidFinishLoading() override;
+ void manualStreamDidFail(bool wasCancelled) override;
+ bool handleMouseEvent(const WebMouseEvent&) override;
+ bool handleWheelEvent(const WebWheelEvent&) override;
+ bool handleMouseEnterEvent(const WebMouseEvent&) override;
+ bool handleMouseLeaveEvent(const WebMouseEvent&) override;
+ bool handleContextMenuEvent(const WebMouseEvent&) override;
+ bool handleKeyboardEvent(const WebKeyboardEvent&) override;
+ bool handleEditingCommand(const String& commandName, const String& argument) override;
+ bool isEditingCommandEnabled(const String&) override;
+ bool handlesPageScaleFactor() const override;
+ bool requiresUnifiedScaleFactor() const override { return true; }
+ void setFocus(bool) override { }
+ NPObject* pluginScriptableNPObject() override { return 0; }
+ void windowFocusChanged(bool) override { }
+ void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates) override { }
+ void windowVisibilityChanged(bool) override { }
+ uint64_t pluginComplexTextInputIdentifier() const override { return 0; }
+ void sendComplexTextInput(const String& textInput) override { }
+ void setLayerHostingMode(LayerHostingMode) override { }
+ WebCore::Scrollbar* horizontalScrollbar() override { return m_horizontalScrollbar.get(); }
+ WebCore::Scrollbar* verticalScrollbar() override { return m_verticalScrollbar.get(); }
+ void storageBlockingStateChanged(bool) override { }
+ void privateBrowsingStateChanged(bool) override { }
+ bool getFormValue(String& formValue) override { return false; }
+ bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) override;
+ RefPtr<WebCore::SharedBuffer> liveResourceData() const override;
+ void willDetatchRenderer() override;
+
+ bool isBeingAsynchronouslyInitialized() const override { return false; }
+
+ RetainPtr<PDFDocument> pdfDocumentForPrinting() const override { return m_pdfDocument; }
+ NSObject *accessibilityObject() const override;
+
+ unsigned countFindMatches(const String& target, WebCore::FindOptions, unsigned maxMatchCount) override;
+ bool findString(const String& target, WebCore::FindOptions, unsigned maxMatchCount) override;
+
+ PDFSelection *nextMatchForString(const String& target, BOOL searchForward, BOOL caseSensitive, BOOL wrapSearch, PDFSelection *initialSelection, BOOL startInSelection);
+
+ bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) override;
+ String getSelectionString() const override;
+ String getSelectionForWordAtPoint(const WebCore::FloatPoint&) const override;
+ bool existingSelectionContainsPoint(const WebCore::FloatPoint&) const override;
+
+ bool shouldAllowScripting() override { return false; }
+ bool shouldAllowNavigationFromDrags() override { return true; }
+ bool shouldAlwaysAutoStart() const override { return true; }
+
+ // ScrollableArea functions.
+ WebCore::IntRect scrollCornerRect() const override;
+ WebCore::ScrollableArea* enclosingScrollableArea() const override;
+ bool isScrollableOrRubberbandable() override { return true; }
+ bool hasScrollableOrRubberbandableAncestor() override { return true; }
+ WebCore::IntRect scrollableAreaBoundingBox(bool* = nullptr) const override;
+ void setScrollOffset(const WebCore::ScrollOffset&) override;
+ void invalidateScrollbarRect(WebCore::Scrollbar&, const WebCore::IntRect&) override;
+ void invalidateScrollCornerRect(const WebCore::IntRect&) override;
+ WebCore::IntPoint lastKnownMousePosition() const override { return m_lastMousePositionInPluginCoordinates; }
+ int scrollSize(WebCore::ScrollbarOrientation) const override;
+ bool isActive() const override;
+ bool isScrollCornerVisible() const override { return false; }
+ int scrollOffset(WebCore::ScrollbarOrientation) const override;
+ WebCore::ScrollPosition scrollPosition() const override;
+ WebCore::ScrollPosition minimumScrollPosition() const override;
+ WebCore::ScrollPosition maximumScrollPosition() const override;
+ WebCore::IntSize visibleSize() const override { return m_size; }
+ WebCore::IntSize contentsSize() const override { return m_pdfDocumentSize; }
+ WebCore::Scrollbar* horizontalScrollbar() const override { return m_horizontalScrollbar.get(); }
+ WebCore::Scrollbar* verticalScrollbar() const override { return m_verticalScrollbar.get(); }
+ bool shouldSuspendScrollAnimations() const override { return false; } // If we return true, ScrollAnimatorMac will keep cycling a timer forever, waiting for a good time to animate.
+ void scrollbarStyleChanged(WebCore::ScrollbarStyle, bool forceUpdate) override;
+ WebCore::IntRect convertFromScrollbarToContainingView(const WebCore::Scrollbar&, const WebCore::IntRect& scrollbarRect) const override;
+ WebCore::IntRect convertFromContainingViewToScrollbar(const WebCore::Scrollbar&, const WebCore::IntRect& parentRect) const override;
+ WebCore::IntPoint convertFromScrollbarToContainingView(const WebCore::Scrollbar&, const WebCore::IntPoint& scrollbarPoint) const override;
+ WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::Scrollbar&, const WebCore::IntPoint& parentPoint) const override;
+ bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const override;
+
+ // PDFPlugin functions.
+ void updateScrollbars();
+ Ref<WebCore::Scrollbar> createScrollbar(WebCore::ScrollbarOrientation);
+ void destroyScrollbar(WebCore::ScrollbarOrientation);
+ void pdfDocumentDidLoad();
+ void addArchiveResource();
+ void computePageBoxes();
+ void calculateSizes();
+ void runScriptsInPDFDocument();
+
+ NSEvent *nsEventForWebMouseEvent(const WebMouseEvent&);
+ WebCore::IntPoint convertFromPluginToPDFView(const WebCore::IntPoint&) const;
+ WebCore::IntPoint convertFromRootViewToPlugin(const WebCore::IntPoint&) const;
+ WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&) const;
+
+ bool supportsForms();
+ bool isFullFramePlugin() const;
+
+ void updatePageAndDeviceScaleFactors();
+
+ void createPasswordEntryForm();
+
+ RetainPtr<PDFDocument> pdfDocument() const { return m_pdfDocument; }
+ void setPDFDocument(RetainPtr<PDFDocument> document) { m_pdfDocument = document; }
+
+ WebCore::IntSize pdfDocumentSize() const { return m_pdfDocumentSize; }
+ void setPDFDocumentSize(WebCore::IntSize size) { m_pdfDocumentSize = size; }
+
+ NSData *liveData() const;
+ NSData *rawData() const { return (NSData *)m_data.get(); }
+
+ WebFrame* webFrame() const { return m_frame; }
+
+ enum UpdateCursorMode {
+ UpdateIfNeeded,
+ ForceUpdate
+ };
+
+ enum HitTestResult {
+ None,
+ Text
+ };
+
+ void updateCursor(const WebMouseEvent&, UpdateCursorMode = UpdateIfNeeded);
+
+ JSObjectRef makeJSPDFDoc(JSContextRef);
+ static JSValueRef jsPDFDocPrint(JSContextRef, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+ void convertPostScriptDataIfNeeded();
+
+ // Regular plug-ins don't need access to view, but we add scrollbars to embedding FrameView for proper event handling.
+ PluginView* pluginView();
+ const PluginView* pluginView() const;
+
+ WebFrame* m_frame;
+
+ bool m_isPostScript;
+ bool m_pdfDocumentWasMutated;
+
+ WebCore::IntSize m_scrollOffset;
+
+ RetainPtr<CALayer> m_containerLayer;
+ RetainPtr<CALayer> m_contentLayer;
+ RetainPtr<CALayer> m_horizontalScrollbarLayer;
+ RetainPtr<CALayer> m_verticalScrollbarLayer;
+ RetainPtr<CALayer> m_scrollCornerLayer;
+ RetainPtr<PDFLayerController> m_pdfLayerController;
+ RetainPtr<WKPDFPluginAccessibilityObject> m_accessibilityObject;
+
+ RefPtr<PDFPluginAnnotation> m_activeAnnotation;
+ RefPtr<PDFPluginPasswordField> m_passwordField;
+ RefPtr<WebCore::Element> m_annotationContainer;
+
+ WebCore::AffineTransform m_rootViewToPluginTransform;
+ WebMouseEvent m_lastMouseEvent;
+ WebCore::IntPoint m_lastMousePositionInPluginCoordinates;
+
+ String m_temporaryPDFUUID;
+
+ String m_lastFoundString;
+
+ HitTestResult m_lastHitTestResult;
+
+ RetainPtr<WKPDFLayerControllerDelegate> m_pdfLayerControllerDelegate;
+
+ WebCore::IntSize m_size;
+
+ WebCore::URL m_sourceURL;
+
+ String m_suggestedFilename;
+ RetainPtr<CFMutableDataRef> m_data;
+
+ RetainPtr<PDFDocument> m_pdfDocument;
+ Vector<WebCore::IntRect> m_pageBoxes;
+ WebCore::IntSize m_pdfDocumentSize; // All pages, including gaps.
+
+ RefPtr<WebCore::Scrollbar> m_horizontalScrollbar;
+ RefPtr<WebCore::Scrollbar> m_verticalScrollbar;
+};
+
+} // namespace WebKit
+
+SPECIALIZE_TYPE_TRAITS_PLUGIN(PDFPlugin, PDFPluginType)
+
+#endif // ENABLE(PDFKIT_PLUGIN)
+
+#endif // DeprecatedPDFPlugin_h
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFAnnotationTextWidgetDetails.h b/Source/WebKit2/WebProcess/Plugins/PDF/PDFAnnotationTextWidgetDetails.h
new file mode 100644
index 000000000..8656ff466
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFAnnotationTextWidgetDetails.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <PDFKit/PDFKit.h>
+
+@interface PDFAnnotationTextWidget (Details)
+- (BOOL)isMultiline;
+- (BOOL)isReadOnly;
+@end
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h b/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h
new file mode 100644
index 000000000..858f5f10c
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2012, 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PDFLayerControllerSPI_h
+#define PDFLayerControllerSPI_h
+
+#include "PDFKitImports.h"
+
+#if ENABLE(PDFKIT_PLUGIN)
+#if USE(DEPRECATED_PDF_PLUGIN)
+
+#include "DeprecatedPDFLayerControllerSPI.h"
+
+#else // USE(DEPRECATED_PDF_PLUGIN)
+
+#import <PDFKit/PDFKit.h>
+
+@class CPReadingModel;
+@class PDFViewLayout;
+
+@protocol PDFLayerControllerDelegate <NSObject>
+
+@optional
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController scrollToPoint:(CGPoint)newPosition;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController invalidateRect:(CGRect)rect;
+- (void)pdfLayerControllerInvalidateHUD:(PDFLayerController *)pdfLayerController;
+
+- (void)pdfLayerControllerZoomIn:(PDFLayerController *)pdfLayerController;
+- (void)pdfLayerControllerZoomOut:(PDFLayerController *)pdfLayerController;
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeActiveAnnotation:(PDFAnnotation *)annotation;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didClickLinkWithURL:(NSURL *)url;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeDisplayMode:(int)mode;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeSelection:(PDFSelection *)selection;
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController copyItems:(NSArray *)items withTypes:(NSArray *)types;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController performWebSearchForString:(NSString *)string;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController performSpotlightSearchForString:(NSString *)string;
+- (void)pdfLayerControllerSaveToPDF:(PDFLayerController *)pdfLayerController;
+- (void)pdfLayerControllerOpenWithNativeApplication:(PDFLayerController *)pdfLayerController;
+
+- (NSColorSpace*)pdfLayerControllerColorSpace:(PDFLayerController *)pdfLayerController;
+
+@end
+
+@interface PDFLayerController : NSObject
+@end
+
+@interface PDFLayerController ()
+
+@property (retain) PDFDocument *document;
+@property (assign) id<PDFLayerControllerDelegate> delegate;
+@property (retain) NSArray *searchMatches;
+
+- (void)setFrameSize:(CGSize)size;
+
+- (void)setDisplayMode:(int)mode;
+- (int)displayMode;
+- (int)realDisplayMode;
+
+- (CGSize)contentSize;
+- (CGSize)contentSizeRespectingZoom;
+
+- (CGFloat)contentScaleFactor;
+- (void)setContentScaleFactor:(CGFloat)contentScaleFactor;
+
+- (PDFViewLayout *)layout;
+
+- (void)drawInContext:(CGContextRef)context;
+- (void)drawHUDInContext:(CGContextRef)context;
+
+- (void)mouseDown:(NSEvent *)event;
+- (void)mouseUp:(NSEvent *)event;
+- (void)mouseDragged:(NSEvent *)event;
+
+- (BOOL)mouseDown:(NSEvent *)event inHUDWithBounds:(CGRect)bounds;
+- (BOOL)mouseUp:(NSEvent *)event inHUDWithBounds:(CGRect)bounds;
+- (BOOL)mouseDragged:(NSEvent *)event inHUDWithBounds:(CGRect)bounds;
+
+- (NSMenu *)menuForEvent:(NSEvent *)event;
+
+- (NSArray *)pageRects;
+
+- (void)setVisibleRect:(CGRect)visibleRect;
+
+- (void)gotoSelection:(PDFSelection *)selection;
+- (void)gotoDestination:(PDFDestination *)destination;
+- (void)gotoRect:(CGRect)rect onPage:(PDFPage *)page;
+
+- (PDFSelection *)currentSelection;
+- (void)setCurrentSelection:(PDFSelection *)selection;
+
+- (void)searchInDictionaryWithSelection:(PDFSelection *)selection;
+- (PDFSelection *)getSelectionForWordAtPoint:(CGPoint)point;
+- (NSArray *)rectsForSelectionInLayoutSpace:(PDFSelection *)selection;
+
+- (NSArray *)highlights;
+- (void)setHighlights:(NSArray*)highlights;
+
+- (PDFSelection *)searchSelection;
+- (NSArray *)searchMatches;
+- (void)setSearchSelection:(PDFSelection*)selection;
+- (NSArray *)findString:(NSString *)string caseSensitive:(BOOL)isCaseSensitive highlightMatches:(BOOL)shouldHighlightMatches;
+
+- (void)copySelection;
+- (void)selectAll;
+
+- (PDFPage *)currentPage;
+- (NSUInteger)currentPageIndex;
+
+- (BOOL)documentIsLocked;
+- (void)attemptToUnlockWithPassword:(NSString *)password;
+
+- (CGRect)boundsForAnnotation:(PDFAnnotation *)annotation;
+- (void)activateNextAnnotation:(BOOL)previous;
+
+- (NSRect)frame;
+
+// Accessibility
+
+- (CPReadingModel *)readingModel;
+- (id)accessibilityFocusedUIElement;
+- (NSArray *)accessibilityAttributeNames;
+- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute;
+- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute;
+- (NSArray *)accessibilityParameterizedAttributeNames;
+- (NSString *)accessibilityRoleAttribute;
+- (NSString *)accessibilityRoleDescriptionAttribute;
+- (NSString *)accessibilityValueAttribute;
+- (BOOL)accessibilityIsValueAttributeSettable;
+- (NSString *)accessibilitySelectedTextAttribute;
+- (BOOL)accessibilityIsSelectedTextAttributeSettable;
+- (NSValue *)accessibilitySelectedTextRangeAttribute;
+- (NSNumber *)accessibilityNumberOfCharactersAttribute;
+- (BOOL)accessibilityIsNumberOfCharactersAttributeSettable;
+- (NSValue *)accessibilityVisibleCharacterRangeAttribute;
+- (BOOL)accessibilityIsVisibleCharacterRangeAttributeSettable;
+- (NSNumber *)accessibilityLineForIndexAttributeForParameter:(id)parameter;
+- (NSValue *)accessibilityRangeForLineAttributeForParameter:(id)parameter;
+- (NSString *)accessibilityStringForRangeAttributeForParameter:(id)parameter;
+- (NSValue *)accessibilityBoundsForRangeAttributeForParameter:(id)parameter;
+
+@end
+
+#endif // USE(DEPRECATED_PDF_PLUGIN)
+#endif // ENABLE(PDFPLUGIN)
+
+#endif // PDFLayerControllerSPI_h
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h
new file mode 100644
index 000000000..0c6ab1f3b
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h
@@ -0,0 +1,323 @@
+/*
+ * Copyright (C) 2011, 2012, 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PDFPlugin_h
+#define PDFPlugin_h
+
+#include "PDFKitImports.h"
+
+#if ENABLE(PDFKIT_PLUGIN)
+#if USE(DEPRECATED_PDF_PLUGIN)
+
+#include "DeprecatedPDFPlugin.h"
+
+#else // USE(DEPRECATED_PDF_PLUGIN)
+
+#include "Plugin.h"
+#include "WebEvent.h"
+#include "WebHitTestResultData.h"
+#include <WebCore/AffineTransform.h>
+#include <WebCore/FindOptions.h>
+#include <WebCore/PageOverlay.h>
+#include <WebCore/ScrollableArea.h>
+#include <wtf/RetainPtr.h>
+
+typedef const struct OpaqueJSContext* JSContextRef;
+typedef struct OpaqueJSValue* JSObjectRef;
+typedef const struct OpaqueJSValue* JSValueRef;
+
+OBJC_CLASS NSArray;
+OBJC_CLASS NSAttributedString;
+OBJC_CLASS NSData;
+OBJC_CLASS NSString;
+OBJC_CLASS PDFAnnotation;
+OBJC_CLASS PDFLayerController;
+OBJC_CLASS PDFSelection;
+OBJC_CLASS WKPDFPluginAccessibilityObject;
+OBJC_CLASS WKPDFLayerControllerDelegate;
+
+namespace IPC {
+class DataReference;
+}
+
+namespace WebCore {
+class Element;
+struct PluginInfo;
+}
+
+namespace WebKit {
+
+class PDFPluginAnnotation;
+class PDFPluginPasswordField;
+class PluginView;
+class WebFrame;
+
+class PDFPlugin final : public Plugin {
+public:
+ static Ref<PDFPlugin> create(WebFrame*);
+ ~PDFPlugin();
+
+ static WebCore::PluginInfo pluginInfo();
+
+ WebCore::IntSize size() const { return m_size; }
+ float scaleFactor() const;
+
+ void didMutatePDFDocument() { m_pdfDocumentWasMutated = true; }
+
+ void setActiveAnnotation(PDFAnnotation *);
+
+ void notifyDisplayModeChanged(int);
+
+ void notifySelectionChanged(PDFSelection *);
+
+ void clickedLink(NSURL *);
+ void saveToPDF();
+ void openWithNativeApplication();
+ void writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types);
+ void showDefinitionForAttributedString(NSAttributedString *, CGPoint);
+ void performWebSearch(NSString *);
+ void performSpotlightSearch(NSString *);
+ void invalidatePDFRect(WebCore::IntRect);
+ void invalidateHUD();
+ void scrollToPoint(WebCore::IntPoint);
+
+ void zoomIn();
+ void zoomOut();
+
+ void focusNextAnnotation();
+ void focusPreviousAnnotation();
+
+ void attemptToUnlockPDF(const String& password);
+
+ WebCore::IntPoint convertFromPluginToPDFView(const WebCore::IntPoint&) const;
+ WebCore::IntPoint convertFromRootViewToPlugin(const WebCore::IntPoint&) const;
+ WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&) const;
+
+ WebCore::IntRect convertFromPDFViewToRootView(const WebCore::IntRect&) const;
+ WebCore::FloatRect convertFromPDFViewToScreen(const WebCore::FloatRect&) const;
+
+ WebCore::IntRect boundsOnScreen() const;
+
+ bool showContextMenuAtPoint(const WebCore::IntPoint&);
+
+ String lookupTextAtLocation(const WebCore::FloatPoint&, WebHitTestResultData&, PDFSelection **, NSDictionary **) const;
+ WebCore::FloatRect rectForSelectionInRootView(PDFSelection *) const;
+
+ PDFLayerController *pdfLayerController() const { return m_pdfLayerController.get(); }
+ WebFrame* webFrame() const { return m_frame; }
+
+ bool isLocked() const;
+
+private:
+ explicit PDFPlugin(WebFrame*);
+
+ // Plugin functions.
+ bool initialize(const Parameters&) override;
+ void destroy() override;
+ void paint(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRectInWindowCoordinates) override;
+ void updateControlTints(WebCore::GraphicsContext&) override { }
+ bool supportsSnapshotting() const override { return false; }
+ RefPtr<ShareableBitmap> snapshot() override;
+ PlatformLayer* pluginLayer() override { return nullptr; }
+ bool isTransparent() override { return false; }
+ bool wantsWheelEvents() override { return false; }
+ void geometryDidChange(const WebCore::IntSize& pluginSize, const WebCore::IntRect& clipRect, const WebCore::AffineTransform& pluginToRootViewTransform) override;
+ void contentsScaleFactorChanged(float) override { }
+ void visibilityDidChange(bool) override { }
+ void frameDidFinishLoading(uint64_t requestID) override;
+ void frameDidFail(uint64_t requestID, bool wasCancelled) override;
+ void didEvaluateJavaScript(uint64_t requestID, const String& result) override;
+ void streamWillSendRequest(uint64_t streamID, const WebCore::URL& requestURL, const WebCore::URL& responseURL, int responseStatus) override { }
+ void streamDidReceiveResponse(uint64_t streamID, const WebCore::URL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers, const String& suggestedFileName) override;
+ void streamDidReceiveData(uint64_t streamID, const char* bytes, int length) override;
+ void streamDidFinishLoading(uint64_t streamID) override;
+ void streamDidFail(uint64_t streamID, bool wasCancelled) override;
+ void manualStreamDidReceiveResponse(const WebCore::URL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const WTF::String& mimeType, const WTF::String& headers, const String& suggestedFileName) override;
+ void manualStreamDidReceiveData(const char* bytes, int length) override;
+ void manualStreamDidFinishLoading() override;
+ void manualStreamDidFail(bool wasCancelled) override;
+ bool handleMouseEvent(const WebMouseEvent&) override;
+ bool handleWheelEvent(const WebWheelEvent&) override { return false; }
+ bool handleMouseEnterEvent(const WebMouseEvent&) override;
+ bool handleMouseLeaveEvent(const WebMouseEvent&) override;
+ bool handleContextMenuEvent(const WebMouseEvent&) override;
+ bool handleKeyboardEvent(const WebKeyboardEvent&) override { return false; }
+ bool handleEditingCommand(const String& commandName, const String& argument) override;
+ bool isEditingCommandEnabled(const String&) override;
+ void setFocus(bool) override { }
+ NPObject* pluginScriptableNPObject() override { return nullptr; }
+ void windowFocusChanged(bool) override { }
+ void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates) override { }
+ void windowVisibilityChanged(bool) override { }
+ uint64_t pluginComplexTextInputIdentifier() const override { return 0; }
+ void sendComplexTextInput(const String& textInput) override { }
+ void setLayerHostingMode(LayerHostingMode) override { }
+ WebCore::Scrollbar* horizontalScrollbar() override { return nullptr; }
+ WebCore::Scrollbar* verticalScrollbar() override { return nullptr; }
+ void storageBlockingStateChanged(bool) override { }
+ void privateBrowsingStateChanged(bool) override { }
+ bool getFormValue(String& formValue) override { return false; }
+ bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) override { return false; }
+ RefPtr<WebCore::SharedBuffer> liveResourceData() const override;
+
+ bool handlesPageScaleFactor() const override { return false; }
+ bool requiresUnifiedScaleFactor() const override { return true; }
+
+ bool isBeingAsynchronouslyInitialized() const override { return false; }
+
+ RetainPtr<PDFDocument> pdfDocumentForPrinting() const override { return m_pdfDocument; }
+ NSObject *accessibilityObject() const override;
+
+ unsigned countFindMatches(const String& target, WebCore::FindOptions, unsigned maxMatchCount) override;
+ bool findString(const String& target, WebCore::FindOptions, unsigned maxMatchCount) override;
+
+ PDFSelection *nextMatchForString(const String& target, BOOL searchForward, BOOL caseSensitive, BOOL wrapSearch, PDFSelection *initialSelection, BOOL startInSelection);
+
+ bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) override;
+ String getSelectionString() const override;
+ String getSelectionForWordAtPoint(const WebCore::FloatPoint&) const override;
+ bool existingSelectionContainsPoint(const WebCore::FloatPoint&) const override;
+
+ bool shouldAllowScripting() override { return false; }
+ bool shouldAllowNavigationFromDrags() override { return true; }
+ bool shouldAlwaysAutoStart() const override { return true; }
+ bool canCreateTransientPaintingSnapshot() const override { return false; }
+
+ // PDFPlugin functions.
+ void pdfDocumentDidLoad();
+ void addArchiveResource();
+ void computePageBoxes();
+ void calculateSizes();
+ void didCalculateSizes();
+ void runScriptsInPDFDocument();
+
+ NSEvent *nsEventForWebMouseEvent(const WebMouseEvent&);
+
+ bool supportsForms();
+ bool isFullFramePlugin() const;
+
+ void createPasswordEntryForm();
+
+ RetainPtr<PDFDocument> pdfDocument() const { return m_pdfDocument; }
+ void setPDFDocument(RetainPtr<PDFDocument> document) { m_pdfDocument = document; }
+
+ WebCore::IntSize pdfDocumentSize() const { return m_pdfDocumentSize; }
+ void setPDFDocumentSize(WebCore::IntSize size) { m_pdfDocumentSize = size; }
+
+ NSData *liveData() const;
+ NSData *rawData() const { return (NSData *)m_data.get(); }
+
+ enum class UpdateCursor {
+ IfNeeded,
+ Force
+ };
+
+ enum class HitTestResult {
+ None,
+ Text,
+ HUD
+ };
+
+ void updateCursor(const WebMouseEvent&, UpdateCursor = UpdateCursor::IfNeeded);
+
+ JSObjectRef makeJSPDFDoc(JSContextRef);
+ static JSValueRef jsPDFDocPrint(JSContextRef, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+ void convertPostScriptDataIfNeeded();
+
+ PluginView* pluginView();
+ const PluginView* pluginView() const;
+
+ class HUD : public WebCore::PageOverlay::Client {
+ public:
+ explicit HUD(PDFPlugin& plugin);
+ virtual ~HUD();
+
+ void invalidate();
+ bool containsPointInRootView(WebCore::IntPoint);
+
+ enum class AnimateVisibilityTransition { No, Yes };
+ void setVisible(bool, AnimateVisibilityTransition);
+
+ private:
+ void willMoveToPage(WebCore::PageOverlay&, WebCore::Page*) override;
+ void didMoveToPage(WebCore::PageOverlay&, WebCore::Page*) override;
+ void drawRect(WebCore::PageOverlay&, WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect) override;
+ bool mouseEvent(WebCore::PageOverlay&, const WebCore::PlatformMouseEvent&) override;
+
+ WebCore::IntRect frameInRootView() const;
+
+ bool m_visible { false };
+ Ref<WebCore::PageOverlay> m_overlay;
+ PDFPlugin& m_plugin;
+ };
+
+ WebFrame* m_frame;
+
+ bool m_isPostScript { false };
+ bool m_pdfDocumentWasMutated { false };
+ bool m_usingContinuousMode { true };
+
+ RetainPtr<PDFLayerController> m_pdfLayerController;
+ RetainPtr<WKPDFPluginAccessibilityObject> m_accessibilityObject;
+
+ RefPtr<PDFPluginAnnotation> m_activeAnnotation;
+ RefPtr<PDFPluginPasswordField> m_passwordField;
+ RefPtr<WebCore::Element> m_passwordContainer;
+
+ WebCore::AffineTransform m_rootViewToPluginTransform;
+ WebCore::AffineTransform m_pluginToRootViewTransform;
+ WebMouseEvent m_lastMouseEvent;
+ WebCore::IntPoint m_lastMousePositionInPluginCoordinates;
+
+ String m_temporaryPDFUUID;
+
+ String m_lastFoundString;
+
+ HitTestResult m_lastHitTestResult;
+
+ RetainPtr<WKPDFLayerControllerDelegate> m_pdfLayerControllerDelegate;
+
+ WebCore::IntSize m_size;
+
+ WebCore::URL m_sourceURL;
+
+ String m_suggestedFilename;
+ RetainPtr<CFMutableDataRef> m_data;
+
+ RetainPtr<PDFDocument> m_pdfDocument;
+ WebCore::IntSize m_pdfDocumentSize; // All pages, including gaps.
+
+ HUD m_HUD;
+};
+
+} // namespace WebKit
+
+SPECIALIZE_TYPE_TRAITS_PLUGIN(PDFPlugin, PDFPluginType)
+
+#endif // USE(DEPRECATED_PDF_PLUGIN)
+#endif // ENABLE(PDFKIT_PLUGIN)
+
+#endif // PDFPlugin_h
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginAnnotation.h b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginAnnotation.h
new file mode 100644
index 000000000..f6339701e
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginAnnotation.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PDFPluginAnnotation_h
+#define PDFPluginAnnotation_h
+
+#if ENABLE(PDFKIT_PLUGIN)
+
+#include <WebCore/EventListener.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+class Document;
+class Element;
+}
+
+OBJC_CLASS PDFAnnotation;
+OBJC_CLASS PDFLayerController;
+
+namespace WebKit {
+
+class PDFPlugin;
+
+class PDFPluginAnnotation : public RefCounted<PDFPluginAnnotation> {
+public:
+ static PassRefPtr<PDFPluginAnnotation> create(PDFAnnotation *, PDFLayerController *, PDFPlugin*);
+ virtual ~PDFPluginAnnotation();
+
+ WebCore::Element* element() const { return m_element.get(); }
+ PDFAnnotation *annotation() const { return m_annotation.get(); }
+ PDFPlugin* plugin() const { return m_plugin; }
+
+ virtual void updateGeometry();
+ virtual void commit();
+
+ void attach(WebCore::Element*);
+
+protected:
+ PDFPluginAnnotation(PDFAnnotation *annotation, PDFLayerController *pdfLayerController, PDFPlugin* plugin)
+ : m_parent(0)
+ , m_annotation(annotation)
+ , m_eventListener(PDFPluginAnnotationEventListener::create(this))
+ , m_pdfLayerController(pdfLayerController)
+ , m_plugin(plugin)
+ {
+ }
+
+ WebCore::Element* parent() const { return m_parent; }
+ PDFLayerController *pdfLayerController() const { return m_pdfLayerController; }
+ WebCore::EventListener* eventListener() const { return m_eventListener.get(); }
+
+ virtual bool handleEvent(WebCore::Event*);
+
+private:
+ virtual PassRefPtr<WebCore::Element> createAnnotationElement() = 0;
+
+ class PDFPluginAnnotationEventListener : public WebCore::EventListener {
+ public:
+ static Ref<PDFPluginAnnotationEventListener> create(PDFPluginAnnotation* annotation)
+ {
+ return adoptRef(*new PDFPluginAnnotationEventListener(annotation));
+ }
+
+ bool operator==(const EventListener& listener) const override { return this == &listener; }
+
+ void setAnnotation(PDFPluginAnnotation* annotation) { m_annotation = annotation; }
+
+ private:
+
+ PDFPluginAnnotationEventListener(PDFPluginAnnotation* annotation)
+ : WebCore::EventListener(WebCore::EventListener::CPPEventListenerType)
+ , m_annotation(annotation)
+ {
+ }
+
+ void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) override;
+
+ PDFPluginAnnotation* m_annotation;
+ };
+
+ WebCore::Element* m_parent;
+
+ RefPtr<WebCore::Element> m_element;
+ RetainPtr<PDFAnnotation> m_annotation;
+
+ RefPtr<PDFPluginAnnotationEventListener> m_eventListener;
+
+ PDFLayerController *m_pdfLayerController;
+ PDFPlugin* m_plugin;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(PDFKIT_PLUGIN)
+
+#endif // PDFPluginAnnotation_h
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.h b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.h
new file mode 100644
index 000000000..6af87cd7f
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PDFPluginChoiceAnnotation_h
+#define PDFPluginChoiceAnnotation_h
+
+#if ENABLE(PDFKIT_PLUGIN)
+
+#include "PDFPluginAnnotation.h"
+
+namespace WebCore {
+class Element;
+}
+
+OBJC_CLASS PDFAnnotationChoiceWidget;
+
+namespace WebKit {
+
+class PDFPluginChoiceAnnotation : public PDFPluginAnnotation {
+public:
+ static Ref<PDFPluginChoiceAnnotation> create(PDFAnnotation *, PDFLayerController *, PDFPlugin*);
+
+ void updateGeometry() override;
+ void commit() override;
+
+private:
+ PDFPluginChoiceAnnotation(PDFAnnotation *annotation, PDFLayerController *pdfLayerController, PDFPlugin* plugin)
+ : PDFPluginAnnotation(annotation, pdfLayerController, plugin)
+ {
+ }
+
+ PassRefPtr<WebCore::Element> createAnnotationElement() override;
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ PDFAnnotationChoiceWidget *choiceAnnotation() { return static_cast<PDFAnnotationChoiceWidget *>(annotation()); }
+#pragma clang diagnostic pop
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(PDFKIT_PLUGIN)
+
+#endif // PDFPluginChoiceAnnotation_h
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginPasswordField.h b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginPasswordField.h
new file mode 100644
index 000000000..163250adb
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginPasswordField.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PDFPluginPasswordField_h
+#define PDFPluginPasswordField_h
+
+#if ENABLE(PDFKIT_PLUGIN)
+
+#include "PDFPluginTextAnnotation.h"
+
+namespace WebKit {
+
+class PDFPluginPasswordField : public PDFPluginTextAnnotation {
+public:
+ static Ref<PDFPluginPasswordField> create(PDFLayerController *, PDFPlugin*);
+ virtual ~PDFPluginPasswordField();
+
+ void updateGeometry() override;
+
+private:
+ PDFPluginPasswordField(PDFLayerController *pdfLayerController, PDFPlugin* plugin)
+ : PDFPluginTextAnnotation(0, pdfLayerController, plugin)
+ {
+ }
+
+ PassRefPtr<WebCore::Element> createAnnotationElement() override;
+
+ bool handleEvent(WebCore::Event*) override;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(PDFKIT_PLUGIN)
+
+#endif // PDFPluginTextAnnotation_h
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.h b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.h
new file mode 100644
index 000000000..a8e62e9cc
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PDFPluginTextAnnotation_h
+#define PDFPluginTextAnnotation_h
+
+#if ENABLE(PDFKIT_PLUGIN)
+
+#include "PDFPluginAnnotation.h"
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+class Element;
+}
+
+OBJC_CLASS PDFAnnotationTextWidget;
+
+namespace WebKit {
+
+class PDFPluginTextAnnotation : public PDFPluginAnnotation {
+public:
+ static Ref<PDFPluginTextAnnotation> create(PDFAnnotation *, PDFLayerController *, PDFPlugin*);
+ virtual ~PDFPluginTextAnnotation();
+
+ void updateGeometry() override;
+ void commit() override;
+
+protected:
+ PDFPluginTextAnnotation(PDFAnnotation *annotation, PDFLayerController *pdfLayerController, PDFPlugin* plugin)
+ : PDFPluginAnnotation(annotation, pdfLayerController, plugin)
+ {
+ }
+
+ PassRefPtr<WebCore::Element> createAnnotationElement() override;
+ String value() const;
+
+private:
+ bool handleEvent(WebCore::Event*) override;
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ PDFAnnotationTextWidget *textAnnotation() const { return static_cast<PDFAnnotationTextWidget *>(annotation()); }
+#pragma clang diagnostic pop
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(PDFKIT_PLUGIN)
+
+#endif // PDFPluginTextAnnotation_h