2 * Copyright (C) 2006, 2007, 2008, 2010, 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 #import <WebKitLegacy/WebDocumentPrivate.h>
32 @protocol WebPDFViewPlaceholderDelegate;
35 @class WebPDFViewPlaceholder
36 @discussion This class represents a placeholder for PDFs. It is intended to allow main frame PDFs
37 be drawn to the UI by some other object (ideally the delegate of this class) while still interfacing
38 with WAK and WebKit correctly.
40 @interface WebPDFViewPlaceholder : WAKView <WebPDFDocumentView, WebPDFDocumentRepresentation> {
43 NSArray *_pageYOrigins;
44 CGPDFDocumentRef _document;
45 WebDataSource *_dataSource; // weak to prevent cycles.
47 NSObject<WebPDFViewPlaceholderDelegate> *_delegate;
51 CGSize _containerSize;
55 @method setAsPDFDocRepAndView
56 @abstract This methods sets [WebPDFViewPlaceholder class] as the document and view representations
59 + (void)setAsPDFDocRepAndView;
64 @abstract A delegate object conforming to WebPDFViewPlaceholderDelegate that will be informed about various state changes.
66 @property (assign) NSObject<WebPDFViewPlaceholderDelegate> *delegate;
70 @abstract An array of CGRects (as NSValues) representing the bounds of each page in PDF document coordinate space.
72 @property (readonly, retain) NSArray *pageRects;
75 @property pageYOrigins
76 @abstract An array of CGFloats (as NSNumbers) representing the minimum y for every page in the document.
78 @property (readonly, retain) NSArray *pageYOrigins;
82 @abstract The CGPDFDocumentRef that this object represents. Until the document has loaded, this property will be NULL.
84 @property (readonly) CGPDFDocumentRef document;
85 @property (readonly) CGPDFDocumentRef doc;
89 @abstract Convenience access for the total number of pages in the wrapped document.
91 @property (readonly) NSUInteger totalPages;
95 @abstract PDFs support a meta data field for the document's title. If this field is present in the PDF, title will be that string.
96 If not, title will be the file name.
98 @property (readonly, retain) NSString *title;
101 @property containerSize
102 @abstract sets the size for the containing view. This is used to determine how big the shadows between pages should be.
104 @property (assign) CGSize containerSize;
106 @property (nonatomic, readonly) BOOL didCompleteLayout;
108 - (void)clearDocument;
111 @method didUnlockDocument
112 @abstract Informs the PDF view placeholder that the PDF document has been unlocked. The result of this involves laying
113 out the pages, retaining the document title, and re-evaluating the document's javascript. This should be called on the WebThread.
115 - (void)didUnlockDocument;
118 @method rectForPageNumber
119 @abstract Returns the PDF document coordinate space rect given a page number. pageNumber must be in the range [1,totalPages],
120 since page numbers are 1-based.
122 - (CGRect)rectForPageNumber:(NSUInteger)pageNumber;
125 @method simulateClickOnLinkToURL:
126 @abstract This method simulates a user clicking on the passed in URL.
128 - (void)simulateClickOnLinkToURL:(NSURL *)URL;
134 @protocol WebPDFViewPlaceholderDelegate
135 @discussion This protocol is used to inform the object using the placeholder that the layout for the
136 document has been calculated.
138 @protocol WebPDFViewPlaceholderDelegate
143 @method viewWillClose
144 @abstract This method is called to inform the delegate that the placeholder view's lifetime has ended. This might
145 be called from either the main thread or the WebThread.
147 - (void)viewWillClose;
150 @method didCompleteLayout
151 @abstract This method is called to inform the delegate that the placeholder has completed layout
152 and determined the document's bounds. Will always be called on the main thread.
154 - (void)didCompleteLayout;
159 @method cgPDFDocument
160 @abstract The WebPDFViewPlaceholder may have abdicated responsibility for the underlying CGPDFDocument to the WebPDFViewPlaceholderDelegate.
161 That means that there may be times when the document is needed, but the WebPDFViewPlaceholder no longer has a reference to it. In which case
162 the WebPDFViewPlaceholderDelegate will be asked for the document.
164 - (CGPDFDocumentRef)cgPDFDocument;
168 #endif /* TARGET_OS_IPHONE */