1 /* 2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 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. 12 * 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. 24 */ 25 26 #ifndef PageClientImpl_h 27 #define PageClientImpl_h 28 29 #include "CorrectionPanel.h" 30 #include "PageClient.h" 31 #include <wtf/RetainPtr.h> 32 33 @class WKEditorUndoTargetObjC; 34 @class WKView; 35 36 namespace WebKit { 37 38 class FindIndicatorWindow; 39 40 // NOTE: This does not use String::operator NSString*() since that function 41 // expects to be called on the thread running WebCore. 42 NSString* nsStringFromWebCoreString(const String&); 43 44 class PageClientImpl : public PageClient { 45 public: 46 static PassOwnPtr<PageClientImpl> create(WKView*); 47 virtual ~PageClientImpl(); 48 49 private: 50 PageClientImpl(WKView*); 51 52 virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy(); 53 virtual void setViewNeedsDisplay(const WebCore::IntRect&); 54 virtual void displayView(); 55 virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); 56 57 virtual WebCore::IntSize viewSize(); 58 virtual bool isViewWindowActive(); 59 virtual bool isViewFocused(); 60 virtual bool isViewVisible(); 61 virtual bool isViewInWindow(); 62 63 virtual void processDidCrash(); 64 virtual void pageClosed(); 65 virtual void didRelaunchProcess(); 66 virtual void toolTipChanged(const String& oldToolTip, const String& newToolTip); 67 virtual void setCursor(const WebCore::Cursor&); 68 virtual void setViewportArguments(const WebCore::ViewportArguments&); 69 70 virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo); 71 virtual void clearAllEditCommands(); 72 virtual bool canUndoRedo(WebPageProxy::UndoOrRedo); 73 virtual void executeUndoRedo(WebPageProxy::UndoOrRedo); 74 virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>&); 75 virtual bool executeSavedCommandBySelector(const String& selector); 76 virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag); 77 virtual void updateSecureInputState(); 78 79 virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); 80 virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); 81 virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&); 82 83 virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled); 84 85 virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*); 86 virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*); 87 88 void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut); 89 90 virtual void enterAcceleratedCompositingMode(const LayerTreeContext&); 91 virtual void exitAcceleratedCompositingMode(); 92 93 virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&); 94 virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled); 95 96 virtual CGContextRef containingWindowGraphicsContext(); 97 98 virtual void didChangeScrollbarsForMainFrame() const; 99 100 virtual void didCommitLoadForMainFrame(bool useCustomRepresentation); 101 virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&); 102 103 virtual double customRepresentationZoomFactor(); 104 virtual void setCustomRepresentationZoomFactor(double); 105 virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount); 106 virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount); 107 108 virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects); 109 110 virtual void didPerformDictionaryLookup(const String&, double scaleFactor, const DictionaryPopupInfo&); 111 virtual void dismissDictionaryLookupPanel(); 112 113 virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings); 114 virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel); 115 virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel); 116 virtual void recordAutocorrectionResponse(WebCore::EditorClient::AutocorrectionResponseType, const String& replacedString, const String& replacementString); 117 118 virtual float userSpaceScaleFactor() const; 119 120 WKView* m_wkView; 121 RetainPtr<WKEditorUndoTargetObjC> m_undoTarget; 122 #if !defined(BUILDING_ON_SNOW_LEOPARD) 123 CorrectionPanel m_correctionPanel; 124 #endif 125 }; 126 127 } // namespace WebKit 128 129 #endif // PageClientImpl_h 130