~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebKit/chromium/src/WebPluginContainerImpl.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2009 Google 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 are
 
6
 * met:
 
7
 *
 
8
 *     * Redistributions of source code must retain the above copyright
 
9
 * notice, this list of conditions and the following disclaimer.
 
10
 *     * Redistributions in binary form must reproduce the above
 
11
 * copyright notice, this list of conditions and the following disclaimer
 
12
 * in the documentation and/or other materials provided with the
 
13
 * distribution.
 
14
 *     * Neither the name of Google Inc. nor the names of its
 
15
 * contributors may be used to endorse or promote products derived from
 
16
 * this software without specific prior written permission.
 
17
 *
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
19
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
20
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
21
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
22
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
23
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
24
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
28
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
29
 */
 
30
 
 
31
#ifndef WebPluginContainerImpl_h
 
32
#define WebPluginContainerImpl_h
 
33
 
 
34
#include "PluginViewBase.h"
 
35
#include "WebPluginContainer.h"
 
36
#include "Widget.h"
 
37
 
 
38
#include <public/WebIOSurfaceLayer.h>
 
39
#include <wtf/OwnPtr.h>
 
40
#include <wtf/PassRefPtr.h>
 
41
#include <wtf/Vector.h>
 
42
#include <wtf/text/WTFString.h>
 
43
 
 
44
struct NPObject;
 
45
 
 
46
namespace WebCore {
 
47
class GestureEvent;
 
48
class HTMLPlugInElement;
 
49
class IntRect;
 
50
class KeyboardEvent;
 
51
class MouseEvent;
 
52
class ResourceError;
 
53
class ResourceResponse;
 
54
class TouchEvent;
 
55
class WheelEvent;
 
56
 
 
57
#if ENABLE(GESTURE_EVENTS)
 
58
class PlatformGestureEvent;
 
59
#endif
 
60
}
 
61
 
 
62
namespace WebKit {
 
63
 
 
64
struct WebPrintParams;
 
65
 
 
66
class ScrollbarGroup;
 
67
class WebPlugin;
 
68
class WebPluginLoadObserver;
 
69
class WebExternalTextureLayer;
 
70
 
 
71
class WebPluginContainerImpl : public WebCore::PluginViewBase, public WebPluginContainer {
 
72
public:
 
73
    static PassRefPtr<WebPluginContainerImpl> create(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin)
 
74
    {
 
75
        return adoptRef(new WebPluginContainerImpl(element, webPlugin));
 
76
    }
 
77
 
 
78
    // PluginViewBase methods
 
79
    virtual bool getFormValue(String&);
 
80
    virtual bool supportsKeyboardFocus() const;
 
81
    virtual bool canProcessDrag() const;
 
82
    virtual bool wantsWheelEvents();
 
83
 
 
84
    // Widget methods
 
85
    virtual void setFrameRect(const WebCore::IntRect&);
 
86
    virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
 
87
    virtual void invalidateRect(const WebCore::IntRect&);
 
88
    virtual void setFocus(bool);
 
89
    virtual void show();
 
90
    virtual void hide();
 
91
    virtual void handleEvent(WebCore::Event*);
 
92
    virtual void frameRectsChanged();
 
93
    virtual void setParentVisible(bool);
 
94
    virtual void setParent(WebCore::ScrollView*);
 
95
    virtual void widgetPositionsUpdated();
 
96
    virtual bool isPluginContainer() const { return true; }
 
97
 
 
98
    // WebPluginContainer methods
 
99
    virtual WebElement element();
 
100
    virtual void invalidate();
 
101
    virtual void invalidateRect(const WebRect&);
 
102
    virtual void scrollRect(int dx, int dy, const WebRect&);
 
103
    virtual void reportGeometry();
 
104
    virtual void setBackingTextureId(unsigned);
 
105
    virtual void setBackingIOSurfaceId(int width,
 
106
                                       int height,
 
107
                                       uint32_t ioSurfaceId);
 
108
    virtual void commitBackingTexture();
 
109
    virtual void clearScriptObjects();
 
110
    virtual NPObject* scriptableObjectForElement();
 
111
    virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed);
 
112
    virtual void loadFrameRequest(const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData);
 
113
    virtual void zoomLevelChanged(double zoomLevel);    
 
114
    virtual void setOpaque(bool);
 
115
    virtual bool isRectTopmost(const WebRect&);
 
116
    virtual void requestTouchEventType(TouchEventRequestType);
 
117
    virtual void setWantsWheelEvents(bool);
 
118
    virtual WebPoint windowToLocalPoint(const WebPoint&);
 
119
 
 
120
    // This cannot be null.
 
121
    WebPlugin* plugin() { return m_webPlugin; }
 
122
    void setPlugin(WebPlugin*);
 
123
 
 
124
    virtual float deviceScaleFactor();
 
125
    virtual float pageScaleFactor();
 
126
    virtual float pageZoomFactor();
 
127
 
 
128
    // Printing interface. The plugin can support custom printing
 
129
    // (which means it controls the layout, number of pages etc).
 
130
    // Whether the plugin supports its own paginated print. The other print
 
131
    // interface methods are called only if this method returns true.
 
132
    bool supportsPaginatedPrint() const;
 
133
    // If the plugin content should not be scaled to the printable area of
 
134
    // the page, then this method should return true.
 
135
    bool isPrintScalingDisabled() const;
 
136
    // Sets up printing at the specified WebPrintParams. Returns the number of pages to be printed at these settings.
 
137
    int printBegin(const WebPrintParams&) const;
 
138
    // Prints the page specified by pageNumber (0-based index) into the supplied canvas.
 
139
    bool printPage(int pageNumber, WebCore::GraphicsContext* gc);
 
140
    // Ends the print operation.
 
141
    void printEnd();
 
142
 
 
143
    // Copy the selected text.
 
144
    void copy();
 
145
 
 
146
    // Resource load events for the plugin's source data:
 
147
    void didReceiveResponse(const WebCore::ResourceResponse&);
 
148
    void didReceiveData(const char *data, int dataLength);
 
149
    void didFinishLoading();
 
150
    void didFailLoading(const WebCore::ResourceError&);
 
151
 
 
152
    virtual NPObject* scriptableObject() OVERRIDE;
 
153
 
 
154
    void willDestroyPluginLoadObserver(WebPluginLoadObserver*);
 
155
 
 
156
#if USE(ACCELERATED_COMPOSITING)
 
157
    virtual WebLayer* platformLayer() const;
 
158
#endif
 
159
 
 
160
    ScrollbarGroup* scrollbarGroup();
 
161
 
 
162
    void willStartLiveResize();
 
163
    void willEndLiveResize();
 
164
 
 
165
    bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&);
 
166
 
 
167
private:
 
168
    WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin);
 
169
    ~WebPluginContainerImpl();
 
170
 
 
171
    void handleMouseEvent(WebCore::MouseEvent*);
 
172
    void handleDragEvent(WebCore::MouseEvent*);
 
173
    void handleWheelEvent(WebCore::WheelEvent*);
 
174
    void handleKeyboardEvent(WebCore::KeyboardEvent*);
 
175
    void handleTouchEvent(WebCore::TouchEvent*);
 
176
    void handleGestureEvent(WebCore::GestureEvent*);
 
177
 
 
178
    void synthesizeMouseEventIfPossible(WebCore::TouchEvent*);
 
179
 
 
180
    void calculateGeometry(const WebCore::IntRect& frameRect,
 
181
                           WebCore::IntRect& windowRect,
 
182
                           WebCore::IntRect& clipRect,
 
183
                           Vector<WebCore::IntRect>& cutOutRects);
 
184
    WebCore::IntRect windowClipRect() const;
 
185
    void windowCutOutRects(const WebCore::IntRect& frameRect,
 
186
                           Vector<WebCore::IntRect>& cutOutRects);
 
187
 
 
188
    WebCore::HTMLPlugInElement* m_element;
 
189
    WebPlugin* m_webPlugin;
 
190
    Vector<WebPluginLoadObserver*> m_pluginLoadObservers;
 
191
 
 
192
#if USE(ACCELERATED_COMPOSITING)
 
193
    // A composited plugin will either have no composited layer, a texture layer, or an IOSurface layer.
 
194
    // It will never have both a texture and IOSurface output.
 
195
    unsigned m_textureId;
 
196
    OwnPtr<WebExternalTextureLayer> m_textureLayer;
 
197
 
 
198
    unsigned m_ioSurfaceId;
 
199
    OwnPtr<WebIOSurfaceLayer> m_ioSurfaceLayer;
 
200
#endif
 
201
 
 
202
    // The associated scrollbar group object, created lazily. Used for Pepper
 
203
    // scrollbars.
 
204
    OwnPtr<ScrollbarGroup> m_scrollbarGroup;
 
205
 
 
206
    TouchEventRequestType m_touchEventRequestType;
 
207
    bool m_wantsWheelEvents;
 
208
};
 
209
 
 
210
} // namespace WebKit
 
211
 
 
212
#endif