OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 using namespace WebCore; | 66 using namespace WebCore; |
67 | 67 |
68 namespace WebKit { | 68 namespace WebKit { |
69 | 69 |
70 // Public methods -------------------------------------------------------------- | 70 // Public methods -------------------------------------------------------------- |
71 | 71 |
72 void WebPluginContainerImpl::setFrameRect(const IntRect& frameRect) | 72 void WebPluginContainerImpl::setFrameRect(const IntRect& frameRect) |
73 { | 73 { |
74 Widget::setFrameRect(frameRect); | 74 Widget::setFrameRect(frameRect); |
75 | 75 reportGeometry(); |
76 if (!parent()) | |
77 return; | |
78 | |
79 IntRect windowRect, clipRect; | |
80 Vector<IntRect> cutOutRects; | |
81 calculateGeometry(frameRect, windowRect, clipRect, cutOutRects); | |
82 | |
83 m_webPlugin->updateGeometry(windowRect, clipRect, cutOutRects, isVisible()); | |
84 } | 76 } |
85 | 77 |
86 void WebPluginContainerImpl::paint(GraphicsContext* gc, const IntRect& damageRect) | 78 void WebPluginContainerImpl::paint(GraphicsContext* gc, const IntRect& damageRect) |
87 { | 79 { |
88 if (gc->paintingDisabled()) | 80 if (gc->paintingDisabled()) |
89 return; | 81 return; |
90 | 82 |
91 if (!parent()) | 83 if (!parent()) |
92 return; | 84 return; |
93 | 85 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // where mozilla behaves differently than the spec. | 158 // where mozilla behaves differently than the spec. |
167 if (event->isMouseEvent()) | 159 if (event->isMouseEvent()) |
168 handleMouseEvent(static_cast<MouseEvent*>(event)); | 160 handleMouseEvent(static_cast<MouseEvent*>(event)); |
169 else if (event->isKeyboardEvent()) | 161 else if (event->isKeyboardEvent()) |
170 handleKeyboardEvent(static_cast<KeyboardEvent*>(event)); | 162 handleKeyboardEvent(static_cast<KeyboardEvent*>(event)); |
171 } | 163 } |
172 | 164 |
173 void WebPluginContainerImpl::frameRectsChanged() | 165 void WebPluginContainerImpl::frameRectsChanged() |
174 { | 166 { |
175 Widget::frameRectsChanged(); | 167 Widget::frameRectsChanged(); |
176 | 168 reportGeometry(); |
177 // This is a hack to tickle re-positioning of the plugin in the case where | |
178 // our parent view was scrolled. | |
179 setFrameRect(frameRect()); | |
180 } | 169 } |
181 | 170 |
182 void WebPluginContainerImpl::setParentVisible(bool parentVisible) | 171 void WebPluginContainerImpl::setParentVisible(bool parentVisible) |
183 { | 172 { |
184 // We override this function to make sure that geometry updates are sent | 173 // We override this function to make sure that geometry updates are sent |
185 // over to the plugin. For e.g. when a plugin is instantiated it does not | 174 // over to the plugin. For e.g. when a plugin is instantiated it does not |
186 // have a valid parent. As a result the first geometry update from webkit | 175 // have a valid parent. As a result the first geometry update from webkit |
187 // is ignored. This function is called when the plugin eventually gets a | 176 // is ignored. This function is called when the plugin eventually gets a |
188 // parent. | 177 // parent. |
189 | 178 |
190 if (isParentVisible() == parentVisible) | 179 if (isParentVisible() == parentVisible) |
191 return; // No change. | 180 return; // No change. |
192 | 181 |
193 Widget::setParentVisible(parentVisible); | 182 Widget::setParentVisible(parentVisible); |
194 if (!isSelfVisible()) | 183 if (!isSelfVisible()) |
195 return; // This widget has explicitely been marked as not visible. | 184 return; // This widget has explicitely been marked as not visible. |
196 | 185 |
197 m_webPlugin->updateVisibility(isVisible()); | 186 m_webPlugin->updateVisibility(isVisible()); |
198 } | 187 } |
199 | 188 |
200 void WebPluginContainerImpl::setParent(ScrollView* view) | 189 void WebPluginContainerImpl::setParent(ScrollView* view) |
201 { | 190 { |
202 // We override this function so that if the plugin is windowed, we can call | 191 // We override this function so that if the plugin is windowed, we can call |
203 // NPP_SetWindow at the first possible moment. This ensures that | 192 // NPP_SetWindow at the first possible moment. This ensures that |
204 // NPP_SetWindow is called before the manual load data is sent to a plugin. | 193 // NPP_SetWindow is called before the manual load data is sent to a plugin. |
205 // If this order is reversed, Flash won't load videos. | 194 // If this order is reversed, Flash won't load videos. |
206 | 195 |
207 Widget::setParent(view); | 196 Widget::setParent(view); |
208 if (view) | 197 if (view) |
209 setFrameRect(frameRect()); | 198 reportGeometry(); |
210 } | 199 } |
211 | 200 |
212 void WebPluginContainerImpl::invalidate() | 201 void WebPluginContainerImpl::invalidate() |
213 { | 202 { |
214 Widget::invalidate(); | 203 Widget::invalidate(); |
215 } | 204 } |
216 | 205 |
217 void WebPluginContainerImpl::invalidateRect(const WebRect& rect) | 206 void WebPluginContainerImpl::invalidateRect(const WebRect& rect) |
218 { | 207 { |
219 invalidateRect(static_cast<IntRect>(rect)); | 208 invalidateRect(static_cast<IntRect>(rect)); |
220 } | 209 } |
221 | 210 |
| 211 void WebPluginContainerImpl::reportGeometry() |
| 212 { |
| 213 if (!parent()) |
| 214 return; |
| 215 |
| 216 IntRect windowRect, clipRect; |
| 217 Vector<IntRect> cutOutRects; |
| 218 calculateGeometry(frameRect(), windowRect, clipRect, cutOutRects); |
| 219 |
| 220 m_webPlugin->updateGeometry(windowRect, clipRect, cutOutRects, isVisible()); |
| 221 } |
| 222 |
| 223 void WebPluginContainerImpl::clearScriptObjects() |
| 224 { |
| 225 Frame* frame = m_element->document()->frame(); |
| 226 if (!frame) |
| 227 return; |
| 228 frame->script()->cleanupScriptObjectsForPlugin(this); |
| 229 } |
| 230 |
222 NPObject* WebPluginContainerImpl::scriptableObjectForElement() | 231 NPObject* WebPluginContainerImpl::scriptableObjectForElement() |
223 { | 232 { |
224 return m_element->getNPObject(); | 233 return m_element->getNPObject(); |
225 } | 234 } |
226 | 235 |
227 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popupsAllowed) | 236 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popupsAllowed) |
228 { | 237 { |
229 Frame* frame = m_element->document()->frame(); | 238 Frame* frame = m_element->document()->frame(); |
230 if (!frame) | 239 if (!frame) |
231 return WebString(); | 240 return WebString(); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 roundedIntPoint(iframeRenderer->localToAbsolute()); | 524 roundedIntPoint(iframeRenderer->localToAbsolute()); |
516 RenderBox* rbox = toRenderBox(iframeRenderer); | 525 RenderBox* rbox = toRenderBox(iframeRenderer); |
517 IntSize size(rbox->width(), rbox->height()); | 526 IntSize size(rbox->width(), rbox->height()); |
518 cutOutRects.append(IntRect(point, size)); | 527 cutOutRects.append(IntRect(point, size)); |
519 } | 528 } |
520 } | 529 } |
521 } | 530 } |
522 } | 531 } |
523 | 532 |
524 } // namespace WebKit | 533 } // namespace WebKit |
OLD | NEW |