OLD | NEW |
1 /** | 1 /** |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) | 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) |
5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. | 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
31 #include "core/dom/PostAttachCallbacks.h" | 31 #include "core/dom/PostAttachCallbacks.h" |
32 #include "core/events/Event.h" | 32 #include "core/events/Event.h" |
33 #include "core/html/HTMLImageLoader.h" | 33 #include "core/html/HTMLImageLoader.h" |
34 #include "core/loader/FrameLoaderClient.h" | 34 #include "core/loader/FrameLoaderClient.h" |
35 #include "core/page/EventHandler.h" | 35 #include "core/page/EventHandler.h" |
36 #include "core/frame/Frame.h" | 36 #include "core/frame/Frame.h" |
37 #include "core/platform/MIMETypeFromURL.h" | 37 #include "core/platform/MIMETypeFromURL.h" |
38 #include "core/plugins/PluginView.h" | 38 #include "core/plugins/PluginView.h" |
39 #include "core/rendering/RenderEmbeddedObject.h" | 39 #include "core/rendering/RenderEmbeddedObject.h" |
| 40 #include "core/rendering/RenderImage.h" |
40 #include "core/rendering/RenderWidget.h" | 41 #include "core/rendering/RenderWidget.h" |
41 #include "platform/Widget.h" | 42 #include "platform/Widget.h" |
42 #include "wtf/UnusedParam.h" | 43 #include "wtf/UnusedParam.h" |
43 | 44 |
44 | 45 |
45 namespace WebCore { | 46 namespace WebCore { |
46 | 47 |
47 using namespace HTMLNames; | 48 using namespace HTMLNames; |
48 | 49 |
49 HTMLPlugInElement::HTMLPlugInElement(const QualifiedName& tagName, Document& doc
, bool createdByParser, PreferPlugInsForImagesOption preferPlugInsForImagesOptio
n) | 50 HTMLPlugInElement::HTMLPlugInElement(const QualifiedName& tagName, Document& doc
, bool createdByParser, PreferPlugInsForImagesOption preferPlugInsForImagesOptio
n) |
50 : HTMLFrameOwnerElement(tagName, doc) | 51 : HTMLFrameOwnerElement(tagName, doc) |
51 , m_NPObject(0) | 52 , m_NPObject(0) |
52 , m_isCapturingMouseEvents(false) | 53 , m_isCapturingMouseEvents(false) |
53 , m_inBeforeLoadEventHandler(false) | 54 , m_inBeforeLoadEventHandler(false) |
54 // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay | 55 // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay |
55 // widget updates until after all children are parsed. For HTMLEmbedElement | 56 // widget updates until after all children are parsed. For HTMLEmbedElement |
56 // this delay is unnecessary, but it is simpler to make both classes share | 57 // this delay is unnecessary, but it is simpler to make both classes share |
57 // the same codepath in this class. | 58 // the same codepath in this class. |
58 , m_needsWidgetUpdate(!createdByParser) | 59 , m_needsWidgetUpdate(!createdByParser) |
59 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPrefe
rPlugInsForImages) | 60 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPrefe
rPlugInsForImages) |
60 , m_displayState(Playing) | 61 , m_displayState(Playing) |
61 { | 62 { |
| 63 setHasCustomStyleCallbacks(); |
62 } | 64 } |
63 | 65 |
64 HTMLPlugInElement::~HTMLPlugInElement() | 66 HTMLPlugInElement::~HTMLPlugInElement() |
65 { | 67 { |
66 ASSERT(!m_pluginWrapper); // cleared in detach() | 68 ASSERT(!m_pluginWrapper); // cleared in detach() |
67 | 69 |
68 if (m_NPObject) { | 70 if (m_NPObject) { |
69 _NPN_ReleaseObject(m_NPObject); | 71 _NPN_ReleaseObject(m_NPObject); |
70 m_NPObject = 0; | 72 m_NPObject = 0; |
71 } | 73 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 160 } |
159 | 161 |
160 if (m_NPObject) { | 162 if (m_NPObject) { |
161 _NPN_ReleaseObject(m_NPObject); | 163 _NPN_ReleaseObject(m_NPObject); |
162 m_NPObject = 0; | 164 m_NPObject = 0; |
163 } | 165 } |
164 | 166 |
165 HTMLFrameOwnerElement::detach(context); | 167 HTMLFrameOwnerElement::detach(context); |
166 } | 168 } |
167 | 169 |
| 170 RenderObject* HTMLPlugInElement::createRenderer(RenderStyle* style) |
| 171 { |
| 172 // Fallback content breaks the DOM->Renderer class relationship of this |
| 173 // class and all superclasses because createObject won't necessarily |
| 174 // return a RenderEmbeddedObject, RenderPart or even RenderWidget. |
| 175 if (useFallbackContent()) |
| 176 return RenderObject::createObject(this, style); |
| 177 |
| 178 if (isImageType()) { |
| 179 RenderImage* image = new RenderImage(this); |
| 180 image->setImageResource(RenderImageResource::create()); |
| 181 return image; |
| 182 } |
| 183 |
| 184 return new RenderEmbeddedObject(this); |
| 185 } |
| 186 |
| 187 void HTMLPlugInElement::willRecalcStyle(StyleRecalcChange) |
| 188 { |
| 189 // FIXME: Why is this necessary? Manual re-attach is almost always wrong. |
| 190 if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageTy
pe()) |
| 191 reattach(); |
| 192 } |
| 193 |
| 194 void HTMLPlugInElement::finishParsingChildren() |
| 195 { |
| 196 HTMLFrameOwnerElement::finishParsingChildren(); |
| 197 if (useFallbackContent()) |
| 198 return; |
| 199 |
| 200 setNeedsWidgetUpdate(true); |
| 201 if (inDocument()) |
| 202 setNeedsStyleRecalc(); |
| 203 } |
| 204 |
168 void HTMLPlugInElement::resetInstance() | 205 void HTMLPlugInElement::resetInstance() |
169 { | 206 { |
170 m_pluginWrapper.clear(); | 207 m_pluginWrapper.clear(); |
171 } | 208 } |
172 | 209 |
173 SharedPersistent<v8::Object>* HTMLPlugInElement::pluginWrapper() | 210 SharedPersistent<v8::Object>* HTMLPlugInElement::pluginWrapper() |
174 { | 211 { |
175 Frame* frame = document().frame(); | 212 Frame* frame = document().frame(); |
176 if (!frame) | 213 if (!frame) |
177 return 0; | 214 return 0; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 367 |
331 RenderEmbeddedObject* HTMLPlugInElement::renderEmbeddedObject() const | 368 RenderEmbeddedObject* HTMLPlugInElement::renderEmbeddedObject() const |
332 { | 369 { |
333 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers | 370 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers |
334 // when using fallback content. | 371 // when using fallback content. |
335 if (!renderer() || !renderer()->isEmbeddedObject()) | 372 if (!renderer() || !renderer()->isEmbeddedObject()) |
336 return 0; | 373 return 0; |
337 return toRenderEmbeddedObject(renderer()); | 374 return toRenderEmbeddedObject(renderer()); |
338 } | 375 } |
339 | 376 |
| 377 // We don't use m_url, as it may not be the final URL that the object loads, |
| 378 // depending on <param> values. |
| 379 bool HTMLPlugInElement::allowedToLoadFrameURL(const String& url) |
| 380 { |
| 381 KURL completeURL = document().completeURL(url); |
| 382 if (contentFrame() && protocolIsJavaScript(completeURL) |
| 383 && !document().securityOrigin()->canAccess(contentDocument()->securityOr
igin())) |
| 384 return false; |
| 385 return document().frame()->isURLAllowed(completeURL); |
340 } | 386 } |
| 387 |
| 388 // We don't use m_url, or m_serviceType as they may not be the final values |
| 389 // that <object> uses depending on <param> values. |
| 390 bool HTMLPlugInElement::wouldLoadAsNetscapePlugin(const String& url, const Strin
g& serviceType) |
| 391 { |
| 392 ASSERT(document().frame()); |
| 393 KURL completedURL; |
| 394 if (!url.isEmpty()) |
| 395 completedURL = document().completeURL(url); |
| 396 return document().frame()->loader().client()->objectContentType(completedURL
, serviceType, shouldPreferPlugInsForImages()) == ObjectContentNetscapePlugin; |
| 397 } |
| 398 |
| 399 } |
OLD | NEW |