2
* Copyright (C) 2009 Google 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 are
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
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.
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.
31
#ifndef WebPluginContainerImpl_h
32
#define WebPluginContainerImpl_h
34
#include "PluginViewBase.h"
35
#include "WebPluginContainer.h"
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>
48
class HTMLPlugInElement;
53
class ResourceResponse;
57
#if ENABLE(GESTURE_EVENTS)
58
class PlatformGestureEvent;
64
struct WebPrintParams;
68
class WebPluginLoadObserver;
69
class WebExternalTextureLayer;
71
class WebPluginContainerImpl : public WebCore::PluginViewBase, public WebPluginContainer {
73
static PassRefPtr<WebPluginContainerImpl> create(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin)
75
return adoptRef(new WebPluginContainerImpl(element, webPlugin));
78
// PluginViewBase methods
79
virtual bool getFormValue(String&);
80
virtual bool supportsKeyboardFocus() const;
81
virtual bool canProcessDrag() const;
82
virtual bool wantsWheelEvents();
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);
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; }
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,
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&);
120
// This cannot be null.
121
WebPlugin* plugin() { return m_webPlugin; }
122
void setPlugin(WebPlugin*);
124
virtual float deviceScaleFactor();
125
virtual float pageScaleFactor();
126
virtual float pageZoomFactor();
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.
143
// Copy the selected text.
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&);
152
virtual NPObject* scriptableObject() OVERRIDE;
154
void willDestroyPluginLoadObserver(WebPluginLoadObserver*);
156
#if USE(ACCELERATED_COMPOSITING)
157
virtual WebLayer* platformLayer() const;
160
ScrollbarGroup* scrollbarGroup();
162
void willStartLiveResize();
163
void willEndLiveResize();
165
bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&);
168
WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin);
169
~WebPluginContainerImpl();
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*);
178
void synthesizeMouseEventIfPossible(WebCore::TouchEvent*);
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);
188
WebCore::HTMLPlugInElement* m_element;
189
WebPlugin* m_webPlugin;
190
Vector<WebPluginLoadObserver*> m_pluginLoadObservers;
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;
198
unsigned m_ioSurfaceId;
199
OwnPtr<WebIOSurfaceLayer> m_ioSurfaceLayer;
202
// The associated scrollbar group object, created lazily. Used for Pepper
204
OwnPtr<ScrollbarGroup> m_scrollbarGroup;
206
TouchEventRequestType m_touchEventRequestType;
207
bool m_wantsWheelEvents;
210
} // namespace WebKit